From 8c3aee6f6888a14ae24dde23d4fefa2df0ee4f00 Mon Sep 17 00:00:00 2001 From: ThatcherK Date: Thu, 9 Nov 2023 15:23:06 +0300 Subject: [PATCH] Bundle assets --- assets/core.js | 2 +- assets/vendor.js | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/assets/core.js b/assets/core.js index ba741c95..225f064d 100644 --- a/assets/core.js +++ b/assets/core.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{45:function(e,t,n){e.exports=n(94)},93:function(e,t,n){},94:function(e,t,n){"use strict";n.r(t);var a,r=n(1),o=n(7),i=n(95),c=n(11),s=n.n(c),l=n(14),u=n(0),d=n.n(u),f=n(2),p=n.n(f),b=n(3),m=n(15),g=n(8),h=n.n(g),v=m.a.div(a||(a=Object(b.a)(["\n color: red;\n font-size: 11px;\n position: relative;\n padding: 5px 5px 5px 0px;\n display: block;\n"]))),y=function(e){var t=Object(u.useState)(""),n=t[0],a=t[1],r=function(t){t?"maxSelectedOptions"===t.type&&a(e.selectErrorMessage):a("")};return d.a.createElement("div",{className:h()(e.className)},d.a.Children.map(e.children,(function(e){return d.a.isValidElement(e)?d.a.cloneElement(e,{onError:r}):e})),n?d.a.createElement(v,{className:"data-selector--wrapper"},n):null)};y.propTypes={selectErrorMessage:p.a.string,children:p.a.node,className:p.a.string};var O=y,j=n(22),w=n(23),x=n(42),C={control:function(e){return Object.assign({},e,{borderColor:"#ddd",borderRadius:"none",boxShadow:"none",":hover":{borderColor:"#357ba5"},":active":{borderColor:"#357ba5"}})},menu:function(e){return Object.assign({},e,{color:"#443e42",backgroundColor:"#FFFFFF"})},option:function(e,t){return Object.assign({},e,{fontSize:"14px",":hover":{backgroundColor:"#4e9ac6",color:"#ffffff"},backgroundColor:t.isSelected?"#357ba5":"transparent"})},singleValue:function(e){return Object.assign({},e,{fontSize:"14px"})},multiValue:function(e){return Object.assign({},e,{fontSize:"14px"})},multiValueLabel:function(e,t){return t.data.isCloseable?e:Object.assign({},e,{paddingRight:6})},multiValueRemove:function(e,t){return t.data.isCloseable?e:Object.assign({},e,{display:"none"})},input:function(e){return Object.assign({},e,{fontSize:"14px"})},indicatorsContainer:function(e){return Object.assign({},e,{pointerEvents:"none"})}},S=function(e){var t=e.label,n=e.onError,a=e.maxSelectedOptions,o=e.defaultValue,i=e.singleSelectOptions,c=e.className,s=Object(w.a)(e,["label","onError","maxSelectedOptions","defaultValue","singleSelectOptions","className"]),l=Object(u.useState)(o),d=l[0],f=l[1];Object(u.useEffect)((function(){s.onChange&&s.onChange(d),n&&n()}),[d]),Object(u.useEffect)((function(){s.value&&f(s.value)}),[s.value]);return Object(r.c)("div",{className:h()("labelled-data-selector--wrapper",c)},Object(r.c)("label",null,Object(r.c)("b",null,t)),Object(r.c)(x.a,Object(j.a)({},s,{value:d,onChange:function(e){if(s.isMulti)if(e.length){var t=e.findIndex((function(e){return i.find((function(t){return t.value===e.value}))}));s.isMulti&&e.length>1&&-1!==t?f(0===t?e.slice(1):[e[t]]):a&&e.length>a?n&&n({type:"maxSelectedOptions",message:"Only up to "+a+" selections allowed"}):f(e)}else f(o);else f(e)},css:{marginRight:"25px"},styles:C,isClearable:"undefined"!==s.isClearable?s.isClearable:d.length>1})))};S.propTypes={label:p.a.string,options:p.a.array,maxSelectedOptions:p.a.number,onChange:p.a.func,onError:p.a.func,defaultValue:p.a.array,singleSelectOptions:p.a.array,isMulti:p.a.bool,isClearable:p.a.bool,className:p.a.string,value:p.a.array},S.defaultProps={maxSelectedOptions:2,singleSelectOptions:[]};var E=S,L=n(34);function N(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return k(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return k(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n"+e.title+""}}}},color:W.rainbow,xAxis:{axisLine:{show:!0,lineStyle:{color:"#ddd"}},axisLabel:{fontFamily:"Geomanist Regular,sans-serif",fontSize:13,color:"#32313f"},splitLine:{show:!1},nameTextStyle:{color:"#32313f",fontFamily:"Geomanist Regular,sans-serif"}},yAxis:{axisLabel:{fontFamily:"Geomanist Regular,sans-serif",fontSize:13,color:"#32313f"},axisLine:{show:!1,lineStyle:{color:"#ddd"}},axisTick:{show:!1},splitLine:{show:!1},nameTextStyle:{color:"#32313f",fontFamily:"Geomanist Regular,sans-serif"}},axisPointer:{type:"none"},grid:{top:10},textStyle:{fontFamily:"Geomanist Regular,sans-serif"}},H=n(20),J=n.n(H),K=function(){return d.a.createElement("div",{className:"no-data"},"No Data")},X=function(e,t,n){var a=e.slice();return t.forEach((function(t,r){void 0===a[r]?a[r]=n.cloneUnlessOtherwiseSpecified(t,n):n.isMergeableObject(t)?a[r]=J()(e[r],t,n):-1===e.indexOf(t)&&a.push(t)})),a},$=function(e,t){if(void 0===t&&(t={}),Array.isArray(t.yearRange)&&t.yearRange.length){var n=I(t.yearRange);return t.excludeYears?n.filter((function(e){return!t.excludeYears.includes(e)})).map((function(e){return""+e})):n.map((function(e){return""+e}))}var a=t.mapping&&t.mapping.year;if(!a)return[];var r=Array.from(new Set(e.map((function(e){return Number(e[a])})))).sort((function(e,t){return e-t}));return t.excludeYears?r.filter((function(e){return!t.excludeYears.includes(e)})).map((function(e){return""+e})):r.map((function(e){return e.toString()}))},Q=function(e,t,n){var a=e.reduce((function(e,a){return a[n.mapping.series]===t?e+Number(U(a[n.mapping.value])):e}),0);return n.aggregator&&"sum"!==n.aggregator&&"avg"===n.aggregator?a/e.filter((function(e){return e[n.mapping.series]===t})):a},ee=function(e,t,n){var a,r=e.series,o=e.mapping,i=!(a=e.type)||["bar-stacked","column-stacked"].includes(a)?"bar":"area"===a?"line":a;if("pie"!==i){var c=!e.type||["area","bar-stacked","column-stacked"].includes(e.type)?"district-stack":void 0,s=r.map((function(a,l){return{name:a,type:i,stack:c,areaStyle:"area"===e.type?{}:void 0,smooth:!0,emphasis:{focus:"series",label:{show:!0,formatter:function(e){return P(e.value)}}},symbol:"circle",label:{show:c&&l===r.length-1,fontFamily:"Geomanist Regular,sans-serif",position:"top",formatter:function(e){for(var t=0,n=0;n0})))))};oe.propTypes={rows:p.a.arrayOf(p.a.array)};var ie=oe,ce=n(43),se=function(e,t){void 0===t&&(t=[]);var n=e.url,a=e.yearRange,r=Object(ce.a)(n||e.className,(function(){return e.data&&Array.isArray(e.data)?e.data:n?T(n).then((function(t){return e.filters?M(t,e.filters):t})):[]})),o=r.data,i=r.error,c=Object(u.useState)(t),s=c[0],l=c[1];if(i)return{data:[],years:[]};var d=Object(u.useMemo)((function(){return o?(a&&a.length,$(o,e)):[]}),[o]);return{data:Object(u.useMemo)((function(){return o&&o.length?s.length?s.reduce((function(e,t){return"all"===t.value?e:V(e,t.dataProperty,t.value)}),o):o:[]}),[o,s]),years:d,filters:s,setFilters:l,updateFilter:function(e,t){s&&s.length&&l(s.map((function(n){return n.dataProperty===e?Object.assign({},n,{value:t}):n})))}}},le=function(e){return e.show?d.a.createElement("div",{className:h()("button-group",e.className)},d.a.createElement("button",{type:"button",className:h()("button button-sm button-outline",{active:"chart"===e.activeButton}),onClick:e.onClickChart},"Chart"),d.a.createElement("button",{type:"button",className:h()("button button-sm button-outline",{active:"table"===e.activeButton}),onClick:e.onClickTable},"Table")):null};le.propTypes={show:p.a.bool,onClickChart:p.a.func,onClickTable:p.a.func,activeButton:p.a.string,className:p.a.string},le.defaultProps={activeButton:"chart"};var ue=le,de=function(e){var t=se(e.config),n=t.data,a=t.years,r=t.setFilters,o=t.updateFilter,i=Object(u.useState)("chart"),c=i[0],s=i[1],l=Object(u.useState)(e.config.type||"bar"),f=l[0],p=l[1];Object(u.useEffect)((function(){var t,n,a,o,i;r((t=e.config,n=e.subCounty,a=t.mapping,o=t.selectors,i=[],a.subCounty&&n&&i.push({dataProperty:a.subCounty,value:"all"}),o&&o.forEach((function(e){i.push({dataProperty:e.dataProperty,value:e.defaultValue?e.defaultValue.value:"all"})})),i))}),[]),Object(u.useEffect)((function(){var t=e.subCounty,n=e.config;t&&n.mapping.subCounty&&o(n.mapping.subCounty,e.subCounty)}),[e.subCounty]);return d.a.createElement(d.a.Fragment,null,d.a.createElement("div",{className:h()("spotlight-banner data-selector--wrapper dicharts--actions",{"align-left":!e.config.selectors})},e.config.selectors?d.a.createElement(A,{configs:e.config.selectors,onChange:function(e,t){o(e.dataProperty,t.value)}}):null,d.a.createElement(ue,{show:!!e.config.table,onClickChart:function(){return s("chart")},onClickTable:function(){return s("table")},activeButton:c}),"chart"===c&&e.config.typeOptions?d.a.createElement(Z,{options:e.config.typeOptions,onChange:p}):null),"chart"===c?d.a.createElement(ne,Object(j.a)({className:h()({"dicharts--padding-top":!e.config.selectors})},e,{data:n,years:a,height:e.config.height,type:f})):null,"table"===c&&e.config.table?d.a.createElement(ie,{rows:B(e.config.table,n,e.subCounty)}):null)};de.propTypes={config:p.a.object,subCounty:p.a.string},de.defaultProps={subCounty:"all"};var fe,pe,be=de,me=function(e){(function(e){return e.className?e.series&&Array.isArray(e.series)?e.mapping?e.mapping.series?e.mapping.year?e.mapping.value?(e.mapping.subCounty||window.console.warn("Potentially invalid chart config: mapping.subCounty may be required!"),!0):(window.console.error("Invalid chart config: mapping.value is required!"),!1):(window.console.error("Invalid chart config: mapping.year is required!"),!1):(window.console.error("Invalid chart config: mapping.series is required!"),!1):(window.console.error("Invalid chart config: mapping is required!"),!1):(window.console.error(e.series?"Invalid chart config: Invalid series config - expected an array!":"Invalid chart config: Series is required!"),!1):(window.console.error("Invalid chart config: className is required!"),!1)})(e)&&window.DICharts.handler.addChart({className:e.className,echarts:{onAdd:function(t){Array.prototype.forEach.call(t,(function(t){t.classList.add("dicharts--dimensions"),t.parentElement.classList.add("auto-height");var n=new window.DICharts.Chart(t.parentElement);n.showLoading();var a="all",r=Object(o.createRoot)(t);r.render(d.a.createElement(be,{config:e,subCounty:a})),window.DIState&&window.DIState.addListener((function(){var t=window.DIState.getState.subCounty;t&&t!==a&&(a=t,r.render(d.a.createElement(be,{config:e,subCounty:a})))})),n.hideLoading()}))}}})},ge=function(){if(window.DIState){var e=[];window.DIState.addListener((function(){var t=window.DIState.getState.charts;t&&e.length!==t.length&&(e=t).forEach(me)}))}else window.console.log("State is not defined")},he=n(12),ve=n.n(he),ye=function(e){var t=e.map,n=e.show,a=e.onAdd,r=Object(w.a)(e,["map","show","onAdd"]);return t&&(t.getLayer(r.id)&&t.removeLayer(r.id),n&&(t.addLayer(r),a&&a(t,r.id))),null};ye.defaultProps={show:!0},ye.propTypes={map:p.a.object,show:p.a.bool,onAdd:p.a.func};var Oe={width:"100%",position:"absolute",top:0,bottom:0,background:"#F3F3F3"},je=function(e){ve.a.accessToken=e.accessToken;var t=Object(u.useRef)(null),n=Object(u.useState)(void 0),a=n[0],o=n[1];Object(u.useEffect)((function(){if(t&&t.current){var n=new ve.a.Map(Object.assign({container:t.current},e.options));e.showNavigationControls&&n.addControl(new ve.a.NavigationControl),n.on("load",(function(t){o(n),e.onLoad&&e.onLoad(n,t)}))}}),[]);return Object(r.c)("div",{ref:t,style:Object.assign({},Oe,e.style),css:Object(r.b)(fe||(fe=Object(b.a)(["\n background: ",";\n font-family: geomanist, sans-serif;\n "])),e.background)},u.Children.map(e.children,(function(e){return Object(u.isValidElement)(e)&&e.type===ye?Object(u.cloneElement)(e,{map:a}):null})),Object(r.c)(r.a,{styles:Object(r.b)(pe||(pe=Object(b.a)(["\n div .mapboxgl-canary {\n background: red;\n }\n\n div .mapboxgl-popup {\n z-index: 400;\n max-width: 100% !important;\n }\n\n div .mapboxgl-popup-content {\n background-color: rgba(0, 0, 0, 0.9) !important;\n box-shadow: none !important;\n color: #ffffff !important;\n font-family: geomanist, sans-serif;\n -webkit-tap-highlight-color: black;\n opacity: 0.8;\n padding: 20px;\n }\n\n div .mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {\n border-top-color: rgba(0, 0, 0, 0.9);\n opacity: 0.8;\n }\n\n div .mapboxgl-popup-content .mapBox-popup p {\n margin-bottom: 0;\n }\n\n div .mapboxgl-popup-content .mapboxgl-popup-close-button {\n color: #ffffff;\n font-size: 1.8rem;\n }\n "])))}))};je.defaultProps={style:Oe,options:{minZoom:6,zoom:6.1},showNavigationControls:!0,background:"inherit"},je.propTypes={accessToken:p.a.string,style:p.a.object,background:p.a.string,showNavigationControls:p.a.bool,onLoad:p.a.func,options:p.a.object,children:p.a.node,locationData:p.a.object};var we=n(24),xe=n(4),Ce=function(e,t){return t?t(e):e},Se=function(e,t){return t&&"number"==typeof t.value?(e.dataPrefix||"")+''+(n=t.value,void 0===a&&(a=1),(n>=1e12?(n/1e12).toFixed(a)+"tn":n>=1e9?(n/1e9).toFixed(a)+"bn":n>=1e6?(n/1e6).toFixed(a)+"m":n>=1e3?(n/1e3).toFixed(a)+"k":n>=0?""+n.toFixed(a):n<=-1e12?(n/1e12).toFixed(a)+"tn":n<=-1e9?(n/1e9).toFixed(a)+"bn":n<=-1e6?(n/1e6).toFixed(a)+"m":n<=1e3?(n/1e3).toFixed(a)+"k":""+n.toFixed(a))+"")+(e.dataSuffix||""):"No Data";var n,a},Ee=function(e){var t=e.geometry&&e.geometry.coordinates;return t?new he.LngLat(t[0],t[1]):null},Le=function(e,t,n){var a=e.querySourceFeatures("composite",{sourceLayer:n.sourceLayer,filter:["in",n.nameProperty,Ce(t,n.formatter)]});return a&&a.length?function(e){if(Array.isArray(e)){var t=e.map((function(e){return Object(we.a)(e.geometry).geometry.coordinates}));return t.push(t[0]),Ee(Object(we.a)(Object(xe.f)([t])))}return Ee(Object(we.a)(e))}(a):null},Ne=function(e,t,n,a,r){return t.setLngLat(n).setHTML('\n
\n
\n '+a.toLowerCase()+"\n
\n "+(r?''+r+"":"")+"\n
\n ").addTo(e)},ke=function(e,t,n){return t.find((function(t){var a=n?n(t.name):t.name;return e.toLowerCase()===(""+a).toLowerCase()}))},Pe=Object(u.createContext)(),Ie=Object(u.createContext)(),Te=n(38),Fe=function(e){function t(t){var n;return(n=e.call(this,t)||this).state={hasError:!1},n}Object(Te.a)(t,e),t.getDerivedStateFromError=function(){return{hasError:!0}};var n=t.prototype;return n.componentDidCatch=function(e,t){window.console.log("Error Boundary:",e,t)},n.render=function(){return this.state.hasError?d.a.createElement("div",null,"Something went wrong! Please contact your administrator"):this.props.children},t}(u.Component);Fe.propTypes={children:p.a.any};var Ae,_e=Fe,De=function(e,t){return e.find((function(e){return e.id===t}))},ze=function(e){return e.map((function(e){return{value:e.id,label:e.name}}))},Re=function(e,t){var n=De(e,t);return n?n.indicators.map((function(e){return{value:e.id,label:e.name}})):[]},qe=function(e,t,n){if(t&&n){var a=De(e,t);if(!(a&&a.indicators&&a.indicators.length))return[];var r=a.indicators.find((function(e){return e.id===n}));if(r&&r.yearRange)return I(r.yearRange).filter((function(e){return r.excludeYears?!r.excludeYears.includes(e):e})).reverse().map((function(e){return{value:e,label:e}}))}return[]},Ve=function(e){var t=Object(u.useContext)(Ie),n=t.filterOptions,a=t.updateFilterOptions;return Object(u.useEffect)((function(){!n.topic&&e.length&&a({topic:e[0].id})}),[]),Object(u.useEffect)((function(){if(n.topic){var t=De(e,n.topic),r=t&&t.indicators&&t.indicators.length?t.indicators[0]:null;r&&a({indicator:r.id})}}),[n.topic]),Object(u.useEffect)((function(){if(n.indicator){var t=qe(e,n.topic,n.indicator);t.length&&!t.find((function(e){return e.value===n.year}))&&a({year:t[0].value})}}),[n.indicator]),{topicOptions:ze(e||[]),indicatorOptions:Re(e,n.topic),yearOptions:qe(e,n.topic,n.indicator)}},Me=function(){var e=Object(u.useContext)(Ie),t=e.filters,n=e.topics,a=e.filterOptions,o=e.updateFilterOptions,i=Ve(n),c=i.topicOptions,s=i.indicatorOptions,l=i.yearOptions,d=a.year,f=a.indicator,p=function(e,t,n){var a;if(Array.isArray(e)&&e.length)e[0].value!==n&&o(((a={})[t]=e[0].value,a));else if(e&&!Array.isArray(e)){var r;if(e.value!==n)o(((r={})[t]=e&&e.value,r))}};return Object(r.c)("form",{className:"form"},Object(r.c)("div",{className:h()("form-field","form-field--inline-block"),css:Object(r.b)(Ae||(Ae=Object(b.a)(["\n z-index: auto;\n margin-left: 5px;\n "])))},Object(r.c)(E,{label:t.topicLabel,options:c,defaultValue:[c[0]],classNamePrefix:"topic-selector",isClearable:!1,css:{minWidth:"100%"},onChange:function(e){return o({topic:e&&e.value})}}),s&&s.length?Object(r.c)(E,{label:t.indicatorLabel,options:s,value:[f&&s.find((function(e){return e.value===f}))||s[0]],classNamePrefix:"indicator-selector",isClearable:!1,css:{minWidth:"100%",marginTop:"1em"},onChange:function(e){return p(e,"indicator",f)}}):null,l&&l.length?Object(r.c)(E,{label:t.yearLabel,options:l,value:[d&&l.find((function(e){return e.value===d}))||l[0]],classNamePrefix:"year-selector",isClearable:!1,css:{minWidth:"100%",marginTop:"1em"},onChange:function(e){return p(e,"year",d)}}):null))},Ue=function(e){var t=e.children;return d.a.createElement("div",{className:"spotlight-legend","data-testid":"spotlight-legend"},u.Children.map(t,(function(e){return e})))};Ue.propTypes={children:p.a.any};var Be=Ue,Ge=n(39),Ze=function(e){var t=e.children,n=e.className,a=e.bgColor,r=e.textColor,o=Ge(a);return d.a.createElement("span",{className:n,"data-testid":"spotlight-legend-item"},t,d.a.createElement("style",null,"\n span."+n+" {\n background-color: "+(a||"#D1CBCF")+" !important;\n color: "+(r||o.isLight()?"#000":"#FFF")+";\n }\n "))};Ze.propTypes={children:p.a.any,className:p.a.string,bgColor:p.a.string,textColor:p.a.string};var We=Ze,Ye=function(){var e,t,n=Object(u.useContext)(Ie).activeIndicator;return d.a.createElement("div",{className:"spotlight__content"},d.a.createElement(_e,null,d.a.createElement(Me,null)),n?d.a.createElement(d.a.Fragment,null,d.a.createElement("div",{className:"spotlight__subheading"},n.name),n.description?d.a.createElement("p",{className:"spotlight__excerpt"},n.description):null,d.a.createElement(Be,null,(e=n.range,t=n.colours,e&&t?e.map((function(n,a){return d.a.createElement(We,{className:"item-"+n,bgColor:t[a],key:n},0===a?"< "+e[0]:e[a-1]+"-"+n)})).concat([d.a.createElement(We,{className:"item-last",bgColor:t[t.length-1],key:e.length},"> "+e[e.length-1])]):null),d.a.createElement(We,null,"no data / not applicable"))):null)},He=n(40),Je={type:"shapefile",style:"mapbox://styles/edwinmp/ck42rrx240t8p1cqpkhgy2g0m/draft",sourceLayer:"Uganda_Sub-Counties_2019-8w0zb5",layerName:"uganda-Sub-counties-2019-8w0zb5",center:[32.655221,1.344666],zoom:8,minZoom:8,maxZoom:9,districtNameProperty:"District",nameProperty:"Subcounty",codeProperty:"scode2019",formatter:function(e,t){return void 0===t&&(t="map"),e.toUpperCase()}},Ke=function(e,t,n,a){n&&(e.setFilter(t,["==",a.nameProperty,Ce(n.name,a.formatter)]),setTimeout((function(){if(n.coordinates)e.flyTo({center:n.coordinates,zoom:8.5});else{var t=a.formatter?a.formatter(n.name):n.name;!function e(t,n,a,r){return void 0===r&&(r=!0),new Promise((function(o,i){var c=Le(t,n,a);c?(t.flyTo({center:c,zoom:16}),o(c)):r?(t.flyTo({center:a.center,zoom:a.zoom||6.1}),setTimeout((function(){e(t,n,a,!1).then((function(e){return o(e)})).catch(i)}),500)):i(new Error("Location "+n+" not found!"))}))}(e,t,a)}}),500))},Xe=function(e,t,n){if(!t)return[];if(!t.mapping)throw new Error("Mapping is required for indicator "+t.id);var a=t.mapping,r=a.location,o=a.value,i=a.year,c=M(e,t.filters);return c=n?c.filter((function(e){return""+e[i]==""+n})).map((function(e){return{name:e[r],value:Number(e[o])}})):c.map((function(e){return{name:e[r],value:Number(e[o])}})),t.aggregator?function(e,t){var n=Object(He.groupBy)(e,(function(e){return e.name}));return Object.keys(n).map((function(e){var a=n[e].reduce((function(e,t){return e+t.value}),0),r=a/n[e].length;return{name:e,value:"sum"===t?a:r}}))}(c,t.aggregator):c},$e=function(e){return e.split(",").map((function(e){return parseFloat(e)}))},Qe=["Waiga Primary School","Gods Mercy Primary School","Bukeeka COU Primary School"],et=["Bukeeka COU Primary School","Kungu CU Primary School","King Jesus Nursery And Primary School","Nile View Primary School","Imam Hassan Primary School Maligita","Bright Future Nursery And Primary School Kangulumira"],tt=function(e,t){var n="https://raw.githubusercontent.com/devinit/ug-district-dashboard-viz/dev/public/assets/data/"+e.toLowerCase()+"/schools-locations.csv",a={type:"FeatureCollection",features:[]};return t&&n&&n?(T(n).then((function(n){var r=n.filter((function(t){return"Masindi"===e?!Qe.includes(t.school_name):!et.includes(t.school_name)}));"all"===t.ownership?r.filter((function(e){return e.level===t.level})).forEach((function(e){if(e.gps_coordinates){var t=$e(e.gps_coordinates);t&&a.features.push({type:"Feature",geometry:{type:"Point",coordinates:[t[1],t[0]]},properties:{level:e.level,ownership:e.ownership,name:e.school_name,parish:e.parish}})}})):r.filter((function(e){return e.level===t.level&&e.ownership===t.ownership})).forEach((function(e){if(e.gps_coordinates){var t=$e(e.gps_coordinates);t&&a.features.push({type:"Feature",geometry:{type:"Point",coordinates:[t[1],t[0]]},properties:{level:e.level,ownership:e.ownership,name:e.school_name,parish:e.parish}})}}))})).catch((function(e){console.log(e)})),a):a};function nt(e){return"numberOfPrimarySchools"===e?{level:"Primary",ownership:"all"}:"numberOfSecondarySchools"===e?{level:"Secondary",ownership:"all"}:"numberOfGovernmentPrimarySchools"===e?{level:"Primary",ownership:"Government"}:"numberOfPrivatePrimarySchools"===e?{level:"Primary",ownership:"Private"}:"numberOfGovernmentSecondarySchools"===e?{level:"Secondary",ownership:"Government"}:"numberOfPrivateSecondarySchools"===e?{level:"Secondary",ownership:"Private"}:""}var at,rt=function(e,t,n,a){!function(e,t,n){var a=n.popup,r=n.nameProperty,o=n.formatter,i=n.data,c=function(e,t){if(e.features&&e.features[0].properties){var n=e.features[0].geometry;if("Polygon"===n.type||"MultiPolygon"===n.type)return e.features[0].properties[t]||null}return null}(t,r);if(c){var s=o?o(c,"tooltip"):c;if(i){var l=ke(s,i);Ne(e,a,t.lngLat,s,Se(n,l))}else Ne(e,a,t.lngLat,s,"")}}(t,n,Object.assign({},a,{popup:e}))},ot=new he.Popup({offset:5}),it=new he.Popup({offset:5}),ct=function(e,t,n){void 0===n&&(n={});var a=Object(u.useState)(),r=a[0],o=a[1],i=Object(u.useState)(n),c=i[0],d=i[1],f=Object(u.useState)([]),p=f[0],b=f[1],m=Object(u.useState)(),g=m[0],h=m[1],v=Object(u.useState)(""),y=v[0],O=v[1],j=Object(u.useCallback)((function(e){r.getCanvas().style.cursor="pointer",rt(ot,r,e,Object.assign({},t,{data:p},c))}),[r,p,c]),w=Object(u.useCallback)((function(){r.getCanvas().style.cursor="",ot.remove()}),[r,e]),x=Object(u.useCallback)((function(e){e.preventDefault(),r.off("mousemove","highlight",j),ot.remove(),e.features.length&&r.setLayoutProperty("points","icon-size",["match",["get","name"],e.features[0].properties.name,.4,.2])}),[r,g]),C=Object(u.useCallback)((function(e){for(var t=e.features[0].geometry.coordinates.slice(),n=e.features[0].properties,a=n.name,o=n.parish,i=n.ownership;Math.abs(e.lngLat.lng-t[0])>180;)t[0]+=e.lngLat.lng>t[0]?360:-360;it.setLngLat(t).setHTML('\n
\n
\n '+a+"\n
\n

Coordinates: "+t+"

\n

Ownership: "+i+"

\n

Parish: "+(o||"No parish data")+"

\n
\n ").addTo(r)})),S=Object(u.useCallback)((function(){r.on("mousemove","highlight",j),ot.remove(),r.setLayoutProperty("points","icon-size",.2)}),[r,e]);return Object(u.useEffect)((function(){r&&(r.getLayer("points")&&r.removeLayer("points"),g.features.length&&r.loadImage("https://docs.mapbox.com/mapbox-gl-js/assets/custom_marker.png",(function(e,t){if(e)throw e;r.hasImage("custom-marker")||r.addImage("custom-marker",t,{sdf:!0}),r.getSource("points")||r.addSource("points",{type:"geojson",data:g,generateId:!0}),r.getLayer("points")||r.addLayer({id:"points",type:"symbol",source:"points",layout:{"icon-image":"custom-marker","icon-anchor":"bottom","icon-size":.2,"icon-allow-overlap":!0},paint:{"icon-color":["match",["get","level"],"Primary","#ff9c1a","Secondary","#00b3b3","#ffffff"]},minzoom:8}),r.getSource("points").setData(g)})))}),[r,p,g,y]),Object(u.useEffect)((function(){r&&(r.getStyle().layers.forEach((function(e){["background","highlight"].includes(e.id)||r.setLayoutProperty(e.id,"visibility","none")})),function(e,t,n){t.clientWidth<700?e.setZoom(n.zoom?n.zoom-1:5):t.clientWidth<900?e.setZoom(n.minZoom?n.minZoom+.8:5.8):e.setZoom(n.zoom||6.1)}(r,r.getContainer(),t),r.off("mousemove","points",x),r.off("mouseleave","highlight",w),r.off("mouseover","highlight",j),r.off("click","points",C),r.on("mousemove","highlight",j),r.on("mouseleave","highlight",w),r.on("mousemove","points",x),r.on("mouseleave","points",S),r.on("click","points",C))}),[r,e,c,p]),Object(u.useEffect)((function(){var t=function(){var e=Object(l.a)(s.a.mark((function e(t){var n;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,T(t);case 2:n=e.sent,b(Xe(n,c.indicator,c.year));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();c.indicator&&c.year&&(O(nt(c.indicator.id)),h(tt(e.name,nt(c.indicator.id))),t(c.indicator.url))}),[c.indicator,c.year]),{map:r,data:p,setData:b,setMap:o,setOptions:d}},st=function(e,t,n,a,o){var i=[a].map((function(e){return Object(r.c)(ye,{key:"highlight-hidden",id:e.layerName,source:"composite","source-layer":e.sourceLayer,show:!1})}));function c(e,t){Ke(e,t,n,Object.assign({},a,{nameProperty:a.districtNameProperty}))}if(!e&&o.range&&o.colours&&t.length){var s=function(e,t,n,a){return e&&t&&n?e.map((function(e){var r=Ce(e.name,a),o=t.find((function(t){return null!==e.value&&e.value<=parseFloat(t)}));return o?[r,n[t.indexOf(o)]]:e.value>parseFloat(t[t.length-1])?[r,n[n.length-1]]:[r,"#b3adad"]})):[]}(t,o.range,o.colours,a.formatter);return i.concat(Object(r.c)(ye,{key:"highlight",id:"highlight",source:"composite","source-layer":a.sourceLayer,maxzoom:a.maxZoom&&a.maxZoom+2,type:"fill",paint:{"fill-color":{property:a.nameProperty,type:"categorical",default:"#D1CBCF",stops:s},"fill-opacity":.9,"fill-outline-color":"#ffffff"},onAdd:c}))}return i.concat(Object(r.c)(ye,{key:"highlight",id:"highlight",source:"composite","source-layer":a.sourceLayer,maxzoom:a.maxZoom&&a.maxZoom+2,type:"fill",paint:{"fill-color":"#D1CBCF","fill-opacity":.75,"fill-outline-color":"#ffffff"},onAdd:c}))},lt={topic:null,indicator:null,year:null},ut=m.a.div(at||(at=Object(b.a)(["\n position: absolute;\n top: 1.75em;\n z-index: 1;\n left: 1.4em;\n"])));function dt(e,t){switch(t.type){case"UPDATE_FILTERS":return Object.assign({},e,{filterOptions:t.merge?Object.assign({},e.filterOptions,t.filterOptions):t.filterOptions,activeTopic:t.activeTopic,activeIndicator:t.activeIndicator,activeYear:t.activeYear});case"SET_DATA":return Object.assign({},e,{data:t.data});case"RESET_FILTERS":return Object.assign({},e,{filterOptions:lt});default:throw new Error}}var ft={filterOptions:lt},pt=function(e){var t=Object(u.useState)(!0),n=t[0],a=t[1],o=Object(u.useReducer)(dt,ft),i=o[0],c=o[1],s=i.filterOptions,l=i.activeIndicator,d=i.activeTopic,f=i.activeYear,p=ct(e.location,e.configs.formatter?Object.assign({},Je,{formatter:e.configs.formatter}):Je),b=p.data,m=p.map,g=p.setMap,h=p.setOptions;Object(u.useEffect)((function(){if(l){var e=s.year;h({dataPrefix:l.name+": ",dataSuffix:e&&" in "+e,indicator:l,year:e})}}),[l,s.year,m]);var v,y,O=function(t,n){void 0===n&&(n=!0);var a=function(e,t){var n=t.topic,a=t.indicator,r=t.year;if(n){var o=e.find((function(e){return e.id===n}));if(o&&a){var i=o.indicators.find((function(e){return e.id===a}));if(i)return{topic:o,indicator:i,year:r}}return{topic:o}}return{}}(e.configs.data,Object.assign({},s,t)),r=a.topic,o=a.indicator,i=a.year;c({type:"UPDATE_FILTERS",merge:n,filterOptions:t,activeTopic:r,activeIndicator:o,activeYear:i})},j=(v=e.configs.data,y=s.topic,v.find((function(e){return e.id===y}))),w=Object(u.useMemo)((function(){return{filters:e.filters,topics:e.configs.data,filterOptions:s,updateFilterOptions:O,activeTopic:d,activeIndicator:l,activeYear:f}}));return Object(r.c)(Ie.Provider,{value:w},Object(r.c)("div",{className:"spotlight"},Object(r.c)("div",{className:"spotlight__aside spotlight__aside--no-margin",css:{minHeight:"600px"}},Object(r.c)(Ye,null)),Object(r.c)("div",{className:"spotlight__main spotlight__main--map"},n?Object(r.c)("div",null,"Loading ..."):null,j&&j.dashboardUrl?Object(r.c)(ut,null,Object(r.c)("a",{href:j.dashboardUrl,className:"button button--secondary--fill"},j.dashboardButtonCaption)):null,Object(r.c)(je,{accessToken:"pk.eyJ1IjoiZWR3aW5tcCIsImEiOiJjazFsdHVtcG0wOG9mM2RueWJscHhmcXZqIn0.cDR43UvfMaOY9cNJsEKsvg",locationData:tt(e.location.name),options:Object.assign({style:Je.style,center:Je.center,minZoom:Je.minZoom||6,zoom:Je.zoom||6.1,maxZoom:Je.maxZoom||7,scrollZoom:!1},e.configs.options),style:{width:"100%",background:"#ffffff"},onLoad:function(e){a(!1),g(e)}},st(n,b,e.location,e.configs.formatter?Object.assign({},Je,{formatter:e.configs.formatter}):Je,l?{range:l.range,colours:l.colours}:{})))))};pt.defaultProps={data:[]},pt.propTypes={configs:p.a.object,filters:p.a.object,data:p.a.array,location:p.a.shape({name:p.a.string,fullName:p.a.string,coordinates:p.a.array})};var bt,mt,gt,ht,vt,yt,Ot,jt=pt,wt=m.a.div(bt||(bt=Object(b.a)(["\n background: #ffffff;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n"]))),xt=function(){return d.a.createElement(wt,null,d.a.createElement(K,null))},Ct=function(e){window.DICharts.handler.addChart({className:e,echarts:{onAdd:function(e){Array.prototype.forEach.call(e,(function(e){var t=new window.DICharts.Chart(e.parentElement);if(t.showLoading(),window.DIState){var n=Object(o.createRoot)(e);window.DIState.addListener((function(){t.showLoading();var e=window.DIState.getState,a=e.map,r=e.location;a?n.render(d.a.createElement(jt,{configs:a,location:r,filters:a.filters})):n.render(d.a.createElement(xt,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},St=n(41),Et=function(e){var t=e.close,n=e.description,a=e.source;return Object(r.c)("div",{className:"spotlight-modal",css:Object(r.b)(gt||(gt=Object(b.a)(["\n font-size: 12px;\n "])))},Object(r.c)("a",{className:"close",onClick:t,css:Object(r.b)(ht||(ht=Object(b.a)(["\n cursor: pointer;\n position: absolute;\n display: block;\n padding: 5px 10px;\n line-height: 20px;\n right: 0px;\n top: 0px;\n font-size: 20px;\n background: transparent;\n color: #333131;\n font-weight: 900;\n "])))},"×"),Object(r.c)("div",{className:"content",css:Object(r.b)(vt||(vt=Object(b.a)(["\n width: 100%;\n padding: 10px 5px 10px 5px;\n "])))},Object(r.c)("p",{className:"description",css:Object(r.b)(yt||(yt=Object(b.a)(["\n font-size: 14px;\n "])))},n),a?Object(r.c)(d.a.Fragment,null,Object(r.c)("br",null),Object(r.c)("p",{className:"source",css:Object(r.b)(Ot||(Ot=Object(b.a)(["\n text-align: left;\n "])))},a?Object(r.c)(d.a.Fragment,null,Object(r.c)("b",{css:Object(r.b)(mt||(mt=Object(b.a)(["\n font-family: Geomanist Bold, sans-serif;\n "])))},"Source:"," "),a):null)," "):null))};Et.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string,close:p.a.func.isRequired};var Lt,Nt,kt=Et,Pt=function(e){return Object(r.c)(St.a,{trigger:Object(r.c)("span",{className:"spotlight__stat-icon",css:Object(r.b)(Lt||(Lt=Object(b.a)(["\n display: inline-flex;\n margin-left: 2px;\n cursor: pointer;\n padding: 8px;\n "])))},Object(r.c)("i",{onClick:function(){document.querySelectorAll(".popup-content ").forEach((function(e){e.setAttribute("style","display:none;")}))},role:"presentation","aria-hidden":"true",className:"ico ico--12 ico-info-slate",css:Object(r.b)(Nt||(Nt=Object(b.a)(["\n top: -1px;\n "])))})),offsetX:20,arrowStyle:{height:"10px",width:"10px",position:"absolute",background:"rgb(255, 255, 255)",transform:"rotate(225deg)",margin:"-5px",zIndex:-1,boxShadow:"rgb(0 0 0 / 20%) 1px 1px 1px",bottom:"0%",left:"82px"},position:"bottom center",closeOnDocumentClick:!0,contentStyle:{zIndex:200,width:"350px",background:"#fff",fontWeight:400,fontStyle:"normal",fontSize:"12px",color:"#60575d",border:0,borderRadius:"0.28571429rem",boxShadow:"0 2px 4px 0 rgba(34, 36, 38, 0.12), 0 2px 10px 0 rgba(34, 36, 38, 0.15)",padding:"5px"}},(function(t){return Object(r.c)(kt,{close:t,description:e.description,source:e.source})}))};Pt.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string};var It=Pt,Tt=function(e){var t=e.meta,n=void 0===t?{}:t,a=e.heading,r=e.children;return d.a.createElement("div",{className:"spotlight__stat"},d.a.createElement("h3",{className:"spotlight__stat-heading"},a,n.description||n.source?d.a.createElement(It,{description:n.description,source:n.source}):null),r)};Tt.defaultProps={meta:{}},Tt.propTypes={heading:p.a.string,meta:p.a.shape({description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string}),children:p.a.any};var Ft,At=Tt,_t=function(e){var t=e.value,n=e.note;return Object(r.c)("p",{className:"spotlight__stat-data"},t,n&&n.content?Object(r.c)("span",{className:"spotlight__stat-data__note",css:Object(r.b)(Ft||(Ft=Object(b.a)(["\n transform: none;\n position: relative;\n top: -10px;\n "])))},n.content," ",n.meta?Object(r.c)(It,{description:n.meta.description,source:n.meta.source}):null):null)};_t.propTypes={note:p.a.object,value:p.a.string};var Dt,zt=_t,Rt=function(e){var t=e.children;return Object(r.c)("article",{className:"tabs__content",css:Object(r.b)(Dt||(Dt=Object(b.a)(["\n z-index: 200;\n "])))},t)};Rt.propTypes={children:p.a.any};var qt=Rt,Vt=function(e){var t=e.id,n=e.active,a=e.label,r=e.children,o=e.onActivate;return d.a.createElement("section",{className:"tabs__container",id:t},d.a.createElement("input",{className:"tabs__input",type:"radio",name:"sections",id:t+"-option",defaultChecked:n}),d.a.createElement("label",{className:"tabs__label",htmlFor:t+"-option",onClick:o},a),u.Children.map(r,(function(e){return Object(u.isValidElement)(e)&&e.type===qt?e:null})))};Vt.propTypes={id:p.a.string.isRequired,label:p.a.string.isRequired,active:p.a.bool,onActivate:p.a.func,children:p.a.any};var Mt=Vt,Ut=function(e){var t=e.children,n=e.onClick;return d.a.createElement("div",{className:"tabs__content__header",onClick:n},t)};Ut.propTypes={children:p.a.any,onClick:p.a.func};var Bt,Gt,Zt,Wt,Yt,Ht=Ut,Jt=function(e){var t=Object(u.useContext)(Pe),n=t.data,a=t.location,o=t.options,i="education",c=q(o.tabs,i);if(void 0!==c.show&&!c.show)return null;var s=n&&n.education?n.education.find((function(e){return"Number of Schools"===e.caption})):null;return Object(r.c)(Mt,{id:i,label:c.label||"Education",active:!!e.active||c.active},Object(r.c)(qt,null,Object(r.c)(Ht,null,s?Object(r.c)("div",{css:Object(r.b)(Bt||(Bt=Object(b.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(Gt||(Gt=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(Zt||(Zt=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(Wt||(Wt=Object(b.a)(["\n font-size: 3rem;\n "])))},P(s.value)),Object(r.c)(It,{description:"Last updated: "+s.lastUpdated})),c.dashboardURL?Object(r.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null):null),Object(r.c)("div",{className:"l-2up"},n&&n.education?n.education.filter((function(e){return"Number of Schools"!==e.caption})).map((function(e){return Object(r.c)("div",{className:"l-2up__col",key:e.caption},Object(r.c)(At,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(Yt||(Yt=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(zt,{value:e.value})))})):null)))};Jt.propTypes={active:p.a.bool};var Kt,Xt,$t,Qt,en,tn=Jt,nn=function(e){var t=Object(u.useContext)(Pe),n=t.data,a=t.location,o=t.options,i="overview",c=q(o.tabs,i);return void 0===c.show||c.show?Object(r.c)(Mt,{id:i,label:c.label||"Overview",active:!!e.active||c.active},Object(r.c)(qt,null,Object(r.c)(Ht,null,n&&n.population?Object(r.c)("div",{css:Object(r.b)(Kt||(Kt=Object(b.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(Xt||(Xt=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)($t||($t=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Total Population in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(Qt||(Qt=Object(b.a)(["\n font-size: 3rem;\n "])))},P(n.population.value)),Object(r.c)(It,{description:"Last updated: "+n.population.lastUpdated})),c.dashboardURL?Object(r.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null):null),Object(r.c)("div",{className:"l-2up"},n&&n.administration?n.administration.map((function(e){return Object(r.c)("div",{className:"l-2up__col",key:e.caption},Object(r.c)(At,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(en||(en=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(zt,{value:e.value})))})):null))):null};nn.propTypes={active:p.a.bool};var an,rn,on,cn,sn,ln,un=nn,dn=function(e){var t=Object(u.useContext)(Pe),n=t.data,a=t.location,o=t.options,i="production",c=q(o.tabs,i);if(void 0!==c.show&&!c.show)return null;var s=n&&n.production?n.production.find((function(e){return""===e.caption})):null;return Object(r.c)(Mt,{id:i,label:c.label||"Production",active:!!e.active||c.active},Object(r.c)(qt,null,Object(r.c)(Ht,null,Object(r.c)("div",{css:Object(r.b)(an||(an=Object(b.a)(["\n display: flex;\n "])))},s?Object(r.c)("div",{css:Object(r.b)(rn||(rn=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(on||(on=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(cn||(cn=Object(b.a)(["\n font-size: 3rem;\n "])))},P(s.value)),Object(r.c)(It,{description:"Last updated: "+s.lastUpdated})):null,c.dashboardURL?Object(r.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null)),n&&n.production&&n.production.length?Object(r.c)("div",{className:"l-2up"},n.production.filter((function(e){return""!==e.caption})).map((function(e){return Object(r.c)("div",{className:"l-2up__col",key:e.caption},Object(r.c)(At,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(sn||(sn=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(zt,{value:e.value})))}))):Object(r.c)("div",{css:Object(r.b)(ln||(ln=Object(b.a)(["\n font-size: 16px;\n display: flex;\n justify-content: center;\n width: 100%;\n "])))},"No Production Data")))};dn.propTypes={active:p.a.bool};var fn,pn=dn,bn=function(e){var t=e.children;return Object(r.c)("div",{className:"tabs",css:Object(r.b)(fn||(fn=Object(b.a)(["\n z-index: 0;\n "])))},t)};bn.propTypes={children:p.a.any};var mn=bn,gn=function(e){var t=Object(u.useState)({}),n=t[0],a=t[1];return Object(u.useEffect)((function(){e.data&&a(function(e){var t={},n=function(e){return{caption:e.Item,value:e.Value,lastUpdated:e["Last Updated"]}},a=e.find((function(e){return"Total Population"===e.Item}));return a&&(t.population=n(a)),t.administration=e.filter((function(e){return"Total Population"!==e.Item&&"Administration"===e.Department})).map(n),t.education=e.filter((function(e){return"Total Population"!==e.Item&&"Education"===e.Department})).map(n),t.production=e.filter((function(e){return"Total Population"!==e.Item&&"Production"===e.Department})).map(n),t}(e.data))}),[e.data]),Object(r.c)(Pe.Provider,{value:Object.assign({},e,{data:n})},Object(r.c)(mn,null,Object(r.c)(un,{active:!0}),Object(r.c)(tn,null),Object(r.c)(pn,null)))};gn.propTypes={data:p.a.array.isRequired,location:p.a.object.isRequired,options:p.a.object.isRequired};var hn=gn,vn=function(e){window.DICharts.handler.addChart({className:e,echarts:{onAdd:function(e){Array.prototype.forEach.call(e,(function(e){var t=new window.DICharts.Chart(e.parentElement);if(t.showLoading(),window.DIState){var n=Object(o.createRoot)(e);window.DIState.addListener((function(){t.showLoading();var e=window.DIState.getState,a=e.keyFacts,r=e.location;a&&a.url?T(a.url).then((function(e){Array.isArray(e)?n.render(d.a.createElement(hn,{data:e,options:a,location:r})):e.results?n.render(d.a.createElement(hn,{data:e.results,options:a,location:r})):(window.console.error("Invalid data shape. Expected an array or an object with a results property.",e),n.render(d.a.createElement(xt,null)))})).catch((function(e){window.console.log(e),n.render(d.a.createElement(xt,null))})):a&&a.data?n.render(d.a.createElement(hn,{data:a.data,options:a,location:r})):n.render(d.a.createElement(xt,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},yn=function(){var e=Object(l.a)(s.a.mark((function e(t,n){var a,r,o,i,c,l;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.data,r=t.config,o=t.subCounty,i=t.tableRoot,c=r.selectors.map((function(e){return{property:e.dataProperty,value:"all"}})),l=function(e,t){var n=Array.isArray(t)?t[0].value:t.value;if(n){var s=c.find((function(t){return t.property===e.config.dataProperty}));if(s){s.value=n;var l=c.reduce((function(e,t){return"all"===t.value?e:V(e,t.property,t.value)}),a),u=B(r,l,o);i.render(d.a.createElement(ie,{rows:u}))}}},e.abrupt("return",_(r.selectorClassName,{selectors:r.selectors,onChange:l,makeSticky:!1,nodes:n}));case 4:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),On=function(e){(function(e){return e.className?e.mapping?e.mapping.rows?e.mapping.year?e.mapping.value?e.mapping.subCounty?!!e.mapping.level||(window.console.error("Invalid table config: mapping[mapping.level] is required!"),!1):(window.console.error("Invalid table config: mapping.subCounty is required!"),!1):(window.console.error("Invalid table config: mapping.value is required!"),!1):(window.console.error("Invalid table config: mapping.year is required!"),!1):(window.console.error("Invalid table config: mapping.series is required!"),!1):(window.console.error("Invalid table config: mapping is required!"),!1):(window.console.error("Invalid table config: className is required!"),!1)})(e)&&window.DICharts.handler.addChart({className:e.className,d3:{onAdd:function(t){T(e.url).then((function(n){Array.prototype.forEach.call(t,(function(t){var a=new window.DICharts.Chart(t.parentElement);a.showLoading();var r=Object(o.createRoot)(t),i="all",c=[];window.DIState.addListener((function(){a.showLoading();var o=window.DIState.getState.subCounty;if(o!==i){i=o||"all";var s=e.filters&&e.filters.subCounties?function(e,t,n){return e.filter((function(e){return!t||"all"===t||e[n].toLowerCase()===t.toLowerCase()}))}(n,i,e.mapping.subCounty):n,l=B(e,s,i);r.render(d.a.createElement(ie,{rows:l})),e.selectors&&e.selectors.length&&yn({data:s,subCounty:i,config:e,tableRoot:r},c).then((function(e){c=e})),a.hideLoading(),t.parentElement.classList.add("auto-height")}}))}))}))}}})},jn=function(){if(window.DIState){var e=[];window.DIState.addListener((function(){var t=window.DIState.getState.tables;t&&e.length!==t.length&&(e=t).forEach((function(e){On(e)}))}))}else window.console.log("State is not defined")};n(93);window.addEventListener("load",(function(){_("district-selectors",{makeSticky:!0}),Ct("dicharts--district-map"),jn(),vn("dicharts--keyfacts"),ge()}))}},[[45,1,2]]]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{103:function(e,t,n){},104:function(e,t,n){"use strict";n.r(t);var a,r=n(1),o=n(9),i=n(107),c=n(11),s=n.n(c),l=n(15),u=n(0),d=n.n(u),f=n(3),p=n.n(f),b=n(4),m=n(19),g=n(10),h=n.n(g),v=m.a.div(a||(a=Object(b.a)(["\n color: red;\n font-size: 11px;\n position: relative;\n padding: 5px 5px 5px 0px;\n display: block;\n"]))),y=function(e){var t=Object(u.useState)(""),n=t[0],a=t[1],r=function(t){t?"maxSelectedOptions"===t.type&&a(e.selectErrorMessage):a("")};return d.a.createElement("div",{className:h()(e.className)},d.a.Children.map(e.children,(function(e){return d.a.isValidElement(e)?d.a.cloneElement(e,{onError:r}):e})),n?d.a.createElement(v,{className:"data-selector--wrapper"},n):null)};y.propTypes={selectErrorMessage:p.a.string,children:p.a.node,className:p.a.string};var O=y,j=n(25),w=n(26),x=n(47),C={control:function(e){return Object.assign({},e,{borderColor:"#ddd",borderRadius:"none",boxShadow:"none",":hover":{borderColor:"#357ba5"},":active":{borderColor:"#357ba5"}})},menu:function(e){return Object.assign({},e,{color:"#443e42",backgroundColor:"#FFFFFF"})},option:function(e,t){return Object.assign({},e,{fontSize:"14px",":hover":{backgroundColor:"#4e9ac6",color:"#ffffff"},backgroundColor:t.isSelected?"#357ba5":"transparent"})},singleValue:function(e){return Object.assign({},e,{fontSize:"14px"})},multiValue:function(e){return Object.assign({},e,{fontSize:"14px"})},multiValueLabel:function(e,t){return t.data.isCloseable?e:Object.assign({},e,{paddingRight:6})},multiValueRemove:function(e,t){return t.data.isCloseable?e:Object.assign({},e,{display:"none"})},input:function(e){return Object.assign({},e,{fontSize:"14px"})},indicatorsContainer:function(e){return Object.assign({},e,{pointerEvents:"none"})}},S=function(e){var t=e.label,n=e.onError,a=e.maxSelectedOptions,o=e.defaultValue,i=e.singleSelectOptions,c=e.className,s=Object(w.a)(e,["label","onError","maxSelectedOptions","defaultValue","singleSelectOptions","className"]),l=Object(u.useState)(o),d=l[0],f=l[1];Object(u.useEffect)((function(){s.onChange&&s.onChange(d),n&&n()}),[d]),Object(u.useEffect)((function(){s.value&&f(s.value)}),[s.value]);return Object(r.c)("div",{className:h()("labelled-data-selector--wrapper",c)},Object(r.c)("label",null,Object(r.c)("b",null,t)),Object(r.c)(x.a,Object(j.a)({},s,{value:d,onChange:function(e){if(s.isMulti)if(e.length){var t=e.findIndex((function(e){return i.find((function(t){return t.value===e.value}))}));s.isMulti&&e.length>1&&-1!==t?f(0===t?e.slice(1):[e[t]]):a&&e.length>a?n&&n({type:"maxSelectedOptions",message:"Only up to "+a+" selections allowed"}):f(e)}else f(o);else f(e)},css:{marginRight:"25px"},styles:C,isClearable:"undefined"!==s.isClearable?s.isClearable:d.length>1})))};S.propTypes={label:p.a.string,options:p.a.array,maxSelectedOptions:p.a.number,onChange:p.a.func,onError:p.a.func,defaultValue:p.a.array,singleSelectOptions:p.a.array,isMulti:p.a.bool,isClearable:p.a.bool,className:p.a.string,value:p.a.array},S.defaultProps={maxSelectedOptions:2,singleSelectOptions:[]};var E=S,L=n(106),N=n(39);function k(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return P(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return P(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n"+e.title+""}}}},color:H.rainbow,xAxis:{axisLine:{show:!0,lineStyle:{color:"#ddd"}},axisLabel:{fontFamily:"Geomanist Regular,sans-serif",fontSize:13,color:"#32313f"},splitLine:{show:!1},nameTextStyle:{color:"#32313f",fontFamily:"Geomanist Regular,sans-serif"}},yAxis:{axisLabel:{fontFamily:"Geomanist Regular,sans-serif",fontSize:13,color:"#32313f"},axisLine:{show:!1,lineStyle:{color:"#ddd"}},axisTick:{show:!1},splitLine:{show:!1},nameTextStyle:{color:"#32313f",fontFamily:"Geomanist Regular,sans-serif"}},axisPointer:{type:"none"},grid:{top:10},textStyle:{fontFamily:"Geomanist Regular,sans-serif"}},K=n(24),X=n.n(K),$=function(){return d.a.createElement("div",{className:"no-data"},"No Data")},Q=function(e,t,n){var a=e.slice();return t.forEach((function(t,r){void 0===a[r]?a[r]=n.cloneUnlessOtherwiseSpecified(t,n):n.isMergeableObject(t)?a[r]=X()(e[r],t,n):-1===e.indexOf(t)&&a.push(t)})),a},ee=function(e,t){if(void 0===t&&(t={}),Array.isArray(t.yearRange)&&t.yearRange.length){var n=T(t.yearRange);return t.excludeYears?n.filter((function(e){return!t.excludeYears.includes(e)})).map((function(e){return""+e})):n.map((function(e){return""+e}))}var a=t.mapping&&t.mapping.year;if(!a)return[];var r=Array.from(new Set(e.map((function(e){return Number(e[a])})))).sort((function(e,t){return e-t}));return t.excludeYears?r.filter((function(e){return!t.excludeYears.includes(e)})).map((function(e){return""+e})):r.map((function(e){return e.toString()}))},te=function(e,t,n){var a=e.reduce((function(e,a){return a[n.mapping.series]===t?e+Number(G(a[n.mapping.value])):e}),0);return n.aggregator&&"sum"!==n.aggregator&&"avg"===n.aggregator?a/e.filter((function(e){return e[n.mapping.series]===t})):a},ne=function(e,t,n){var a,r=e.series,o=e.mapping,i=!(a=e.type)||["bar-stacked","column-stacked"].includes(a)?"bar":"area"===a?"line":a;if("pie"!==i){var c=!e.type||["area","bar-stacked","column-stacked"].includes(e.type)?"district-stack":void 0,s=r.map((function(a,l){return{name:a,type:i,stack:c,areaStyle:"area"===e.type?{}:void 0,smooth:!0,emphasis:{focus:"series",label:{show:!0,formatter:function(e){return I(e.value)}}},symbol:"circle",label:{show:c&&l===r.length-1,fontFamily:"Geomanist Regular,sans-serif",position:"top",formatter:function(e){for(var t=0,n=0;n0})))))};ce.propTypes={rows:p.a.arrayOf(p.a.array)};var se=ce,le=n(48),ue=function(e,t){void 0===t&&(t=[]);var n=e.url,a=e.yearRange,r=e.dataID,o=Object(le.a)(n||e.className||r,Object(l.a)(s.a.mark((function t(){var a;return s.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.data||!Array.isArray(e.data)){t.next=2;break}return t.abrupt("return",e.data);case 2:if(!n&&!r){t.next=5;break}return a=n?A:F,t.abrupt("return",a(n||r).then((function(t){return e.filters?B(t,e.filters):t})));case 5:return t.abrupt("return",[]);case 6:case"end":return t.stop()}}),t)})))),i=o.data,c=o.error,d=Object(u.useState)(t),f=d[0],p=d[1];if(c)return{data:[],years:[]};var b=Object(u.useMemo)((function(){return i?(a&&a.length,ee(i,e)):[]}),[i]);return{data:Object(u.useMemo)((function(){return i&&i.length?f.length?f.reduce((function(e,t){return"all"===t.value?e:U(e,t.dataProperty,t.value)}),i):i:[]}),[i,f]),years:b,filters:f,setFilters:p,updateFilter:function(e,t){f&&f.length&&p(f.map((function(n){return n.dataProperty===e?Object.assign({},n,{value:t}):n})))}}},de=function(e){return e.show?d.a.createElement("div",{className:h()("button-group",e.className)},d.a.createElement("button",{type:"button",className:h()("button button-sm button-outline",{active:"chart"===e.activeButton}),onClick:e.onClickChart},"Chart"),d.a.createElement("button",{type:"button",className:h()("button button-sm button-outline",{active:"table"===e.activeButton}),onClick:e.onClickTable},"Table")):null};de.propTypes={show:p.a.bool,onClickChart:p.a.func,onClickTable:p.a.func,activeButton:p.a.string,className:p.a.string},de.defaultProps={activeButton:"chart"};var fe=de,pe=function(e){var t=ue(e.config),n=t.data,a=t.years,r=t.setFilters,o=t.updateFilter,i=Object(u.useState)("chart"),c=i[0],s=i[1],l=Object(u.useState)(e.config.type||"bar"),f=l[0],p=l[1];Object(u.useEffect)((function(){var t,n,a,o,i;r((t=e.config,n=e.subCounty,a=t.mapping,o=t.selectors,i=[],a.subCounty&&n&&i.push({dataProperty:a.subCounty,value:"all"}),o&&o.forEach((function(e){i.push({dataProperty:e.dataProperty,value:e.defaultValue?e.defaultValue.value:"all"})})),i))}),[]),Object(u.useEffect)((function(){var t=e.subCounty,n=e.config;t&&n.mapping.subCounty&&o(n.mapping.subCounty,e.subCounty)}),[e.subCounty]);return d.a.createElement(d.a.Fragment,null,d.a.createElement("div",{className:h()("spotlight-banner data-selector--wrapper dicharts--actions",{"align-left":!e.config.selectors})},e.config.selectors?d.a.createElement(D,{configs:e.config.selectors,onChange:function(e,t){o(e.dataProperty,t.value)}}):null,d.a.createElement(fe,{show:!!e.config.table,onClickChart:function(){return s("chart")},onClickTable:function(){return s("table")},activeButton:c}),"chart"===c&&e.config.typeOptions?d.a.createElement(Y,{options:e.config.typeOptions,onChange:p}):null),"chart"===c?d.a.createElement(re,Object(j.a)({className:h()({"dicharts--padding-top":!e.config.selectors})},e,{data:n,years:a,height:e.config.height,type:f})):null,"table"===c&&e.config.table?d.a.createElement(se,{rows:Z(e.config.table,n,e.subCounty)}):null)};pe.propTypes={config:p.a.object,subCounty:p.a.string},pe.defaultProps={subCounty:"all"};var be,me,ge=pe,he=function(e){(function(e){return e.className?e.series&&Array.isArray(e.series)?e.mapping?e.mapping.series?e.mapping.year?e.mapping.value?(e.mapping.subCounty||window.console.warn("Potentially invalid chart config: mapping.subCounty may be required!"),!0):(window.console.error("Invalid chart config: mapping.value is required!"),!1):(window.console.error("Invalid chart config: mapping.year is required!"),!1):(window.console.error("Invalid chart config: mapping.series is required!"),!1):(window.console.error("Invalid chart config: mapping is required!"),!1):(window.console.error(e.series?"Invalid chart config: Invalid series config - expected an array!":"Invalid chart config: Series is required!"),!1):(window.console.error("Invalid chart config: className is required!"),!1)})(e)&&window.DICharts.handler.addChart({className:e.className,echarts:{onAdd:function(t){Array.prototype.forEach.call(t,(function(t){t.classList.add("dicharts--dimensions"),t.parentElement.classList.add("auto-height");var n=new window.DICharts.Chart(t.parentElement);n.showLoading();var a="all",r=Object(o.createRoot)(t);r.render(d.a.createElement(ge,{config:e,subCounty:a})),window.DIState&&window.DIState.addListener((function(){var t=window.DIState.getState.subCounty;t&&t!==a&&(a=t,r.render(d.a.createElement(ge,{config:e,subCounty:a})))})),n.hideLoading()}))}}})},ve=function(){if(window.DIState){var e=[];window.DIState.addListener((function(){var t=window.DIState.getState.charts;t&&e.length!==t.length&&(e=t).forEach(he)}))}else window.console.log("State is not defined")},ye=n(14),Oe=n.n(ye),je=function(e){var t=e.map,n=e.show,a=e.onAdd,r=Object(w.a)(e,["map","show","onAdd"]);return t&&(t.getLayer(r.id)&&t.removeLayer(r.id),n&&(t.addLayer(r),a&&a(t,r.id))),null};je.defaultProps={show:!0},je.propTypes={map:p.a.object,show:p.a.bool,onAdd:p.a.func};var we={width:"100%",position:"absolute",top:0,bottom:0,background:"#F3F3F3"},xe=function(e){Oe.a.accessToken=e.accessToken;var t=Object(u.useRef)(null),n=Object(u.useState)(void 0),a=n[0],o=n[1];Object(u.useEffect)((function(){if(t&&t.current){var n=new Oe.a.Map(Object.assign({container:t.current},e.options));e.showNavigationControls&&n.addControl(new Oe.a.NavigationControl),n.on("load",(function(t){o(n),e.onLoad&&e.onLoad(n,t)}))}}),[]);return Object(r.c)("div",{ref:t,style:Object.assign({},we,e.style),css:Object(r.b)(be||(be=Object(b.a)(["\n background: ",";\n font-family: geomanist, sans-serif;\n "])),e.background)},u.Children.map(e.children,(function(e){return Object(u.isValidElement)(e)&&e.type===je?Object(u.cloneElement)(e,{map:a}):null})),Object(r.c)(r.a,{styles:Object(r.b)(me||(me=Object(b.a)(["\n div .mapboxgl-canary {\n background: red;\n }\n\n div .mapboxgl-popup {\n z-index: 400;\n max-width: 100% !important;\n }\n\n div .mapboxgl-popup-content {\n background-color: rgba(0, 0, 0, 0.9) !important;\n box-shadow: none !important;\n color: #ffffff !important;\n font-family: geomanist, sans-serif;\n -webkit-tap-highlight-color: black;\n opacity: 0.8;\n padding: 20px;\n }\n\n div .mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {\n border-top-color: rgba(0, 0, 0, 0.9);\n opacity: 0.8;\n }\n\n div .mapboxgl-popup-content .mapBox-popup p {\n margin-bottom: 0;\n }\n\n div .mapboxgl-popup-content .mapboxgl-popup-close-button {\n color: #ffffff;\n font-size: 1.8rem;\n }\n "])))}))};xe.defaultProps={style:we,options:{minZoom:6,zoom:6.1},showNavigationControls:!0,background:"inherit"},xe.propTypes={accessToken:p.a.string,style:p.a.object,background:p.a.string,showNavigationControls:p.a.bool,onLoad:p.a.func,options:p.a.object,children:p.a.node,locationData:p.a.object};var Ce=n(29),Se=n(6),Ee=function(e,t){return t?t(e):e},Le=function(e,t){return t&&"number"==typeof t.value?(e.dataPrefix||"")+''+(n=t.value,void 0===a&&(a=1),(n>=1e12?(n/1e12).toFixed(a)+"tn":n>=1e9?(n/1e9).toFixed(a)+"bn":n>=1e6?(n/1e6).toFixed(a)+"m":n>=1e3?(n/1e3).toFixed(a)+"k":n>=0?""+n.toFixed(a):n<=-1e12?(n/1e12).toFixed(a)+"tn":n<=-1e9?(n/1e9).toFixed(a)+"bn":n<=-1e6?(n/1e6).toFixed(a)+"m":n<=1e3?(n/1e3).toFixed(a)+"k":""+n.toFixed(a))+"")+(e.dataSuffix||""):"No Data";var n,a},Ne=function(e){var t=e.geometry&&e.geometry.coordinates;return t?new ye.LngLat(t[0],t[1]):null},ke=function(e,t,n){var a=e.querySourceFeatures("composite",{sourceLayer:n.sourceLayer,filter:["in",n.nameProperty,Ee(t,n.formatter)]});return a&&a.length?function(e){if(Array.isArray(e)){var t=e.map((function(e){return Object(Ce.a)(e.geometry).geometry.coordinates}));return t.push(t[0]),Ne(Object(Ce.a)(Object(Se.f)([t])))}return Ne(Object(Ce.a)(e))}(a):null},Pe=function(e,t,n,a,r){return t.setLngLat(n).setHTML('\n
\n
\n '+a.toLowerCase()+"\n
\n "+(r?''+r+"":"")+"\n
\n ").addTo(e)},Ie=function(e,t,n){return t.find((function(t){var a=n?n(t.name):t.name;return e.toLowerCase()===(""+a).toLowerCase()}))},Te=Object(u.createContext)(),Fe=Object(u.createContext)(),Ae=n(43),_e=function(e){function t(t){var n;return(n=e.call(this,t)||this).state={hasError:!1},n}Object(Ae.a)(t,e),t.getDerivedStateFromError=function(){return{hasError:!0}};var n=t.prototype;return n.componentDidCatch=function(e,t){window.console.log("Error Boundary:",e,t)},n.render=function(){return this.state.hasError?d.a.createElement("div",null,"Something went wrong! Please contact your administrator"):this.props.children},t}(u.Component);_e.propTypes={children:p.a.any};var De,ze=_e,Re=function(e,t){return e.find((function(e){return e.id===t}))},qe=function(e){return e.map((function(e){return{value:e.id,label:e.name}}))},Ve=function(e,t){var n=Re(e,t);return n?n.indicators.map((function(e){return{value:e.id,label:e.name}})):[]},Me=function(e,t,n){if(t&&n){var a=Re(e,t);if(!(a&&a.indicators&&a.indicators.length))return[];var r=a.indicators.find((function(e){return e.id===n}));if(r&&r.yearRange)return T(r.yearRange).filter((function(e){return r.excludeYears?!r.excludeYears.includes(e):e})).reverse().map((function(e){return{value:e,label:e}}))}return[]},Ue=function(e){var t=Object(u.useContext)(Fe),n=t.filterOptions,a=t.updateFilterOptions;return Object(u.useEffect)((function(){!n.topic&&e.length&&a({topic:e[0].id})}),[]),Object(u.useEffect)((function(){if(n.topic){var t=Re(e,n.topic),r=t&&t.indicators&&t.indicators.length?t.indicators[0]:null;r&&a({indicator:r.id})}}),[n.topic]),Object(u.useEffect)((function(){if(n.indicator){var t=Me(e,n.topic,n.indicator);t.length&&!t.find((function(e){return e.value===n.year}))&&a({year:t[0].value})}}),[n.indicator]),{topicOptions:qe(e||[]),indicatorOptions:Ve(e,n.topic),yearOptions:Me(e,n.topic,n.indicator)}},Be=function(){var e=Object(u.useContext)(Fe),t=e.filters,n=e.topics,a=e.filterOptions,o=e.updateFilterOptions,i=Ue(n),c=i.topicOptions,s=i.indicatorOptions,l=i.yearOptions,d=a.year,f=a.indicator,p=function(e,t,n){var a;if(Array.isArray(e)&&e.length)e[0].value!==n&&o(((a={})[t]=e[0].value,a));else if(e&&!Array.isArray(e)){var r;if(e.value!==n)o(((r={})[t]=e&&e.value,r))}};return Object(r.c)("form",{className:"form"},Object(r.c)("div",{className:h()("form-field","form-field--inline-block"),css:Object(r.b)(De||(De=Object(b.a)(["\n z-index: auto;\n margin-left: 5px;\n "])))},Object(r.c)(E,{label:t.topicLabel,options:c,defaultValue:[c[0]],classNamePrefix:"topic-selector",isClearable:!1,css:{minWidth:"100%"},onChange:function(e){return o({topic:e&&e.value})}}),s&&s.length?Object(r.c)(E,{label:t.indicatorLabel,options:s,value:[f&&s.find((function(e){return e.value===f}))||s[0]],classNamePrefix:"indicator-selector",isClearable:!1,css:{minWidth:"100%",marginTop:"1em"},onChange:function(e){return p(e,"indicator",f)}}):null,l&&l.length?Object(r.c)(E,{label:t.yearLabel,options:l,value:[d&&l.find((function(e){return e.value===d}))||l[0]],classNamePrefix:"year-selector",isClearable:!1,css:{minWidth:"100%",marginTop:"1em"},onChange:function(e){return p(e,"year",d)}}):null))},Ge=function(e){var t=e.children;return d.a.createElement("div",{className:"spotlight-legend","data-testid":"spotlight-legend"},u.Children.map(t,(function(e){return e})))};Ge.propTypes={children:p.a.any};var Ze=Ge,We=n(44),Ye=function(e){var t=e.children,n=e.className,a=e.bgColor,r=e.textColor,o=We(a);return d.a.createElement("span",{className:n,"data-testid":"spotlight-legend-item"},t,d.a.createElement("style",null,"\n span."+n+" {\n background-color: "+(a||"#D1CBCF")+" !important;\n color: "+(r||o.isLight()?"#000":"#FFF")+";\n }\n "))};Ye.propTypes={children:p.a.any,className:p.a.string,bgColor:p.a.string,textColor:p.a.string};var He=Ye,Je=function(){var e,t,n=Object(u.useContext)(Fe).activeIndicator;return d.a.createElement("div",{className:"spotlight__content"},d.a.createElement(ze,null,d.a.createElement(Be,null)),n?d.a.createElement(d.a.Fragment,null,d.a.createElement("div",{className:"spotlight__subheading"},n.name),n.description?d.a.createElement("p",{className:"spotlight__excerpt"},n.description):null,d.a.createElement(Ze,null,(e=n.range,t=n.colours,e&&t?e.map((function(n,a){return d.a.createElement(He,{className:"item-"+n,bgColor:t[a],key:n},0===a?"< "+e[0]:e[a-1]+"-"+n)})).concat([d.a.createElement(He,{className:"item-last",bgColor:t[t.length-1],key:e.length},"> "+e[e.length-1])]):null),d.a.createElement(He,null,"no data / not applicable"))):null)},Ke=n(45),Xe={type:"shapefile",style:"mapbox://styles/edwinmp/ck42rrx240t8p1cqpkhgy2g0m/draft",sourceLayer:"Uganda_Sub-Counties_2019-8w0zb5",layerName:"uganda-Sub-counties-2019-8w0zb5",center:[32.655221,1.344666],zoom:8,minZoom:8,maxZoom:9,districtNameProperty:"District",nameProperty:"Subcounty",codeProperty:"scode2019",formatter:function(e,t){return void 0===t&&(t="map"),e.toUpperCase()}},$e=function(e,t,n,a){n&&(e.setFilter(t,["==",a.nameProperty,Ee(n.name,a.formatter)]),setTimeout((function(){if(n.coordinates)e.flyTo({center:n.coordinates,zoom:8.5});else{var t=a.formatter?a.formatter(n.name):n.name;!function e(t,n,a,r){return void 0===r&&(r=!0),new Promise((function(o,i){var c=ke(t,n,a);c?(t.flyTo({center:c,zoom:16}),o(c)):r?(t.flyTo({center:a.center,zoom:a.zoom||6.1}),setTimeout((function(){e(t,n,a,!1).then((function(e){return o(e)})).catch(i)}),500)):i(new Error("Location "+n+" not found!"))}))}(e,t,a)}}),500))},Qe=function(e,t,n){if(!t)return[];if(!t.mapping)throw new Error("Mapping is required for indicator "+t.id);var a=t.mapping,r=a.location,o=a.value,i=a.year,c=B(e,t.filters);return c=n?c.filter((function(e){return""+e[i]==""+n})).map((function(e){return{name:e[r],value:Number(e[o])}})):c.map((function(e){return{name:e[r],value:Number(e[o])}})),t.aggregator?function(e,t){var n=Object(Ke.groupBy)(e,(function(e){return e.name}));return Object.keys(n).map((function(e){var a=n[e].reduce((function(e,t){return e+t.value}),0),r=a/n[e].length;return{name:e,value:"sum"===t?a:r}}))}(c,t.aggregator):c},et=function(e){return e.split(",").map((function(e){return parseFloat(e)}))},tt=["Waiga Primary School","Gods Mercy Primary School","Bukeeka COU Primary School"],nt=["Bukeeka COU Primary School","Kungu CU Primary School","King Jesus Nursery And Primary School","Nile View Primary School","Imam Hassan Primary School Maligita","Bright Future Nursery And Primary School Kangulumira"],at=function(e,t){var n="https://raw.githubusercontent.com/devinit/ug-district-dashboard-viz/dev/public/assets/data/"+e.toLowerCase()+"/schools-locations.csv",a={type:"FeatureCollection",features:[]};return t&&n&&n?(A(n).then((function(n){var r=n.filter((function(t){return"Masindi"===e?!tt.includes(t.school_name):!nt.includes(t.school_name)}));"all"===t.ownership?r.filter((function(e){return e.level===t.level})).forEach((function(e){if(e.gps_coordinates){var t=et(e.gps_coordinates);t&&a.features.push({type:"Feature",geometry:{type:"Point",coordinates:[t[1],t[0]]},properties:{level:e.level,ownership:e.ownership,name:e.school_name,parish:e.parish}})}})):r.filter((function(e){return e.level===t.level&&e.ownership===t.ownership})).forEach((function(e){if(e.gps_coordinates){var t=et(e.gps_coordinates);t&&a.features.push({type:"Feature",geometry:{type:"Point",coordinates:[t[1],t[0]]},properties:{level:e.level,ownership:e.ownership,name:e.school_name,parish:e.parish}})}}))})).catch((function(e){console.log(e)})),a):a};function rt(e){return"numberOfPrimarySchools"===e?{level:"Primary",ownership:"all"}:"numberOfSecondarySchools"===e?{level:"Secondary",ownership:"all"}:"numberOfGovernmentPrimarySchools"===e?{level:"Primary",ownership:"Government"}:"numberOfPrivatePrimarySchools"===e?{level:"Primary",ownership:"Private"}:"numberOfGovernmentSecondarySchools"===e?{level:"Secondary",ownership:"Government"}:"numberOfPrivateSecondarySchools"===e?{level:"Secondary",ownership:"Private"}:""}var ot,it=function(e,t,n,a){!function(e,t,n){var a=n.popup,r=n.nameProperty,o=n.formatter,i=n.data,c=function(e,t){if(e.features&&e.features[0].properties){var n=e.features[0].geometry;if("Polygon"===n.type||"MultiPolygon"===n.type)return e.features[0].properties[t]||null}return null}(t,r);if(c){var s=o?o(c,"tooltip"):c;if(i){var l=Ie(s,i);Pe(e,a,t.lngLat,s,Le(n,l))}else Pe(e,a,t.lngLat,s,"")}}(t,n,Object.assign({},a,{popup:e}))},ct=new ye.Popup({offset:5}),st=new ye.Popup({offset:5}),lt=function(e,t,n){void 0===n&&(n={});var a=Object(u.useState)(),r=a[0],o=a[1],i=Object(u.useState)(n),c=i[0],d=i[1],f=Object(u.useState)([]),p=f[0],b=f[1],m=Object(u.useState)(),g=m[0],h=m[1],v=Object(u.useState)(""),y=v[0],O=v[1],j=Object(u.useCallback)((function(e){r.getCanvas().style.cursor="pointer",it(ct,r,e,Object.assign({},t,{data:p},c))}),[r,p,c]),w=Object(u.useCallback)((function(){r.getCanvas().style.cursor="",ct.remove()}),[r,e]),x=Object(u.useCallback)((function(e){e.preventDefault(),r.off("mousemove","highlight",j),ct.remove(),e.features.length&&r.setLayoutProperty("points","icon-size",["match",["get","name"],e.features[0].properties.name,.4,.2])}),[r,g]),C=Object(u.useCallback)((function(e){for(var t=e.features[0].geometry.coordinates.slice(),n=e.features[0].properties,a=n.name,o=n.parish,i=n.ownership;Math.abs(e.lngLat.lng-t[0])>180;)t[0]+=e.lngLat.lng>t[0]?360:-360;st.setLngLat(t).setHTML('\n
\n
\n '+a+"\n
\n

Coordinates: "+t+"

\n

Ownership: "+i+"

\n

Parish: "+(o||"No parish data")+"

\n
\n ").addTo(r)})),S=Object(u.useCallback)((function(){r.on("mousemove","highlight",j),ct.remove(),r.setLayoutProperty("points","icon-size",.2)}),[r,e]);return Object(u.useEffect)((function(){r&&(r.getLayer("points")&&r.removeLayer("points"),g&&r.loadImage("https://docs.mapbox.com/mapbox-gl-js/assets/custom_marker.png",(function(e,t){if(e)throw e;r.hasImage("custom-marker")||r.addImage("custom-marker",t,{sdf:!0}),r.getSource("points")||r.addSource("points",{type:"geojson",data:g,generateId:!0}),r.getLayer("points")||r.addLayer({id:"points",type:"symbol",source:"points",layout:{"icon-image":"custom-marker","icon-anchor":"bottom","icon-size":.2,"icon-allow-overlap":!0},paint:{"icon-color":["match",["get","level"],"Primary","#ff9c1a","Secondary","#00b3b3","#ffffff"]},minzoom:8}),r.getSource("points").setData(g)})))}),[r,p,g,y]),Object(u.useEffect)((function(){r&&(r.getStyle().layers.forEach((function(e){["background","highlight"].includes(e.id)||r.setLayoutProperty(e.id,"visibility","none")})),function(e,t,n){t.clientWidth<700?e.setZoom(n.zoom?n.zoom-1:5):t.clientWidth<900?e.setZoom(n.minZoom?n.minZoom+.8:5.8):e.setZoom(n.zoom||6.1)}(r,r.getContainer(),t),r.off("mousemove","points",x),r.off("mouseleave","highlight",w),r.off("mouseover","highlight",j),r.off("click","points",C),r.on("mousemove","highlight",j),r.on("mouseleave","highlight",w),r.on("mousemove","points",x),r.on("mouseleave","points",S),r.on("click","points",C))}),[r,e,c,p]),Object(u.useEffect)((function(){var t=function(){var e=Object(l.a)(s.a.mark((function e(t){var n;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,A(t);case 2:n=e.sent,b(Qe(n,c.indicator,c.year));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();c.indicator&&c.year&&(O(rt(c.indicator.id)),h(at(e.name,rt(c.indicator.id))),t(c.indicator.url))}),[c.indicator,c.year]),{map:r,data:p,setData:b,setMap:o,setOptions:d}},ut=function(e,t,n,a,o){var i=[a].map((function(e){return Object(r.c)(je,{key:"highlight-hidden",id:e.layerName,source:"composite","source-layer":e.sourceLayer,show:!1})}));function c(e,t){$e(e,t,n,Object.assign({},a,{nameProperty:a.districtNameProperty}))}if(!e&&o.range&&o.colours&&t.length){var s=function(e,t,n,a){return e&&t&&n?e.map((function(e){var r=Ee(e.name,a),o=t.find((function(t){return null!==e.value&&e.value<=parseFloat(t)}));return o?[r,n[t.indexOf(o)]]:e.value>parseFloat(t[t.length-1])?[r,n[n.length-1]]:[r,"#b3adad"]})):[]}(t,o.range,o.colours,a.formatter);return i.concat(Object(r.c)(je,{key:"highlight",id:"highlight",source:"composite","source-layer":a.sourceLayer,maxzoom:a.maxZoom&&a.maxZoom+2,type:"fill",paint:{"fill-color":{property:a.nameProperty,type:"categorical",default:"#D1CBCF",stops:s},"fill-opacity":.9,"fill-outline-color":"#ffffff"},onAdd:c}))}return i.concat(Object(r.c)(je,{key:"highlight",id:"highlight",source:"composite","source-layer":a.sourceLayer,maxzoom:a.maxZoom&&a.maxZoom+2,type:"fill",paint:{"fill-color":"#D1CBCF","fill-opacity":.75,"fill-outline-color":"#ffffff"},onAdd:c}))},dt={topic:null,indicator:null,year:null},ft=m.a.div(ot||(ot=Object(b.a)(["\n position: absolute;\n top: 1.75em;\n z-index: 1;\n left: 1.4em;\n"])));function pt(e,t){switch(t.type){case"UPDATE_FILTERS":return Object.assign({},e,{filterOptions:t.merge?Object.assign({},e.filterOptions,t.filterOptions):t.filterOptions,activeTopic:t.activeTopic,activeIndicator:t.activeIndicator,activeYear:t.activeYear});case"SET_DATA":return Object.assign({},e,{data:t.data});case"RESET_FILTERS":return Object.assign({},e,{filterOptions:dt});default:throw new Error}}var bt={filterOptions:dt},mt=function(e){var t=Object(u.useState)(!0),n=t[0],a=t[1],o=Object(u.useReducer)(pt,bt),i=o[0],c=o[1],s=i.filterOptions,l=i.activeIndicator,d=i.activeTopic,f=i.activeYear,p=lt(e.location,e.configs.formatter?Object.assign({},Xe,{formatter:e.configs.formatter}):Xe),b=p.data,m=p.map,g=p.setMap,h=p.setOptions;Object(u.useEffect)((function(){if(l){var e=s.year;h({dataPrefix:l.name+": ",dataSuffix:e&&" in "+e,indicator:l,year:e})}}),[l,s.year,m]);var v,y,O=function(t,n){void 0===n&&(n=!0);var a=function(e,t){var n=t.topic,a=t.indicator,r=t.year;if(n){var o=e.find((function(e){return e.id===n}));if(o&&a){var i=o.indicators.find((function(e){return e.id===a}));if(i)return{topic:o,indicator:i,year:r}}return{topic:o}}return{}}(e.configs.data,Object.assign({},s,t)),r=a.topic,o=a.indicator,i=a.year;c({type:"UPDATE_FILTERS",merge:n,filterOptions:t,activeTopic:r,activeIndicator:o,activeYear:i})},j=(v=e.configs.data,y=s.topic,v.find((function(e){return e.id===y}))),w=Object(u.useMemo)((function(){return{filters:e.filters,topics:e.configs.data,filterOptions:s,updateFilterOptions:O,activeTopic:d,activeIndicator:l,activeYear:f}}));return Object(r.c)(Fe.Provider,{value:w},Object(r.c)("div",{className:"spotlight"},Object(r.c)("div",{className:"spotlight__aside spotlight__aside--no-margin",css:{minHeight:"600px"}},Object(r.c)(Je,null)),Object(r.c)("div",{className:"spotlight__main spotlight__main--map"},n?Object(r.c)("div",null,"Loading ..."):null,j&&j.dashboardUrl?Object(r.c)(ft,null,Object(r.c)("a",{href:j.dashboardUrl,className:"button button--secondary--fill"},j.dashboardButtonCaption)):null,Object(r.c)(xe,{accessToken:"pk.eyJ1IjoiZWR3aW5tcCIsImEiOiJjazFsdHVtcG0wOG9mM2RueWJscHhmcXZqIn0.cDR43UvfMaOY9cNJsEKsvg",locationData:at(e.location.name),options:Object.assign({style:Xe.style,center:Xe.center,minZoom:Xe.minZoom||6,zoom:Xe.zoom||6.1,maxZoom:Xe.maxZoom||7,scrollZoom:!1},e.configs.options),style:{width:"100%",background:"#ffffff"},onLoad:function(e){a(!1),g(e)}},ut(n,b,e.location,e.configs.formatter?Object.assign({},Xe,{formatter:e.configs.formatter}):Xe,l?{range:l.range,colours:l.colours}:{})))))};mt.defaultProps={data:[]},mt.propTypes={configs:p.a.object,filters:p.a.object,data:p.a.array,location:p.a.shape({name:p.a.string,fullName:p.a.string,coordinates:p.a.array})};var gt,ht,vt,yt,Ot,jt,wt,xt=mt,Ct=m.a.div(gt||(gt=Object(b.a)(["\n background: #ffffff;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n"]))),St=function(){return d.a.createElement(Ct,null,d.a.createElement($,null))},Et=function(e){window.DICharts.handler.addChart({className:e,echarts:{onAdd:function(e){Array.prototype.forEach.call(e,(function(e){var t=new window.DICharts.Chart(e.parentElement);if(t.showLoading(),window.DIState){var n=Object(o.createRoot)(e);window.DIState.addListener((function(){t.showLoading();var e=window.DIState.getState,a=e.map,r=e.location;a?n.render(d.a.createElement(xt,{configs:a,location:r,filters:a.filters})):n.render(d.a.createElement(St,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},Lt=n(46),Nt=function(e){var t=e.close,n=e.description,a=e.source;return Object(r.c)("div",{className:"spotlight-modal",css:Object(r.b)(vt||(vt=Object(b.a)(["\n font-size: 12px;\n "])))},Object(r.c)("a",{className:"close",onClick:t,css:Object(r.b)(yt||(yt=Object(b.a)(["\n cursor: pointer;\n position: absolute;\n display: block;\n padding: 5px 10px;\n line-height: 20px;\n right: 0px;\n top: 0px;\n font-size: 20px;\n background: transparent;\n color: #333131;\n font-weight: 900;\n "])))},"×"),Object(r.c)("div",{className:"content",css:Object(r.b)(Ot||(Ot=Object(b.a)(["\n width: 100%;\n padding: 10px 5px 10px 5px;\n "])))},Object(r.c)("p",{className:"description",css:Object(r.b)(jt||(jt=Object(b.a)(["\n font-size: 14px;\n "])))},n),a?Object(r.c)(d.a.Fragment,null,Object(r.c)("br",null),Object(r.c)("p",{className:"source",css:Object(r.b)(wt||(wt=Object(b.a)(["\n text-align: left;\n "])))},a?Object(r.c)(d.a.Fragment,null,Object(r.c)("b",{css:Object(r.b)(ht||(ht=Object(b.a)(["\n font-family: Geomanist Bold, sans-serif;\n "])))},"Source:"," "),a):null)," "):null))};Nt.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string,close:p.a.func.isRequired};var kt,Pt,It=Nt,Tt=function(e){return Object(r.c)(Lt.a,{trigger:Object(r.c)("span",{className:"spotlight__stat-icon",css:Object(r.b)(kt||(kt=Object(b.a)(["\n display: inline-flex;\n margin-left: 2px;\n cursor: pointer;\n padding: 8px;\n "])))},Object(r.c)("i",{onClick:function(){document.querySelectorAll(".popup-content ").forEach((function(e){e.setAttribute("style","display:none;")}))},role:"presentation","aria-hidden":"true",className:"ico ico--12 ico-info-slate",css:Object(r.b)(Pt||(Pt=Object(b.a)(["\n top: -1px;\n "])))})),offsetX:20,arrowStyle:{height:"10px",width:"10px",position:"absolute",background:"rgb(255, 255, 255)",transform:"rotate(225deg)",margin:"-5px",zIndex:-1,boxShadow:"rgb(0 0 0 / 20%) 1px 1px 1px",bottom:"0%",left:"82px"},position:"bottom center",closeOnDocumentClick:!0,contentStyle:{zIndex:200,width:"350px",background:"#fff",fontWeight:400,fontStyle:"normal",fontSize:"12px",color:"#60575d",border:0,borderRadius:"0.28571429rem",boxShadow:"0 2px 4px 0 rgba(34, 36, 38, 0.12), 0 2px 10px 0 rgba(34, 36, 38, 0.15)",padding:"5px"}},(function(t){return Object(r.c)(It,{close:t,description:e.description,source:e.source})}))};Tt.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string};var Ft=Tt,At=function(e){var t=e.meta,n=void 0===t?{}:t,a=e.heading,r=e.children;return d.a.createElement("div",{className:"spotlight__stat"},d.a.createElement("h3",{className:"spotlight__stat-heading"},a,n.description||n.source?d.a.createElement(Ft,{description:n.description,source:n.source}):null),r)};At.defaultProps={meta:{}},At.propTypes={heading:p.a.string,meta:p.a.shape({description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string}),children:p.a.any};var _t,Dt=At,zt=function(e){var t=e.value,n=e.note;return Object(r.c)("p",{className:"spotlight__stat-data"},t,n&&n.content?Object(r.c)("span",{className:"spotlight__stat-data__note",css:Object(r.b)(_t||(_t=Object(b.a)(["\n transform: none;\n position: relative;\n top: -10px;\n "])))},n.content," ",n.meta?Object(r.c)(Ft,{description:n.meta.description,source:n.meta.source}):null):null)};zt.propTypes={note:p.a.object,value:p.a.string};var Rt,qt=zt,Vt=function(e){var t=e.children;return Object(r.c)("article",{className:"tabs__content",css:Object(r.b)(Rt||(Rt=Object(b.a)(["\n z-index: 200;\n "])))},t)};Vt.propTypes={children:p.a.any};var Mt=Vt,Ut=function(e){var t=e.id,n=e.active,a=e.label,r=e.children,o=e.onActivate;return d.a.createElement("section",{className:"tabs__container",id:t},d.a.createElement("input",{className:"tabs__input",type:"radio",name:"sections",id:t+"-option",defaultChecked:n}),d.a.createElement("label",{className:"tabs__label",htmlFor:t+"-option",onClick:o},a),u.Children.map(r,(function(e){return Object(u.isValidElement)(e)&&e.type===Mt?e:null})))};Ut.propTypes={id:p.a.string.isRequired,label:p.a.string.isRequired,active:p.a.bool,onActivate:p.a.func,children:p.a.any};var Bt=Ut,Gt=function(e){var t=e.children,n=e.onClick;return d.a.createElement("div",{className:"tabs__content__header",onClick:n},t)};Gt.propTypes={children:p.a.any,onClick:p.a.func};var Zt,Wt,Yt,Ht,Jt,Kt=Gt,Xt=function(e){var t=Object(u.useContext)(Te),n=t.data,a=t.location,o=t.options,i="education",c=M(o.tabs,i);if(void 0!==c.show&&!c.show)return null;var s=n&&n.education?n.education.find((function(e){return"Number of Schools"===e.caption})):null;return Object(r.c)(Bt,{id:i,label:c.label||"Education",active:!!e.active||c.active},Object(r.c)(Mt,null,Object(r.c)(Kt,null,s?Object(r.c)("div",{css:Object(r.b)(Zt||(Zt=Object(b.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(Wt||(Wt=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(Yt||(Yt=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(Ht||(Ht=Object(b.a)(["\n font-size: 3rem;\n "])))},I(s.value)),Object(r.c)(Ft,{description:"Last updated: "+s.lastUpdated})),c.dashboardURL?Object(r.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null):null),Object(r.c)("div",{className:"l-2up"},n&&n.education?n.education.filter((function(e){return"Number of Schools"!==e.caption})).map((function(e){return Object(r.c)("div",{className:"l-2up__col",key:e.caption},Object(r.c)(Dt,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(Jt||(Jt=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(qt,{value:e.value})))})):null)))};Xt.propTypes={active:p.a.bool};var $t,Qt,en,tn,nn,an=Xt,rn=function(e){var t=Object(u.useContext)(Te),n=t.data,a=t.location,o=t.options,i="overview",c=M(o.tabs,i);return void 0===c.show||c.show?Object(r.c)(Bt,{id:i,label:c.label||"Overview",active:!!e.active||c.active},Object(r.c)(Mt,null,Object(r.c)(Kt,null,n&&n.population?Object(r.c)("div",{css:Object(r.b)($t||($t=Object(b.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(Qt||(Qt=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(en||(en=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Total Population in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(tn||(tn=Object(b.a)(["\n font-size: 3rem;\n "])))},I(n.population.value)),Object(r.c)(Ft,{description:"Last updated: "+n.population.lastUpdated})),c.dashboardURL?Object(r.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null):null),Object(r.c)("div",{className:"l-2up"},n&&n.administration?n.administration.map((function(e){return Object(r.c)("div",{className:"l-2up__col",key:e.caption},Object(r.c)(Dt,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(nn||(nn=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(qt,{value:e.value})))})):null))):null};rn.propTypes={active:p.a.bool};var on,cn,sn,ln,un,dn,fn=rn,pn=function(e){var t=Object(u.useContext)(Te),n=t.data,a=t.location,o=t.options,i="production",c=M(o.tabs,i);if(void 0!==c.show&&!c.show)return null;var s=n&&n.production?n.production.find((function(e){return""===e.caption})):null;return Object(r.c)(Bt,{id:i,label:c.label||"Production",active:!!e.active||c.active},Object(r.c)(Mt,null,Object(r.c)(Kt,null,Object(r.c)("div",{css:Object(r.b)(on||(on=Object(b.a)(["\n display: flex;\n "])))},s?Object(r.c)("div",{css:Object(r.b)(cn||(cn=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(sn||(sn=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(ln||(ln=Object(b.a)(["\n font-size: 3rem;\n "])))},I(s.value)),Object(r.c)(Ft,{description:"Last updated: "+s.lastUpdated})):null,c.dashboardURL?Object(r.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null)),n&&n.production&&n.production.length?Object(r.c)("div",{className:"l-2up"},n.production.filter((function(e){return""!==e.caption})).map((function(e){return Object(r.c)("div",{className:"l-2up__col",key:e.caption},Object(r.c)(Dt,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(un||(un=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(qt,{value:e.value})))}))):Object(r.c)("div",{css:Object(r.b)(dn||(dn=Object(b.a)(["\n font-size: 16px;\n display: flex;\n justify-content: center;\n width: 100%;\n "])))},"No Production Data")))};pn.propTypes={active:p.a.bool};var bn,mn=pn,gn=function(e){var t=e.children;return Object(r.c)("div",{className:"tabs",css:Object(r.b)(bn||(bn=Object(b.a)(["\n z-index: 0;\n "])))},t)};gn.propTypes={children:p.a.any};var hn=gn,vn=function(e){var t=Object(u.useState)({}),n=t[0],a=t[1];return Object(u.useEffect)((function(){e.data&&a(function(e){var t={},n=function(e){return{caption:e.Item,value:e.Value,lastUpdated:e["Last Updated"]}},a=e.find((function(e){return"Total Population"===e.Item}));return a&&(t.population=n(a)),t.administration=e.filter((function(e){return"Total Population"!==e.Item&&"Administration"===e.Department})).map(n),t.education=e.filter((function(e){return"Total Population"!==e.Item&&"Education"===e.Department})).map(n),t.production=e.filter((function(e){return"Total Population"!==e.Item&&"Production"===e.Department})).map(n),t}(e.data))}),[e.data]),Object(r.c)(Te.Provider,{value:Object.assign({},e,{data:n})},Object(r.c)(hn,null,Object(r.c)(fn,{active:!0}),Object(r.c)(an,null),Object(r.c)(mn,null)))};vn.propTypes={data:p.a.array.isRequired,location:p.a.object.isRequired,options:p.a.object.isRequired};var yn=vn,On=function(e){window.DICharts.handler.addChart({className:e,echarts:{onAdd:function(e){Array.prototype.forEach.call(e,(function(e){var t=new window.DICharts.Chart(e.parentElement);if(t.showLoading(),window.DIState){var n=Object(o.createRoot)(e);window.DIState.addListener((function(){t.showLoading();var e=window.DIState.getState,a=e.keyFacts,r=e.location;a&&a.url?A(a.url).then((function(e){Array.isArray(e)?n.render(d.a.createElement(yn,{data:e,options:a,location:r})):e.results?n.render(d.a.createElement(yn,{data:e.results,options:a,location:r})):(window.console.error("Invalid data shape. Expected an array or an object with a results property.",e),n.render(d.a.createElement(St,null)))})).catch((function(e){window.console.log(e),n.render(d.a.createElement(St,null))})):a&&a.data?n.render(d.a.createElement(yn,{data:a.data,options:a,location:r})):n.render(d.a.createElement(St,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},jn=function(){var e=Object(l.a)(s.a.mark((function e(t,n){var a,r,o,i,c,l;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=t.data,r=t.config,o=t.subCounty,i=t.tableRoot,c=r.selectors.map((function(e){return{property:e.dataProperty,value:"all"}})),l=function(e,t){var n=Array.isArray(t)?t[0].value:t.value;if(n){var s=c.find((function(t){return t.property===e.config.dataProperty}));if(s){s.value=n;var l=c.reduce((function(e,t){return"all"===t.value?e:U(e,t.property,t.value)}),a),u=Z(r,l,o);i.render(d.a.createElement(se,{rows:u}))}}},e.abrupt("return",z(r.selectorClassName,{selectors:r.selectors,onChange:l,makeSticky:!1,nodes:n}));case 4:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),wn=function(e){(function(e){return e.className?e.mapping?e.mapping.rows?e.mapping.year?e.mapping.value?e.mapping.subCounty?!!e.mapping.level||(window.console.error("Invalid table config: mapping[mapping.level] is required!"),!1):(window.console.error("Invalid table config: mapping.subCounty is required!"),!1):(window.console.error("Invalid table config: mapping.value is required!"),!1):(window.console.error("Invalid table config: mapping.year is required!"),!1):(window.console.error("Invalid table config: mapping.series is required!"),!1):(window.console.error("Invalid table config: mapping is required!"),!1):(window.console.error("Invalid table config: className is required!"),!1)})(e)&&window.DICharts.handler.addChart({className:e.className,d3:{onAdd:function(t){A(e.url).then((function(n){Array.prototype.forEach.call(t,(function(t){var a=new window.DICharts.Chart(t.parentElement);a.showLoading();var r=Object(o.createRoot)(t),i="all",c=[];window.DIState.addListener((function(){a.showLoading();var o=window.DIState.getState.subCounty;if(o!==i){i=o||"all";var s=e.filters&&e.filters.subCounties?function(e,t,n){return e.filter((function(e){return!t||"all"===t||e[n].toLowerCase()===t.toLowerCase()}))}(n,i,e.mapping.subCounty):n,l=Z(e,s,i);r.render(d.a.createElement(se,{rows:l})),e.selectors&&e.selectors.length&&jn({data:s,subCounty:i,config:e,tableRoot:r},c).then((function(e){c=e})),a.hideLoading(),t.parentElement.classList.add("auto-height")}}))}))}))}}})},xn=function(){if(window.DIState){var e=[];window.DIState.addListener((function(){var t=window.DIState.getState.tables;t&&e.length!==t.length&&(e=t).forEach((function(e){wn(e)}))}))}else window.console.log("State is not defined")};n(103);window.addEventListener("load",(function(){z("district-selectors",{makeSticky:!0}),Et("dicharts--district-map"),xn(),On("dicharts--keyfacts"),ve()}))},50:function(e,t,n){e.exports=n(104)}},[[50,1,2]]]); \ No newline at end of file diff --git a/assets/vendor.js b/assets/vendor.js index aa5bb9fd..ebc63b27 100644 --- a/assets/vendor.js +++ b/assets/vendor.js @@ -1,16 +1,16 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[2],[function(e,t,n){"use strict";e.exports=n(47)},function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return c})),n.d(t,"c",(function(){return l})),n.d(t,"d",(function(){return h}));var r=n(5),i=n(0),o=n(6),a=n(9),s=n(10),l=(n(16),n(58),n(19),n(26),function(e,t){var n=arguments;if(null==t||!r.e.call(t,"css"))return i.createElement.apply(void 0,n);var o=n.length,a=new Array(o);a[0]=r.b,a[1]=Object(r.d)(e,t);for(var s=2;s{const t=i.call(e);return s[t]||(s[t]=t.slice(8,-1).toLowerCase())});var s;const l=e=>(e=e.toLowerCase(),t=>a(t)===e),u=e=>t=>typeof t===e,{isArray:c}=Array,h=u("undefined");const d=l("ArrayBuffer");const f=u("string"),p=u("function"),m=u("number"),g=e=>null!==e&&"object"==typeof e,_=e=>{if("object"!==a(e))return!1;const t=o(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},y=l("Date"),v=l("File"),x=l("Blob"),b=l("FileList"),w=l("URLSearchParams");function E(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,i;if("object"!=typeof e&&(e=[e]),c(e))for(r=0,i=e.length;r0;)if(r=n[i],t===r.toLowerCase())return r;return null}const S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:e,A=e=>!h(e)&&e!==S;const k=(M="undefined"!=typeof Uint8Array&&o(Uint8Array),e=>M&&e instanceof M);var M;const C=l("HTMLFormElement"),I=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),P=l("RegExp"),O=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};E(n,(n,i)=>{let o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)},z="abcdefghijklmnopqrstuvwxyz",L={DIGIT:"0123456789",ALPHA:z,ALPHA_DIGIT:z+z.toUpperCase()+"0123456789"};const D=l("AsyncFunction");t.a={isArray:c,isArrayBuffer:d,isBuffer:function(e){return null!==e&&!h(e)&&null!==e.constructor&&!h(e.constructor)&&p(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||p(e.append)&&("formdata"===(t=a(e))||"object"===t&&p(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&d(e.buffer),t},isString:f,isNumber:m,isBoolean:e=>!0===e||!1===e,isObject:g,isPlainObject:_,isUndefined:h,isDate:y,isFile:v,isBlob:x,isRegExp:P,isFunction:p,isStream:e=>g(e)&&p(e.pipe),isURLSearchParams:w,isTypedArray:k,isFileList:b,forEach:E,merge:function e(){const{caseless:t}=A(this)&&this||{},n={},r=(r,i)=>{const o=t&&T(n,i)||i;_(n[o])&&_(r)?n[o]=e(n[o],r):_(r)?n[o]=e({},r):c(r)?n[o]=r.slice():n[o]=r};for(let e=0,t=arguments.length;e(E(t,(t,i)=>{n&&p(t)?e[i]=Object(r.a)(t,n):e[i]=t},{allOwnKeys:i}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let i,a,s;const l={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)s=i[a],r&&!r(s,e,t)||l[s]||(t[s]=e[s],l[s]=!0);e=!1!==n&&o(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:a,kindOfTest:l,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(c(e))return e;let t=e.length;if(!m(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:C,hasOwnProperty:I,hasOwnProp:I,reduceDescriptors:O,freezeMethods:e=>{O(e,(t,n)=>{if(p(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];p(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))})},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach(e=>{n[e]=!0})};return c(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:T,global:S,isContextDefined:A,ALPHABET:L,generateString:(e=16,t=L.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&p(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(g(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const i=c(e)?[]:{};return E(e,(e,t)=>{const o=n(e,r+1);!h(o)&&(i[t]=o)}),t[r]=void 0,i}}return e};return n(e,0)},isAsyncFn:D,isThenable:e=>e&&(g(e)||p(e))&&p(e.then)&&p(e.catch)}}).call(this,n(17))},function(e,t,n){e.exports=n(61)()},function(e,t,n){"use strict";function r(e,t){return t||(t=e.slice(0)),e.raw=t,e}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";var r=n(2);function i(e,t,n,r,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i)}r.a.inherits(i,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:r.a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const o=i.prototype,a={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{a[e]={value:e}}),Object.defineProperties(i,a),Object.defineProperty(o,"isAxiosError",{value:!0}),i.from=(e,t,n,a,s,l)=>{const u=Object.create(o);return r.a.toFlatObject(e,u,(function(e){return e!==Error.prototype}),e=>"isAxiosError"!==e),i.call(u,e.message,t,n,a,s),u.cause=e,u.name=e.name,l&&Object.assign(u,l),u},t.a=i},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"e",(function(){return i})),n.d(t,"f",(function(){return o})),n.d(t,"d",(function(){return a})),n.d(t,"b",(function(){return s})),n.d(t,"c",(function(){return l}));function r(e,t,n){void 0===n&&(n={});var r={type:"Feature"};return(0===n.id||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function i(e,t,n){if(void 0===n&&(n={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!s(e[0])||!s(e[1]))throw new Error("coordinates must contain numbers");return r({type:"Point",coordinates:e},t,n)}function o(e,t,n){void 0===n&&(n={});for(var i=0,o=e;i=4;++r,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(i){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(i)+l,styles:i,next:d}}},function(e,t,n){e.exports=n(52)},function(e,t,n){(function(t){e.exports=function(){"use strict";var e,n,r;function i(t,i){if(e)if(n){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 = {}; ("+e+")(sharedChunk); ("+n+")(sharedChunk); self.onerror = null;",a={};e(a),r=i(a),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(r.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else n=i;else e=i}return i(0,(function(e){var n="undefined"!=typeof self?self:{},r="2.15.0";let i;const o={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==i){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{i=null!=t.env.API_URL_REGEX?new RegExp(t.env.API_URL_REGEX):e}catch(t){i=e}}return i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!o.API_URL)return null;try{const e=new URL(o.API_URL);return"api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return 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},a={supported:!1,testSupport:function(e){!u&&l&&(c?h(e):s=e)}};let s,l,u=!1,c=!1;function h(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,l),e.isContextLost())return;a.supported=!0}catch(e){}e.deleteTexture(t),u=!0}n.document&&(l=n.document.createElement("img"),l.onload=function(){s&&h(s),s=null,c=!0},l.onerror=function(){u=!0,s=null},l.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const d="01";function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p=m;function m(e,t,n,r){this.cx=3*e,this.bx=3*(n-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=n,this.p2y=r}m.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)i?a=n:s=n,n=.5*(s-a)+a;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var _=f(p),g=y;function y(e,t){this.x=e,this.y=t}y.prototype={clone:function(){return new y(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround:function(e,t){var n=Math.cos(e),r=Math.sin(e),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-r*(this.y-t.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},y.convert=function(e){return e instanceof y?e:Array.isArray(e)?new y(e[0],e[1]):e};var v=f(g);const x=Math.PI/180,b=180/Math.PI;function w(e){return e*x}function E(e){return e*b}const T=[[0,0],[1,0],[1,1],[0,1]];function S(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function k(e,t,n,r){const i=new _(e,t,n,r);return function(e){return i.solve(e)}}const M=k(.25,.1,.25,1);function C(e,t,n){return Math.min(n,Math.max(t,e))}function A(e,t,n){return(n=C((n-e)/(t-e),0,1))*n*(3-2*n)}function I(e,t,n){const r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function P(e,t,n){if(!e.length)return n(null,[]);let r=e.length;const i=new Array(e.length);let o=null;e.forEach((e,a)=>{t(e,(e,t)=>{e&&(o=e),i[a]=t,0==--r&&n(o,i)})})}function O(e){const t=[];for(const n in e)t.push(e[n]);return t}function z(e,...t){for(const n of t)for(const t in n)e[t]=n[t];return e}let L=1;function D(){return L++}function R(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function B(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function F(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function j(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function N(e,t){return-1!==e.indexOf(t,e.length-t.length)}function U(e,t,n){const r={};for(const i in e)r[i]=t.call(n||this,e[i],i,e);return r}function V(e,t,n){const r={};for(const i in e)t.call(n||this,e[i],i,e)&&(r[i]=e[i]);return r}function G(e){return Array.isArray(e)?e.map(G):"object"==typeof e&&e?U(e,G):e}const q={};function $(e){q[e]||("undefined"!=typeof console&&console.warn(e),q[e]=!0)}function Z(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function W(e){let t=0;for(let n,r,i=0,o=e.length,a=o-1;i@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,n,r,i)=>{const o=r||i;return t[n]=!o||o.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let Y=null;function K(e){if(null==Y){const t=e.navigator?e.navigator.userAgent:null;Y=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Y}function J(e){try{const t=n[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function Q(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const ee="mapbox-tiles";let te,ne,re=500,ie=50;function oe(){try{return n.caches}catch(e){}}function ae(){oe()&&!te&&(te=n.caches.open(ee))}function se(e){const t=e.indexOf("?");if(t<0)return e;const n=function(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}(e).filter(e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]});return n.length?`${e.slice(0,t)}?${n.join("&")}`:e.slice(0,t)}let le=1/0;const ue={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(ue);class ce extends Error{constructor(e,t,n){401===t&&be(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const he=X()?()=>self.worker&&self.worker.referrer:()=>("blob:"===n.location.protocol?n.parent:n).location.href,de=function(e,t){if(!(/^file:/.test(r=e.url)||/^file:/.test(he())&&!/^\w+:/.test(r))){if(n.fetch&&n.Request&&n.AbortController&&n.Request.prototype.hasOwnProperty("signal"))return function(e,t){const r=new n.AbortController,i=new n.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:he(),referrerPolicy:e.referrerPolicy,signal:r.signal});let o=!1,a=!1;const s=(l=i.url).indexOf("sku=")>0&&be(l);var l;"json"===e.type&&i.headers.set("Accept","application/json");const u=(r,o,l)=>{if(a)return;if(r&&"SecurityError"!==r.message&&$(r.toString()),o&&l)return c(o);const u=Date.now();n.fetch(i).then(n=>{if(n.ok){const e=s?n.clone():null;return c(n,e,u)}return t(new ce(n.statusText,n.status,e.url))}).catch(n=>{"AbortError"!==n.name&&t(new Error(`${n.message} ${e.url}`))})},c=(r,s,l)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then(e=>{a||(s&&l&&function(e,t,r){if(ae(),!te)return;const i={status:t.status,statusText:t.statusText,headers:new n.Headers};t.headers.forEach((e,t)=>i.headers.set(t,e));const o=H(t.headers.get("Cache-Control")||"");if(o["no-store"])return;o["max-age"]&&i.headers.set("Expires",new Date(r+1e3*o["max-age"]).toUTCString());const a=i.headers.get("Expires");a&&(new Date(a).getTime()-r<42e4||function(e,t){if(void 0===ne)try{new Response(new ReadableStream),ne=!0}catch(e){ne=!1}ne?t(e.body):e.blob().then(t)}(t,t=>{const r=new n.Response(t,i);ae(),te&&te.then(t=>t.put(se(e.url),r)).catch(e=>$(e.message))}))}(i,s,l),o=!0,t(null,e,r.headers.get("Cache-Control"),r.headers.get("Expires")))}).catch(e=>{a||t(new Error(e.message))})};return s?function(e,t){if(ae(),!te)return t(null);const n=se(e.url);te.then(e=>{e.match(n).then(r=>{const i=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),n=H(e.headers.get("Cache-Control")||"");return t>Date.now()&&!n["no-cache"]}(r);e.delete(n),i&&e.put(n,r.clone()),t(null,r,i)}).catch(t)}).catch(t)}(i,u):u(null,null),{cancel:()=>{a=!0,o||r.abort()}}}(e,t);if(X()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var r;return function(e,t){const r=new n.XMLHttpRequest;r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{t(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===e.type)try{n=JSON.parse(r.response)}catch(e){return t(e)}t(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else t(new ce(r.statusText,r.status,e.url))},r.send(e.body),{cancel:()=>r.abort()}}(e,t)},fe=function(e,t){return de(z(e,{type:"arrayBuffer"}),t)};function pe(e){const t=n.document.createElement("a");return t.href=e,t.protocol===n.document.location.protocol&&t.host===n.document.location.host}const me="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let _e,ge;_e=[],ge=0;const ye=function(e,t){if(a.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),ge>=o.MAX_PARALLEL_IMAGE_REQUESTS){const n={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return _e.push(n),n}ge++;let r=!1;const i=()=>{if(!r)for(r=!0,ge--;_e.length&&ge{i(),e?t(e):r&&(n.createImageBitmap?function(e,t){const r=new n.Blob([new Uint8Array(e)],{type:"image/png"});n.createImageBitmap(r).then(e=>{t(null,e)}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(r,(e,n)=>t(e,n,o,a)):function(e,t){const r=new n.Image,i=n.URL;r.onload=()=>{t(null,r),i.revokeObjectURL(r.src),r.onload=null,n.requestAnimationFrame(()=>{r.src=me})},r.onerror=()=>t(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 n.Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?i.createObjectURL(o):me}(r,(e,n)=>t(e,n,o,a)))});return{cancel:()=>{s.cancel(),i()}}},ve="NO_ACCESS_TOKEN";function xe(e){return 0===e.indexOf("mapbox:")}function be(e){return o.API_URL_REGEX.test(e)}function we(e){return o.API_CDN_URL_REGEX.test(e)}function Ee(e){return o.API_STYLE_REGEX.test(e)&&!Te(e)}function Te(e){return o.API_SPRITE_REGEX.test(e)}const Se=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ke(e){const t=e.match(Se);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Me(e){const t=e.params.length?"?"+e.params.join("&"):"";return`${e.protocol}://${e.authority}${e.path}${t}`}const Ce="mapbox.eventData";function Ae(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(n.atob(t[1]).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(e){return null}}class Ie{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=Ae(o.ACCESS_TOKEN);let r="";return r=t&&t.u?n.btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t)))):o.ACCESS_TOKEN||"",e?`${Ce}.${e}:${r}`:`${Ce}:${r}`}fetchEventData(){const e=J("localStorage"),t=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{const e=n.localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const i=n.localStorage.getItem(r);i&&(this.anonId=i)}catch(e){$("Unable to read from LocalStorage")}}saveEventData(){const e=J("localStorage"),t=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{n.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&n.localStorage.setItem(t,JSON.stringify(this.eventData))}catch(e){$("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,n,r){if(!o.EVENTS_URL)return;const i=ke(o.EVENTS_URL);i.params.push("access_token="+(r||o.ACCESS_TOKEN||""));const a={event:this.type,created:new Date(e).toISOString()},s=t?z(a,t):a,l={url:Me(i),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=function(e,t){return de(z(e,{method:"POST"}),t)}(l,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const Pe=new class extends Ie{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){o.EVENTS_URL&&o.ACCESS_TOKEN&&Array.isArray(e)&&e.some(e=>xe(e)||be(e))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Ae(o.ACCESS_TOKEN),n=t?t.u:o.ACCESS_TOKEN;let i=n!==this.eventData.tokenU;F(this.anonId)||(this.anonId=R(),i=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(a),n=(a-this.eventData.lastSuccess)/864e5;i=i||n>=1||n<-1||e.getDate()!==t.getDate()}else i=!0;i?this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:d,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=a,this.eventData.tokenU=n)},e):this.processRequests()}},Oe=Pe.postTurnstileEvent.bind(Pe),ze=new class extends Ie{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,n,r){this.skuToken=t,this.errorCb=r,o.EVENTS_URL&&(n||o.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(ve)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),F(this.anonId)||(this.anonId=R()),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:d,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e))}},Le=ze.postMapLoadEvent.bind(ze),De=new class extends Ie{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){o.EVENTS_URL&&(e||o.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,performanceData:i}=this.queue.shift(),o=function(e){const t=n.performance.getEntriesByType("resource"),i=n.performance.getEntriesByType("mark"),o=function(e){const t={};if(e)for(const n in e)if("other"!==n)for(const r of e[n]){const e=n+"ResolveRangeMin",i=n+"ResolveRangeMax",o=n+"RequestCount",a=n+"RequestCachedCount";t[e]=Math.min(t[e]||1/0,r.startTime),t[i]=Math.max(t[i]||-1/0,r.responseEnd);const s=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==r.transferSize&&0===r.transferSize&&s(a),s(o)}return t}(function(e,t){const n={};if(e)for(const r of e){const e=t(r);void 0===n[e]&&(n[e]=[]),n[e].push(r)}return n}(t,Ve)),a=n.devicePixelRatio,s=n.navigator.connection||n.navigator.mozConnection||n.navigator.webkitConnection,l={counters:[],metadata:[],attributes:[]},u=(e,t,n)=>{null!=n&&e.push({name:t,value:n.toString()})};for(const e in o)u(l.counters,e,o[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(u(l.counters,"interactionRangeMin",e.interactionRange[0]),u(l.counters,"interactionRangeMax",e.interactionRange[1])),i)for(const e of Object.keys(Ne)){const t=Ne[e],n=i.find(e=>e.name===t);n&&u(l.counters,t,n.startTime)}return u(l.counters,"visibilityHidden",e.visibilityHidden),u(l.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(Ee(e)){const t=e.split("/").slice(-2);if(2===t.length)return`mapbox://styles/${t[0]}/${t[1]}`}}}(t)),u(l.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),u(l.attributes,"fogEnabled",e.fogEnabled?"true":"false"),u(l.attributes,"projection",e.projection),u(l.attributes,"zoom",e.zoom),u(l.metadata,"devicePixelRatio",a),u(l.metadata,"connectionEffectiveType",s?s.effectiveType:void 0),u(l.metadata,"navigatorUserAgent",n.navigator.userAgent),u(l.metadata,"screenWidth",n.screen.width),u(l.metadata,"screenHeight",n.screen.height),u(l.metadata,"windowWidth",n.innerWidth),u(l.metadata,"windowHeight",n.innerHeight),u(l.metadata,"mapWidth",e.width/a),u(l.metadata,"mapHeight",e.height/a),u(l.metadata,"webglRenderer",e.renderer),u(l.metadata,"webglVendor",e.vendor),u(l.metadata,"sdkVersion",r),u(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(i);for(const e of o.metadata);for(const e of o.counters);for(const e of o.attributes);this.postEvent(t,o,()=>{},e)}},Re=De.postPerformanceEvent.bind(De),Be=new class extends Ie{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,n,r){if(!o.API_URL||!o.SESSION_PATH)return;const i=ke(o.API_URL+o.SESSION_PATH);i.params.push("sku="+(t||"")),i.params.push("access_token="+(r||o.ACCESS_TOKEN||""));const a={url:Me(i),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return de(z(e,{method:"GET"}),t)}(a,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(e,t,n,r){this.skuToken=t,this.errorCb=r,o.SESSION_PATH&&o.API_URL&&(n||o.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(ve)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||this.getSession(n,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}},Fe=Be.getSessionAPI.bind(Be),je=new Set,Ne={create:"create",load:"load",fullLoad:"fullLoad"},Ue={mark(e){n.performance.mark(e)},measure(e,t,r){n.performance.measure(e,t,r)}};function Ve(e){const t=e.name.split("?")[0];return we(t)&&t.includes("mapbox-gl.js")?"javascript":we(t)&&t.includes("mapbox-gl.css")?"css":function(e){return o.API_FONTS_REGEX.test(e)}(t)?"fontRange":Te(t)?"sprite":Ee(t)?"style":function(e){return o.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}const Ge=n.performance;function qe(e){const t=e?e.url.toString():void 0;return Ge.getEntriesByName(t)}let $e,Ze,We,Xe;const He={now:()=>void 0!==We?We:n.performance.now(),setNow(e){We=e},restoreNow(){We=void 0},frame(e){const t=n.requestAnimationFrame(e);return{cancel:()=>n.cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:r,height:i}=e;Xe||(Xe=n.document.createElement("canvas"));const o=Xe.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return(r>Xe.width||i>Xe.height)&&(Xe.width=r,Xe.height=i),o.clearRect(-t,-t,r+2*t,i+2*t),o.drawImage(e,0,0,r,i),o.getImageData(-t,-t,r+2*t,i+2*t)},resolveURL:e=>($e||($e=n.document.createElement("a")),$e.href=e,$e.href),get devicePixelRatio(){return n.devicePixelRatio},get prefersReducedMotion(){return!!n.matchMedia&&(null==Ze&&(Ze=n.matchMedia("(prefers-reduced-motion: reduce)")),Ze.matches)}};function Ye(e,t,n){n[e]&&-1!==n[e].indexOf(t)||(n[e]=n[e]||[],n[e].push(t))}function Ke(e,t,n){if(n&&n[e]){const r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}class Je{constructor(e,t={}){z(this,t),this.type=e}}class Qe extends Je{constructor(e,t={}){super("error",z({error:e},t))}}class et{on(e,t){return this._listeners=this._listeners||{},Ye(e,t,this._listeners),this}off(e,t){return Ke(e,t,this._listeners),Ke(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ye(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new Je(e,t||{}));const n=e.type;if(this.listens(n)){e.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const n of t)n.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of r)Ke(n,t,this._oneTimeListeners),t.call(this,e);const i=this._eventedParent;i&&(z(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof Qe&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var tt=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"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"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":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"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":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"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"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"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":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"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":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"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"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function nt(e,...t){for(const n of t)for(const t in n)e[t]=n[t];return e}function rt(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function it(e){if(Array.isArray(e))return e.map(it);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const n in e)t[n]=it(e[n]);return t}return rt(e)}class ot extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var at=ot;class st{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,n]of t)this.bindings[e]=n}concat(e){return new st(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(e+" not found in scope.")}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var lt=st;const ut={kind:"null"},ct={kind:"number"},ht={kind:"string"},dt={kind:"boolean"},ft={kind:"color"},pt={kind:"object"},mt={kind:"value"},_t={kind:"collator"},gt={kind:"formatted"},yt={kind:"resolvedImage"};function vt(e,t){return{kind:"array",itemType:e,N:t}}function xt(e){if("array"===e.kind){const t=xt(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const bt=[ut,ct,ht,dt,ft,gt,pt,vt(mt),yt];function wt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!wt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of bt)if(!wt(e,t))return null}return`Expected ${xt(e)} but found ${xt(t)} instead.`}function Et(e,t){return t.some(t=>t.kind===e.kind)}function Tt(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}var St,kt={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 Mt(e){return(e=Math.round(e))<0?0:e>255?255:e}function Ct(e){return Mt("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function At(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function It(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}try{St={}.parseCSSColor=function(e){var t,n=e.replace(/ /g,"").toLowerCase();if(n in kt)return kt[n].slice();if("#"===n[0])return 4===n.length?(t=parseInt(n.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===n.length&&(t=parseInt(n.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=n.indexOf("("),i=n.indexOf(")");if(-1!==r&&i+1===n.length){var o=n.substr(0,r),a=n.substr(r+1,i-(r+1)).split(","),s=1;switch(o){case"rgba":if(4!==a.length)return null;s=At(a.pop());case"rgb":return 3!==a.length?null:[Ct(a[0]),Ct(a[1]),Ct(a[2]),s];case"hsla":if(4!==a.length)return null;s=At(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,u=At(a[1]),c=At(a[2]),h=c<=.5?c*(u+1):c+u-c*u,d=2*c-h;return[Mt(255*It(d,h,l+1/3)),Mt(255*It(d,h,l)),Mt(255*It(d,h,l-1/3)),s];default:return null}}return null}}catch(e){}class Pt{constructor(e,t,n,r=1){this.r=e,this.g=t,this.b=n,this.a=r}static parse(e){if(!e)return;if(e instanceof Pt)return e;if("string"!=typeof e)return;const t=St(e);return t?new Pt(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,n,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(n)},${r})`}toArray(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*n/r,r]}toArray01(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,n/r,r]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:n,a:r}=this;return[e,t,n,r]}}Pt.black=new Pt(0,0,0,1),Pt.white=new Pt(1,1,1,1),Pt.transparent=new Pt(0,0,0,0),Pt.red=new Pt(1,0,0,1),Pt.blue=new Pt(0,0,1,1);var Ot=Pt;class zt{constructor(e,t,n){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Lt{constructor(e,t,n,r,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i}}class Dt{constructor(e){this.sections=e}static fromString(e){return new Dt([new Lt(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Dt?e:Dt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const n={};t.fontStack&&(n["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(n["font-scale"]=t.scale),t.textColor&&(n["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(n)}return e}}class Rt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Rt({name:e,available:!1}):null}serialize(){return["image",this.name]}}function Bt(e,t,n,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,n,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,n,r]:[e,t,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ft(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof Ot)return!0;if(e instanceof zt)return!0;if(e instanceof Dt)return!0;if(e instanceof Rt)return!0;if(Array.isArray(e)){for(const t of e)if(!Ft(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Ft(e[t]))return!1;return!0}return!1}function jt(e){if(null===e)return ut;if("string"==typeof e)return ht;if("boolean"==typeof e)return dt;if("number"==typeof e)return ct;if(e instanceof Ot)return ft;if(e instanceof zt)return _t;if(e instanceof Dt)return gt;if(e instanceof Rt)return yt;if(Array.isArray(e)){const t=e.length;let n;for(const t of e){const e=jt(t);if(n){if(n===e)continue;n=mt;break}n=e}return vt(n||mt,t)}return pt}function Nt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ot||e instanceof Dt||e instanceof Rt?e.toString():JSON.stringify(e)}class Ut{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ft(e[1]))return t.error("invalid value");const n=e[1];let r=jt(n);const i=t.expectedType;return"array"!==r.kind||0!==r.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(r=i),new Ut(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Ot?["rgba"].concat(this.value.toArray()):this.value instanceof Dt?this.value.serialize():this.value}}var Vt=Ut,Gt=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const qt={string:ht,number:ct,boolean:dt,object:pt};class $t{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let n,r=1;const i=e[0];if("array"===i){let i,o;if(e.length>2){const n=e[1];if("string"!=typeof n||!(n in qt)||"object"===n)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=qt[n],r++}else i=mt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}n=vt(i,o)}else n=qt[i];const o=[];for(;re.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const n=e.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){t.push(n.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map(e=>e.serialize()))}}var Zt=$t;class Wt{constructor(e){this.type=gt,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&"object"==typeof n)return t.error("First argument must be an image or text section.");const r=[];let i=!1;for(let n=1;n<=e.length-1;++n){const o=e[n];if(i&&"object"==typeof o&&!Array.isArray(o)){i=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,ct),!e))return null;let n=null;if(o["text-font"]&&(n=t.parse(o["text-font"],1,vt(ht)),!n))return null;let a=null;if(o["text-color"]&&(a=t.parse(o["text-color"],1,ft),!a))return null;const s=r[r.length-1];s.scale=e,s.font=n,s.textColor=a}else{const o=t.parse(e[n],1,mt);if(!o)return null;const a=o.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new Wt(r)}evaluate(e){return new Dt(this.sections.map(t=>{const n=t.content.evaluate(e);return jt(n)===yt?new Lt("",n,null,null,null):new Lt(Nt(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const n={};t.scale&&(n["font-scale"]=t.scale.serialize()),t.font&&(n["text-font"]=t.font.serialize()),t.textColor&&(n["text-color"]=t.textColor.serialize()),e.push(n)}return e}}class Xt{constructor(e){this.type=yt,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,ht);return n?new Xt(n):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),n=Rt.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Ht={"to-boolean":dt,"to-color":ft,"to-number":ct,"to-string":ht};class Yt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[0];if(("to-boolean"===n||"to-string"===n)&&2!==e.length)return t.error("Expected one argument.");const r=Ht[n],i=[];for(let n=1;n4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Bt(t[0],t[1],t[2],t[3]),!n))return new Ot(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Gt(n||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const n of this.args){if(t=n.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new Gt(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Dt.fromString(Nt(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?Rt.fromString(Nt(this.args[0].evaluate(e))):Nt(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Wt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Xt(this.args[0]).serialize();const e=["to-"+this.type.kind];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Kt=Yt;const Jt=["Unknown","Point","LineString","Polygon"];var Qt=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&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Jt[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 e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:n,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Ot.parse(e)),t}};class en{constructor(e,t,n,r){this.name=e,this.type=t,this._evaluate=n,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const n=e[0],r=en.definitions[n];if(!r)return t.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let s=null;for(const[r,o]of a){s=new Cn(t.registry,t.path,null,t.scope);const a=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(xt).join(", ")})`:`(${xt(t.type)}...)`;var t}).join(" | "),r=[];for(let n=1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function sn(e,t){const n=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=Math.pow(2,t.z);return[Math.round(n*i*rn),Math.round(r*i*rn)]}function ln(e,t,n){const r=e[0]-t[0],i=e[1]-t[1],o=e[0]-n[0],a=e[1]-n[1];return r*a-o*i==0&&r*o<=0&&i*a<=0}function un(e,t){let n=!1;for(let a=0,s=t.length;a(r=e)[1]!=(o=s[t+1])[1]>r[1]&&r[0]<(o[0]-i[0])*(r[1]-i[1])/(o[1]-i[1])+i[0]&&(n=!n)}}var r,i,o;return n}function cn(e,t){for(let n=0;n0&&s<0||a<0&&s>0}function dn(e,t,n){for(const u of n)for(let n=0;nn[2]){const t=.5*r;let i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;0===i&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}on(t,e)}function yn(e,t,n,r){const i=Math.pow(2,r.z)*rn,o=[r.x*rn,r.y*rn],a=[];if(!e)return a;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];gn(r,t,n,i),a.push(r)}return a}function vn(e,t,n,r){const i=Math.pow(2,r.z)*rn,o=[r.x*rn,r.y*rn],a=[];if(!e)return a;for(const n of e){const e=[];for(const r of n){const n=[r.x+o[0],r.y+o[1]];on(t,n),e.push(n)}a.push(e)}if(t[2]-t[0]<=i/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const e of a)for(const r of e)gn(r,t,n,i)}var s;return a}class xn{constructor(e,t){this.type=dt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ft(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e{t&&!wn(e)&&(t=!1)}),t}function En(e){if(e instanceof tn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!En(e)&&(t=!1)}),t}function Tn(e,t){if(e instanceof tn&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild(e=>{n&&!Tn(e,t)&&(n=!1)}),n}class Sn{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const n=e[1];return t.scope.has(n)?new Sn(n,t.scope.get(n)):t.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var kn=Sn;class Mn{constructor(e,t=[],n,r=new lt,i=[]){this.registry=e,this.path=t,this.key=t.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=i,this.expectedType=n}parse(e,t,n,r,i={}){return t?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return"assert"===n?new Zt(t,[e]):"coerce"===n?new Kt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=e[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 i=this.registry[r];if(i){let r=i.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,i=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==i.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==i.kind&&"string"!==i.kind){if(this.checkSubtype(e,i))return null}else r=n(r,e,t.typeAnnotation||"coerce");else r=n(r,e,t.typeAnnotation||"assert")}if(!(r instanceof Vt)&&"resolvedImage"!==r.type.kind&&function e(t){if(t instanceof kn)return e(t.boundExpression);if(t instanceof tn&&"error"===t.name)return!1;if(t instanceof nn)return!1;if(t instanceof bn)return!1;const n=t instanceof Kt||t instanceof Zt;let r=!0;return t.eachChild(t=>{r=n?r&&e(t):r&&t instanceof Vt}),!!r&&wn(t)&&Tn(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}(r)){const t=new Qt;try{r=new Vt(r.type,r.evaluate(t))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,n){const r="number"==typeof e?this.path.concat(e):this.path,i=n?this.scope.concat(n):this.scope;return new Mn(this.registry,r,t||null,i,this.errors)}error(e,...t){const n=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new at(n,e))}checkSubtype(e,t){const n=wt(e,t);return n&&this.error(n),n}}var Cn=Mn;function An(e,t){const n=e.length-1;let r,i,o=0,a=n,s=0;for(;o<=a;)if(s=Math.floor((o+a)/2),r=e[s],i=e[s+1],r<=t){if(s===n||tt))throw new Gt("Input is not a number.");a=s-1}return 0}class In{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const n=t.parse(e[1],1,ct);if(!n)return null;const r=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let n=1;n=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const u=t.parse(a,l,i);if(!u)return null;i=i||u.type,r.push([o,u])}return new In(i,n,r)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[An(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var Pn=In;function On(e,t,n){return e*(1-n)+t*n}var zn=Object.freeze({__proto__:null,array:function(e,t,n){return e.map((e,r)=>On(e,t[r],n))},color:function(e,t,n){return new Ot(On(e.r,t.r,n),On(e.g,t.g,n),On(e.b,t.b,n),On(e.a,t.a,n))},number:On});const Ln=6/29,Dn=3*Ln*Ln,Rn=Math.PI/180,Bn=180/Math.PI;function Fn(e){return e>.008856451679035631?Math.pow(e,1/3):e/Dn+4/29}function jn(e){return e>Ln?e*e*e:Dn*(e-4/29)}function Nn(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Un(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Vn(e){const t=Un(e.r),n=Un(e.g),r=Un(e.b),i=Fn((.4124564*t+.3575761*n+.1804375*r)/.95047),o=Fn((.2126729*t+.7151522*n+.072175*r)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-Fn((.0193339*t+.119192*n+.9503041*r)/1.08883)),alpha:e.a}}function Gn(e){let t=(e.l+16)/116,n=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*jn(t),n=.95047*jn(n),r=1.08883*jn(r),new Ot(Nn(3.2404542*n-1.5371385*t-.4985314*r),Nn(-.969266*n+1.8760108*t+.041556*r),Nn(.0556434*n-.2040259*t+1.0572252*r),e.alpha)}function qn(e,t,n){const r=t-e;return e+n*(r>180||r<-180?r-360*Math.round(r/360):r)}const $n={forward:Vn,reverse:Gn,interpolate:function(e,t,n){return{l:On(e.l,t.l,n),a:On(e.a,t.a,n),b:On(e.b,t.b,n),alpha:On(e.alpha,t.alpha,n)}}},Zn={forward:function(e){const{l:t,a:n,b:r}=Vn(e),i=Math.atan2(r,n)*Bn;return{h:i<0?i+360:i,c:Math.sqrt(n*n+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Rn,n=e.c;return Gn({l:e.l,a:Math.cos(t)*n,b:Math.sin(t)*n,alpha:e.alpha})},interpolate:function(e,t,n){return{h:qn(e.h,t.h,n),c:On(e.c,t.c,n),l:On(e.l,t.l,n),alpha:On(e.alpha,t.alpha,n)}}};var Wn=Object.freeze({__proto__:null,hcl:Zn,lab:$n});class Xn{constructor(e,t,n,r,i){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let i=0;if("exponential"===e.name)i=Hn(t,e.base,n,r);else if("linear"===e.name)i=Hn(t,1,n,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;i=new _(o[0],o[1],o[2],o[3]).solve(Hn(t,1,n,r))}return i}static parse(e,t){let[n,r,i,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error("Unknown interpolation type "+String(r[0]),1,0);{const e=r.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,ct),!i)return null;const a=[];let s=null;"interpolate-hcl"===n||"interpolate-lab"===n?s=ft:t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);for(let e=0;e=n)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=t.parse(r,l,s);if(!u)return null;s=s||u.type,a.push([n,u])}return"number"===s.kind||"color"===s.kind||"array"===s.kind&&"number"===s.itemType.kind&&"number"==typeof s.N?new Xn(s,n,r,i,a):t.error(`Type ${xt(s)} is not interpolatable.`)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;if(r>=t[i-1])return n[i-1].evaluate(e);const o=An(t,r),a=Xn.interpolationFactor(this.interpolation,r,t[o],t[o+1]),s=n[o].evaluate(e),l=n[o+1].evaluate(e);return"interpolate"===this.operator?zn[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?Zn.reverse(Zn.interpolate(Zn.forward(s),Zn.forward(l),a)):$n.reverse($n.interpolate($n.forward(s),$n.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="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 t=[this.operator,e,this.input.serialize()];for(let e=0;ewt(r,e.type));return new Kn(o?mt:n,i)}evaluate(e){let t,n=null,r=0;for(const i of this.args){if(r++,n=i.evaluate(e),n&&n instanceof Rt&&!n.available&&(t||(t=n),n=null,r===this.args.length))return t;if(null!==n)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Jn=Kn;class Qn{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const n=[];for(let r=1;r=n.length)throw new Gt(`Array index out of bounds: ${t} > ${n.length-1}.`);if(t!==Math.floor(t))throw new Gt(`Array index must be an integer, but found ${t} instead.`);return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var nr=tr;class rr{constructor(e,t){this.type=dt,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,mt),r=t.parse(e[2],2,mt);return n&&r?Et(n.type,[dt,ht,ct,ut,mt])?new rr(n,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${xt(n.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(null==n)return!1;if(!Tt(t,["boolean","string","number","null"]))throw new Gt(`Expected first argument to be of type boolean, string, number or null, but found ${xt(jt(t))} instead.`);if(!Tt(n,["string","array"]))throw new Gt(`Expected second argument to be of type array or string, but found ${xt(jt(n))} instead.`);return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var ir=rr;class or{constructor(e,t,n){this.type=ct,this.needle=e,this.haystack=t,this.fromIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,mt),r=t.parse(e[2],2,mt);if(!n||!r)return null;if(!Et(n.type,[dt,ht,ct,ut,mt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${xt(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,ct);return i?new or(n,r,i):null}return new or(n,r)}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!Tt(t,["boolean","string","number","null"]))throw new Gt(`Expected first argument to be of type boolean, string, number or null, but found ${xt(jt(t))} instead.`);if(!Tt(n,["string","array"]))throw new Gt(`Expected second argument to be of type array or string, but found ${xt(jt(n))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return n.indexOf(t,r)}return n.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var ar=or;class sr{constructor(e,t,n,r,i,o){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let n,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const i={},o=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,jt(e)))return null}else n=jt(e);if(void 0!==i[String(e)])return u.error("Branch labels must be unique.");i[String(e)]=o.length}const c=t.parse(l,a,r);if(!c)return null;r=r||c.type,o.push(c)}const a=t.parse(e[1],1,mt);if(!a)return null;const s=t.parse(e[e.length-1],e.length-1,r);return s?"value"!==a.type.kind&&t.concat(1).checkSubtype(n,a.type)?null:new sr(n,r,a,i,o,s):null}evaluate(e){const t=this.input.evaluate(e);return(jt(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),n=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=n.length,n.push([this.cases[e],[e]])):n[t][1].push(e)}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of n)e.push(1===r.length?i(r[0]):r.map(i)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var lr=sr;class ur{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r=[];for(let i=1;it.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var cr=ur;class hr{constructor(e,t,n,r){this.type=e,this.input=t,this.beginIndex=n,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,mt),r=t.parse(e[2],2,ct);if(!n||!r)return null;if(!Et(n.type,[vt(mt),ht,mt]))return t.error(`Expected first argument to be of type array or string, but found ${xt(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,ct);return i?new hr(n.type,n,r,i):null}return new hr(n.type,n,r)}evaluate(e){const t=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!Tt(t,["string","array"]))throw new Gt(`Expected first argument to be of type array or string, but found ${xt(jt(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(n,r)}return t.slice(n)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var dr=hr;function fr(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function pr(e,t,n,r){return 0===r.compare(t,n)}function mr(e,t,n){const r="=="!==e&&"!="!==e;return class i{constructor(e,t,n){this.type=dt,this.lhs=e,this.rhs=t,this.collator=n,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const n=e[0];let o=t.parse(e[1],1,mt);if(!o)return null;if(!fr(n,o.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${xt(o.type)}'.`);let a=t.parse(e[2],2,mt);if(!a)return null;if(!fr(n,a.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${xt(a.type)}'.`);if(o.type.kind!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${xt(o.type)}' and '${xt(a.type)}'.`);r&&("value"===o.type.kind&&"value"!==a.type.kind?o=new Zt(a.type,[o]):"value"!==o.type.kind&&"value"===a.type.kind&&(a=new Zt(o.type,[a])));let s=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,_t),!s)return null}return new i(o,a,s)}evaluate(i){const o=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const t=jt(o),n=jt(a);if(t.kind!==n.kind||"string"!==t.kind&&"number"!==t.kind)throw new Gt(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=jt(o),n=jt(a);if("string"!==e.kind||"string"!==n.kind)return t(i,o,a)}return this.collator?n(i,o,a,this.collator.evaluate(i)):t(i,o,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize())}),t}}}const _r=mr("==",(function(e,t,n){return t===n}),pr),gr=mr("!=",(function(e,t,n){return t!==n}),(function(e,t,n,r){return!pr(0,t,n,r)})),yr=mr("<",(function(e,t,n){return t",(function(e,t,n){return t>n}),(function(e,t,n,r){return r.compare(t,n)>0})),xr=mr("<=",(function(e,t,n){return t<=n}),(function(e,t,n,r){return r.compare(t,n)<=0})),br=mr(">=",(function(e,t,n){return t>=n}),(function(e,t,n,r){return r.compare(t,n)>=0}));class wr{constructor(e,t,n,r,i,o){this.type=ht,this.number=e,this.locale=t,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,ct);if(!n)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let i=null;if(r.locale&&(i=t.parse(r.locale,1,ht),!i))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,ht),!o))return null;let a=null;if(r.unit&&(a=t.parse(r.unit,1,ht),!a))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,ct),!s))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,ct),!l)?null:new wr(n,i,o,a,s,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Er{constructor(e){this.type=ct,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const n=t.parse(e[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?t.error(`Expected argument of type string or array, but found ${xt(n.type)} instead.`):new Er(n):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Gt(`Expected value to be of type string or array, but found ${xt(jt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}const Tr={"==":_r,"!=":gr,">":vr,"<":yr,">=":br,"<=":xr,array:Zt,at:nr,boolean:Zt,case:cr,coalesce:Jn,collator:nn,format:Wt,image:Xt,in:ir,"index-of":ar,interpolate:Yn,"interpolate-hcl":Yn,"interpolate-lab":Yn,length:Er,let:er,literal:Vt,match:lr,number:Zt,"number-format":wr,object:Zt,slice:dr,step:Pn,string:Zt,"to-boolean":Kt,"to-color":Kt,"to-number":Kt,"to-string":Kt,var:kn,within:bn};function Sr(e,[t,n,r,i]){t=t.evaluate(e),n=n.evaluate(e),r=r.evaluate(e);const o=i?i.evaluate(e):1,a=Bt(t,n,r,o);if(a)throw new Gt(a);return new Ot(t/255*o,n/255*o,r/255*o,o)}function kr(e,t){return e in t}function Mr(e,t){const n=t[e];return void 0===n?null:n}function Cr(e){return{type:e}}tn.register(Tr,{error:[{kind:"error"},[ht],(e,[t])=>{throw new Gt(t.evaluate(e))}],typeof:[ht,[mt],(e,[t])=>xt(jt(t.evaluate(e)))],"to-rgba":[vt(ct,4),[ft],(e,[t])=>t.evaluate(e).toArray()],rgb:[ft,[ct,ct,ct],Sr],rgba:[ft,[ct,ct,ct,ct],Sr],has:{type:dt,overloads:[[[ht],(e,[t])=>kr(t.evaluate(e),e.properties())],[[ht,pt],(e,[t,n])=>kr(t.evaluate(e),n.evaluate(e))]]},get:{type:mt,overloads:[[[ht],(e,[t])=>Mr(t.evaluate(e),e.properties())],[[ht,pt],(e,[t,n])=>Mr(t.evaluate(e),n.evaluate(e))]]},"feature-state":[mt,[ht],(e,[t])=>Mr(t.evaluate(e),e.featureState||{})],properties:[pt,[],e=>e.properties()],"geometry-type":[ht,[],e=>e.geometryType()],id:[mt,[],e=>e.id()],zoom:[ct,[],e=>e.globals.zoom],pitch:[ct,[],e=>e.globals.pitch||0],"distance-from-center":[ct,[],e=>e.distanceFromCenter()],"heatmap-density":[ct,[],e=>e.globals.heatmapDensity||0],"line-progress":[ct,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[ct,[],e=>e.globals.skyRadialProgress||0],accumulated:[mt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ct,Cr(ct),(e,t)=>{let n=0;for(const r of t)n+=r.evaluate(e);return n}],"*":[ct,Cr(ct),(e,t)=>{let n=1;for(const r of t)n*=r.evaluate(e);return n}],"-":{type:ct,overloads:[[[ct,ct],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[ct],(e,[t])=>-t.evaluate(e)]]},"/":[ct,[ct,ct],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[ct,[ct,ct],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[ct,[],()=>Math.LN2],pi:[ct,[],()=>Math.PI],e:[ct,[],()=>Math.E],"^":[ct,[ct,ct],(e,[t,n])=>Math.pow(t.evaluate(e),n.evaluate(e))],sqrt:[ct,[ct],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ct,[ct],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ct,[ct],(e,[t])=>Math.log(t.evaluate(e))],log2:[ct,[ct],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ct,[ct],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ct,[ct],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ct,[ct],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ct,[ct],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ct,[ct],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ct,[ct],(e,[t])=>Math.atan(t.evaluate(e))],min:[ct,Cr(ct),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ct,Cr(ct),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ct,[ct],(e,[t])=>Math.abs(t.evaluate(e))],round:[ct,[ct],(e,[t])=>{const n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[ct,[ct],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ct,[ct],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[dt,[ht,mt],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[dt,[mt],(e,[t])=>e.id()===t.value],"filter-type-==":[dt,[ht],(e,[t])=>e.geometryType()===t.value],"filter-<":[dt,[ht,mt],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r{const n=e.id(),r=t.value;return typeof n==typeof r&&n":[dt,[ht,mt],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[dt,[mt],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[dt,[ht,mt],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[dt,[mt],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[dt,[ht,mt],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[dt,[mt],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[dt,[mt],(e,[t])=>t.value in e.properties()],"filter-has-id":[dt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[dt,[vt(ht)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[dt,[vt(mt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[dt,[ht,vt(mt)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[dt,[ht,vt(mt)],(e,[t,n])=>function(e,t,n,r){for(;n<=r;){const i=n+r>>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}(e.properties()[t.value],n.value,0,n.value.length-1)],all:{type:dt,overloads:[[[dt,dt],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[Cr(dt),(e,t)=>{for(const n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:dt,overloads:[[[dt,dt],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[Cr(dt),(e,t)=>{for(const n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[dt,[dt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[dt,[ht],(e,[t])=>{const n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[ht,[ht],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[ht,[ht],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[ht,Cr(mt),(e,t)=>t.map(t=>Nt(t.evaluate(e))).join("")],"resolved-locale":[ht,[_t],(e,[t])=>t.evaluate(e).resolvedLocale()]});var Ar=Tr;function Ir(e){return{result:"success",value:e}}function Pr(e){return{result:"error",value:e}}function Or(e){return"data-driven"===e["property-type"]}function zr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Lr(e){return!!e.expression&&e.expression.interpolated}function Dr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Rr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Br(e){return e}function Fr(e,t,n){return void 0!==e?e:void 0!==t?t:void 0!==n?n:void 0}function jr(e,t,n,r,i){return Fr(typeof n===i?r[n]:void 0,e.default,t.default)}function Nr(e,t,n){if("number"!==Dr(n))return Fr(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];const i=An(e.stops.map(e=>e[0]),n);return e.stops[i][1]}function Ur(e,t,n){const r=void 0!==e.base?e.base:1;if("number"!==Dr(n))return Fr(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];const o=An(e.stops.map(e=>e[0]),n),a=function(e,t,n,r){const i=r-n,o=e-n;return 0===i?0:1===t?o/i:(Math.pow(t,o)-1)/(Math.pow(t,i)-1)}(n,r,e.stops[o][0],e.stops[o+1][0]),s=e.stops[o][1],l=e.stops[o+1][1];let u=zn[t.type]||Br;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Wn[e.colorSpace];u=(e,n)=>t.reverse(t.interpolate(t.forward(e),t.forward(n),a))}return"function"==typeof s.evaluate?{evaluate(...e){const t=s.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==n)return u(t,n,a)}}:u(s,l,a)}function Vr(e,t,n){return"color"===t.type?n=Ot.parse(n):"formatted"===t.type?n=Dt.fromString(n.toString()):"resolvedImage"===t.type?n=Rt.fromString(n.toString()):Dr(n)===t.type||"enum"===t.type&&t.values[n]||(n=void 0),Fr(n,e.default,t.default)}class Gr{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new Qt,this._defaultValue=t?function(e){return"color"===e.type&&(Rr(e.default)||Array.isArray(e.default))?new Ot(0,0,0,0):"color"===e.type?Ot.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,n,r,i,o,a,s){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=n,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,n,r,i,o,a,s){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Gt(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function qr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Ar}function $r(e,t){const n=new Cn(Ar,[],t?function(e){const t={color:ft,string:ht,number:ct,enum:ht,boolean:dt,formatted:gt,resolvedImage:yt};return"array"===e.type?vt(t[e.value]||mt,e.length):t[e.type]}(t):void 0),r=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?Ir(new Gr(r,t)):Pr(n.errors)}class Zr{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!En(t.expression)}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}}class Wr{constructor(e,t,n,r){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent="camera"!==e&&!En(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}interpolationFactor(e,t,n){return this.interpolationType?Yn.interpolationFactor(this.interpolationType,e,t,n):0}}function Xr(e,t){if("error"===(e=$r(e,t)).result)return e;const n=e.value.expression,r=wn(n);if(!r&&!Or(t))return Pr([new at("","data expressions not supported")]);const i=Tn(n,["zoom","pitch","distance-from-center"]);if(!i&&!zr(t))return Pr([new at("","zoom expressions not supported")]);const o=function e(t){let n=null;if(t instanceof er)n=e(t.result);else if(t instanceof Jn){for(const r of t.args)if(n=e(r),n)break}else(t instanceof Pn||t instanceof Yn)&&t.input instanceof tn&&"zoom"===t.input.name&&(n=t);return n instanceof at||t.eachChild(t=>{const r=e(t);r instanceof at?n=r:!n&&r?n=new at("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&r&&n!==r&&(n=new at("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),n}(n);return o||i?o instanceof at?Pr([o]):o instanceof Yn&&!Lr(t)?Pr([new at("",'"interpolate" expressions cannot be used with this property')]):Ir(o?new Wr(r?"camera":"composite",e.value,o.labels,o instanceof Yn?o.interpolation:void 0):new Zr(r?"constant":"source",e.value)):Pr([new at("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Hr{constructor(e,t){this._parameters=e,this._specification=t,nt(this,function e(t,n){const r="color"===n.type,i=t.stops&&"object"==typeof t.stops[0][0],o=i||!(i||void 0!==t.property),a=t.type||(Lr(n)?"exponential":"interval");if(r&&((t=nt({},t)).stops&&(t.stops=t.stops.map(e=>[e[0],Ot.parse(e[1])])),t.default=Ot.parse(t.default?t.default:n.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Wn[t.colorSpace])throw new Error("Unknown color space: "+t.colorSpace);let s,l,u;if("exponential"===a)s=Ur;else if("interval"===a)s=Nr;else if("categorical"===a){s=jr,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0]}else{if("identity"!==a)throw new Error(`Unknown function type "${a}"`);s=Vr}if(i){const r={},i=[];for(let e=0;ee[0]),evaluate:({zoom:e},r)=>Ur({stops:o,base:t.base},n,e).evaluate(e,r)}}if(o){const e="exponential"===a?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:e,interpolationFactor:Yn.interpolationFactor.bind(void 0,e),zoomStops:t.stops.map(e=>e[0]),evaluate:({zoom:e})=>s(t,n,e,l,u)}}return{kind:"source",evaluate(e,r){const i=r&&r.properties?r.properties[t.property]:void 0;return void 0===i?Fr(t.default,n.default):s(t,n,i,l,u)}}}(this._parameters,this._specification))}static deserialize(e){return new Hr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}class Yr{constructor(e,t,n,r){this.message=(e?e+": ":"")+n,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function Kr(e){const t=e.key,n=e.value,r=e.valueSpec||{},i=e.objectElementValidators||{},o=e.style,a=e.styleSpec;let s=[];const l=Dr(n);if("object"!==l)return[new Yr(t,n,`object expected, ${l} found`)];for(const e in n){const l=e.split(".")[0];let u;i[l]?u=i[l]:r[l]?u=Mi:i["*"]?u=i["*"]:r["*"]&&(u=Mi),u?s=s.concat(u({key:(t?t+".":t)+e,value:n[e],valueSpec:r[l]||r["*"],style:o,styleSpec:a,object:n,objectKey:e},n)):s.push(new Yr(t,n[e],`unknown property "${e}"`))}for(const e in r)i[e]||r[e].required&&void 0===r[e].default&&void 0===n[e]&&s.push(new Yr(t,n,`missing required property "${e}"`));return s}function Jr(e){const t=e.value,n=e.valueSpec,r=e.style,i=e.styleSpec,o=e.key,a=e.arrayElementValidator||Mi;if("array"!==Dr(t))return[new Yr(o,t,`array expected, ${Dr(t)} found`)];if(n.length&&t.length!==n.length)return[new Yr(o,t,`array length ${n.length} expected, length ${t.length} found`)];if(n["min-length"]&&t.lengthi)return[new Yr(t,n,`${n} is greater than the maximum value ${i}`)]}return[]}function ei(e){const t=e.valueSpec,n=rt(e.value.type);let r,i,o,a={};const s="categorical"!==n&&void 0===e.value.property,l=!s,u="array"===Dr(e.value.stops)&&"array"===Dr(e.value.stops[0])&&"object"===Dr(e.value.stops[0][0]),c=Kr({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return[new Yr(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Jr({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Dr(r)&&0===r.length&&t.push(new Yr(e.key,r,"array must have at least one stop")),t},default:function(e){return Mi({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===n&&s&&c.push(new Yr(e.key,e.value,'missing required property "property"')),"identity"===n||e.value.stops||c.push(new Yr(e.key,e.value,'missing required property "stops"')),"exponential"===n&&e.valueSpec.expression&&!Lr(e.valueSpec)&&c.push(new Yr(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Or(e.valueSpec)?c.push(new Yr(e.key,e.value,"property functions not supported")):s&&!zr(e.valueSpec)&&c.push(new Yr(e.key,e.value,"zoom functions not supported"))),"categorical"!==n&&!u||void 0!==e.value.property||c.push(new Yr(e.key,e.value,'"property" property is required')),c;function h(e){let n=[];const r=e.value,s=e.key;if("array"!==Dr(r))return[new Yr(s,r,`array expected, ${Dr(r)} found`)];if(2!==r.length)return[new Yr(s,r,`array length 2 expected, length ${r.length} found`)];if(u){if("object"!==Dr(r[0]))return[new Yr(s,r,`object expected, ${Dr(r[0])} found`)];if(void 0===r[0].zoom)return[new Yr(s,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new Yr(s,r,"object stop key must have value")];const t=rt(r[0].zoom);if("number"!=typeof t)return[new Yr(s,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new Yr(s,r[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,i=void 0,a={}),n=n.concat(Kr({key:s+"[0]",value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Qr,value:d}}))}else n=n.concat(d({key:s+"[0]",value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return qr(it(r[1]))?n.concat([new Yr(s+"[1]",r[1],"expressions are not allowed in function stops.")]):n.concat(Mi({key:s+"[1]",value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const s=Dr(e.value),l=rt(e.value),u=null!==e.value?e.value:o;if(r){if(s!==r)return[new Yr(e.key,u,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if("number"!==s&&"string"!==s&&"boolean"!==s&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new Yr(e.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==n){let r=`number expected, ${s} found`;return Or(t)&&void 0===n&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Yr(e.key,u,r)]}return"categorical"!==n||"number"!==s||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===s&&"number"==typeof l&&"number"==typeof i&&void 0!==i&&lnew Yr(`${e.key}${t.key}`,e.value,t.message));const n=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!n.outputDefined())return[new Yr(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!En(n))return[new Yr(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return function e(t,n){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(n.valueSpec&&n.valueSpec.expression)for(const e of n.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const i=[];return t instanceof tn&&r.has(t.name)?[new Yr(n.key,n.value,`["${t.name}"] expression is not supported in a filter for a ${n.object.type} layer with id: ${n.object.id}`)]:(t.eachChild(t=>{i.push(...e(t,n))}),i)}(n,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Tn(n,["zoom","feature-state"]))return[new Yr(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!wn(n))return[new Yr(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ni(e){const t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?-1===r.values.indexOf(rt(n))&&i.push(new Yr(t,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(rt(n))&&i.push(new Yr(t,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),i}function ri(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!ri(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function ii(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};ri(e)||(e=ui(e));const n=e;let r=!0;try{r=function(e){if(!oi(e))return e;let t=it(e);return function e(t){let n=!1;const r=[];if("case"===t[0]){for(let e=1;ee(t))}(t),t}(n)}catch(e){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(n,null,2)}\n `)}const i=tt["filter_"+t],o=$r(r,i);let a=null;if("error"===o.result)throw new Error(o.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=(e,t,n)=>o.value.evaluate(e,t,{},n);let s=null,l=null;if(r!==n){const e=$r(n,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));s=(t,n,r,i,o)=>e.value.evaluate(t,n,{},r,void 0,void 0,i,o),l=!wn(e.value.expression)}return{filter:a,dynamicFilter:s||void 0,needGeometry:li(r),needFeature:!!l}}function oi(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t",">=","<","<=","to-boolean"]);function si(e,t){return et?1:0}function li(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?ci(e[1],e[2],t):"any"===t?(n=e.slice(1),["any"].concat(n.map(ui))):"all"===t?["all"].concat(e.slice(1).map(ui)):"none"===t?["all"].concat(e.slice(1).map(ui).map(fi)):"in"===t?hi(e[1],e.slice(2)):"!in"===t?fi(hi(e[1],e.slice(2))):"has"===t?di(e[1]):"!has"===t?fi(di(e[1])):"within"!==t||e;var n}function ci(e,t,n){switch(e){case"$type":return["filter-type-"+n,t];case"$id":return["filter-id-"+n,t];default:return["filter-"+n,e,t]}}function hi(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(si)]]:["filter-in-small",e,["literal",t]]}}function di(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function fi(e){return["!",e]}function pi(e){return ri(it(e.value))?ti(nt({},e,{expressionContext:"filter",valueSpec:e.styleSpec["filter_"+(e.layerType||"fill")]})):function e(t){const n=t.value,r=t.key;if("array"!==Dr(n))return[new Yr(r,n,`array expected, ${Dr(n)} found`)];const i=t.styleSpec;let o,a=[];if(n.length<1)return[new Yr(r,n,"filter array must have at least 1 element")];switch(a=a.concat(ni({key:r+"[0]",value:n[0],valueSpec:i.filter_operator,style:t.style,styleSpec:t.styleSpec})),rt(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===rt(n[1])&&a.push(new Yr(r,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":3!==n.length&&a.push(new Yr(r,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&(o=Dr(n[1]),"string"!==o&&a.push(new Yr(r+"[1]",n[1],`string expected, ${o} found`)));for(let e=2;e{e in n&&t.push(new Yr(r,n[e],`"${e}" is prohibited for ref layers`))}),i.layers.forEach(t=>{rt(t.id)===s&&(e=t)}),e?e.ref?t.push(new Yr(r,n.ref,"ref cannot reference another ref layer")):a=rt(e.type):"string"==typeof s&&t.push(new Yr(r,n.ref,`ref layer "${s}" not found`))}else if("background"!==a&&"sky"!==a)if(n.source){const e=i.sources&&i.sources[n.source],o=e&&rt(e.type);e?"vector"===o&&"raster"===a?t.push(new Yr(r,n.source,`layer "${n.id}" requires a raster source`)):"raster"===o&&"raster"!==a?t.push(new Yr(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==o||n["source-layer"]?"raster-dem"===o&&"hillshade"!==a?t.push(new Yr(r,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!n.paint||!n.paint["line-gradient"]&&!n.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new Yr(r,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Yr(r,n,`layer "${n.id}" must specify a "source-layer"`)):t.push(new Yr(r,n.source,`source "${n.source}" not found`))}else t.push(new Yr(r,n,'missing required property "source"'));return t=t.concat(Kr({key:r,value:n,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Mi({key:r+".type",value:n.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:n,objectKey:"type"}),filter:e=>pi(nt({layerType:a},e)),layout:e=>Kr({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>gi(nt({layerType:a},e))}}),paint:e=>Kr({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>_i(nt({layerType:a},e))}})}})),t}function vi(e){const t=e.value,n=e.key,r=Dr(t);return"string"!==r?[new Yr(n,t,`string expected, ${r} found`)]:[]}const xi={promoteId:function({key:e,value:t}){if("string"===Dr(t))return vi({key:e,value:t});{const n=[];for(const r in t)n.push(...vi({key:`${e}.${r}`,value:t[r]}));return n}}};function bi(e){const t=e.value,n=e.key,r=e.styleSpec,i=e.style;if(!t.type)return[new Yr(n,t,'"type" is required')];const o=rt(t.type);let a;switch(o){case"vector":case"raster":case"raster-dem":return a=Kr({key:n,value:t,valueSpec:r["source_"+o.replace("-","_")],style:e.style,styleSpec:r,objectElementValidators:xi}),a;case"geojson":if(a=Kr({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,objectElementValidators:xi}),t.cluster)for(const e in t.clusterProperties){const[r,i]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...ti({key:`${n}.${e}.map`,value:i,expressionContext:"cluster-map"})),a.push(...ti({key:`${n}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Kr({key:n,value:t,valueSpec:r.source_video,style:i,styleSpec:r});case"image":return Kr({key:n,value:t,valueSpec:r.source_image,style:i,styleSpec:r});case"canvas":return[new Yr(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ni({key:n+".type",value:t.type,valueSpec:{values:wi(r)},style:i,styleSpec:r})}}function wi(e){return e.source.reduce((t,n)=>{const r=e[n];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values))),t},[])}function Ei(e){const t=e.value,n=e.styleSpec,r=n.light,i=e.style;let o=[];const a=Dr(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new Yr("light",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?Mi({key:e,value:t[e],valueSpec:n.transition,style:i,styleSpec:n}):r[e]?Mi({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}):[new Yr(e,t[e],`unknown property "${e}"`)])}return o}function Ti(e){const t=e.value,n=e.key,r=e.style,i=e.styleSpec,o=i.terrain;let a=[];const s=Dr(t);if(void 0===t)return a;if("object"!==s)return a=a.concat([new Yr("terrain",t,`object expected, ${s} found`)]),a;for(const e in t){const n=e.match(/^(.*)-transition$/);a=a.concat(n&&o[n[1]]&&o[n[1]].transition?Mi({key:e,value:t[e],valueSpec:i.transition,style:r,styleSpec:i}):o[e]?Mi({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:i}):[new Yr(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=r.sources&&r.sources[t.source],i=e&&rt(e.type);e?"raster-dem"!==i&&a.push(new Yr(n,t.source,`terrain cannot be used with a source of type ${String(i)}, it only be used with a "raster-dem" source type`)):a.push(new Yr(n,t.source,`source "${t.source}" not found`))}else a.push(new Yr(n,t,'terrain is missing required property "source"'));return a}function Si(e){const t=e.value,n=e.style,r=e.styleSpec,i=r.fog;let o=[];const a=Dr(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new Yr("fog",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&i[a[1]]&&i[a[1]].transition?Mi({key:e,value:t[e],valueSpec:r.transition,style:n,styleSpec:r}):i[e]?Mi({key:e,value:t[e],valueSpec:i[e],style:n,styleSpec:r}):[new Yr(e,t[e],`unknown property "${e}"`)])}return o}const ki={"*":()=>[],array:Jr,boolean:function(e){const t=e.value,n=e.key,r=Dr(t);return"boolean"!==r?[new Yr(n,t,`boolean expected, ${r} found`)]:[]},number:Qr,color:function(e){const t=e.key,n=e.value,r=Dr(n);return"string"!==r?[new Yr(t,n,`color expected, ${r} found`)]:null===St(n)?[new Yr(t,n,`color expected, "${n}" found`)]:[]},enum:ni,filter:pi,function:ei,layer:yi,object:Kr,source:bi,light:Ei,terrain:Ti,fog:Si,string:vi,formatted:function(e){return 0===vi(e).length?[]:ti(e)},resolvedImage:function(e){return 0===vi(e).length?[]:ti(e)},projection:function(e){const t=e.value,n=e.styleSpec,r=n.projection,i=e.style;let o=[];const a=Dr(t);if("object"===a)for(const e in t)o=o.concat(Mi({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}));else"string"!==a&&(o=o.concat([new Yr("projection",t,`object or string expected, ${a} found`)]));return o}};function Mi(e){const t=e.value,n=e.valueSpec,r=e.styleSpec;return n.expression&&Rr(rt(t))?ei(e):n.expression&&qr(it(t))?ti(e):n.type&&ki[n.type]?ki[n.type](e):Kr(nt({},e,{valueSpec:n.type?r[n.type]:n}))}function Ci(e){const t=e.value,n=e.key,r=vi(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new Yr(n,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new Yr(n,t,'"glyphs" url must include a "{range}" token'))),r}function Ai(e,t=tt){return Oi(Mi({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:Ci,"*":()=>[]}}))}const Ii=e=>Oi(_i(e)),Pi=e=>Oi(gi(e));function Oi(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function zi(e,t){let n=!1;if(t&&t.length)for(const r of t)e.fire(new Qe(new Error(r.message))),n=!0;return n}var Li=Di;function Di(e,t,n){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(n=i[2]);for(var o=0;o=c[f+0]&&r>=c[f+1])?(a[d]=!0,o.push(u[d])):a[d]=!1}}},Di.prototype._forEachCell=function(e,t,n,r,i,o,a,s){for(var l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(n),h=this._convertToCellCoord(r),d=l;d<=c;d++)for(var f=u;f<=h;f++){var p=this.d*f+d;if((!s||s(this._convertFromCellCoord(d),this._convertFromCellCoord(f),this._convertFromCellCoord(d+1),this._convertFromCellCoord(f+1)))&&i.call(this,e,t,n,r,p,o,a,s))return}},Di.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},Di.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},Di.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,n=0,r=0;r=0||(i[n]=Ui(e[n],t)));e instanceof Error&&(i.message=e.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(i.$name=r),i}throw new Error("can't serialize object of type "+typeof e)}function Vi(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||ji(e)||Ni(e)||ArrayBuffer.isView(e)||e instanceof n.ImageData)return e;if(Array.isArray(e))return e.map(Vi);if("object"==typeof e){const t=e.$name||"Object",{klass:n}=Bi[t];if(!n)throw new Error("can't deserialize unregistered class "+t);if(n.deserialize)return n.deserialize(e);const r=Object.create(n.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=Vi(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const Gi=e=>e>=128&&e<=255,qi=e=>e>=1536&&e<=1791,$i=e=>e>=1872&&e<=1919,Zi=e=>e>=2208&&e<=2303,Wi=e=>e>=4352&&e<=4607,Xi=e=>e>=5120&&e<=5759,Hi=e=>e>=6016&&e<=6143,Yi=e=>e>=6320&&e<=6399,Ki=e=>e>=8192&&e<=8303,Ji=e=>e>=8448&&e<=8527,Qi=e=>e>=8528&&e<=8591,eo=e=>e>=8960&&e<=9215,to=e=>e>=9216&&e<=9279,no=e=>e>=9280&&e<=9311,ro=e=>e>=9312&&e<=9471,io=e=>e>=9632&&e<=9727,oo=e=>e>=9728&&e<=9983,ao=e=>e>=11008&&e<=11263,so=e=>e>=11904&&e<=12031,lo=e=>e>=12032&&e<=12255,uo=e=>e>=12272&&e<=12287,co=e=>e>=12288&&e<=12351,ho=e=>e>=12352&&e<=12447,fo=e=>e>=12448&&e<=12543,po=e=>e>=12544&&e<=12591,mo=e=>e>=12592&&e<=12687,_o=e=>e>=12688&&e<=12703,go=e=>e>=12704&&e<=12735,yo=e=>e>=12736&&e<=12783,vo=e=>e>=12784&&e<=12799,xo=e=>e>=12800&&e<=13055,bo=e=>e>=13056&&e<=13311,wo=e=>e>=13312&&e<=19903,Eo=e=>e>=19904&&e<=19967,To=e=>e>=19968&&e<=40959,So=e=>e>=40960&&e<=42127,ko=e=>e>=42128&&e<=42191,Mo=e=>e>=43360&&e<=43391,Co=e=>e>=44032&&e<=55215,Ao=e=>e>=55216&&e<=55295,Io=e=>e>=57344&&e<=63743,Po=e=>e>=63744&&e<=64255,Oo=e=>e>=64336&&e<=65023,zo=e=>e>=65040&&e<=65055,Lo=e=>e>=65072&&e<=65103,Do=e=>e>=65104&&e<=65135,Ro=e=>e>=65136&&e<=65279,Bo=e=>e>=65280&&e<=65519;function Fo(e){for(const t of e)if(Uo(t.charCodeAt(0)))return!0;return!1}function jo(e){for(const t of e)if(!No(t.charCodeAt(0)))return!1;return!0}function No(e){return!(qi(e)||$i(e)||Zi(e)||Oo(e)||Ro(e))}function Uo(e){return!(746!==e&&747!==e&&(e<4352||!(go(e)||po(e)||Lo(e)&&!(e>=65097&&e<=65103)||Po(e)||bo(e)||so(e)||yo(e)||!(!co(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||wo(e)||To(e)||xo(e)||mo(e)||Mo(e)||Ao(e)||Wi(e)||Co(e)||ho(e)||uo(e)||_o(e)||lo(e)||vo(e)||fo(e)&&12540!==e||!(!Bo(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!Do(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||Xi(e)||Yi(e)||zo(e)||Eo(e)||So(e)||ko(e))))}function Vo(e){return!(Uo(e)||function(e){return!!(Gi(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||Ki(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||Ji(e)||Qi(e)||eo(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||to(e)&&9251!==e||no(e)||ro(e)||io(e)||oo(e)&&!(e>=9754&&e<=9759)||ao(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||co(e)||fo(e)||Io(e)||Lo(e)||Do(e)||Bo(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function Go(e){return e>=1424&&e<=2303||Oo(e)||Ro(e)}function qo(e,t){return!(!t&&Go(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||Hi(e))}function $o(e){for(const t of e)if(Go(t.charCodeAt(0)))return!0;return!1}const Zo="deferred",Wo="loading",Xo="loaded";let Ho=null,Yo="unavailable",Ko=null;const Jo=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Yo="error"),Ho&&Ho(e)};function Qo(){ea.fire(new Je("pluginStateChange",{pluginStatus:Yo,pluginURL:Ko}))}const ea=new et,ta=function(){return Yo},na=function(){if(Yo!==Zo||!Ko)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Yo=Wo,Qo(),Ko&&fe({url:Ko},e=>{e?Jo(e):(Yo=Xo,Qo())})},ra={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Yo===Xo||null!=ra.applyArabicShaping,isLoading:()=>Yo===Wo,setState(e){Yo=e.pluginStatus,Ko=e.pluginURL},isParsed:()=>null!=ra.applyArabicShaping&&null!=ra.processBidirectionalText&&null!=ra.processStyledBidirectionalText,getPluginURL:()=>Ko};class ia{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const n of e)if(!qo(n.charCodeAt(0),t))return!1;return!0}(e,ra.isLoaded())}}class oa{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(Rr(e))return new Hr(e,t);if(qr(e)){const n=Xr(e,t);if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));return n.value}{let n=e;return"string"==typeof e&&"color"===t.type&&(n=Ot.parse(e)),{kind:"constant",evaluate:()=>n}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class aa{constructor(e){this.property=e,this.value=new oa(e,void 0)}transitioned(e,t){return new la(this.property,this.value,t,z({},e.transition,this.transition),e.now)}untransitioned(){return new la(this.property,this.value,null,{},0)}}class sa{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return G(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new aa(this._values[e].property)),this._values[e].value=new oa(this._values[e].property,null===t?void 0:G(t))}getTransition(e){return G(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new aa(this._values[e].property)),this._values[e].transition=G(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const n=this.getValue(t);void 0!==n&&(e[t]=n);const r=this.getTransition(t);void 0!==r&&(e[t+"-transition"]=r)}return e}transitioned(e,t){const n=new ua(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){const e=new ua(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class la{constructor(e,t,n,r,i){const o=r.delay||0,a=r.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+o,this.end=this.begin+a,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){const r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),o=this.prior;if(o){if(r>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(rthis.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_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 ba(e,t=1){let n=0,r=0;return{members:e.map(e=>{const i=ya[e.type].BYTES_PER_ELEMENT,o=n=wa(n,Math.max(t,i)),a=e.components||1;return r=Math.max(r,i),n+=i*a,{name:e.name,type:e.type,components:a,offset:o}}),size:wa(n,Math.max(r,t)),alignment:t}}function wa(e,t){return Math.ceil(e/t)*t}class Ea extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=n,e}}Ea.prototype.bytesPerElement=4,Fi(Ea,"StructArrayLayout2i4");class Ta extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}}Ta.prototype.bytesPerElement=6,Fi(Ta,"StructArrayLayout3i6");class Sa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=n,this.int16[o+2]=r,this.int16[o+3]=i,e}}Sa.prototype.bytesPerElement=8,Fi(Sa,"StructArrayLayout4i8");class ka extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.uint8[u+4]=r,this.uint8[u+5]=i,this.uint8[u+6]=o,this.uint8[u+7]=a,this.float32[c+2]=s,e}}ka.prototype.bytesPerElement=12,Fi(ka,"StructArrayLayout2i4ub1f12");class Ma extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.float32[o+3]=i,e}}Ma.prototype.bytesPerElement=16,Fi(Ma,"StructArrayLayout4f16");class Ca extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=6*e,s=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=n,this.uint16[a+2]=r,this.uint16[a+3]=i,this.float32[s+2]=o,e}}Ca.prototype.bytesPerElement=12,Fi(Ca,"StructArrayLayout4ui1f12");class Aa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=n,this.uint16[o+2]=r,this.uint16[o+3]=i,e}}Aa.prototype.bytesPerElement=8,Fi(Aa,"StructArrayLayout4ui8");class Ia extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,e}}Ia.prototype.bytesPerElement=12,Fi(Ia,"StructArrayLayout6i12");class Pa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,n,r,i,o,a,s,l,u,c,h)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=12*e;return this.int16[f+0]=t,this.int16[f+1]=n,this.int16[f+2]=r,this.int16[f+3]=i,this.uint16[f+4]=o,this.uint16[f+5]=a,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=d,e}}Pa.prototype.bytesPerElement=24,Fi(Pa,"StructArrayLayout4i4ui4i24");class Oa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.float32[l+2]=i,this.float32[l+3]=o,this.float32[l+4]=a,e}}Oa.prototype.bytesPerElement=20,Fi(Oa,"StructArrayLayout3i3f20");class za extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}za.prototype.bytesPerElement=4,Fi(za,"StructArrayLayout1ul4");class La extends xa{_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(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,n,r,i,o,a,s,l,u,c,h,d)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f){const p=20*e,m=10*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=r,this.int16[p+3]=i,this.int16[p+4]=o,this.float32[m+3]=a,this.float32[m+4]=s,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[p+14]=c,this.uint32[m+8]=h,this.uint16[p+18]=d,this.uint16[p+19]=f,e}}La.prototype.bytesPerElement=40,Fi(La,"StructArrayLayout5i4f1i1ul2ui40");class Da extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.int16[l+2]=r,this.int16[l+4]=i,this.int16[l+5]=o,this.int16[l+6]=a,this.int16[l+7]=s,e}}Da.prototype.bytesPerElement=16,Fi(Da,"StructArrayLayout3i2i2i16");class Ra extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=4*e,s=8*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.int16[s+6]=i,this.int16[s+7]=o,e}}Ra.prototype.bytesPerElement=16,Fi(Ra,"StructArrayLayout2f1f2i16");class Ba extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=12*e,a=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=n,this.float32[a+1]=r,this.float32[a+2]=i,e}}Ba.prototype.bytesPerElement=12,Fi(Ba,"StructArrayLayout2ub2f12");class Fa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}Fa.prototype.bytesPerElement=12,Fi(Fa,"StructArrayLayout3f12");class ja extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}}ja.prototype.bytesPerElement=6,Fi(ja,"StructArrayLayout3ui6");class Na extends xa{_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(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b){const w=30*e,E=15*e,T=60*e;return this.int16[w+0]=t,this.int16[w+1]=n,this.int16[w+2]=r,this.float32[E+2]=i,this.float32[E+3]=o,this.uint16[w+8]=a,this.uint16[w+9]=s,this.uint32[E+5]=l,this.uint32[E+6]=u,this.uint32[E+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=f,this.float32[E+10]=p,this.float32[E+11]=m,this.uint8[T+48]=_,this.uint8[T+49]=g,this.uint8[T+50]=y,this.uint32[E+13]=v,this.int16[w+28]=x,this.uint8[T+58]=b,e}}Na.prototype.bytesPerElement=60,Fi(Na,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Ua extends xa{_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(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,E,T,S,k,M,C,A){const I=this.length;return this.resize(I+1),this.emplace(I,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,E,T,S,k,M,C,A)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,E,T,S,k,M,C,A,I){const P=38*e,O=19*e;return this.int16[P+0]=t,this.int16[P+1]=n,this.int16[P+2]=r,this.float32[O+2]=i,this.float32[O+3]=o,this.int16[P+8]=a,this.int16[P+9]=s,this.int16[P+10]=l,this.int16[P+11]=u,this.int16[P+12]=c,this.int16[P+13]=h,this.uint16[P+14]=d,this.uint16[P+15]=f,this.uint16[P+16]=p,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]=E,this.uint16[P+26]=T,this.uint16[P+27]=S,this.uint16[P+28]=k,this.uint32[O+15]=M,this.float32[O+16]=C,this.float32[O+17]=A,this.float32[O+18]=I,e}}Ua.prototype.bytesPerElement=76,Fi(Ua,"StructArrayLayout3i2f6i15ui1ul3f76");class Va extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Va.prototype.bytesPerElement=4,Fi(Va,"StructArrayLayout1f4");class Ga extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,this.float32[a+4]=o,e}}Ga.prototype.bytesPerElement=20,Fi(Ga,"StructArrayLayout5f20");class qa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=n,this.uint16[o+3]=r,this.uint16[o+4]=i,e}}qa.prototype.bytesPerElement=12,Fi(qa,"StructArrayLayout1ul3ui12");class $a extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}}$a.prototype.bytesPerElement=4,Fi($a,"StructArrayLayout2ui4");class Za extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Za.prototype.bytesPerElement=2,Fi(Za,"StructArrayLayout1ui2");class Wa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=n,e}}Wa.prototype.bytesPerElement=8,Fi(Wa,"StructArrayLayout2f8");class Xa extends va{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]}}Xa.prototype.size=40;class Ha extends La{get(e){return new Xa(this,e)}}Fi(Ha,"CollisionBoxArray");class Ya extends va{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(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}Ya.prototype.size=60;class Ka extends Na{get(e){return new Ya(this,e)}}Fi(Ka,"PlacedSymbolArray");class Ja extends va{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(e){this._structArray.uint32[this._pos4+15]=e}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]}}Ja.prototype.size=76;class Qa extends Ua{get(e){return new Ja(this,e)}}Fi(Qa,"SymbolInstanceArray");class es extends Va{getoffsetX(e){return this.float32[1*e+0]}}Fi(es,"GlyphOffsetArray");class ts extends Ea{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Fi(ts,"SymbolLineVertexArray");class ns extends va{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]}}ns.prototype.size=12;class rs extends qa{get(e){return new ns(this,e)}}Fi(rs,"FeatureIndexArray");class is extends $a{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Fi(is,"FillExtrusionCentroidArray");const os=ba([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),as=ba([{name:"a_dash",components:4,type:"Uint16"}]);var ss={exports:{}},ls={exports:{}};ls.exports=function(e,t){var n,r,i,o,a,s,l,u;for(r=e.length-(n=3&e.length),i=t,a=3432918353,s=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};var us=ls.exports,cs={exports:{}};cs.exports=function(e,t){for(var n,r=e.length,i=t^r,o=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:i^=(255&e.charCodeAt(o+2))<<16;case 2:i^=(255&e.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var hs=us,ds=cs.exports;ss.exports=hs,ss.exports.murmur3=hs,ss.exports.murmur2=ds;var fs=f(ss.exports);class ps{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(ms(e)),this.positions.push(t,n,r)}getPositions(e){const t=ms(e);let n=0,r=this.ids.length-1;for(;n>1;this.ids[e]>=t?r=e:n=e+1}const i=[];for(;this.ids[n]===t;)i.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return i}static serialize(e,t){const n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return function e(t,n,r,i){for(;r>1];let a=r-1,s=i+1;for(;;){do{a++}while(t[a]o);if(a>=s)break;_s(t,a,s),_s(n,3*a,3*s),_s(n,3*a+1,3*s+1),_s(n,3*a+2,3*s+2)}s-r"u_"+e),this.type=n}setUniform(e,t,n,r,i){t.set(e,i,r.constantOr(this.value))}getBinding(e,t){return"color"===this.type?new xs(e):new ys(e)}}class ks{constructor(e,t){this.uniformNames=t.map(e=>"u_"+e),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,t,n,r,i){const o="u_pattern"===i||"u_dash"===i?this.pattern:"u_pixel_ratio"===i?this.pixelRatio:null;o&&t.set(e,i,o)}getBinding(e,t){return"u_pattern"===t||"u_dash"===t?new vs(e):new ys(e)}}class Ms{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:"a_"+e,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,n,r,i,o){const a=this.paintVertexArray.length,s=this.expression.evaluate(new ia(0),t,{},i,r,o);this.paintVertexArray.resize(e),this._setPaintValue(a,e,s)}updatePaintArray(e,t,n,r,i){const o=this.expression.evaluate({zoom:0},n,r,void 0,i);this._setPaintValue(e,t,o)}_setPaintValue(e,t,n){if("color"===this.type){const r=Ts(n);for(let n=e;n`u_${e}_t`),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:"a_"+e,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,t,n,r,i,o){const a=this.expression.evaluate(new ia(this.zoom),t,{},i,r,o),s=this.expression.evaluate(new ia(this.zoom+1),t,{},i,r,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,a,s)}updatePaintArray(e,t,n,r,i){const o=this.expression.evaluate({zoom:this.zoom},n,r,void 0,i),a=this.expression.evaluate({zoom:this.zoom+1},n,r,void 0,i);this._setPaintValue(e,t,o,a)}_setPaintValue(e,t,n,r){if("color"===this.type){const i=Ts(n),o=Ts(r);for(let n=e;n!0)){this.binders={},this._buffers=[];const r=[];for(const i in e.paint._values){if(!n(i))continue;const o=e.paint.get(i);if(!(o instanceof ha&&Or(o.property.specification)))continue;const a=zs(i,e.type),s=o.value,l=o.property.specification.type,u=!!o.property.useIntegerZoom,c="line-dasharray"===i||i.endsWith("pattern"),h="line-dasharray"===i&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==s.kind||h)if("source"===s.kind||h||c){const t=Rs(i,l,"source");this.binders[i]=c?new As(s,a,l,t,e.id):new Ms(s,a,l,t),r.push("/a_"+i)}else{const e=Rs(i,l,"composite");this.binders[i]=new Cs(s,a,l,u,t,e),r.push("/z_"+i)}else this.binders[i]=c?new ks(s.value,a):new Ss(s.value,a,l),r.push("/u_"+i)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Ms||t instanceof Cs?t.maxValue:0}populatePaintArrays(e,t,n,r,i,o){for(const a in this.binders){const s=this.binders[a];(s instanceof Ms||s instanceof Cs||s instanceof As)&&s.populatePaintArray(e,t,n,r,i,o)}}setConstantPatternPositions(e){for(const t in this.binders){const n=this.binders[t];n instanceof ks&&n.setConstantPatternPositions(e)}}updatePaintArrays(e,t,n,r,i,o){let a=!1;for(const s in e){const l=t.getPositions(s);for(const t of l){const l=n.feature(t.index);for(const n in this.binders){const u=this.binders[n];if((u instanceof Ms||u instanceof Cs||u instanceof As)&&!0===u.expression.isStateDependent){const c=r.paint.get(n);u.expression=c.value,u.updatePaintArray(t.start,t.end,l,e[s],i,o),a=!0}}}}return a}defines(){const e=[];for(const t in this.binders){const n=this.binders[t];(n instanceof Ss||n instanceof ks)&&e.push(...n.uniformNames.map(e=>"#define HAS_UNIFORM_"+e))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const n=this.binders[t];if(n instanceof Ms||n instanceof Cs||n instanceof As)for(let t=0;t!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Is(r,t,n);this.needsUpload=!1,this._featureMap=new ps,this._bufferOffset=0}populatePaintArrays(e,t,n,r,i,o,a){for(const n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r,i,o,a);void 0!==t.id&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r,i){for(const o of n)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,r,i)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const Os={"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","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function zs(e,t){return Os[e]||[e.replace(t+"-","").replace(/-/g,"_")]}const Ls={"line-pattern":{source:Ca,composite:Ca},"fill-pattern":{source:Ca,composite:Ca},"fill-extrusion-pattern":{source:Ca,composite:Ca},"line-dasharray":{source:Aa,composite:Aa}},Ds={color:{source:Wa,composite:Ma},number:{source:Va,composite:Wa}};function Rs(e,t,n){const r=Ls[e];return r&&r[n]||Ds[t][n]}Fi(Ss,"ConstantBinder"),Fi(ks,"PatternConstantBinder"),Fi(Ms,"SourceExpressionBinder"),Fi(As,"PatternCompositeBinder"),Fi(Cs,"CompositeExpressionBinder"),Fi(Is,"ProgramConfiguration",{omit:["_buffers"]}),Fi(Ps,"ProgramConfigurationSet");const Bs="-transition";class Fs extends et{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new ca(t.layout)),t.paint)){this._transitionablePaint=new sa(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new da(t.paint)}}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,n={}){null!=t&&this._validate(Pi,`layers.${this.id}.layout.${e}`,e,t,n)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return N(e,Bs)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,n={}){if(null!=t&&this._validate(Ii,`layers.${this.id}.paint.${e}`,e,t,n))return!1;if(N(e,Bs))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const n=this._transitionablePaint._values[e],r=n.value.isDataDriven(),i=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const o=this._transitionablePaint._values[e].value,a=o.isDataDriven(),s=N(e,"pattern")||"line-dasharray"===e;return a||r||s||this._handleOverridablePaintPropertyUpdate(e,i,o)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,n){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),V(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,n,r,i={}){return(!i||!1!==i.validate)&&zi(this,e.call(Ai,{key:t,layerType:this.type,objectKey:n,value:r,styleSpec:tt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof ha&&Or(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=ii(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const js=ba([{name:"a_pos",components:2,type:"Int16"}],4),Ns=ba([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Us{constructor(e=[]){this.segments=e}prepareSegment(e,t,n,r){let i=this.segments[this.segments.length-1];return e>Us.MAX_VERTEX_ARRAY_LENGTH&&$(`Max vertices per segment is ${Us.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!i||i.vertexLength+e>Us.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r)&&(i={vertexOffset:t.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==r&&(i.sortKey=r),this.segments.push(i)),i}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,n,r){return new Us([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}Us.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Fi(Us,"SegmentVector");var Vs=8192;class Gs{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof yu?new yu(e.lng,e.lat):yu.convert(e),this}setSouthWest(e){return this._sw=e instanceof yu?new yu(e.lng,e.lat):yu.convert(e),this}extend(e){const t=this._sw,n=this._ne;let r,i;if(e instanceof yu)r=e,i=e;else{if(!(e instanceof Gs))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Gs.convert(e)):this.extend(yu.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(yu.convert(e)):this;if(r=e._sw,i=e._ne,!r||!i)return this}return t||n?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),n.lng=Math.max(i.lng,n.lng),n.lat=Math.max(i.lat,n.lat)):(this._sw=new yu(r.lng,r.lat),this._ne=new yu(i.lng,i.lat)),this}getCenter(){return new yu((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 yu(this.getWest(),this.getNorth())}getSouthEast(){return new yu(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(e){const{lng:t,lat:n}=yu.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}static convert(e){return!e||e instanceof Gs?e:new Gs(e)}}var qs=1e-6,$s="undefined"!=typeof Float32Array?Float32Array:Array;function Zs(){var e=new $s(9);return $s!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Ws(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],f=n[1],p=n[2],m=n[3],_=n[4],g=n[5],y=n[6],v=n[7],x=n[8];return e[0]=d*r+f*a+p*u,e[1]=d*i+f*s+p*c,e[2]=d*o+f*l+p*h,e[3]=m*r+_*a+g*u,e[4]=m*i+_*s+g*c,e[5]=m*o+_*l+g*h,e[6]=y*r+v*a+x*u,e[7]=y*i+v*s+x*c,e[8]=y*o+v*l+x*h,e}function Xs(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Hs(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],_=t[14],g=t[15],y=n*s-r*a,v=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,E=i*u-o*l,T=c*m-h*p,S=c*_-d*p,k=c*g-f*p,M=h*_-d*m,C=h*g-f*m,A=d*g-f*_,I=y*A-v*C+x*M+b*k-w*S+E*T;return I?(e[0]=(s*A-l*C+u*M)*(I=1/I),e[1]=(i*C-r*A-o*M)*I,e[2]=(m*E-_*w+g*b)*I,e[3]=(d*w-h*E-f*b)*I,e[4]=(l*k-a*A-u*S)*I,e[5]=(n*A-i*k+o*S)*I,e[6]=(_*x-p*E-g*v)*I,e[7]=(c*E-d*x+f*v)*I,e[8]=(a*C-s*k+u*T)*I,e[9]=(r*k-n*C-o*T)*I,e[10]=(p*w-m*x+g*y)*I,e[11]=(h*x-c*w-f*y)*I,e[12]=(s*S-a*M-l*T)*I,e[13]=(n*M-r*S+i*T)*I,e[14]=(m*v-p*b-_*y)*I,e[15]=(c*b-h*v+d*y)*I,e):null}function Ys(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],m=t[12],_=t[13],g=t[14],y=t[15],v=n[0],x=n[1],b=n[2],w=n[3];return e[0]=v*r+x*s+b*h+w*m,e[1]=v*i+x*l+b*d+w*_,e[2]=v*o+x*u+b*f+w*g,e[3]=v*a+x*c+b*p+w*y,e[4]=(v=n[4])*r+(x=n[5])*s+(b=n[6])*h+(w=n[7])*m,e[5]=v*i+x*l+b*d+w*_,e[6]=v*o+x*u+b*f+w*g,e[7]=v*a+x*c+b*p+w*y,e[8]=(v=n[8])*r+(x=n[9])*s+(b=n[10])*h+(w=n[11])*m,e[9]=v*i+x*l+b*d+w*_,e[10]=v*o+x*u+b*f+w*g,e[11]=v*a+x*c+b*p+w*y,e[12]=(v=n[12])*r+(x=n[13])*s+(b=n[14])*h+(w=n[15])*m,e[13]=v*i+x*l+b*d+w*_,e[14]=v*o+x*u+b*f+w*g,e[15]=v*a+x*c+b*p+w*y,e}function Ks(e,t,n){var r,i,o,a,s,l,u,c,h,d,f,p,m=n[0],_=n[1],g=n[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],e[0]=r=t[0],e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=f,e[11]=p,e[12]=r*m+s*_+h*g+t[12],e[13]=i*m+l*_+d*g+t[13],e[14]=o*m+u*_+f*g+t[14],e[15]=a*m+c*_+p*g+t[15]),e}function Js(e,t,n){var r=n[0],i=n[1],o=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Qs(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*i+u*r,e[5]=a*i+c*r,e[6]=s*i+h*r,e[7]=l*i+d*r,e[8]=u*i-o*r,e[9]=c*i-a*r,e[10]=h*i-s*r,e[11]=d*i-l*r,e}function el(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i-u*r,e[1]=a*i-c*r,e[2]=s*i-h*r,e[3]=l*i-d*r,e[8]=o*r+u*i,e[9]=a*r+c*i,e[10]=s*r+h*i,e[11]=l*r+d*i,e}function tl(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function nl(e,t,n){var r,i,o,a=n[0],s=n[1],l=n[2],u=Math.hypot(a,s,l);return u0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function _l(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function gl(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2];return e[0]=i*l-o*s,e[1]=o*a-r*l,e[2]=r*s-i*a,e}function yl(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/(a=a||1),e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,e}function vl(e,t,n){var r=n[0],i=n[1],o=n[2],a=t[0],s=t[1],l=t[2],u=i*l-o*s,c=o*a-r*l,h=r*s-i*a,d=i*h-o*c,f=o*u-r*h,p=r*c-i*u,m=2*n[3];return c*=m,h*=m,f*=2,p*=2,e[0]=a+(u*=m)+(d*=2),e[1]=s+c+f,e[2]=l+h+p,e}var xl,bl=ul,wl=cl,El=al;function Tl(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function Sl(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=r*a,e[2]=i*a,e[3]=o*a,e}function kl(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,e}function Ml(){var e=new $s(4);return $s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Cl(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Al(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e}function Il(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e}il(),xl=new $s(4),$s!=Float32Array&&(xl[0]=0,xl[1]=0,xl[2]=0,xl[3]=0);var Pl=Sl;il(),sl(1,0,0),sl(0,1,0),Ml(),Ml(),Zs();const Ol=ba([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:zl}=Ol,Ll=ba([{name:"a_pos_3",components:3,type:"Int16"}]);var Dl=ba([{name:"a_pos",type:"Int16",components:2}]);class Rl{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,n){const r=_l(t,this.dir);if(Math.abs(r)<1e-6)return!1;const i=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return n[0]=this.pos[0]+this.dir[0]*i,n[1]=this.pos[1]+this.dir[1]*i,n[2]=this.pos[2]+this.dir[2]*i,!0}closestPointOnSphere(e,t,n){if(function(e,t){var n=e[0],r=e[1],i=e[2],o=t[0],a=t[1],s=t[2];return Math.abs(n-o)<=qs*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=qs*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=qs*Math.max(1,Math.abs(i),Math.abs(s))}(this.pos,e)||0===t)return n[0]=n[1]=n[2]=0,!1;const[r,i,o]=this.dir,a=this.pos[0]-e[0],s=this.pos[1]-e[1],l=this.pos[2]-e[2],u=r*r+i*i+o*o,c=2*(a*r+s*i+l*o),h=c*c-4*u*(a*a+s*s+l*l-t*t);if(h<0){const e=Math.max(-c/2,0),u=a+r*e,h=s+i*e,d=l+o*e,f=Math.hypot(u,h,d);return n[0]=u*t/f,n[1]=h*t/f,n[2]=d*t/f,!1}{const e=(-c-Math.sqrt(h))/(2*u);if(e<0){const e=Math.hypot(a,s,l);return n[0]=a*t/e,n[1]=s*t/e,n[2]=l*t/e,!1}return n[0]=a+r*e,n[1]=s+i*e,n[2]=l+o*e,!0}}}class Bl{constructor(e,t,n,r,i){this.TL=e,this.TR=t,this.BR=n,this.BL=r,this.horizon=i}static fromInvProjectionMatrix(e,t,n){const r=[-1,1,1],i=[1,1,1],o=[1,-1,1],a=[-1,-1,1],s=yl(r,r,e),l=yl(i,i,e),u=yl(o,o,e),c=yl(a,a,e);return new Bl(s,l,u,c,t/n)}}class Fl{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,n,r){const i=Math.pow(2,n),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(n=>{const o=kl([],n,e),a=1/o[3]/t*i;return function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}(o,o,[a,a,r?1/o[3]:a,a])}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=ml([],gl([],bl([],o[e[0]],o[e[1]]),bl([],o[e[2]],o[e[1]]))),n=-_l(t,o[e[1]]);return t.concat(n)});return new Fl(o,a)}}class jl{static fromPoints(e){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const r of e)hl(t,t,r),dl(n,n,r);return new jl(t,n)}static applyTransform(e,t){const n=e.getCorners();for(let e=0;e=0;if(0===o)return 0;o!==t.length&&(n=!1)}if(n)return 2;for(let t=0;t<3;t++){let n=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let i=0;ithis.max[t]-this.min[t])return 0}return 1}}const Nl=Vs/Math.PI/2,Ul=[64,32,16],Vl=-Nl,Gl=Nl,ql=[new jl([Vl,Vl,Vl],[Gl,Gl,Gl]),new jl([Vl,Vl,Vl],[0,0,Gl]),new jl([0,Vl,Vl],[Gl,0,Gl]),new jl([Vl,0,Vl],[0,Gl,Gl]),new jl([0,0,Vl],[Gl,Gl,Gl])];function $l(e){return e*Nl/mu}function Zl(e,t,n,r=!0){const i=fl([],e._camera.position,e.worldSize),o=[t,n,1,1];kl(o,o,e.pixelMatrixInverse),Tl(o,o,1/o[3]);const a=ml([],bl([],o,i)),s=e.globeMatrix,l=[s[12],s[13],s[14]],u=bl([],l,i),c=al(u),h=ml([],u),d=e.worldSize/(2*Math.PI),f=_l(h,a),p=Math.asin(d/c);if(p1?null:function(e,t,n,r){const i=Math.sin(n);return e*(Math.sin((1-r)*n)/i)+t*(Math.sin(r*n)/i)}(e.a[t],e.b[t],e.angle,C(n,0,1))+e.center[t]}function Hl(e){if(e.z<=1)return ql[e.z+2*e.y+e.x];const t=eu(Ql(e));return jl.fromPoints(t)}function Yl(e,t,n){return fl(e,e,1-n),pl(e,e,t,n)}function Kl(e,t){const n=uu(t.zoom);if(0===n)return Hl(e);const r=Ql(e),i=eu(r),o=xu(r.getWest())*t.worldSize,a=xu(r.getEast())*t.worldSize,s=bu(r.getNorth())*t.worldSize,l=bu(r.getSouth())*t.worldSize,u=[o,s,0],c=[a,s,0],h=[o,l,0],d=[a,l,0],f=Hs([],t.globeMatrix);return yl(u,u,f),yl(c,c,f),yl(h,h,f),yl(d,d,f),i[0]=Yl(i[0],h,n),i[1]=Yl(i[1],d,n),i[2]=Yl(i[2],c,n),i[3]=Yl(i[3],u,n),jl.fromPoints(i)}function Jl(e,t,n){for(const r of e)yl(r,r,t),fl(r,r,n)}function Ql({x:e,y:t,z:n}){const r=1/(1<Math.PI/2*1.01}const du=w(85),fu=Math.cos(du),pu=Math.sin(du),mu=6371008.8,_u=2*Math.PI*mu;class gu{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new gu(I(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return mu*Math.acos(Math.min(i,1))}toBounds(e=0){const t=360*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return new Gs(new gu(this.lng-n,this.lat-t),new gu(this.lng+n,this.lat+t))}toEcef(e){const t=$l(e);return nu(this.lat,this.lng,Nl+t)}static convert(e){if(e instanceof gu)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new gu(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new gu(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}var yu=gu;function vu(e){return _u*Math.cos(e*Math.PI/180)}function xu(e){return(180+e)/360}function bu(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function wu(e,t){return e/vu(t)}function Eu(e){return 360*e-180}function Tu(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Su(e,t){return e*vu(Tu(t))}const ku=85.051129;function Mu(e){return 1/Math.cos(e*Math.PI/180)}class Cu{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e,t=0){const n=yu.convert(e);return new Cu(xu(n.lng),bu(n.lat),wu(t,n.lat))}toLngLat(){return new yu(Eu(this.x),Tu(this.y))}toAltitude(){return Su(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/_u*Mu(Tu(this.y))}}function Au(e,t,n,r,i,o,a,s,l){const u=(t+r)/2,c=(n+i)/2,h=new v(u,c);s(h),function(e,t,n,r,i,o){const a=n-i,s=r-o;return Math.abs((r-t)*a-(n-e)*s)/Math.hypot(a,s)}(h.x,h.y,o.x,o.y,a.x,a.y)>=l?(Au(e,t,n,u,c,o,h,s,l),Au(e,u,c,r,i,h,a,s,l)):e.push(a)}function Iu(e,t,n){let r=e[0],i=r.x,o=r.y;t(r);const a=[r];for(let s=1;se.x+1||re.y+1)&&$("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Ru(e,t,n){const r=e.loadGeometry(),i=e.extent,o=Vs/i;if(t&&n&&n.projection.isReprojectedInTileSpace){const o=1<{const n=Eu((t.x+e.x/i)/o),r=Tu((t.y+e.y/i)/o),c=u.project(n,r);e.x=(c.x*a-s)*i,e.y=(c.y*a-l)*i};for(let t=0;t=i||n.y<0||n.y>=i||(c(n),e.push(n));r[t]=e}}for(const e of r)for(const t of e)Du(t,o);return r}function Bu(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Ru(e):[]}}function Fu(e,t,n,r,i){e.emplaceBack(2*t+(r+1)/2,2*n+(i+1)/2)}function ju(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class Nu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Ea,this.indexArray=new ja,this.segments=new Us,this.programConfigurations=new Ps(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){const i=this.layers[0],o=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:t,id:i,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Bu(t,e);if(!this.layers[0]._featureFilter.filter(new ia(this.zoom),u,n))continue;const c=a?a.evaluate(u,{},n):void 0,h={id:i,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?u.geometry:Ru(t,n,r),patterns:{},sortKey:c};o.push(h)}a&&o.sort((e,t)=>e.sortKey-t.sortKey);let s=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Ia,s=r.projection);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:a}=r,l=e[o].feature;this.addFeature(r,i,o,t.availableImages,n,s),t.featureIndex.insert(l,i,o,a,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,js.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Ns.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,n,r,i,o){for(const n of t)for(const t of n){const n=t.x,r=t.y;if(n<0||n>=Vs||r<0||r>=Vs)continue;if(o){const e=o.projectTilePoint(n,r,i),t=o.upVector(i,n,r),a=this.globeExtVertexArray;ju(a,e,t),ju(a,e,t),ju(a,e,t),ju(a,e,t)}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;Fu(this.layoutVertexArray,n,r,-1,-1),Fu(this.layoutVertexArray,n,r,1,-1),Fu(this.layoutVertexArray,n,r,1,1),Fu(this.layoutVertexArray,n,r,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+2,s+3),a.vertexLength+=4,a.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},r,i)}}function Uu(e,t){for(let n=0;n1){if($u(e,t))return!0;for(let r=0;r1?n:n.sub(t)._mult(i)._add(t))}function Hu(e,t){let n,r,i,o=!1;for(let a=0;at.y!=i.y>t.y&&t.x<(i.x-r.x)*(t.y-r.y)/(i.y-r.y)+r.x&&(o=!o)}return o}function Yu(e,t){let n=!1;for(let r=0,i=e.length-1;rt.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}function Ku(e,t,n,r,i){for(const o of e)if(t<=o.x&&n<=o.y&&r>=o.x&&i>=o.y)return!0;const o=[new v(t,n),new v(t,i),new v(r,i),new v(r,n)];if(e.length>2)for(const t of o)if(Yu(e,t))return!0;for(let t=0;ti.x&&t.x>i.x||e.yi.y&&t.y>i.y)return!1;const o=Z(e,t,n[0]);return o!==Z(e,t,n[1])||o!==Z(e,t,n[2])||o!==Z(e,t,n[3])}function Qu(e,t,n){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function ec(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function tc(e,t,n,r,i){if(!t[0]&&!t[1])return e;const o=v.convert(t)._mult(i);"viewport"===n&&o._rotate(-r);const a=[];for(let t=0;t0){const e=n.projection.upVector(u,h.x,h.y);f.x+=e[0]*c*d,f.y+=e[1]*c*d,f.z+=e[2]*c*d}const p=o?h:ac(f.x,f.y,f.z,r),m=o?e.tilespaceRays.map(e=>uc(e,d)):e.queryGeometry.screenGeometry,_=kl([],[f.x,f.y,f.z,1],r);if(!a&&o?l*=_[3]/n.cameraToCenterDistance:a&&!o&&(l*=n.cameraToCenterDistance/_[3]),o){const e=Tu((t.y/Vs+u.y)/(1<e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=e.data,s=t.data;for(let l=0;l{t[e.evaluationKey]=o;const a=e.expression.evaluate(t);i.data[n+r+0]=Math.floor(255*a.r/a.a),i.data[n+r+1]=Math.floor(255*a.g/a.a),i.data[n+r+2]=Math.floor(255*a.b/a.a),i.data[n+r+3]=Math.floor(255*a.a)};if(e.clips)for(let t=0,i=0;t80*n){r=o=e[0],i=a=e[1];for(var p=n;po&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-r,a-i))?32767/u:0}return Sc(d,f,n,r,i,u,0),f}function Ec(e,t,n,r,i){var o,a;if(i===Wc(e,t,n,r)>0)for(o=t;o=t;o-=r)a=qc(o,e[o],e[o+1],a);return a&&Fc(a,a.next)&&($c(a),a=a.next),a}function Tc(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!Fc(r,r.next)&&0!==Bc(r.prev,r,r.next))r=r.next;else{if($c(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function Sc(e,t,n,r,i,o,a){if(e){!a&&o&&function(e,t,n,r){var i=e;do{0===i.z&&(i.z=zc(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,a,s,l,u=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?Mc(e,r,i,o):kc(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),$c(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?Sc(e=Cc(Tc(e),t,n),t,n,r,i,o,2):2===a&&Ac(e,t,n,r,i,o):Sc(Tc(e),t,n,r,i,o,1);break}}}function kc(e){var t=e.prev,n=e,r=e.next;if(Bc(t,n,r)>=0)return!1;for(var i=t.x,o=n.x,a=r.x,s=t.y,l=n.y,u=r.y,c=io?i>a?i:a:o>a?o:a,f=s>l?s>u?s:u:l>u?l:u,p=r.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&Dc(i,s,o,l,a,u,p.x,p.y)&&Bc(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Mc(e,t,n,r){var i=e.prev,o=e,a=e.next;if(Bc(i,o,a)>=0)return!1;for(var s=i.x,l=o.x,u=a.x,c=i.y,h=o.y,d=a.y,f=sl?s>u?s:u:l>u?l:u,_=c>h?c>d?c:d:h>d?h:d,g=zc(f,p,t,n,r),y=zc(m,_,t,n,r),v=e.prevZ,x=e.nextZ;v&&v.z>=g&&x&&x.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==i&&v!==a&&Dc(s,c,l,h,u,d,v.x,v.y)&&Bc(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==i&&x!==a&&Dc(s,c,l,h,u,d,x.x,x.y)&&Bc(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==i&&v!==a&&Dc(s,c,l,h,u,d,v.x,v.y)&&Bc(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==i&&x!==a&&Dc(s,c,l,h,u,d,x.x,x.y)&&Bc(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Cc(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!Fc(i,o)&&jc(i,r,r.next,o)&&Vc(i,o)&&Vc(o,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),$c(r),$c(r.next),r=e=o),r=r.next}while(r!==e);return Tc(r)}function Ac(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Rc(a,s)){var l=Gc(a,s);return a=Tc(a,a.next),l=Tc(l,l.next),Sc(a,t,n,r,i,o,0),void Sc(l,t,n,r,i,o,0)}s=s.next}a=a.next}while(a!==e)}function Ic(e,t){return e.x-t.x}function Pc(e,t){var n=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a&&(a=s,n=r.x=r.x&&r.x>=c&&i!==r.x&&Dc(on.x||r.x===n.x&&Oc(n,r)))&&(n=r,d=l)),r=r.next}while(r!==u);return n}(e,t);if(!n)return t;var r=Gc(n,e);return Tc(r,r.next),Tc(n,n.next)}function Oc(e,t){return Bc(e.prev,e,t.prev)<0&&Bc(t.next,e,e.next)<0}function zc(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Lc(e){var t=e,n=e;do{(t.x=(e-a)*(o-s)&&(e-a)*(r-s)>=(n-a)*(t-s)&&(n-a)*(o-s)>=(i-a)*(r-s)}function Rc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&jc(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Vc(e,t)&&Vc(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Bc(e.prev,e,t.prev)||Bc(e,t.prev,t))||Fc(e,t)&&Bc(e.prev,e,e.next)>0&&Bc(t.prev,t,t.next)>0)}function Bc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Fc(e,t){return e.x===t.x&&e.y===t.y}function jc(e,t,n,r){var i=Uc(Bc(e,t,n)),o=Uc(Bc(e,t,r)),a=Uc(Bc(n,r,e)),s=Uc(Bc(n,r,t));return i!==o&&a!==s||!(0!==i||!Nc(e,n,t))||!(0!==o||!Nc(e,r,t))||!(0!==a||!Nc(n,e,r))||!(0!==s||!Nc(n,t,r))}function Nc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Uc(e){return e>0?1:e<0?-1:0}function Vc(e,t){return Bc(e.prev,e,e.next)<0?Bc(e,t,e.next)>=0&&Bc(e,e.prev,t)>=0:Bc(e,t,e.prev)<0||Bc(e,e.next,t)<0}function Gc(e,t){var n=new Zc(e.i,e.x,e.y),r=new Zc(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function qc(e,t,n,r){var i=new Zc(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function $c(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Zc(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Wc(e,t,n,r){for(var i=0,o=t,a=n-r;o0&&n.holes.push(r+=e[i-1].length)}return n};var Xc=f(bc.exports);function Hc(e,t,n,r,i){!function e(t,n,r,i,o){for(;i>r;){if(i-r>600){var a=i-r+1,s=n-r+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(s-a/2<0?-1:1);e(t,n,Math.max(r,Math.floor(n-s*u/a+c)),Math.min(i,Math.floor(n+(a-s)*u/a+c)),o)}var h=t[n],d=r,f=i;for(Yc(t,r,n),o(t[i],h)>0&&Yc(t,r,i);d0;)f--}0===o(t[r],h)?Yc(t,r,f):Yc(t,++f,i),f<=n&&(r=f+1),n<=f&&(i=f-1)}}(e,t,n||0,r||e.length-1,i||Kc)}function Yc(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Kc(e,t){return et?1:0}function Jc(e,t){const n=e.length;if(n<=1)return[e];const r=[];let i,o;for(let t=0;t1)for(let e=0;ee.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ea,this.indexArray=new ja,this.indexArray2=new $a,this.programConfigurations=new Ps(e.layers,e.zoom),this.segments=new Us,this.segments2=new Us,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection}populate(e,t,n,r){this.hasPattern=eh("fill",this.layers,t);const i=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:a,id:s,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Bu(a,e);if(!this.layers[0]._featureFilter.filter(new ia(this.zoom),c,n))continue;const h=i?i.evaluate(c,{},n,t.availableImages):void 0,d={id:s,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Ru(a,n,r),patterns:{},sortKey:h};o.push(d)}i&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:a}=r;if(this.hasPattern){const e=th("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,{},t.availableImages);t.featureIndex.insert(e[o].feature,i,o,a,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}addFeatures(e,t,n,r,i){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xc),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,n,r,i,o=[]){for(const e of Jc(t,500)){let t=0;for(const n of e)t+=n.length;const n=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=n.vertexLength,i=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(i.length/2);const n=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=n.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),i.push(t[0].x),i.push(t[0].y);for(let e=1;e>3}if(i--,1===r||2===r)o+=e.readSVarint(),a+=e.readSVarint(),1===r&&(t&&s.push(t),t=[]),t.push(new ch(o,a));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&s.push(t),s},dh.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,n=1,r=0,i=0,o=0,a=1/0,s=-1/0,l=1/0,u=-1/0;e.pos>3}if(r--,1===n||2===n)(i+=e.readSVarint())s&&(s=i),(o+=e.readSVarint())u&&(u=o);else if(7!==n)throw new Error("unknown command "+n)}return[a,l,s,u]},dh.prototype.toGeoJSON=function(e,t,n){var r,i,o=this.extent*Math.pow(2,n),a=this.extent*e,s=this.extent*t,l=this.loadGeometry(),u=dh.types[this.type];function c(e){for(var t=0;t>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(n))}gh.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new mh(this._pbf,t,this.extent,this._keys,this._values)};var vh=_h;function xh(e,t,n){if(3===e){var r=new vh(n,n.readVarint()+n.pos);r.length&&(t[r.name]=r)}}var bh=uh.VectorTile=function(e,t){this.layers=e.readFields(xh,{},t)},wh=uh.VectorTileFeature=hh;function Eh(e,t,n,r){const i=[],o=0===r?(e,t,n,r,i,o)=>{e.push(new v(o,n+(o-t)/(r-t)*(i-n)))}:(e,t,n,r,i,o)=>{e.push(new v(t+(o-n)/(i-n)*(r-t),o))};for(const a of e){const e=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let e=0;et&&o(a,s,l,u,c,t):h>n?d=t&&o(a,s,l,u,c,t),d>n&&h<=n&&o(a,s,l,u,c,n)}let s=i[i.length-1];const l=0===r?s.x:s.y;l>=t&&l<=n&&a.push(s),a.length&&(s=a[a.length-1],a[0].x===s.x&&a[0].y===s.y||a.push(a[0]),e.push(a))}e.length&&i.push(e)}return i}uh.VectorTileLayer=_h;const Th=wh.types,Sh=Math.pow(2,13);function kh(e,t,n,r,i,o,a,s){e.emplaceBack((t<<1)+a,(n<<1)+o,(Math.floor(r*Sh)<<1)+i,Math.round(s))}function Mh(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class Ch{constructor(){this.acc=new v(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new v(e.x,e.y),this.max=new v(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const n=this.min,r=this.max;e.xr.x&&(r.x=e.x),e.yr.y&&(r.y=e.y),((0===e.x||e.x===Vs)&&e.x===t.x)!=((0===e.y||e.y===Vs)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,On(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Vs!=e.x>Vs&&this.addBorderIntersection(1,On(t.y,e.y,(Vs-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,On(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Vs!=e.y>Vs&&this.addBorderIntersection(3,On(t.x,e.x,(Vs-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){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 n=this.borders[e];tn[1]&&(n[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const n=0===e.x?0:1;this.addBorderIntersection(n,t.y),this.addBorderIntersection(n,e.y)}else{const n=0===e.y?2:3;this.addBorderIntersection(n,t.x),this.addBorderIntersection(n,e.x)}}centroid(){const e=this.polyCount.reduce((e,t)=>e+t.edges,0);return 0!==e?this.acc.div(e)._round():new v(0,0)}span(){return new v(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0)}}class Ah{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new Sa,this.centroidVertexArray=new is,this.indexArray=new ja,this.programConfigurations=new Ps(e.layers,e.zoom),this.segments=new Us,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.enableTerrain=e.enableTerrain}populate(e,t,n,r){this.features=[],this.hasPattern=eh("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<=0;e--){const t=d[e];(0===t.length||(f=t[0]).every(e=>e.x<=0)||f.every(e=>e.x>=Vs)||f.every(e=>e.y<=0)||f.every(e=>e.y>=Vs))&&d.splice(e,1)}var f;let p;if(u)p=Bh(d,s,r);else{p=[];for(const e of d)p.push({polygon:e,bounds:s})}const m=h?this.edgeRadius:0;for(const{polygon:e,bounds:t}of p){let n=0,i=0;for(const t of e)h&&!t[0].equals(t[t.length-1])&&t.push(t[0]),i+=h?t.length-1:t.length;const o=this.segments.prepareSegment((h?5:4)*i,this.layoutVertexArray,this.indexArray);if(h){const t=[],i=[];n=o.vertexLength;for(const n of e){let a,s;n.length&&n!==e[0]&&i.push(t.length/2),a=n[1].sub(n[0])._perp()._unit();for(let e=1;e4&&Lh(i[i.length-2],i[0],i[1]),f=m?Ph(i[i.length-2],i[0],i[1],m):0;a=i[1].sub(i[0])._perp()._unit();let p=!0;for(let _=1,g=0;_0?1:0,T=y.dist(v);if(g+T>32768&&(g=0),m){s=x.sub(v)._perp()._unit();let e=Oh(y,v,x,Ih(a,s),m);isNaN(e)&&(e=0);const t=v.sub(y)._unit();y=y.add(t.mult(f))._round(),v=v.add(t.mult(-e))._round(),f=e,a=s}const S=o.vertexLength,k=i.length>4&&Lh(y,v,x);let M=Dh(g,d,p);if(kh(this.layoutVertexArray,y.x,y.y,w,E,0,0,M),kh(this.layoutVertexArray,y.x,y.y,w,E,0,1,M),g+=T,M=Dh(g,k,!p),d=k,kh(this.layoutVertexArray,v.x,v.y,w,E,0,0,M),kh(this.layoutVertexArray,v.x,v.y,w,E,0,1,M),o.vertexLength+=4,this.indexArray.emplaceBack(S+0,S+1,S+2),this.indexArray.emplaceBack(S+1,S+3,S+2),o.primitiveLength+=2,m){const r=n+(1===_?i.length-2:_-2),a=1===_?n:r+1;if(this.indexArray.emplaceBack(S+1,r,S+3),this.indexArray.emplaceBack(r,a,S+3),o.primitiveLength+=2,void 0===e&&(e=S),!zh(x,i[_],t)){const t=_===i.length-1?e:o.vertexLength;this.indexArray.emplaceBack(S+2,S+3,t),this.indexArray.emplaceBack(S+3,t+1,t),this.indexArray.emplaceBack(S+3,a,t+1),o.primitiveLength+=3}p=!p}if(u){const e=this.layoutVertexExtArray,t=l.projectTilePoint(y.x,y.y,r),n=l.projectTilePoint(v.x,v.y,r),i=l.upVector(r,y.x,y.y),o=l.upVector(r,v.x,v.y);Mh(e,t,i),Mh(e,t,i),Mh(e,n,o),Mh(e,n,o)}}h&&(n+=i.length-1)}}if(c&&c.polyCount.length>0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const e=c.borders,t=this.featuresOnBorder.push(c)-1;for(let n=0;n<4;n++)e[n][0]!==Number.MAX_VALUE&&this.borders[n].push(t)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((t,n)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}encodeCentroid(e,t,n=!0){let r,i;if(e)if(0!==e.y){const n=t.span()._mult(this.tileToMeter);r=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(n.x/10)),i=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(n.y/10))}else r=Math.ceil(7*(e.x+450)),i=0;else r=0,i=+n;let o=n?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;tn[1].x&&t.x>n[1].x||e.yn[1].y&&t.y>n[1].y}function Lh(e,t,n){if(e.x<0||e.x>=Vs||t.x<0||t.x>=Vs||n.x<0||n.x>=Vs)return!1;const r=n.sub(t),i=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&i.x*o.x+i.y*o.y<0}function Dh(e,t,n){const r=t?2|e:-3&e;return n?1|r:-2&r}function Rh(){const e=Math.PI/32,t=Math.tan(e),n=mu;return n*Math.sqrt(1+2*t*t)-n}function Bh(e,t,n){const r=1<{for(const n of e)a.push({polygon:n,bounds:t})},l=Math.ceil(Math.log2(n)),u=Math.ceil(Math.log2(r)),c=l-u,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?f.push({polygons:d,bounds:e,depth:t+1}):s(d,e)}if(p.length){const e=[new v(0===n?c:r.x,1===n?c:r.y),a];h.length>t+1?f.push({polygons:p,bounds:e,depth:t+1}):s(p,e)}}return a}(e,t,Math.ceil((o-i)/11.25),Math.ceil((a-s)/11.25),1,(e,t,i)=>{if(0===e)return.5*(t+i);{const e=Tu((n.y+t/Vs)/r);return(bu(.5*(Tu((n.y+i/Vs)/r)+e))*r-n.y)*Vs}})}Fi(Ah,"FillExtrusionBucket",{omit:["layers","features"]}),Fi(Ch,"PartMetadata");const Fh=new _a({"fill-extrusion-edge-radius":new fa(tt["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var jh={paint:new _a({"fill-extrusion-opacity":new fa(tt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new pa(tt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new fa(tt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new fa(tt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new pa(tt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new pa(tt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new pa(tt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new fa(tt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new fa(tt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new fa(tt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new fa(tt["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:Fh};function Nh(e,t,n){var r=2*Math.PI*6378137/256/Math.pow(2,n);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Uh{constructor(e,t,n){this.z=e,this.x=t,this.y=n,this.key=qh(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const n=function(e,t,n){var r=Nh(256*e,256*(t=Math.pow(2,n)-t-1),n),i=Nh(256*(e+1),256*(t+1),n);return r[0]+","+r[1]+","+i[0]+","+i[1]}(this.x,this.y,this.z),r=function(e,t,n){let r,i="";for(let o=e;o>0;o--)r=1<this.canonical.z?new Gh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Gh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return qh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return qh(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Gh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new Gh(t,this.wrap,t,n,r),new Gh(t,this.wrap,t,n+1,r),new Gh(t,this.wrap,t,n,r+1),new Gh(t,this.wrap,t,n+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new ka,this.layoutVertexArray2=new Ma,this.indexArray=new ja,this.programConfigurations=new Ps(e.layers,e.zoom),this.segments=new Us,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){this.hasPattern=eh("line",this.layers,t);const i=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:a,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Bu(t,e);if(!this.layers[0]._featureFilter.filter(new ia(this.zoom),u,n))continue;const c=i?i.evaluate(u,{},n):void 0,h={id:a,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?u.geometry:Ru(t,n,r),patterns:{},sortKey:c};o.push(h)}i&&o.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:a,featureIndex:s}=t,l=this.addConstantDashes(a);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:u}=r;if(l&&this.addFeatureDashes(r,a),this.hasPattern){const e=th("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,a.positions,t.availableImages);s.insert(e[o].feature,i,o,u,this.index)}}addConstantDashes(e){let t=!1;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,i=n.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==i.kind)t=!0;else{const t=i.value,n=r.value;if(!n)continue;e.addDash(n,t)}}return t}addFeatureDashes(e,t){const n=this.zoom;for(const r of this.layers){const i=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===o.kind)continue;let a,s;if("constant"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:n},e);s="constant"===o.kind?o.value:o.evaluate({zoom:n},e),t.addDash(a,s),e.patterns[r.id]=t.getKey(a,s)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}addFeatures(e,t,n,r,i){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Jh)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yh),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,n,r,i,o){const a=this.layers[0].layout,s=a.get("line-join").evaluate(e,{}),l=a.get("line-cap").evaluate(e,{}),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const n of t)this.addLine(n,e,s,l,u,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r)}addLine(e,t,n,r,i,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[s-1].equals(e[s-2]);)s--;let l=0;for(;l0;if(b&&t>l){const e=h.dist(d);if(e>2*u){const t=h.sub(h.sub(d)._mult(u/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,p,0,0,c),d=t}}const E=d&&f;let T=E?n:a?"butt":r;if(E&&"round"===T&&(vi&&(T="bevel"),"bevel"===T&&(v>2&&(T="flipbevel"),v100)_=m.mult(-1);else{const e=v*p.add(m).mag()/p.sub(m).mag();_._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(h,_,0,0,c),this.addCurrentVertex(h,_.mult(-1),0,0,c)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(v*v-1),t=w?e:0,n=w?0:e;if(d&&this.addCurrentVertex(h,p,t,n,c),"fakeround"===T){const e=Math.round(180*x/Math.PI/20);for(let t=1;t2*u){const t=h.add(f.sub(h)._mult(u/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,c),h=t}}}}addCurrentVertex(e,t,n,r,i,o=!1){const a=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*n,t.y-t.x*n,o,!1,n,i),this.addHalfVertex(e,a,s,o,!0,-r,i)}addHalfVertex({x:e,y:t},n,r,i,o,a,s){this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(t<<1)+(o?1:0),Math.round(63*n)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),s.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}Fi(td,"LineBucket",{omit:["layers","patternFeatures"]});const nd=new _a({"line-cap":new pa(tt.layout_line["line-cap"]),"line-join":new pa(tt.layout_line["line-join"]),"line-miter-limit":new fa(tt.layout_line["line-miter-limit"]),"line-round-limit":new fa(tt.layout_line["line-round-limit"]),"line-sort-key":new pa(tt.layout_line["line-sort-key"])});var rd={paint:new _a({"line-opacity":new pa(tt.paint_line["line-opacity"]),"line-color":new pa(tt.paint_line["line-color"]),"line-translate":new fa(tt.paint_line["line-translate"]),"line-translate-anchor":new fa(tt.paint_line["line-translate-anchor"]),"line-width":new pa(tt.paint_line["line-width"]),"line-gap-width":new pa(tt.paint_line["line-gap-width"]),"line-offset":new pa(tt.paint_line["line-offset"]),"line-blur":new pa(tt.paint_line["line-blur"]),"line-dasharray":new pa(tt.paint_line["line-dasharray"]),"line-pattern":new pa(tt.paint_line["line-pattern"]),"line-gradient":new ma(tt.paint_line["line-gradient"]),"line-trim-offset":new fa(tt.paint_line["line-trim-offset"])}),layout:nd};const id=new class extends pa{possiblyEvaluate(e,t){return t=new ia(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=z({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,r)}}(rd.paint.properties["line-width"].specification);function od(e,t){return t>0?t+2*e:e}id.useIntegerZoom=!0;const ad=ba([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),sd=ba([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),ld=ba([{name:"a_projected_pos",components:4,type:"Float32"}],4);ba([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const ud=ba([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),cd=ba([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);ba([{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 hd=ba([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),dd=ba([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ba([{name:"triangle",components:3,type:"Uint16"}]),ba([{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"}]),ba([{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"}]),ba([{type:"Float32",name:"offsetX"}]),ba([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const fd=128;function pd(e,t){const{expression:n}=t;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new ia(e+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=n;let i=0;for(;i{e.text=function(e,t,n){const r=t.layout.get("text-transform").evaluate(n,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),ra.applyArabicShaping&&(e=ra.applyArabicShaping(e)),e}(e.text,t,n)}),e}const vd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function xd(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function bd(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var wd=Sd,Ed=function(e,t,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,c=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-c)-1,f>>=-c,c+=s;c>0;o=256*o+e[t+h],h+=d,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+e[t+h],h+=d,c-=8);if(0===o)o=1-u;else{if(o===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,r),o-=u}return(f?-1:1)*a*Math.pow(2,o-r)},Td=function(e,t,n,r,i,o){var a,s,l,u=8*o-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(s=0,a=c):a+h>=1?(s=(t*l-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[n+f]=255&s,f+=p,s/=256,i-=8);for(a=a<0;e[n+f]=255&a,f+=p,a/=256,u-=8);e[n+f-p]|=128*m}; -/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function Sd(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}Sd.Varint=0,Sd.Fixed64=1,Sd.Bytes=2,Sd.Fixed32=5;var kd=4294967296,Md=1/kd,Cd="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Ad(e){return e.type===Sd.Bytes?e.readVarint()+e.pos:e.pos+1}function Id(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Pd(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function Od(e,t){for(var n=0;n>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Gd(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}Sd.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos>3,o=this.pos;this.type=7&r,e(i,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Ud(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Gd(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Ud(this.buf,this.pos)+Ud(this.buf,this.pos+4)*kd;return this.pos+=8,e},readSFixed64:function(){var e=Ud(this.buf,this.pos)+Gd(this.buf,this.pos+4)*kd;return this.pos+=8,e},readFloat:function(){var e=Ed(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Ed(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,n,r=this.buf;return t=127&(n=r[this.pos++]),n<128?t:(t|=(127&(n=r[this.pos++]))<<7,n<128?t:(t|=(127&(n=r[this.pos++]))<<14,n<128?t:(t|=(127&(n=r[this.pos++]))<<21,n<128?t:function(e,t,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return Id(e,r,t);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return Id(e,r,t);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return Id(e,r,t);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return Id(e,r,t);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return Id(e,r,t);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return Id(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(n=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Cd?function(e,t,n){return Cd.decode(e.subarray(t,n))}(this.buf,t,e):function(e,t,n){for(var r="",i=t;i239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(o=e[i+1]))&&(u=(31&l)<<6|63&o)<=127&&(u=null):3===c?(a=e[i+2],128==(192&(o=e[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&o)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=e[i+2],s=e[i+3],128==(192&(o=e[i+1]))&&128==(192&a)&&128==(192&s)&&((u=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==Sd.Bytes)return e.push(this.readVarint(t));var n=Ad(this);for(e=e||[];this.pos127;);else if(t===Sd.Bytes)this.pos=this.readVarint()+this.pos;else if(t===Sd.Fixed32)this.pos+=4;else{if(t!==Sd.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t268435455||e<0?function(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,n.buf[n.pos]=127&(e>>>=7)}(n,0,t),function(e,t){var n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var r,i,o=0;o55295&&r<57344){if(!i){r>56319||o+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&Pd(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),Td(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Td(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n=128&&Pd(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,Sd.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,Od,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,zd,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Rd,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Ld,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Dd,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Bd,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Fd,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,jd,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Nd,t)},writeBytesField:function(e,t){this.writeTag(e,Sd.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,Sd.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,Sd.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,Sd.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,Sd.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,Sd.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,Sd.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,Sd.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,Sd.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,Sd.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var qd=f(wd);function $d(e,t,n){t.glyphs=[],1===e&&n.readMessage(Zd,t)}function Zd(e,t,n){if(3===e){const{id:e,bitmap:r,width:i,height:o,left:a,top:s,advance:l}=n.readMessage(Wd,{});t.glyphs.push({id:e,bitmap:new pc({width:i+6,height:o+6},r),metrics:{width:i,height:o,left:a,top:s,advance:l}})}else 4===e?t.ascender=n.readSVarint():5===e&&(t.descender=n.readSVarint())}function Wd(e,t,n){1===e?t.id=n.readVarint():2===e?t.bitmap=n.readBytes():3===e?t.width=n.readVarint():4===e?t.height=n.readVarint():5===e?t.left=n.readSVarint():6===e?t.top=n.readSVarint():7===e&&(t.advance=n.readVarint())}function Xd(e){let t=0,n=0;for(const r of e)t+=r.w*r.h,n=Math.max(n,r.w);e.sort((e,t)=>t.h-e.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}];let i=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const n=r[e];if(!(t.w>n.w||t.h>n.h)){if(t.x=n.x,t.y=n.y,o=Math.max(o,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===n.w&&t.h===n.h){const t=r.pop();ee.hasImage(t)),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),t),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),t)}patchUpdatedImage(e,t,n){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,i]=e.tl;n.update(t.data,void 0,{x:r,y:i})}}Fi(Hd,"ImagePosition"),Fi(Yd,"ImageAtlas");const Kd={horizontal:1,vertical:2,horizontalOnly:3};class Jd{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const n=new Jd;return n.scale=e||1,n.fontStack=t,n}static forImage(e){const t=new Jd;return t.imageName=e,t}}class Qd{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const n=new Qd;for(let r=0;r=0&&n>=e&&tf[this.text.charCodeAt(n)];n--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const n=new Qd;return n.text=this.text.substring(e,t),n.sectionIndex=this.sectionIndex.slice(e,t),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Jd.forText(e.scale,e.fontStack||t));const n=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ef(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=Qd.fromFeature(e,i);h===Kd.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(e,t,n,r,i,o){if(!e)return[];const a=[],s=function(e,t,n,r,i,o){let a=0;for(let n=0;n=0;let u=0;for(let n=0;n0&&o>b&&(b=o)}else{const e=n[s.fontStack];if(!e)continue;e[m]&&(T=e[m]);const r=t[s.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(v=o.metrics,k=8203!==m?24:0,_){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,n=(e+t)*g;w-n/2;){if(a--,a<0)return!1;s-=e[a].dist(o),o=e[a]}s+=e[a].dist(e[a+1]),a++;const l=[];let u=0;for(;sr;)u-=l.shift().angleDelta;if(u>i)return!1;a++,s+=t.dist(n)}return!0}function pf(e){let t=0;for(let n=0;nu){const c=(u-l)/o,h=On(r.x,i.x,c),d=On(r.y,i.y,c),f=new df(h,d,0,i.angleTo(r),n);return!a||ff(e,f,s,a,t)?f:void 0}l+=o}}function yf(e,t,n,r,i,o,a,s,l){const u=mf(r,o,a),c=_f(r,i),h=c*a,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&g=0&&y=0&&f+c<=h){const n=new df(g,y,0,m,e);n._round(),i&&!ff(t,n,a,i,o)||p.push(n)}}d+=l}return l||p.length||s||(p=e(t,d/2,r,i,o,a,s,!0,u)),p}(e,d?t/2*s%t:(c/2+2*o)*a*s%t,t,u,n,h,d,!1,l)}function vf(e,t,n,r,i){const o=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new v(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new v(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=i&&u.y>=i||(a.y>=i?a=new v(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round():u.y>=i&&(u=new v(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round()),l&&a.equals(l[l.length-1])||(l=[a],o.push(l)),l.push(u)))))}}return o}Fi(df,"Anchor");const xf=1e20;function bf(e,t,n,r,i,o,a,s,l){for(let u=t;u-1);l++,o[l]=s,a[l]=u,a[l+1]=xf}for(let s=0,l=0;s{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let i=r.glyphs[t];if(void 0!==i)return void n(null,{stack:e,id:t,glyph:i});if(i=this._tinySDF(r,e,t),i)return r.glyphs[t]=i,void n(null,{stack:e,id:t,glyph:i});const o=Math.floor(t/256);if(256*o>65535)return void n(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void n(null,{stack:e,id:t,glyph:i});let a=r.requests[o];a||(a=r.requests[o]=[],Tf.loadGlyphRange(e,o,this.url,this.requestManager,(e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[o]=!0}for(const n of a)n(e,t);delete r.requests[o]})),a.push((r,i)=>{r?n(r):i&&n(null,{stack:e,id:t,glyph:i.glyphs[t]||null})})},(e,n)=>{if(e)t(e);else if(n){const e={};for(const{stack:t,id:r,glyph:i}of n)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[r]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Ef.none&&(this.localGlyphMode===Ef.all?!!this.localFontFamily:!!this.localFontFamily&&(To(e)||Co(e)||ho(e)||fo(e)||co(e)))}_tinySDF(e,t,n){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(n))return;let i=e.tinySDF;if(!i){let n="400";/bold/i.test(t)?n="900":/medium/i.test(t)?n="500":/light/i.test(t)&&(n="200"),i=e.tinySDF=new Tf.TinySDF({fontFamily:r,fontWeight:n,fontSize:48,buffer:6,radius:16}),i.fontWeight=n}if(this.localGlyphs[i.fontWeight][n])return this.localGlyphs[i.fontWeight][n];const o=String.fromCharCode(n),{data:a,width:s,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:d,glyphAdvance:f}=i.draw(o);return this.localGlyphs[i.fontWeight][n]={id:n,bitmap:new pc({width:s,height:l},a),metrics:{width:u/2,height:c/2,left:h/2,top:d/2-27,advance:f/2,localGlyph:!0}}}}function Sf(e,t,n,r){const i=[],o=e.image,a=o.pixelRatio,s=o.paddedRect.w-2,l=o.paddedRect.h-2,u=e.right-e.left,c=e.bottom-e.top,h=o.stretchX||[[0,s]],d=o.stretchY||[[0,l]],f=(e,t)=>e+t[1]-t[0],p=h.reduce(f,0),m=d.reduce(f,0),_=s-p,g=l-m;let y=0,x=p,b=0,w=m,E=0,T=_,S=0,k=g;if(o.content&&r){const e=o.content;y=kf(h,0,e[0]),b=kf(d,0,e[1]),x=kf(h,e[0],e[2]),w=kf(d,e[1],e[3]),E=e[0]-y,S=e[1]-b,T=e[2]-e[0]-x,k=e[3]-e[1]-w}const M=(r,i,s,l)=>{const h=Cf(r.stretch-y,x,u,e.left),d=Af(r.fixed-E,T,r.stretch,p),f=Cf(i.stretch-b,w,c,e.top),_=Af(i.fixed-S,k,i.stretch,m),g=Cf(s.stretch-y,x,u,e.left),M=Af(s.fixed-E,T,s.stretch,p),C=Cf(l.stretch-b,w,c,e.top),A=Af(l.fixed-S,k,l.stretch,m),I=new v(h,f),P=new v(g,f),O=new v(g,C),z=new v(h,C),L=new v(d/a,_/a),D=new v(M/a,A/a),R=t*Math.PI/180;if(R){const e=Math.sin(R),t=Math.cos(R),n=[t,-e,e,t];I._matMult(n),P._matMult(n),z._matMult(n),O._matMult(n)}const B=r.stretch+r.fixed,F=i.stretch+i.fixed;return{tl:I,tr:P,bl:z,br:O,tex:{x:o.paddedRect.x+1+B,y:o.paddedRect.y+1+F,w:s.stretch+s.fixed-B,h:l.stretch+l.fixed-F},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:D,minFontScaleX:T/a/u,minFontScaleY:k/a/c,isSDF:n}};if(r&&(o.stretchX||o.stretchY)){const e=Mf(h,_,p),t=Mf(d,g,m);for(let n=0;n{if(e)i(e);else if(t){const e={},n=function(e){return new qd(e).readFields($d,{})}(t);for(const t of n.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:n.ascender,descender:n.descender})}})},Tf.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=n;const s=this.size=e+4*t,l=this._createCanvas(s),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${o} ${e}px ${i}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(n),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),u=s+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),d=new Uint8ClampedArray(h),f={data:d,width:u,height:c,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===l)return f;const{ctx:p,buffer:m,gridInner:_,gridOuter:g}=this;p.clearRect(m,m,s,l),p.fillText(e,m,m+a);const y=p.getImageData(m,m,s,l);g.fill(xf,0,h),_.fill(0,0,h);for(let e=0;e0?e*e:0,_[r]=e<0?e*e:0}}bf(g,0,0,u,c,u,this.f,this.v,this.z),bf(_,m,m,s,l,u,this.f,this.v,this.z);for(let e=0;e0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,r=t[e];for(;e>0;){const i=e-1>>1,o=t[i];if(n(r,o)>=0)break;t[e]=o,e=i}t[e]=r}_down(e){const{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e=0)break;t[e]=o,e=r}t[e]=i}}function Of(e,t){return et?1:0}function zf(e,t=1,n=!1){let r=1/0,i=1/0,o=-1/0,a=-1/0;const s=e[0];for(let e=0;eo)&&(o=t.x),(!e||t.y>a)&&(a=t.y)}const l=Math.min(o-r,a-i);let u=l/2;const c=new Pf([],Lf);if(0===l)return new v(r,i);for(let t=r;th.d||!h.d)&&(h=r,n&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-h.d<=t||(u=r.h/2,c.push(new Df(r.p.x-u,r.p.y-u,u,e)),c.push(new Df(r.p.x+u,r.p.y-u,u,e)),c.push(new Df(r.p.x-u,r.p.y+u,u,e)),c.push(new Df(r.p.x+u,r.p.y+u,u,e)),d+=4)}return n&&(console.log("num probes: "+d),console.log("best distance: "+h.d)),h.p}function Lf(e,t){return t.max-e.max}class Df{constructor(e,t,n,r){this.p=new v(e,t),this.h=n,this.d=function(e,t){let n=!1,r=1/0;for(let i=0;ie.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n),r=Math.min(r,Xu(e,i,s))}}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}}const Rf=Number.POSITIVE_INFINITY,Bf=Math.sqrt(2);function Ff(e,[t,n]){let r=0,i=0;if(n===Rf){t<0&&(t=0);const n=t/Bf;switch(e){case"top-right":case"top-left":i=n-7;break;case"bottom-right":case"bottom-left":i=7-n;break;case"bottom":i=7-t;break;case"top":i=t-7}switch(e){case"top-right":case"bottom-right":r=-n;break;case"top-left":case"bottom-left":r=n;break;case"left":r=t;break;case"right":r=-t}}else{switch(t=Math.abs(t),n=Math.abs(n),e){case"top-right":case"top-left":case"top":i=n-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-n}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}}return[r,i]}function jf(e,t,n,r,i,o,a,s,l,u){e.createArrays(),e.tilePixelRatio=Vs/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const c=e.layers[0].layout,h=e.layers[0]._unevaluatedLayout._values,d={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:n}=e.textSizeData;d.compositeTextSizes=[h["text-size"].possiblyEvaluate(new ia(t),s),h["text-size"].possiblyEvaluate(new ia(n),s)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:n}=e.iconSizeData;d.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new ia(t),s),h["icon-size"].possiblyEvaluate(new ia(n),s)]}d.layoutTextSize=h["text-size"].possiblyEvaluate(new ia(l+1),s),d.layoutIconSize=h["icon-size"].possiblyEvaluate(new ia(l+1),s),d.textMaxSize=h["text-size"].possiblyEvaluate(new ia(18),s);const f="map"===c.get("text-rotation-alignment")&&"point"!==c.get("symbol-placement"),p=c.get("text-size");for(const o of e.features){const l=c.get("text-font").evaluate(o,{},s).join(","),h=p.evaluate(o,{},s),m=d.layoutTextSize.evaluate(o,{},s),_=(d.layoutIconSize.evaluate(o,{},s),{horizontal:{},vertical:void 0}),g=o.text;let y,v=[0,0];if(g){const r=g.toString(),a=24*c.get("text-letter-spacing").evaluate(o,{},s),u=24*c.get("text-line-height").evaluate(o,{},s),d=jo(r)?a:0,p=c.get("text-anchor").evaluate(o,{},s),y=c.get("text-variable-anchor");if(!y){const e=c.get("text-radial-offset").evaluate(o,{},s);v=e?Ff(p,[24*e,Rf]):c.get("text-offset").evaluate(o,{},s).map(e=>24*e)}let x=f?"center":c.get("text-justify").evaluate(o,{},s);const b="point"===c.get("symbol-placement"),w=b?24*c.get("text-max-width").evaluate(o,{},s):1/0,E=o=>{e.allowVerticalPlacement&&Fo(r)&&(_.vertical=ef(g,t,n,i,l,w,u,p,o,d,v,Kd.vertical,!0,m,h))};if(!f&&y){const e="auto"===x?y.map(e=>Nf(e)):[x];let r=!1;for(let o=0;o=0||!Fo(r)){const e=ef(g,t,n,i,l,w,u,p,x,d,v,Kd.horizontal,!1,m,h);e&&(_.horizontal[x]=e)}E(b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const t=r[o.icon.name];t&&(y=cf(i[o.icon.name],c.get("icon-offset").evaluate(o,{},s),c.get("icon-anchor").evaluate(o,{},s)),x=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&$("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==c.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const b=$f(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!b&&b.iconsInText),(b||y)&&Uf(e,o,_,y,r,d,m,0,v,x,a,s,u)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Nf(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Uf(e,t,n,r,i,o,a,s,l,u,c,h,d){let f=o.textMaxSize.evaluate(t,{},h);void 0===f&&(f=a);const p=e.layers[0].layout,m=p.get("icon-offset").evaluate(t,{},h),_=$f(n.horizontal)||n.vertical,g="globe"===d.name,y=a/24,v=e.tilePixelRatio*f/24,x=(A=e.overscaling,e.zoom>18&&A>2&&(A>>=1),Math.max(Vs/(512*A),1)*p.get("symbol-spacing")),b=p.get("text-padding")*e.tilePixelRatio,E=p.get("icon-padding")*e.tilePixelRatio,T=w(p.get("text-max-angle")),S="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),k="map"===p.get("icon-rotation-alignment")&&"point"!==p.get("symbol-placement"),M=p.get("symbol-placement"),C=x/2;var A;const I=p.get("icon-text-fit");let P;r&&"none"!==I&&(e.allowVerticalPlacement&&n.vertical&&(P=hf(r,n.vertical,I,p.get("icon-text-fit-padding"),m,y)),_&&(r=hf(r,_,I,p.get("icon-text-fit-padding"),m,y)));const O=(a,s,f)=>{if(s.x<0||s.x>=Vs||s.y<0||s.y>=Vs)return;let p=null;if(g){const{x:e,y:t,z:n}=d.projectTilePoint(s.x,s.y,f);p={anchor:new df(e,t,n,0,void 0),up:d.upVector(f,s.x,s.y)}}!function(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,E,T){const S=e.addToLineVertexArray(t,r);let k,M,C,A,I,P,O,z=0,L=0,D=0,R=0,B=-1,F=-1;const j={};let N=fs("");const U=n?n.anchor:t;let V=0,G=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[V,G]=l.layout.get("text-offset").evaluate(x,{},T).map(e=>24*e):(V=24*l.layout.get("text-radial-offset").evaluate(x,{},T),G=Rf),e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(p)P=Wf(e),s&&(O=Wf(s));else{const n=l.layout.get("text-rotate").evaluate(x,{},T)+90;C=Zf(u,U,t,c,h,d,e,f,n,m),s&&(A=Zf(u,U,t,c,h,d,s,g,n))}}if(o){const r=l.layout.get("icon-rotate").evaluate(x,{},T),i="none"!==l.layout.get("icon-text-fit"),a=Sf(o,r,w,i),f=s?Sf(s,r,w,i):void 0;M=Zf(u,U,t,c,h,d,o,g,r),z=4*a.length;const p=e.iconSizeData;let m=null;"source"===p.kind?(m=[fd*l.layout.get("icon-size").evaluate(x,{},T)],m[0]>Gf&&$(`${e.layerIds[0]}: Value for "icon-size" is >= ${Vf}. Reduce your "icon-size".`)):"composite"===p.kind&&(m=[fd*b.compositeIconSizes[0].evaluate(x,{},T),fd*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Gf||m[1]>Gf)&&$(`${e.layerIds[0]}: Value for "icon-size" is >= ${Vf}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,m,v,y,x,!1,n,t,S.lineStartIndex,S.lineLength,-1,E,T),B=e.icon.placedSymbolArray.length-1,f&&(L=4*f.length,e.addSymbols(e.icon,f,m,v,y,x,Kd.vertical,n,t,S.lineStartIndex,S.lineLength,-1,E,T),F=e.icon.placedSymbolArray.length-1)}for(const r in i.horizontal){const o=i.horizontal[r];k||(N=fs(o.text),p?I=Wf(o):k=Zf(u,U,t,c,h,d,o,f,l.layout.get("text-rotate").evaluate(x,{},T),m));const s=1===o.positionedLines.length;if(D+=qf(e,n,t,o,a,l,p,x,m,S,i.vertical?Kd.horizontal:Kd.horizontalOnly,s?Object.keys(i.horizontal):[r],j,B,b,E,T),s)break}i.vertical&&(R+=qf(e,n,t,i.vertical,a,l,p,x,m,S,Kd.vertical,["vertical"],j,F,b,E,T));let q=-1;const Z=(e,t)=>e?Math.max(e,t):t;q=Z(I,q),q=Z(P,q),q=Z(O,q);const W=q>-1?1:0;e.glyphOffsetArray.length>=kp.MAX_GLYPHS&&$("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey),e.symbolInstances.emplaceBack(U.x,U.y,U.z,t.x,t.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,B,F,N,void 0!==k?k:e.collisionBoxArray.length,void 0!==k?k+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,void 0!==M?M:e.collisionBoxArray.length,void 0!==M?M+1:e.collisionBoxArray.length,A||e.collisionBoxArray.length,A?A+1:e.collisionBoxArray.length,c,D,R,z,L,W,0,V,G,q)}(e,s,p,a,n,r,i,P,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,b,S,l,0,E,k,m,t,o,u,c,h)};if("line"===M)for(const i of vf(t.geometry,0,0,Vs,Vs)){const t=yf(i,x,T,n.vertical||_,r,24,v,e.overscaling,Vs);for(const n of t)_&&Xf(e,_.text,C,n)||O(i,n,h)}else if("line-center"===M){for(const e of t.geometry)if(e.length>1){const t=gf(e,T,n.vertical||_,r,24,v);t&&O(e,t,h)}}else if("Polygon"===t.type)for(const e of Jc(t.geometry,0)){const t=zf(e,16);O(e[0],new df(t.x,t.y,0,0,void 0),h)}else if("LineString"===t.type)for(const e of t.geometry)O(e,new df(e[0].x,e[0].y,0,0,void 0),h);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)O([t],new df(t.x,t.y,0,0,void 0),h)}const Vf=255,Gf=Vf*fd;function qf(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_){const g=function(e,t,n,r,i,o,a,s){const l=[];if(0===t.positionedLines.length)return l;const u=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=function(e){const t=e[0],n=e[1],r=t*n;return r>0?[t,-n]:r<0?[-t,n]:0===t?[n,t]:[n,-t]}(n);let h=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)h-=e.lineOffset;const d=t.positionedLines.length,f=h/d;let p=t.top-n[1];for(let e=0;eGf&&$(`${e.layerIds[0]}: Value for "text-size" is >= ${Vf}. Reduce your "text-size".`)):"composite"===y.kind&&(x=[fd*p.compositeTextSizes[0].evaluate(s,{},_),fd*p.compositeTextSizes[1].evaluate(s,{},_)],(x[0]>Gf||x[1]>Gf)&&$(`${e.layerIds[0]}: Value for "text-size" is >= ${Vf}. Reduce your "text-size".`)),e.addSymbols(e.text,g,x,l,a,s,c,t,n,u.lineStartIndex,u.lineLength,f,m,_);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function $f(e){for(const t in e)return e[t];return null}function Zf(e,t,n,r,i,o,a,s,l,u){let c=a.top,h=a.bottom,d=a.left,f=a.right;const p=a.collisionPadding;if(p&&(d-=p[0],c-=p[1],f+=p[2],h+=p[3]),l){const e=new v(d,c),t=new v(f,c),n=new v(d,h),r=new v(f,h),i=w(l);let o=new v(0,0);u&&(o=new v(u[0],u[1])),e._rotateAround(i,o),t._rotateAround(i,o),n._rotateAround(i,o),r._rotateAround(i,o),d=Math.min(e.x,t.x,n.x,r.x),f=Math.max(e.x,t.x,n.x,r.x),c=Math.min(e.y,t.y,n.y,r.y),h=Math.max(e.y,t.y,n.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,n.x,n.y,d,c,f,h,s,r,i,o),e.length-1}function Wf(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Xf(e,t,n,r){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])v&&(x(e,u,r,i,s,l),x(u,n,s,l,o,a))}x(h,d,r,o,i,o),x(d,f,i,o,i,a),x(f,p,i,a,r,a),x(p,h,r,a,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:t}}const Kf=Xs(new Float32Array(16));class Jf{constructor(e){this.spec=e,this.name=e.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(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new yu(0,0)}projectTilePoint(e,t,n){return{x:e,y:t,z:0}}locationPoint(e,t,n=!0){return e._coordinatePoint(e.locationCoordinate(t),n)}pixelsPerMeter(e,t){return wu(1,e)*t}pixelSpaceConversion(e,t,n){return 1}farthestPixelDistance(e){return Hf(e,e.pixelsPerMeter)}pointCoordinate(e,t,n,r){const i=e.horizonLineFromTop(!1),o=new v(t,Math.max(i,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,n){const r=new v(t,n);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const n=e.horizonLineFromTop();return t.y0?t<-sp+n&&(t=-sp+n):t>sp-n&&(t=sp-n);const o=i/Math.pow(lp(t),r);let a=o*Math.sin(r*e),s=i-o*Math.cos(r*e);return a=.5*(a/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:a,y:this.southernCenter?s:1-s,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:n,f:r}=this,i=r-t,o=Math.sign(i),a=Math.sign(n)*Math.sqrt(e*e+i*i);let s=Math.atan2(e,Math.abs(i))*o;i*n<0&&(s-=Math.PI*Math.sign(e)*o);const l=C(E(s/n)+this.center[0],-180,180),u=C(E(2*Math.atan(Math.pow(r/a,1/n))-sp),-ku,ku);return new yu(l,this.southernCenter?-u:u)}}class cp extends Jf{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:xu(e),y:bu(t),z:0}}unproject(e,t){const n=Eu(e),r=Tu(t);return new yu(n,r)}}const hp=w(ku);class dp extends Jf{project(e,t){const n=(t=w(t))*t,r=n*n;return{x:.5*((e=w(e))*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let n=t=(2*(1-t)-1)*Math.PI,r=25,i=0,o=n*n;do{o=n*n;const e=o*o;i=(n*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),n=C(n-i,-hp,hp)}while(Math.abs(i)>1e-6&&--r>0);o=n*n;const a=C(E(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=E(n);return new yu(a,s)}}const fp=w(ku);class pp extends Jf{project(e,t){t=w(t),e=w(e);const n=Math.cos(t),r=2/Math.PI,i=Math.acos(n*Math.cos(e/2)),o=Math.sin(i)/i,a=.5*(e*r+2*n*Math.sin(e/2)/o)||0,s=.5*(t+Math.sin(t)/o)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}unproject(e,t){let n=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,i=25;const o=1e-6;let a=0,s=0;do{const i=Math.cos(r),o=Math.sin(r),l=2*o*i,u=o*o,c=i*i,h=Math.cos(n/2),d=Math.sin(n/2),f=2*h*d,p=d*d,m=1-c*h*h,_=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,y=.5*(2*g*i*d+2*n/Math.PI)-e,v=.5*(g*o+r)-t,x=.5*_*(c*p+g*i*h*u)+1/Math.PI,b=_*(f*l/4-g*o*d),w=.125*_*(l*d-g*o*c*f),E=.5*_*(u*h+g*p*i)+.5,T=b*w-E*x;a=(v*b-y*E)/T,s=(y*w-v*x)/T,n=C(n-a,-Math.PI,Math.PI),r=C(r-s,-fp,fp)}while((Math.abs(a)>o||Math.abs(s)>o)&&--i>0);return new yu(E(n),E(r))}}class mp extends Jf{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(w(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:n,cosPhi:r}=this;return{x:w(e)*r*n+.5,y:-Math.sin(w(t))/r*n+.5,z:0}}unproject(e,t){const{scale:n,cosPhi:r}=this,i=-(t-.5)/n,o=C(E((e-.5)/n)/r,-180,180),a=Math.asin(C(i*r,-1,1)),s=C(E(a),-ku,ku);return new yu(o,s)}}class _p extends cp{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,t,n){const r=ru(e,t,n);return yl(r,r,au(Hl(n))),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const n=nu(t.lat,t.lng),r=ml([],n),i=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;pl(n,n,r,wu(1,0)*Vs*i);const o=Xs(new Float64Array(16));return Ys(o,e.pixelMatrix,e.globeMatrix),yl(n,n,o),new v(n[0],n[1])}pixelsPerMeter(e,t){return wu(1,0)*t}pixelSpaceConversion(e,t,n){const r=wu(1,e)*t,i=On(wu(1,45)*t,r,n);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,n){const r=su(Hl(n.canonical));return Ys(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:n}=e,r=au(Hl(t));return el(r,r,w(n.lng)),Qs(r,r,w(n.lat)),Js(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,n,r){return Zl(e,t,n,!0)||new Cu(0,0)}pointCoordinate3D(e,t,n){const r=this.pointCoordinate(e,t,n,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!Zl(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const n=e.cameraToCenterDistance,r=e._centerAltitude*t,i=e._camera,o=e._camera.forward(),a=ll([],fl([],o,-n),[0,0,r]),s=e.worldSize/(2*Math.PI),l=[0,0,-s],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=fl([],i.up(),c),d=fl([],i.right(),c*u),f=ml([],ll([],ll([],o,h),d)),p=[];let m;if(new Rl(a,f).closestPointOnSphere(l,s,p)){const t=ll([],p,l),n=bl([],t,a);m=Math.cos(e.fovAboveCenter)*al(n)}else{const e=bl([],a,l),t=bl([],l,a);ml(t,t);const n=al(e)-s;m=Math.sqrt(n*(n+2*s));const r=Math.acos(m/(s+n))-Math.acos(_l(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=uu(e.zoom);if(n>0){const r=Hf(e,wu(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return On(t,r+i*(1-Math.cos(o)),Math.pow(n,10))}return t}upVector(e,t,n){return ru(t,n,e,1)}upVectorScale(e){return{metersToTile:$l(iu(Hl(e)))}}}function gp(e){const t=e.parallels,n=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new cp(e);case"equirectangular":return new ap(e);case"naturalEarth":return new dp(e);case"equalEarth":return new op(e);case"winkelTripel":return new pp(e);case"albers":return n?new mp(e):new Qf(e);case"lambertConformalConic":return n?new mp(e):new up(e);case"globe":return new _p(e)}throw new Error("Invalid projection name: "+e.name)}const yp=wh.types,vp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function xp(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=s?Math.min(Gf,Math.round(s[0])):0,p=s?Math.min(Gf,Math.round(s[1])):0;e.emplaceBack(t,n,Math.round(32*r),Math.round(32*i),o,a,(f<<1)+(l?1:0),p,16*u,16*c,256*h,256*d)}function bp(e,t,n,r,i,o,a){e.emplaceBack(t,n,r,i,o,a)}function wp(e,t,n,r,i){e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i)}function Ep(e){for(const t of e.sections)if($o(t.text))return!0;return!1}class Tp{constructor(e){this.layoutVertexArray=new Pa,this.indexArray=new ja,this.programConfigurations=e,this.segments=new Us,this.dynamicLayoutVertexArray=new Ma,this.opacityVertexArray=new za,this.placedSymbolArray=new Ka,this.globeExtVertexArray=new Oa}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ad.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,ld.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,vp,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,sd.members,!0)),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(e))}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())}}Fi(Tp,"SymbolBuffers");class Sp{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new Us,this.collisionVertexArray=new Ba,this.collisionVertexArrayExt=new Fa}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,ud.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,cd.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Fi(Sp,"CollisionBuffers");class kp{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Xs([]),this.placementViewportMatrix=Xs([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=pd(this.zoom,t["text-size"]),this.iconSizeData=pd(this.zoom,t["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),i=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(e=>Kd[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new Tp(new Ps(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Tp(new Ps(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new es,this.lineVertexArray=new ts,this.symbolInstances=new Qa}calculateGlyphDependencies(e,t,n,r,i){for(let n=0;n0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const f=t.iconDependencies,p=t.glyphDependencies,m=t.availableImages,_=new ia(this.zoom);for(const{feature:t,id:l,index:u,sourceLayerIndex:g}of e){const e=i._featureFilter.needGeometry,y=Bu(t,e);if(!i._featureFilter.filter(_,y,n))continue;if(e||(y.geometry=Ru(t,n,r)),a&&1!==t.type&&n.z<=5){const e=y.geometry,t=.98078528056,r=(e,r)=>_l(ru(e.x,e.y,n,1),ru(r.x,r.y,n,1))=0;for(const n of v.sections)if(n.image)f[n.image.name]=!0;else{const r=Fo(v.toString()),i=n.fontStack||e,o=p[i]=p[i]||{};this.calculateGlyphDependencies(n.text,o,t,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},n={},r=[];let i=0;function o(t){r.push(e[t]),i++}function a(e,t,i){const o=n[e];return delete n[e],n[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(i[0]),o}function s(e,n,i){const o=t[n];return delete t[n],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=i[0].concat(r[o].geometry[0]),o}function l(e,t,n){const r=n?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let u=0;ue.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,n,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,n,r),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,n,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=gp(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const n=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:n}of t)this.lineVertexArray.emplaceBack(e,n);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,t,n,r,i,o,a,s,l,u,c,h,d,f){const p=e.indexArray,m=e.layoutVertexArray,_=e.globeExtVertexArray,g=e.segments.prepareSegment(4*t.length,m,p,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,v=g.vertexLength,x=this.allowVerticalPlacement&&a===Kd.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let r=0;r=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=md(this.textSizeData,e,i)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,n){const r=this.icon.placedSymbolArray.get(n),i=md(this.iconSizeData,e,r);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,n){e.emplaceBack(t,-n,-n),e.emplaceBack(t,n,-n),e.emplaceBack(t,n,n),e.emplaceBack(t,-n,n)}_updateTextDebugCollisionBoxes(e,t,n,r,i,o){for(let a=r;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+4*n.numGlyphs;for(let t=n.vertexStartIndex;tr[e]-r[t]||i[t]-i[e]),o}addToSortKeyRanges(e,t){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===t?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:s}=t;n>=0&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&this.addIndicesForPlacedSymbol(this.text,r),i>=0&&i!==r&&i!==n&&this.addIndicesForPlacedSymbol(this.text,i),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Fi(kp,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),kp.MAX_GLYPHS=65535,kp.addDynamicAttributes=wp;const Mp=new _a({"symbol-placement":new fa(tt.layout_symbol["symbol-placement"]),"symbol-spacing":new fa(tt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new fa(tt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new pa(tt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new fa(tt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new fa(tt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new fa(tt.layout_symbol["icon-ignore-placement"]),"icon-optional":new fa(tt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new fa(tt.layout_symbol["icon-rotation-alignment"]),"icon-size":new pa(tt.layout_symbol["icon-size"]),"icon-text-fit":new fa(tt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new fa(tt.layout_symbol["icon-text-fit-padding"]),"icon-image":new pa(tt.layout_symbol["icon-image"]),"icon-rotate":new pa(tt.layout_symbol["icon-rotate"]),"icon-padding":new fa(tt.layout_symbol["icon-padding"]),"icon-keep-upright":new fa(tt.layout_symbol["icon-keep-upright"]),"icon-offset":new pa(tt.layout_symbol["icon-offset"]),"icon-anchor":new pa(tt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new fa(tt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new fa(tt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new fa(tt.layout_symbol["text-rotation-alignment"]),"text-field":new pa(tt.layout_symbol["text-field"]),"text-font":new pa(tt.layout_symbol["text-font"]),"text-size":new pa(tt.layout_symbol["text-size"]),"text-max-width":new pa(tt.layout_symbol["text-max-width"]),"text-line-height":new pa(tt.layout_symbol["text-line-height"]),"text-letter-spacing":new pa(tt.layout_symbol["text-letter-spacing"]),"text-justify":new pa(tt.layout_symbol["text-justify"]),"text-radial-offset":new pa(tt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new fa(tt.layout_symbol["text-variable-anchor"]),"text-anchor":new pa(tt.layout_symbol["text-anchor"]),"text-max-angle":new fa(tt.layout_symbol["text-max-angle"]),"text-writing-mode":new fa(tt.layout_symbol["text-writing-mode"]),"text-rotate":new pa(tt.layout_symbol["text-rotate"]),"text-padding":new fa(tt.layout_symbol["text-padding"]),"text-keep-upright":new fa(tt.layout_symbol["text-keep-upright"]),"text-transform":new pa(tt.layout_symbol["text-transform"]),"text-offset":new pa(tt.layout_symbol["text-offset"]),"text-allow-overlap":new fa(tt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new fa(tt.layout_symbol["text-ignore-placement"]),"text-optional":new fa(tt.layout_symbol["text-optional"])});var Cp={paint:new _a({"icon-opacity":new pa(tt.paint_symbol["icon-opacity"]),"icon-color":new pa(tt.paint_symbol["icon-color"]),"icon-halo-color":new pa(tt.paint_symbol["icon-halo-color"]),"icon-halo-width":new pa(tt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new pa(tt.paint_symbol["icon-halo-blur"]),"icon-translate":new fa(tt.paint_symbol["icon-translate"]),"icon-translate-anchor":new fa(tt.paint_symbol["icon-translate-anchor"]),"text-opacity":new pa(tt.paint_symbol["text-opacity"]),"text-color":new pa(tt.paint_symbol["text-color"],{runtimeType:ft,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new pa(tt.paint_symbol["text-halo-color"]),"text-halo-width":new pa(tt.paint_symbol["text-halo-width"]),"text-halo-blur":new pa(tt.paint_symbol["text-halo-blur"]),"text-translate":new fa(tt.paint_symbol["text-translate"]),"text-translate-anchor":new fa(tt.paint_symbol["text-translate-anchor"])}),layout:Mp};class Ap{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:ut,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Fi(Ap,"FormatSectionOverride",{omit:["defaultValue"]});class Ip extends Fs{constructor(e){super(e,Cp)}recalculate(e,t){super.recalculate(e,t),"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 n=this.layout.get("text-writing-mode");if(n){const e=[];for(const t of n)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,r){const i=this.layout.get(e).evaluate(t,{},n,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||qr(o.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,(t,n)=>n in e?String(e[n]):"")}(t.properties,i)}createBucket(e){return new kp(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Cp.paint.overridableProperties){if(!Ip.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),n=new Ap(t),r=new Gr(n,t.property.specification);let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new Zr("source",r):new Wr("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new ha(t.property,i,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&Ip.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const n=e.get("text-field"),r=Cp.paint.properties[t];let i=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(i=!0)};if("constant"===n.value.kind&&n.value.value instanceof Dt)o(n.value.value.sections);else if("source"===n.value.kind){const e=t=>{i||(t instanceof Vt&&jt(t.value)===gt?o(t.value.sections):t instanceof Wt?o(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}getProgramConfiguration(e){return new Is(this,e)}}var Pp={paint:new _a({"background-color":new fa(tt.paint_background["background-color"]),"background-pattern":new fa(tt.paint_background["background-pattern"]),"background-opacity":new fa(tt.paint_background["background-opacity"])})},Op={paint:new _a({"raster-opacity":new fa(tt.paint_raster["raster-opacity"]),"raster-hue-rotate":new fa(tt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new fa(tt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new fa(tt.paint_raster["raster-brightness-max"]),"raster-saturation":new fa(tt.paint_raster["raster-saturation"]),"raster-contrast":new fa(tt.paint_raster["raster-contrast"]),"raster-resampling":new fa(tt.paint_raster["raster-resampling"]),"raster-fade-duration":new fa(tt.paint_raster["raster-fade-duration"])})};class zp extends Fs{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var Lp={paint:new _a({"sky-type":new fa(tt.paint_sky["sky-type"]),"sky-atmosphere-sun":new fa(tt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new fa(tt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new fa(tt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new fa(tt.paint_sky["sky-gradient-radius"]),"sky-gradient":new ma(tt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new fa(tt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new fa(tt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new fa(tt.paint_sky["sky-opacity"])})};function Dp(e,t,n){const r=[0,0,1],i=Cl([]);return Il(i,i,n?-w(e)+Math.PI:w(e)),Al(i,i,-w(t)),vl(r,r,i),ml(r,r)}const Rp={circle:class extends Fs{constructor(e){super(e,ic)}createBucket(e){return new Nu(e)}queryRadius(e){const t=e;return Qu("circle-radius",this,t)+Qu("circle-stroke-width",this,t)+ec(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=nc(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(t,n)+this.paint.get("circle-stroke-width").evaluate(t,n);return oc(e,r,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new Is(this,e)}},heatmap:class extends Fs{createBucket(e){return new cc(e)}constructor(e){super(e,_c),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=gc({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(e){return Qu("heatmap-radius",this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=this.paint.get("heatmap-radius").evaluate(t,n);return oc(e,r,o,a,s,!0,!0,new v(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new Is(this,e)}},hillshade:class extends Fs{constructor(e){super(e,yc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Fs{constructor(e){super(e,ih)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),n=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(e){return new Is(this,e)}recalculate(e,t){super.recalculate(e,t);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new nh(e)}queryRadius(){return ec(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,n,r,i,o){return!e.queryGeometry.isAboveHorizon&&Gu(tc(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends Fs{constructor(e){super(e,jh)}createBucket(e){return new Ah(e)}queryRadius(){return ec(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new Is(this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s,l){const u=nc(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(t,n),h=this.paint.get("fill-extrusion-base").evaluate(t,n),d=[0,0],f=s&&o.elevation,p=o.elevation?o.elevation.exaggeration():1,m=e.tile.getBucket(this);if(f&&m instanceof Ah){const e=m.centroidVertexArray,t=l+1;te.polygon).flat());const _=f?s:null,[g,y]=function(e,t,n,r,i,o,a,s,l,u,c){return"globe"===e.projection.name?function(e,t,n,r,i,o,a,s,l,u,c){const h=[],d=[],f=e.projection.upVectorScale(c,e.center.lat,e.worldSize).metersToTile,p=[0,0,0,1],m=[0,0,0,1],_=(e,t,n,r)=>{e[0]=t,e[1]=n,e[2]=r,e[3]=1},g=Rh();n>0&&(n+=g),r+=g;for(const g of t){const t=[],y=[];for(const h of g){const d=h.x+i.x,g=h.y+i.y,v=e.projection.projectTilePoint(d,g,c),x=e.projection.upVector(c,h.x,h.y);let b=n,w=r;if(a){const e=Xh(d,g,n,r,a,s,l,u);b+=e.base,w+=e.top}0!==n?_(p,v.x+x[0]*f*b,v.y+x[1]*f*b,v.z+x[2]*f*b):_(p,v.x,v.y,v.z),_(m,v.x+x[0]*f*w,v.y+x[1]*f*w,v.z+x[2]*f*w),yl(p,p,o),yl(m,m,o),t.push(new $h(p[0],p[1],p[2])),y.push(new $h(m[0],m[1],m[2]))}h.push(t),d.push(y)}return[h,d]}(e,t,n,r,i,o,a,s,l,u,c):a?function(e,t,n,r,i,o,a,s,l){const u=[],c=[],h=[0,0,0,1];for(const d of e){const e=[],f=[];for(const u of d){const c=u.x+r.x,d=u.y+r.y,p=Xh(c,d,t,n,o,a,s,l);h[0]=c,h[1]=d,h[2]=p.base,h[3]=1,kl(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new $h(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=d,h[2]=p.top,h[3]=1,kl(h,h,i),h[3]=Math.max(h[3],1e-5);const _=new $h(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),f.push(_)}u.push(e),c.push(f)}return[u,c]}(t,n,r,i,o,a,s,l,u):function(e,t,n,r,i){const o=[],a=[],s=i[8]*t,l=i[9]*t,u=i[10]*t,c=i[11]*t,h=i[8]*n,d=i[9]*n,f=i[10]*n,p=i[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x+r.x,a=o.y+r.y,m=i[0]*t+i[4]*a+i[12],_=i[1]*t+i[5]*a+i[13],g=i[2]*t+i[6]*a+i[14],y=i[3]*t+i[7]*a+i[15],v=m+s,x=_+l,b=g+u,w=Math.max(y+c,1e-5),E=m+h,T=_+d,S=g+f,k=Math.max(y+p,1e-5);e.push(new $h(v/w,x/w,b/w)),n.push(new $h(E/k,T/k,S/k))}o.push(e),a.push(n)}return[o,a]}(t,n,r,i,o)}(o,r,h,c,u,a,_,d,p,o.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(e,t,n){let r=1/0;Gu(n,t)&&(r=Wh(n,t[0]));for(let i=0;i=3)for(let t=0;t{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 jp{constructor(){this.tasks={},this.taskQueue=[],j(["process"],this),this.invoker=new Fp(this.process),this.nextId=0}add(e,t){const n=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:n}){return n=n||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-n:"maybePrepare"===e&&t?400-n:500:200-n:100-n}(t);if(0===r){X();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:e,metadata:t,priority:r,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){X();try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let n=0;n>=1)>1;){const e=n+i>>1,l=r+o>>1;1&t?(i=n,o=r,n=a,r=s):(n=i,r=o,i=a,o=s),a=e,s=l}const l=4*e;Gp[l+0]=n,Gp[l+1]=r,Gp[l+2]=i,Gp[l+3]=o}const qp=new Uint16Array(2178),$p=new Uint8Array(1089),Zp=new Uint16Array(1089);function Wp(e){return 0===e?-.03125:32===e?.03125:0}var Xp=ba([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Hp={type:2,extent:Vs,loadGeometry:()=>[[new v(0,0),new v(8193,0),new v(8193,8193),new v(0,8193),new v(0,0)]]};class Yp{constructor(e,t,n,r,i){this.tileID=e,this.uid=D(),this.uses=0,this.tileSize=t,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)n[t.id]=r}}return n}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof kp){if(this.hasSymbolBuckets=!0,!n)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof kp&&t.hasRTLText){this.hasRTLText=!0,ra.isLoading()||ra.isLoaded()||"deferred"!==ta()||na();break}}this.queryPadding=0;for(const e in this.buckets){const n=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(n))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new Ha}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].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._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=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(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const n=this.buckets[t];n.uploadPending()&&n.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Bp(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Bp(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Bp(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,n,r,i,o,a,s){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:a,transform:o,params:i,tileTransform:this.tileTransform},e,t,n):{}}querySourceFeatures(e,t){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const r=n.loadVTLayers(),i=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[i];if(!o)return;const a=ii(t&&t.filter),{z:s,x:l,y:u}=this.tileID.canonical,c={z:s,x:l,y:u};for(let t=0;te)n=!1;else if(t)if(this.expirationTime=0;e--){const t=4*e,n=Gp[t+0],r=Gp[t+1],i=Gp[t+2],o=Gp[t+3],a=n+i>>1,s=r+o>>1,l=a+s-r,u=s+n-a,c=33*r+n,h=33*o+i,d=33*s+a,f=Math.hypot((qp[2*c+0]+qp[2*h+0])/2-qp[2*d+0],(qp[2*c+1]+qp[2*h+1])/2-qp[2*d+1])>=16;$p[d]=$p[d]||(f?1:0),e<1022&&($p[d]=$p[d]||$p[33*(r+u>>1)+(n+l>>1)]||$p[33*(o+u>>1)+(i+l>>1)])}const i=new Sa,o=new ja;let a=0;function s(e,t){const n=33*t+e;return 0===Zp[n]&&(i.emplaceBack(qp[2*n+0],qp[2*n+1],e*Vs/32,t*Vs/32),Zp[n]=++a),Zp[n]-1}function l(e,t,n,r,i,a){const u=e+n>>1,c=t+r>>1;if(Math.abs(e-i)+Math.abs(t-a)>1&&$p[33*c+u])l(i,a,e,t,u,c),l(n,r,i,a,u,c);else{const l=s(e,t),u=s(n,r),c=s(i,a);o.emplaceBack(l,u,c)}}return l(0,0,32,32,32,0),l(32,32,0,0,0,32),{vertices:i,indices:o}}(this.tileID.canonical,t);r=e.vertices,i=e.indices}else{r=new Sa,i=new ja;for(const{x:e,y:t}of n)r.emplaceBack(e,t,0,0);const e=Xc(r.int16,void 0,4);for(let t=0;t0&&(a=Hs(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,t,i,a,o),this._makeGlobeTileDebugTextBuffer(e,r,t,i,a,o)}_globePoint(e,t,n,r,i,o,a){let s=ru(e,t,n);if(o){const i=1<.5?h=-1:c<-.5&&(h=1);let d=(e/Vs+n.x)/i+h,f=(t/Vs+n.y)/i;d=(d-l)*r._pixelsPerMercatorPixel+l,f=(f-u)*r._pixelsPerMercatorPixel+u;const p=[d*r.worldSize,f*r.worldSize,0];yl(p,p,o),s=Yl(s,p,a)}return yl(s,s,i)}_makeGlobeTileDebugBorderBuffer(e,t,n,r,i,o){const a=new Ea,s=new Za,l=new Ta,u=(e,u,c,h,d)=>{const f=(c-e)/(d-1),p=(h-u)/(d-1),m=a.length;for(let c=0;cu*e+t;for(let e=0;et[a])return null}else{const s=1/r[a];let l=(e[a]-n[a])*s,u=(t[a]-n[a])*s;if(l>u){const e=l;l=u,u=e}if(l>i&&(i=l),uo)return null}return i}function em(e,t,n,r,i,o,a,s,l,u,c){const h=r-e,d=i-t,f=o-n,p=a-e,m=s-t,_=l-n,g=c[1]*_-c[2]*m,y=c[2]*p-c[0]*_,v=c[0]*m-c[1]*p,x=h*g+d*y+f*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=u[0]-e,E=u[1]-t,T=u[2]-n,S=(w*g+E*y+T*v)*b;if(S<0||S>1)return null;const k=E*f-T*d,M=T*h-w*f,C=w*d-E*h,A=(c[0]*k+c[1]*M+c[2]*C)*b;return A<0||S+A>1?null:(p*k+m*M+_*C)*b}function tm(e,t,n){return(e-t)/(n-t)}function nm(e,t,n,r,i,o,a,s,l){const u=1<{const o=r?1:0,a=(e+1)*n-o,s=t*n,l=(t+1)*n-o;i[0]=e*n,i[1]=s,i[2]=a,i[3]=l};let a=new Jp(r);const s=[];for(let t=0;t=1;r/=2){const e=n[n.length-1];a=new Jp(r);for(let t=0;t0;){const{idx:s,t:f,nodex:p,nodey:m,depth:_}=d.pop();if(this.leaves[s]){nm(p,m,_,e,t,n,r,c,h);const s=1<<_,l=(p+0)/s,u=(p+1)/s,d=(m+0)/s,g=(m+1)/s,y=om(l,d,this.dem)*a,v=om(u,d,this.dem)*a,x=om(u,g,this.dem)*a,b=om(l,g,this.dem)*a,w=em(c[0],c[1],y,h[0],c[1],v,h[0],h[1],x,i,o),E=em(h[0],h[1],x,c[0],h[1],b,c[0],c[1],y,i,o),T=Math.min(null!==w?w:Number.MAX_VALUE,null!==E?E:Number.MAX_VALUE);if(T!==Number.MAX_VALUE)return T;{const e=pl([],i,o,f);if(im(y,v,b,x,tm(e[0],c[0],h[0]),tm(e[1],c[1],h[1]))>=e[2])return f}continue}let g=0;for(let d=0;d=l[u[n]]&&(u.splice(n,0,d),t=!0);t||(u[g]=d),g++}}for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}static pack(e,t){const n=[0,0,0,0],r=um.getUnpackVector(t);let i=Math.floor((e+r[3])/r[2]);return n[2]=i%256,i=Math.floor(i/256),n[1]=i%256,i=Math.floor(i/256),n[0]=i,n}getPixels(){return new mc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,i=t*this.dim+this.dim,o=n*this.dim,a=n*this.dim+this.dim;switch(t){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:o=a-1;break;case 1:a=o+1}const s=-t*this.dim,l=-n*this.dim;for(let t=o;t{this.remove(e,i)},n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const n=e.wrapped().key,r=void 0===t?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const n in this.data)for(const r of this.data[n])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class hm{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}hm.ReadOnly=!1,hm.ReadWrite=!0,hm.disabled=new hm(519,hm.ReadOnly,[0,1]);class dm{constructor(e,t,n,r,i,o){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=o}}dm.disabled=new dm({func:519,mask:0},0,0,7680,7680,7680);class fm{constructor(e,t,n){this.blendFunction=e,this.blendColor=t,this.mask=n}}fm.Replace=[1,0],fm.disabled=new fm(fm.Replace,Ot.transparent,[!1,!1,!1,!1]),fm.unblended=new fm(fm.Replace,Ot.transparent,[!0,!0,!0,!0]),fm.alphaBlended=new fm([1,771],Ot.transparent,[!0,!0,!0,!0]);class pm{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}pm.disabled=new pm(!1,1029,2305),pm.backCCW=new pm(!0,1029,2305),pm.backCW=new pm(!0,1029,2304),pm.frontCW=new pm(!0,1028,2304),pm.frontCCW=new pm(!0,1028,2305);class mm extends et{constructor(e,t,n){super(),this.id=e,this._onlySymbols=n,t.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),t.on("error",()=>{this._sourceErrored=!0}),this._source=t,this._tiles={},this._cache=new cm(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Kp,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const n=this._tiles[t];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return O(this._tiles).map(e=>e.tileID).sort(_m).map(e=>e.key)}getRenderableIds(e){const t=[];for(const n in this._tiles)this._isIdRenderable(+n,e)&&t.push(this._tiles[n]);return e?t.sort((e,t)=>{const n=e.tileID,r=t.tileID,i=new v(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),o=new v(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-r.overscaledZ||o.y-i.y||o.x-i.x}).map(e=>e.tileID.key):t.map(e=>e.tileID).sort(_m).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const n=this._tiles[e];n&&("loading"!==n.state&&(n.state=t),this._loadTile(n,this._tileLoaded.bind(this,n,e,t)))}_tileLoaded(e,t,n,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new Qe(r,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=He.now(),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Je("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,n,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,n,r){for(const i in this._tiles){let o=this._tiles[i];if(r[i]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>n)continue;let a=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(a=e)}let s=a;for(;s.overscaledZ>t;)if(s=s.scaledTo(s.overscaledZ-1),e[s.key]){r[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=t?n:null}for(let n=e.overscaledZ-1;n>=t;n--){const t=e.scaledTo(n),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const n=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,i=Math.floor(n*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,i):i,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const n in this._tiles){const r=this._tiles[n];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(e,t,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;let r;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new Gh(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(r=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter(e=>this._source.hasTile(e)))):r=[];const i=this._updateRetainedTiles(r);if(gm(this._source.type)&&0!==r.length){const e={},t={},n=Object.keys(i);for(const r of n){const n=i[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=He.now())continue;const a=this.findLoadedParent(n,Math.max(n.overscaledZ-mm.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),t[r]=n}const o=r[r.length-1].overscaledZ;for(const e in this._tiles){const n=this._tiles[e];if(i[e]||!n.hasData())continue;let r=n.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&t[r.key]){i[e]=n.tileID;break}}}for(const t in e)i[t]||(this._coveredTiles[t]=!0,i[t]=e[t])}for(const e in i)this._tiles[e].clearFadeHold();const o=function(e,t){const n=[];for(const r in e)r in t||n.push(r);return n}(this._tiles,i);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const n={},r=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),i=e[0].overscaledZ,o=Math.max(i-mm.maxOverzooming,this._source.minzoom),a=Math.max(i+mm.maxUnderzooming,this._source.minzoom),s={};for(const n of e){const e=this._addTile(n);t[n.key]=n,e.hasData()||r=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],n=this.getTile(e);if(n&&n.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let i=e.wasRequested();for(let a=r.overscaledZ-1;a>=o;--a){const o=r.scaledTo(a);if(n[o.key])break;if(n[o.key]=!0,e=this.getTile(o),!e&&i&&(e=this._addTile(o)),e&&(t[o.key]=o,i=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let n,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){n=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(n=this._getLoadedTile(e),n)break;r=e}for(const e of t)this._loadedParentTiles[e]=n}}_addTile(e){let t=this._tiles[e.key];if(t)return t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const n=Boolean(t);if(!n){const n=this.map?this.map.painter:null;t=new Yp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,n,this._isRaster),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,n||this._source.fire(new Je("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const n=t.getExpiryTimeout();n&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},n))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);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(e,t,n){const r=[],i=this.transform;if(!i)return r;const o="globe"===i.projection.name,a=xu(i.center.lng);for(const s in this._tiles){const l=this._tiles[s];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;let u;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(C(a,...ym(e,-1))-a),Math.abs(C(a,...ym(e,1))-a)];u=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(C(a,...ym(e,-1))-a),Math.abs(C(a,...ym(e,0))-a),Math.abs(C(a,...ym(e,1))-a)];u=[t.indexOf(Math.min(...t))-1]}}else u=[0];for(const n of u){const o=e.containsTile(l,i,t,n);o&&r.push(o)}}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(gm(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=He.now())return!0}return!1}setFeatureState(e,t,n){this._state.updateState(e=e||"_geojsonTileLayer",t,n)}removeFeatureState(e,t,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,n)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,n){const r=this._tiles[e];r&&r.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(const n in this._tiles)this._tiles[n].hasDependency(e,t)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(e,t))}_preloadTiles(e,t){if(!this._sourceLoaded){const n=()=>{this._sourceLoaded&&(this._source.off("data",n),this._preloadTiles(e,t))};return void this._source.on("data",n)}const n=new Map,r=Array.isArray(e)?e:[e],i=this.map.painter.terrain,o=this.usedForTerrain&&i?i.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.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 e of t)n.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}P(Array.from(n.values()),(e,t)=>{const n=new Yp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(n,e=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),t(e,n)})},t)}}function _m(e,t){const n=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-n||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function gm(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function ym(e,t){const n=1<=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bh(new qd(this.rawTileData)).layers,this.sourceLayerCoder=new Np(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,n,r){this.loadVTLayers();const i=e.params||{},o=ii(i.filter),a=e.tileResult,s=e.transform,l=a.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,(e,t,n,r)=>Ku(a.bufferedTilespaceGeometry,e,t,n,r));u.sort(wm);let c=null;s.elevation&&u.length>0&&(c=vm.create(s.elevation,this.tileID));const h={};let d;for(let s=0;s(p||(p=Ru(t,this.tileID.canonical,e.tileTransform)),n.queryIntersectsFeature(a,t,r,p,this.z,e.transform,e.pixelPosMatrix,c,i)))}return h}loadMatchingFeature(e,t,n,r,i,o,a,s,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:d}=t,f=this.bucketLayerIDs[c];if(r&&!function(e,t){for(let n=0;n=0)return!0;return!1}(r,f))return;const p=this.sourceLayerCoder.decode(h),m=this.vtLayers[p].feature(u);if(n.needGeometry){const e=Bu(m,!0);if(!n.filter(new ia(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new ia(this.tileID.overscaledZ),m))return;const _=this.getId(m,p);for(let t=0;t{const a=t instanceof da?t.get(o):null;return a&&a.evaluate?a.evaluate(n,r,i):a})}function wm(e,t){return t-e}Fi(xm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Em{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new pc({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const n=this.getKey(e,t);return this.positions[n]}trim(){const e=this.width,t=this.height=B(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,n){const r=[];let i=e.length%2==1?-e[e.length-1]*n:0,o=e[0]*n,a=!0;r.push({left:i,right:o,isDash:a,zeroLength:0===e[0]});let s=e[0];for(let t=1;t1&&(a=e[++o]);const l=Math.abs(s-a.left),u=Math.abs(s-a.right),c=Math.min(l,u);let h;const d=t/n*(r+1);if(a.isDash){const e=r-Math.abs(d);h=Math.sqrt(c*c+e*e)}else h=r-Math.sqrt(c*c+d*d);this.image.data[i+s]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const n=e[t],r=e[t+1];n.zeroLength?e.splice(t,1):r&&r.isDash===n.isDash&&(r.left=n.left,e.splice(t,1))}const n=e[0],r=e[e.length-1];n.isDash===r.isDash&&(n.left=r.left-this.width,r.right=n.right+this.width);const i=this.width*this.nextRow;let o=0,a=e[o];for(let n=0;n1&&(a=e[++o]);const r=Math.abs(n-a.left),s=Math.abs(n-a.right),l=Math.min(r,s);this.image.data[i+n]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128))}}addDash(e,t){const n=this.getKey(e,t);if(this.positions[n])return this.positions[n];const r="round"===t,i=r?7:0,o=2*i+1;if(this.nextRow+o>this.height)return $("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t=t.maxzoom||"none"!==t.visibility&&(km(e,this.zoom,n),(s[t.id]=t.createBucket({index:a.bucketLayerIDs.length,layers:e,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:n})).populate(d,u,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(e.map(e=>e.id)))}}let h,d,f,p;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=()=>{if(h)return i(h);if(d&&f&&p){const e=new Tm(d),t=new Yd(f,p);for(const r in s){const i=s[r];i instanceof kp?(km(i.layers,this.zoom,n),jf(i,d,e.positions,f,t.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):i.hasPattern&&(i instanceof td||i instanceof nh||i instanceof Ah)&&(km(i.layers,this.zoom,n),i.addFeatures(u,this.tileID.canonical,t.patternPositions,n,this.tileTransform))}this.status="done",i(null,{buckets:O(s).filter(e=>!e.isEmpty()),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,glyphMap:this.returnDependencies?d:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?e.positions:null})}},g=U(u.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(g).length?r.send("getGlyphs",{uid:this.uid,stacks:g},(e,t)=>{h||(h=e,d=t,_())},void 0,!1,m):d={};const y=Object.keys(u.iconDependencies);y.length?r.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"icons"},(e,t)=>{h||(h=e,f=t,_())},void 0,!1,m):f={};const v=Object.keys(u.patternDependencies);v.length?r.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"patterns"},(e,t)=>{h||(h=e,p=t,_())},void 0,!1,m):p={},_()}}function km(e,t,n){const r=new ia(t);for(const t of e)t.recalculate(r,n)}class Mm{constructor(e){this.entries={},this.scheduler=e}request(e,t,n,r){const i=this.entries[e]=this.entries[e]||{callbacks:[]};if(i.result){const[e,n]=i.result;return this.scheduler?this.scheduler.add(()=>{r(e,n)},t):r(e,n),()=>{}}return i.callbacks.push(r),i.cancel||(i.cancel=n((n,r)=>{i.result=[n,r];for(const e of i.callbacks)this.scheduler?this.scheduler.add(()=>{e(n,r)},t):e(n,r);setTimeout(()=>delete this.entries[e],3e3)})),()=>{i.result||(i.callbacks=i.callbacks.filter(e=>e!==r),i.callbacks.length||(i.cancel(),delete this.entries[e]))}}}function Cm(e,t,n){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},t=>{const r=fe(e.request,(e,r,i,o)=>{e?t(e):r&&t(null,{vectorTile:n?void 0:new bh(new qd(r)),rawData:r,cacheControl:i,expires:o})});return()=>{r.cancel(),t()}},t)}const Am=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Im{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,n]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=n>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const i=Am[15&n];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new Im(a,o,i,e)}constructor(e,t=64,n=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const i=Am.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+a+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return function e(t,n,r,i,o,a){if(o-i<=r)return;const s=i+o>>1;(function e(t,n,r,i,o,a){for(;o>i;){if(o-i>600){const s=o-i+1,l=r-i+1,u=Math.log(s),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(s-c)/s)*(l-s/2<0?-1:1);e(t,n,r,Math.max(i,Math.floor(r-l*c/s+h)),Math.min(o,Math.floor(r+(s-l)*c/s+h)),a)}const s=n[2*r+a];let l=i,u=o;for(Pm(t,n,i,r),n[2*o+a]>s&&Pm(t,n,i,o);ls;)u--}n[2*i+a]===s?Pm(t,n,i,u):(u++,Pm(t,n,u,o)),u<=r&&(i=u+1),r<=u&&(o=u-1)}})(t,n,s,i,o,a),e(t,n,r,i,s-1,1-a),e(t,n,r,s+1,o,1-a)}(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,s=[0,i.length-1,0],l=[];for(;s.length;){const u=s.pop()||0,c=s.pop()||0,h=s.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const s=o[2*a],u=o[2*a+1];s>=e&&s<=n&&u>=t&&u<=r&&l.push(i[a])}continue}const d=h+c>>1,f=o[2*d],p=o[2*d+1];f>=e&&f<=n&&p>=t&&p<=r&&l.push(i[d]),(0===u?e<=f:t<=p)&&(s.push(h),s.push(d-1),s.push(1-u)),(0===u?n>=f:r>=p)&&(s.push(d+1),s.push(c),s.push(1-u))}return l}within(e,t,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:i,nodeSize:o}=this,a=[0,r.length-1,0],s=[],l=n*n;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=o){for(let n=h;n<=c;n++)zm(i[2*n],i[2*n+1],e,t)<=l&&s.push(r[n]);continue}const d=h+c>>1,f=i[2*d],p=i[2*d+1];zm(f,p,e,t)<=l&&s.push(r[d]),(0===u?e-n<=f:t-n<=p)&&(a.push(h),a.push(d-1),a.push(1-u)),(0===u?e+n>=f:t+n>=p)&&(a.push(d+1),a.push(c),a.push(1-u))}return s}}function Pm(e,t,n,r){Om(e,n,r),Om(t,2*n,2*r),Om(t,2*n+1,2*r+1)}function Om(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function zm(e,t,n,r){const i=e-n,o=t-r;return i*i+o*o}e.ARRAY_TYPE=$s,e.AUTH_ERR_MSG=ve,e.Aabb=jl,e.Actor=class{constructor(e,t,r){this.target=e,this.parent=t,this.mapId=r,this.callbacks={},this.cancelCallbacks={},j(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=X()?e:n,this.scheduler=new jp}send(e,t,n,r,i=!1,o){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=o,this.callbacks[a]=n);const s=K(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:e,hasCallback:!!n,targetMapId:r,mustQueue:i,sourceMapId:this.mapId,data:Ui(t,s)},s),{cancel:()=>{n&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,n=t.id;if(n&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[n];delete this.cancelCallbacks[n],e&&e.cancel()}else if(t.mustQueue||X()){const e=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,t),e&&e.metadata||{type:"message"})}else this.processTask(n,t)}processTask(e,t){if(""===t.type){const n=this.callbacks[e];delete this.callbacks[e],n&&(t.error?n(Vi(t.error)):n(null,Vi(t.data)))}else{const n=K(this.globalScope)?void 0:[],r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Ui(t):null,data:Ui(r,n)},n)}:e=>{},i=Vi(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,i,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],i.source)[e[1]](i,r)}else r(new Error("Could not find function "+t.type))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},e.CanonicalTileID=Uh,e.Color=Ot,e.ColorMode=fm,e.CullFaceMode=pm,e.DEMData=um,e.DataConstantProperty=fa,e.DedupedRequest=Mm,e.DepthMode=hm,e.EXTENT=Vs,e.Elevation=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const n=t.getSource().maxzoom,r=1<1)return t;const i=r.getSource().maxzoom,o=1<{const o=this.getAtTileOffset(e,i.x,i.y),a=r.upVector(e.canonical,i.x,i.y);return fl(a,a,o*r.upVectorScale(e.canonical,t,n).metersToTile),a}}getForTilePoints(e,t,n,r){if(this.isUsingMockSource())return!1;const i=vm.create(this,e,r);return!!i&&(t.forEach(e=>{e[2]=this.exaggeration()*i.getElevationAt(e[0],e[1],n)}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const n=t.dem.tree,r=t.tileID,i=1<{let r=e===o-1?e-2:0===e?e:e-1;return r+=n?24575:0,[r,t]};for(let e=0;ethis._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!xe(e))return e;const n=ke(e);return n.path="/styles/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!xe(e))return e;const n=ke(e);return n.path="/fonts/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeSourceURL(e,t,n,r){if(!xe(e))return e;const i=ke(e);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),n&&i.params.push("language="+n),r&&i.params.push("worldview="+r),this._makeAPIURL(i,this._customAccessToken||t)}normalizeSpriteURL(e,t,n,r){const i=ke(e);return xe(e)?(i.path=`/styles/v1${i.path}/sprite${t}${n}`,this._makeAPIURL(i,this._customAccessToken||r)):(i.path+=`${t}${n}`,Me(i))}normalizeTileURL(e,t,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!xe(e))return e;const r=ke(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||n&&"raster"!==r.authority&&512===n?"@2x":""}${a.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${o.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${o.TILE_URL_VERSION}${r.path}`);const i=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||o.ACCESS_TOKEN;return o.REQUIRE_ACCESS_TOKEN&&i&&this._skuToken&&r.params.push("sku="+this._skuToken),this._makeAPIURL(r,i)}canonicalizeTileURL(e,t){const n=ke(e);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return e;let r="mapbox://";n.path.match(/^\/raster\/v1\//)?r+="raster/"+n.path.replace(`/${o.RASTER_URL_PREFIX}/`,""):r+="tiles/"+n.path.replace(`/${o.TILE_URL_VERSION}/`,"");let i=n.params;return t&&(i=i.filter(e=>!e.match(/^access_token=/))),i.length&&(r+="?"+i.join("&")),r}canonicalizeTileset(e,t){const n=!!t&&xe(t),r=[];for(const t of e.tiles||[])be(t)?r.push(this.canonicalizeTileURL(t,n)):r.push(t);return r}_makeAPIURL(e,t){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=ke(o.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!o.REQUIRE_ACCESS_TOKEN)return Me(e);if(t=t||o.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error("An API access token is required to use Mapbox GL. "+n);if("s"===t[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+n)}return e.params=e.params.filter(e=>-1===e.indexOf("access_token")),e.params.push("access_token="+(t||"")),Me(e)}},e.ResourceType=ue,e.SegmentVector=Us,e.SourceCache=mm,e.StencilMode=dm,e.StructArrayLayout1ui2=Za,e.StructArrayLayout2f1f2i16=Ra,e.StructArrayLayout2i4=Ea,e.StructArrayLayout2ui4=$a,e.StructArrayLayout3f12=Fa,e.StructArrayLayout3ui6=ja,e.StructArrayLayout4i8=Sa,e.StructArrayLayout5f20=Ga,e.Texture=Bp,e.Tile=Yp,e.Transitionable=sa,e.Uniform1f=ys,e.Uniform1i=class extends gs{constructor(e){super(e),this.current=0}set(e,t,n){this.fetchUniformLocation(e,t)&&this.current!==n&&(this.current=n,this.gl.uniform1i(this.location,n))}},e.Uniform2f=class extends gs{constructor(e){super(e),this.current=[0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]||(this.current=n,this.gl.uniform2f(this.location,n[0],n[1])))}},e.Uniform3f=class extends gs{constructor(e){super(e),this.current=[0,0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]||(this.current=n,this.gl.uniform3f(this.location,n[0],n[1],n[2])))}},e.Uniform4f=vs,e.UniformColor=xs,e.UniformMatrix2f=class extends gs{constructor(e){super(e),this.current=Es}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix2fv(this.location,!1,n);break}}},e.UniformMatrix3f=class extends gs{constructor(e){super(e),this.current=ws}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix3fv(this.location,!1,n);break}}},e.UniformMatrix4f=class extends gs{constructor(e){super(e),this.current=bs}set(e,t,n){if(this.fetchUniformLocation(e,t)){if(n[12]!==this.current[12]||n[0]!==this.current[0])return this.current=n,void this.gl.uniformMatrix4fv(this.location,!1,n);for(let e=1;e<16;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix4fv(this.location,!1,n);break}}}},e.UnwrappedTileID=Vh,e.ValidationError=Yr,e.VectorTileFeature=wh,e.VectorTileWorkerSource=class extends et{constructor(e,t,n,r,i){super(),this.actor=e,this.layerIndex=t,this.availableImages=n,this.loadVectorData=i||Cm,this.loading={},this.loaded={},this.deduped=new Mm(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler}loadTile(e,t){const n=e.uid,r=e&&e.request,i=r&&r.collectResourceTiming,o=this.loading[n]=new Sm(e);o.abort=this.loadVectorData(e,(a,s)=>{const l=!this.loading[n];if(delete this.loading[n],l||a||!s)return o.status="done",l||(this.loaded[n]=o),t(a);const u=s.rawData,c={};s.expires&&(c.expires=s.expires),s.cacheControl&&(c.cacheControl=s.cacheControl),o.vectorTile=s.vectorTile||new bh(new qd(u));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,(e,n)=>{if(e||!n)return t(e);const o={};if(i){const e=qe(r);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)))}t(null,z({rawTileData:u.slice(0)},n,c,o))})};this.isSpriteLoaded?h():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):h()}),this.loaded=this.loaded||{},this.loaded[n]=o})}reloadTile(e,t){const n=this.loaded,r=e.uid,i=this;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.enableTerrain=!!e.enableTerrain,o.projection=e.projection,o.tileTransform=Yf(e.tileID.canonical,e.projection);const a=(e,n)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,i.layerIndex,this.availableImages,i.actor,r)),t(e,n)};"parsing"===o.status?o.reloadCallback=a:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}}abortTile(e,t){const n=e.uid,r=this.loading[n];r&&(r.abort&&r.abort(),delete this.loading[n]),t()}removeTile(e,t){const n=this.loaded,r=e.uid;n&&n[r]&&delete n[r],t()}},e.WritingMode=Kd,e.ZoomDependentExpression=Wr,e.add=ll,e.addDynamicAttributes=wp,e.adjoint=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-s*u,e[1]=i*u-r*c,e[2]=r*s-i*a,e[3]=s*l-o*c,e[4]=n*c-i*l,e[5]=i*o-n*s,e[6]=o*u-a*l,e[7]=r*l-n*u,e[8]=n*a-r*o,e},e.asyncAll=P,e.bezier=k,e.bindAll=j,e.boundsAttributes=Xp,e.bufferConvexPolygon=function(e,t){const n=[];for(let r=0;rie&&(e.getActor().send("enforceCacheSizeLimit",re),le=0)},e.calculateGlobeLabelMatrix=function(e,t){const{x:n,y:r}=e.point,i=lu(n,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return Ys(i,i,su(Hl(t)))},e.calculateGlobeMatrix=function(e){const{x:t,y:n}=e.point,{lng:r,lat:i}=e._center;return lu(t,n,e.worldSize,r,i)},e.calculateGlobeMercatorMatrix=function(e){const t=e.pixelsPerMeter,n=t/wu(1,e.center.lat),r=Xs(new Float64Array(16));return Ks(r,r,[e.point.x,e.point.y,0]),Js(r,r,[n,n,t]),Float32Array.from(r)},e.circumferenceAtLatitude=vu,e.clamp=C,e.clearTileCache=function(e){if(!oe())return;const t=n.caches.delete(ee);e&&t.catch(e).then(()=>e())},e.clipLine=vf,e.clone=function(e){var t=new $s(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.clone$1=G,e.collisionCircleLayout=dd,e.config=o,e.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.create=function(){var e=new $s(16);return $s!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.create$1=Zs,e.createExpression=$r,e.createLayout=ba,e.createStyleLayer=function(e){return"custom"===e.type?new zp(e):new Rp[e.type](e)},e.cross=gl,e.degToRad=w,e.distance=function(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])},e.div=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e},e.dot=_l,e.earthRadius=mu,e.ease=M,e.easeCubicInOut=S,e.ecefToLatLng=function([e,t,n]){const r=Math.hypot(e,t,n),i=Math.atan2(e,n),o=.5*Math.PI-Math.acos(-t/r);return new yu(E(i),E(o))},e.emitValidationErrors=zi,e.endsWith=N,e.enforceCacheSizeLimit=function(e){ae(),te&&te.then(t=>{t.keys().then(n=>{for(let r=0;ro&&(r+=(e[i]-o)*(e[i]-o)),t[i]0){const e=180/r;Ws(f,f,[e/u+1,0,0,0,e/c+1,0,-.5*e/h,.5*e/d,1])}return f[2]=l,f[5]=e.x,f[8]=e.y,f},e.getImage=ye,e.getJSON=function(e,t){return de(z(e,{type:"json"}),t)},e.getLatitudinalLod=function(e){const t=ku-5;e=C(e,-t,t)/t*90;const n=Math.pow(Math.abs(Math.sin(w(e))),3);return Math.round(n*(Ul.length-1))},e.getMapSessionAPI=Fe,e.getPerformanceMeasurement=qe,e.getProjection=gp,e.getRTLTextPluginStatus=ta,e.getReferrer=he,e.getTilePoint=function(e,{x:t,y:n},r=0){return new v(((t-r)*e.scale-e.x)*Vs,(n*e.scale-e.y)*Vs)},e.getTileVec3=function(e,t,n=0){return sl(((t.x-n)*e.scale-e.x)*Vs,(t.y*e.scale-e.y)*Vs,Su(t.z,t.y))},e.getVideo=function(e,t){const r=n.document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(let t=0;t{}}},e.globeCenterToScreenPoint=function(e){const t=[0,0,0],n=Xs(new Float64Array(16));return Ys(n,e.pixelMatrix,e.globeMatrix),yl(t,t,n),new v(t[0],t[1])},e.globeDenormalizeECEF=su,e.globeECEFOrigin=function(e,t){const n=[0,0,0];return yl(n,n,au(Hl(t.canonical))),yl(n,n,e),n},e.globeMetersToEcef=$l,e.globeNormalizeECEF=au,e.globePixelsToTileUnits=function(e,t){return Vs/(512*Math.pow(2,e))*iu(Hl(t))},e.globePoleMatrixForTile=function(e,t,n){const r=Xs(new Float64Array(16)),i=(t/(1<0;return 0===r&&!i&&!a&&o},e.identity=Xs,e.identity$1=Cl,e.invert=Hs,e.isFullscreen=function(){return!!n.document.fullscreenElement||!!n.document.webkitFullscreenElement},e.isLngLatBehindGlobe=hu,e.isMapAuthenticated=function(e){return je.has(e)},e.isMapboxURL=xe,e.isSafariWithAntialiasingBug=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!K(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.latFromMercatorY=Tu,e.latLngToECEF=nu,e.len=El,e.length=al,e.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},e.lngFromMercatorX=Eu,e.loadVectorTile=Cm,e.makeRequest=de,e.mapValue=function(e,t,n,r,i){return C((e-t)/(n-t)*(i-r)+r,r,i)},e.mercatorScale=Mu,e.mercatorXfromLng=xu,e.mercatorYfromLat=bu,e.mercatorZfromAltitude=wu,e.mul=rl,e.mul$1=wl,e.multiply=Ys,e.multiply$1=Ws,e.multiply$2=cl,e.nextPowerOfTwo=B,e.normalize=ml,e.normalize$1=Pl,e.normalize$2=Sl,e.number=On,e.ortho=function(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=(a+o)*u,e[15]=1,e},e.pbf=wd,e.perspective=function(e,t,n,r,i){var o,a=1/Math.tan(t/2);return e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(e[10]=(i+r)*(o=1/(r-i)),e[14]=2*i*r*o):(e[10]=-1,e[14]=-2*r),e},e.pick=function(e,t){const n={};for(let r=0;r0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!hu(e,new yu(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!hu(e,new yu(e.center.lat,-90))]},e.polygonContainsPoint=Yu,e.polygonIntersectsBox=Ku,e.polygonIntersectsPolygon=Uu,e.polygonizeBounds=function(e,t,n=0,r=!0){const i=new v(n,n),o=e.sub(i),a=t.add(i),s=[o,new v(a.x,o.y),a,new v(o.x,a.y)];return r&&s.push(o.clone()),s},e.posAttributes=Dl,e.postMapLoadEvent=Le,e.postPerformanceEvent=Re,e.postTurnstileEvent=Oe,e.potpack=Xd,e.prevPowerOfTwo=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.radToDeg=E,e.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.registerForPluginStateChange=function(e){return e({pluginStatus:Yo,pluginURL:Ko}),ea.on("pluginStateChange",e),e},e.removeAuthState=function(e){je.delete(e)},e.renderColorRamp=gc,e.resample=Iu,e.rotateX=Qs,e.rotateX$1=Al,e.rotateY=el,e.rotateY$1=Il,e.rotateZ=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(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[0]=o*i+u*r,e[1]=a*i+c*r,e[2]=s*i+h*r,e[3]=l*i+d*r,e[4]=u*i-o*r,e[5]=c*i-a*r,e[6]=h*i-s*r,e[7]=d*i-l*r,e},e.rotateZ$1=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+i*s,e[1]=i*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e},e.scale=Js,e.scale$1=Tl,e.scale$2=fl,e.scaleAndAdd=pl,e.set=function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},e.setCacheLimits=function(e,t){re=e,ie=t},e.setColumn=function(e,t,n){e[4*t+0]=n[0],e[4*t+1]=n[1],e[4*t+2]=n[2],e[4*t+3]=n[3]},e.setRTLTextPlugin=function(e,t,n=!1){if(Yo===Zo||Yo===Wo||Yo===Xo)throw new Error("setRTLTextPlugin cannot be called multiple times.");Ko=He.resolveURL(e),Yo=Zo,Ho=t,Qo(),n||na()},e.smoothstep=A,e.spec=tt,e.squaredLength=function(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},e.storeAuthState=function(e,t){t?je.add(e):je.delete(e)},e.sub=bl,e.subtract=ul,e.symbolSize=gd,e.tileAABB=function(e,t,n,r,i,o,a,s,l){if("globe"===l.name)return function(e,t,n){const r=t/e.worldSize,i=e.globeMatrix;if(n.z<=1){const e=Hl(n).getCorners();return Jl(e,i,r),jl.fromPoints(e)}const o=Ql(n),a=eu(o);Jl(a,i,r);const s=Number.MAX_VALUE,l=[-s,-s,-s],u=[s,s,s];if(o.contains(e.center)){for(const e of a)hl(u,u,e),dl(l,l,e);l[2]=0;const t=e.point,n=[t.x*r,t.y*r,0];return hl(u,u,n),dl(l,l,n),new jl(u,l)}const c=[i[12]*r,i[13]*r,i[14]*r],h=o.getCenter(),d=C(e.center.lat,-ku,ku),f=C(h.lat,-ku,ku),p=xu(e.center.lng),m=bu(d);let _=p-xu(h.lng);const g=m-bu(f);_>.5?_-=1:_<-.5&&(_+=1);let y=0;Math.abs(_)>Math.abs(g)?y=_>=0?1:3:(y=g>=0?0:2,pl(c,c,[i[4]*r,i[5]*r,i[6]*r],-Math.sin(w(g>=0?o.getSouth():o.getNorth()))*Nl));const v=a[y],x=a[(y+1)%4],b=new Wl(v,x,c),E=[Xl(b,0)||v[0],Xl(b,1)||v[1],Xl(b,2)||v[2]],T=uu(e.zoom);if(T>0){const r=function({x:e,y:t,z:n},r,i,o,a){const s=1/(1<.5?d=-1:f<-.5&&(d=1),l=((l+d)*r-(o*=r))*i+o,u=((u+d)*r-o)*i+o,c=(c*r-(a*=r))*i+a,h=(h*r-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(n,t,e._pixelsPerMercatorPixel,p,m);for(let e=0;eOi(pi(e)),e.validateFog=e=>Oi(Si(e)),e.validateLayer=e=>Oi(yi(e)),e.validateLight=e=>Oi(Ei(e)),e.validateSource=e=>Oi(bi(e)),e.validateStyle=Ai,e.validateTerrain=e=>Oi(Ti(e)),e.values=O,e.vectorTile=uh,e.version=r,e.warnOnce=$,e.window=n,e.wrap=I})),i(0,(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let n="[";for(const r of e)n+=t(r)+",";return n+"]"}let n="{";for(const r of Object.keys(e).sort())n+=`${r}:${t(e[r])},`;return n+"}"}function n(n){let r="";for(const i of e.refProperties)r+="/"+t(n[i]);return r}class r{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,r){for(const n of t)this._layerConfigs[n.id]=n,(this._layers[n.id]=e.createStyleLayer(n)).compileFilter(),this.keyCache[n.id]&&delete this.keyCache[n.id];for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=function(e,t){const r={};for(let i=0;ithis._layers[e.id]),n=t[0];if("none"===n.visibility)continue;const r=n.source||"";let i=this.familiesBySource[r];i||(i=this.familiesBySource[r]={});const o=n.sourceLayer||"_geojsonTileLayer";let a=i[o];a||(a=i[o]=[]),a.push(t)}}}class i{loadTile(t,n){const{uid:r,encoding:i,rawImageData:o,padding:a,buildQuadTree:s}=t,l=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap?this.getImageData(o,a):o;n(null,new e.DEMData(r,l,i,a<1,s))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const n=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),n}}function o(e,t){if(0!==e.length){a(e[0],t);for(var n=1;n=Math.abs(s)?n-l+s:s-l+n,n=l}n+r>=0!=!!t&&e.reverse()}var s=e.getDefaultExportFromCjs((function e(t,n){var r,i=t&&t.type;if("FeatureCollection"===i)for(r=0;r>31}function E(e,t){for(var n=e.loadGeometry(),r=e.type,i=0,o=0,a=n.length,s=0;se},M=Math.fround||(C=new Float32Array(1),e=>(C[0]=+e,C[0]));var C;class A{constructor(e){this.options=Object.assign(Object.create(k),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:n,maxZoom:r}=this.options;t&&console.time("total time");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;const o=[];for(let t=0;t=n;e--){const n=+Date.now();a=this.trees[e]=this._createTree(this._cluster(a,e)),t&&console.log("z%d: %d clusters in %dms",e,a.numItems,+Date.now()-n)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let n=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){const e=this.getClusters([n,r,180,o],t),a=this.getClusters([-180,r,i,o],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(O(n),z(o),O(i),z(r)),l=a.data,u=[];for(const e of s){const t=this.stride*e;u.push(l[t+5]>1?I(l,t,this.clusterProps):this.points[l[t+3]])}return u}getChildren(e){const t=this._getOriginId(e),n=this._getOriginZoom(e),r="No cluster with the specified id.",i=this.trees[n];if(!i)throw new Error(r);const o=i.data;if(t*this.stride>=o.length)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,n-1)),s=i.within(o[t*this.stride],o[t*this.stride+1],a),l=[];for(const t of s){const n=t*this.stride;o[n+4]===e&&l.push(o[n+5]>1?I(o,n,this.clusterProps):this.points[o[n+3]])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,n){const r=[];return this._appendLeaves(r,e,t=t||10,n=n||0,0),r}getTile(e,t,n){const r=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:o,radius:a}=this.options,s=a/o,l=(n-s)/i,u=(n+1+s)/i,c={features:[]};return this._addTileFeatures(r.range((t-s)/i,l,(t+1+s)/i,u),r.data,t,n,i,c),0===t&&this._addTileFeatures(r.range(1-s/i,l,1,u),r.data,i,n,i,c),t===i-1&&this._addTileFeatures(r.range(0,l,s/i,u),r.data,-1,n,i,c),c.features.length?c:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const n=this.getChildren(e);if(t++,1!==n.length)break;e=n[0].properties.cluster_id}return t}_appendLeaves(e,t,n,r,i){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?i+o.point_count<=r?i+=o.point_count:i=this._appendLeaves(e,o.cluster_id,n,r,i):i1;let l,u,c;if(s)l=P(t,e,this.clusterProps),u=t[e],c=t[e+1];else{const n=this.points[t[e+3]];l=n.properties;const[r,i]=n.geometry.coordinates;u=O(r),c=z(i)}const h={type:1,geometry:[[Math.round(this.options.extent*(u*i-n)),Math.round(this.options.extent*(c*i-r))]],tags:l};let d;d=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:n,extent:r,reduce:i,minPoints:o}=this.options,a=n/(r*Math.pow(2,t)),s=e.data,l=[],u=this.stride;for(let n=0;nt&&(f+=s[n+5])}if(f>d&&f>=o){let e,o=r*d,a=c*d,p=-1;const m=((n/u|0)<<5)+(t+1)+this.points.length;for(const r of h){const l=r*u;if(s[l+2]<=t)continue;s[l+2]=t;const c=s[l+5];o+=s[l]*c,a+=s[l+1]*c,s[l+4]=m,i&&(e||(e=this._map(s,n,!0),p=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(s,l)))}s[n+4]=m,l.push(o/f,a/f,1/0,m,-1,f),i&&l.push(p)}else{for(let e=0;e1)for(const e of h){const n=e*u;if(!(s[n+2]<=t)){s[n+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,n){if(e[t+5]>1){const r=this.clusterProps[e[t+6]];return n?Object.assign({},r):r}const r=this.points[e[t+3]].properties,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}}function I(e,t,n){return{type:"Feature",id:e[t+3],properties:P(e,t,n),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),L(e[t+1])]}};var r}function P(e,t,n){const r=e[t+5],i=r>=1e4?Math.round(r/1e3)+"k":r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+6],a=-1===o?{}:Object.assign({},n[o]);return Object.assign(a,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:i})}function O(e){return e/360+.5}function z(e){const t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function L(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function D(e,t,n,r,i,o){var a=i-n,s=o-r;if(0!==a||0!==s){var l=((e-n)*a+(t-r)*s)/(a*a+s*s);l>1?(n=i,r=o):l>0&&(n+=a*l,r+=s*l)}return(a=e-n)*a+(s=t-r)*s}function R(e,t,n,r){var i={id:void 0===e?null:e,type:t,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,n=e.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)B(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r0&&(a+=r?(i*u-l*o)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-o,2))),i=l,o=u}var c=t.length-3;t[2]=1,function e(t,n,r,i){for(var o,a=i,s=r-n>>1,l=r-n,u=t[n],c=t[n+1],h=t[r],d=t[r+1],f=n+3;fa)o=f,a=p;else if(p===a){var m=Math.abs(f-s);mi&&(o-n>3&&e(t,n,o,i),t[o+2]=a,r-o>3&&e(t,o,r,i))}(t,0,c,n),t[c+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function U(e,t,n,r){for(var i=0;i1?1:n}function q(e,t,n,r,i,o,a,s){if(r/=t,o>=(n/=t)&&a=r)return null;for(var l=[],u=0;u=n&&p=r)){var m=[];if("Point"===d||"MultiPoint"===d)$(h,m,n,r,i);else if("LineString"===d)Z(h,m,n,r,i,!1,s.lineMetrics);else if("MultiLineString"===d)X(h,m,n,r,i,!1);else if("Polygon"===d)X(h,m,n,r,i,!0);else if("MultiPolygon"===d)for(var _=0;_=n&&a<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function Z(e,t,n,r,i,o,a){for(var s,l,u=W(e),c=0===i?Y:K,h=e.start,d=0;dn&&(l=c(u,f,p,_,g,n),a&&(u.start=h+s*l)):y>r?v=n&&(l=c(u,f,p,_,g,n),x=!0),v>r&&y<=r&&(l=c(u,f,p,_,g,r),x=!0),!o&&x&&(a&&(u.end=h+s*l),t.push(u),u=W(e)),a&&(h+=s)}var b=e.length-3;f=e[b],p=e[b+1],m=e[b+2],(y=0===i?f:p)>=n&&y<=r&&H(u,f,p,m),b=u.length-3,o&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&H(u,u[0],u[1],u[2]),u.length&&t.push(u)}function W(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function X(e,t,n,r,i,o){for(var a=0;aa.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function re(e,t,n,r){var i=t.geometry,o=t.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s0&&t.size<(i?a:r))n.numPoints+=t.length/3;else{for(var s=[],l=0;la)&&(n.numSimplified++,s.push(t[l]),s.push(t[l+1])),n.numPoints++;i&&function(e,t){for(var n=0,r=0,i=e.length,o=i-2;r0===t)for(r=0,i=e.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(e,t){var n=[];if("FeatureCollection"===e.type)for(var r=0;r1&&console.time("creation"),d=this.tiles[h]=ne(e,t,n,r,l),this.tileCoords.push({z:t,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,n,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(d.source=e,i){if(t===l.maxZoom||t===i)continue;var p=1<1&&console.time("clipping");var m,_,g,y,v,x,b=.5*l.buffer/l.extent,w=.5-b,E=.5+b,T=1+b;m=_=g=y=null,v=q(e,c,n-b,n+E,0,d.minX,d.maxX,l),x=q(e,c,n+w,n+T,0,d.minX,d.maxX,l),e=null,v&&(m=q(v,c,r-b,r+E,1,d.minY,d.maxY,l),_=q(v,c,r+w,r+T,1,d.minY,d.maxY,l),v=null),x&&(g=q(x,c,r-b,r+E,1,d.minY,d.maxY,l),y=q(x,c,r+w,r+T,1,d.minY,d.maxY,l),x=null),u>1&&console.timeEnd("clipping"),s.push(m||[],t+1,2*n,2*r),s.push(_||[],t+1,2*n,2*r+1),s.push(g||[],t+1,2*n+1,2*r),s.push(y||[],t+1,2*n+1,2*r+1)}}},oe.prototype.getTile=function(e,t,n){var r=this.options,i=r.extent,o=r.debug;if(e<0||e>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",e,t,n);for(var l,u=e,c=t,h=n;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[ae(u,c,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",u,c,h),o>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,e,t,n),o>1&&console.timeEnd("drilling down"),this.tiles[s]?ee(this.tiles[s],i):null):null};class le extends e.VectorTileWorkerSource{constructor(e,t,n,r,i){super(e,t,n,r,se),i&&(this.loadGeoJSON=i)}loadData(t,n){const r=t&&t.request,i=r&&r.collectResourceTiming;this.loadGeoJSON(t,(o,a)=>{if(o||!a)return n(o);if("object"!=typeof a)return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{s(a,!0);try{if(t.filter){const n=e.createExpression(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));const r=a.features.filter(e=>n.value.evaluate({zoom:0},e));a={type:"FeatureCollection",features:r}}this._geoJSONIndex=t.cluster?new A(function({superclusterOptions:t,clusterProperties:n}){if(!n||!t)return t;const r={},i={},o={accumulated:null,zoom:0},a={properties:null},s=Object.keys(n);for(const t of s){const[o,a]=n[t],s=e.createExpression(a),l=e.createExpression("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=s.value,i[t]=l.value}return t.map=e=>{a.properties=e;const t={};for(const e of s)t[e]=r[e].evaluate(o,a);return t},t.reduce=(e,t)=>{a.properties=t;for(const t of s)o.accumulated=e[t],e[t]=i[t].evaluate(o,a)},t}(t)).load(a.features):function(e,t){return new oe(e,t)}(a,t.geojsonVtOptions)}catch(o){return n(o)}this.loaded={};const l={};if(i){const n=e.getPerformanceMeasurement(r);n&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(n)))}n(null,l)}})}reloadTile(e,t){const n=this.loaded;return n&&n[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,n){if(t.request)e.getJSON(t.request,n);else{if("string"!=typeof t.data)return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(t.data))}catch(e){return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class ue{constructor(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:"mercator"}),this.workerSourceTypes={vector:e.VectorTileWorkerSource,geojson:le},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.plugin.isParsed())throw new Error("RTL text plugin already registered.");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,n){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],n()}checkIfReady(e,t,n){n()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,n){this.isSpriteLoaded[t]=n;for(const r in this.workerSources[t]){const i=this.workerSources[t][r];for(const t in i)i[t]instanceof e.VectorTileWorkerSource&&(i[t].isSpriteLoaded=n,i[t].fire(new e.Event("isSpriteLoaded")))}}setImages(e,t,n){this.availableImages[e]=t;for(const n in this.workerSources[e]){const r=this.workerSources[e][n];for(const e in r)r[e].availableImages=t}n()}enableTerrain(e,t,n){this.terrain=t,n()}setProjection(t,n){this.projections[t]=e.getProjection(n)}setLayers(e,t,n){this.getLayerIndex(e).replace(t),n()}updateLayers(e,t,n){this.getLayerIndex(e).update(t.layers,t.removedIds),n()}loadTile(t,n,r){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).loadTile(i,r)}loadDEMTile(t,n,r){const i=this.enableTerrain?e.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(t,n.source).loadTile(i,r)}reloadTile(t,n,r){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).reloadTile(i,r)}abortTile(e,t,n){this.getWorkerSource(e,t.type,t.source).abortTile(t,n)}removeTile(e,t,n){this.getWorkerSource(e,t.type,t.source).removeTile(t,n)}removeSource(e,t,n){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const r=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,n):n()}loadWorkerSource(e,t,n){try{this.self.importScripts(t.url),n()}catch(e){n(e.toString())}}syncRTLPluginState(t,n,r){try{e.plugin.setState(n);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const n=e.plugin.isParsed();r(n?void 0:new Error("RTL Text Plugin failed to import scripts from "+t),n)}}catch(e){r(e.toString())}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new r),t}getWorkerSource(e,t,n){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][n]){const r={send:(t,n,r,i,o,a)=>{this.actor.send(t,n,r,e,o,a)},scheduler:this.actor.scheduler};this.workerSources[e][t][n]=new this.workerSourceTypes[t](r,this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])}return this.workerSources[e][t][n]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new i),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,n){e.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(e,t,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new ue(self)),ue})),i(0,(function(e){function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let r=0;r{e.window.removeEventListener("click",d,!0)},0)}function p(e,t){const n=e.getBoundingClientRect();return g(e,n,t)}function m(e,t){const n=e.getBoundingClientRect(),r=[];for(let i=0;i=0?0:t.button}function g(t,n,r){const i=t.offsetWidth===n.width?1:t.offsetWidth/n.width;return new e.Point((r.clientX-n.left)*i,(r.clientY-n.top)*i)}function y(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*o-i*r;return a?(e[0]=o*(a=1/a),e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e):null}function v(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class x extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(t,n){let r=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(n.content,n)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let n=0;for(const r of e){if(r[0]{this.ready=!0})}broadcast(t,n,r){e.asyncAll(this.actors,(e,r)=>{e.send(t,n,r)},r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}function I(t,n,r){return n*(e.EXTENT/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}A.Actor=e.Actor;class P{constructor(e,t,n,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=n,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(t,n){let r,i;if(t instanceof e.Point||"number"==typeof t[0]){const o=e.Point.convert(t);r=[o],i=n.isPointAboveHorizon(o)}else{const o=e.Point.convert(t[0]),a=e.Point.convert(t[1]);r=[o,a],i=e.polygonizeBounds(o,a).every(e=>n.isPointAboveHorizon(e))}return new P(r,n.getCameraPoint(),i,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.Point(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=r.x?i[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(i[3]=this.cameraPoint)),e.bufferConvexPolygon(i,t)}bufferedCameraGeometryGlobe(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.Point(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,r,t),o=this.cameraPoint.clone();switch(3*((o.y>n.y)+(o.y>r.y))+((o.x>n.x)+(o.x>r.x))){case 0:i[0]=o,i[4]=o.clone();break;case 1:i.splice(1,0,o);break;case 2:i[1]=o;break;case 3:i.splice(4,0,o);break;case 5:i.splice(2,0,o);break;case 6:i[3]=o;break;case 7:i.splice(3,0,o);break;case 8:i[2]=o}return i}containsTile(t,n,r,i=0){const o=t.queryPadding/n._pixelsPerMercatorPixel+1,a=r?this._bufferedCameraMercator(o,n):this._bufferedScreenMercator(o,n);let s=t.tileID.wrap+(a.unwrapped?i:0);const l=a.polygon.map(n=>e.getTilePoint(t.tileTransform,n,s));if(!e.polygonIntersectsBox(l,0,0,e.EXTENT,e.EXTENT))return;s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?i:0);const u=this.screenGeometryMercator.polygon.map(n=>e.getTileVec3(t.tileTransform,n,s)),c=u.map(t=>new e.Point(t[0],t[1])),h=n.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),d=e.getTileVec3(t.tileTransform,h,s),f=u.map(t=>{const n=e.sub(t,t,d);return e.normalize(n,n),new e.Ray(d,n)}),p=I(t,1,n.zoom)*n._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:c,tilespaceRays:f,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.getBounds(l),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var m}_bufferedScreenMercator(e,t){const n=L(e);if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[n]=r,r}}_bufferedCameraMercator(e,t){const n=L(e);if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[n]=r,r}}_projectAndResample(t,n){const r=function(t,n){const r=e.multiply([],n.pixelMatrix,n.globeMatrix),i=[0,-e.GLOBE_RADIUS,0,1],o=[0,e.GLOBE_RADIUS,0,1],a=[0,0,0,1];e.transformMat4$1(i,i,r),e.transformMat4$1(o,o,r),e.transformMat4$1(a,a,r);const s=new e.Point(i[0]/i[3],i[1]/i[3]),l=new e.Point(o[0]/o[3],o[1]/o[3]),u=e.polygonContainsPoint(t,s)&&i[3]1?O(t.slice(0,d),n):[],m=dnew e.Point(z(t.x),t.y)),m=m.map(t=>new e.Point(z(t.x),t.y));const _=[...p];0===_.length&&_.push(m[m.length-1]);const g=e.number(_[_.length-1].y,(0===m.length?p[0]:m[0]).y,f);let y;return y=u?[new e.Point(0,g),new e.Point(0,0),new e.Point(1,0),new e.Point(1,g)]:[new e.Point(1,g),new e.Point(1,1),new e.Point(0,1),new e.Point(0,g)],_.push(...y),0===m.length?_.push(p[0]):_.push(...m),{polygon:_.map(t=>new e.MercatorCoordinate(t.x,t.y)),unwrapped:!1}}(t,n);if(r)return r;const i=function(t,n){let r=!1,i=-1/0,o=0;for(let e=0;ei&&(i=t[e].x,o=e);for(let e=0;e.5&&(i.x{e.x-=1}),{polygon:t,unwrapped:r}}(O(t,n).map(t=>new e.Point(z(t.x),t.y)),n);return{polygon:i.polygon.map(t=>new e.MercatorCoordinate(t.x,t.y)),unwrapped:i.unwrapped}}}function O(t,n){return e.resample(t,e=>{const t=n.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function z(e){return e<0?1+e%1:e%1}function L(e){return 100*e|0}function D(t,n,r,i,o){const a=function(r,i){if(r)return o(r);if(i){t.url&&i.tiles&&t.tiles&&delete t.tiles;const r=e.pick(e.extend(i,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);i.vector_layers&&(r.vectorLayers=i.vector_layers,r.vectorLayerIds=r.vectorLayers.map(e=>e.id)),r.tiles=n.canonicalizeTileset(r,t.url),o(null,r)}};return t.url?e.getJSON(n.transformRequest(n.normalizeSourceURL(t.url,null,r,i),e.ResourceType.Source),a):e.exported.frame(()=>a(null,t))}class R{constructor(t,n,r){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=r||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),r=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*n),i=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*n),o=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*n),a=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*n);return t.x>=r&&t.x=i&&t.y{this._tileJSONRequest=null,this._loaded=!0,i?(n&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: "+n),r&&2!==r.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: "+r),this.fire(new e.ErrorEvent(i))):o&&(e.extend(this,o),o.bounds&&(this.tileBounds=new R(o.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.extend({},this._options)}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(r,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(i.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=n:t.request=t.actor.send("reloadTile",i,o.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",i,o.bind(this),void 0,!0);else{const n=e.loadVectorTile.call({deduped:this._deduped},i,(e,n)=>{e||!n?o.call(this,e):(i.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},t.actor&&t.actor.send("loadTile",i,o.bind(this),void 0,!0))},!0);t.request={cancel:n}}function o(r,i){return delete t.request,t.aborted?n(null):r&&404!==r.status?n(r):(i&&i.resourceTiming&&(t.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&i&&t.setExpiryData(i),t.loadVectorData(i,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class ke extends e.Evented{constructor(t,n,r,i){super(),this.id=t,this.dispatcher=r,this.setEventedParent(i),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.extend({type:"raster"},n),e.extend(this,e.pick(n,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=D(this._options,this.map._requestManager,null,null,(n,r)=>{this._tileJSONRequest=null,this._loaded=!0,n?this.fire(new e.ErrorEvent(n)):r&&(e.extend(this,r),r.bounds&&(this.tileBounds=new R(r.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(r.tiles),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const r=e.exported.devicePixelRatio>=2,i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(i,e.ResourceType.Tile),(r,i,o,a)=>(delete t.request,t.aborted?(t.state="unloaded",n(null)):r?(t.state="errored",n(r)):i?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:a}),t.setTexture(i,this.map.painter),t.state="loaded",e.cacheEntryPossiblyAdded(this.dispatcher),void n(null)):n(null)))}static loadTileData(e,t,n){e.setTexture(t,n)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Me(t,n,r,i,o,a,s,l){const u=[t,r,o,n,i,a,1,1,1],c=[s,l,1],h=e.adjoint([],u),[d,f,p]=e.transformMat3(c,c,e.transpose(h,h));return e.multiply$1(u,[d,0,0,0,f,0,0,0,p],u)}class Ce extends e.Evented{constructor(e,t,n,r){super(),this.id=e,this.dispatcher=n,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(t,n){this._loaded=n||!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),(n,r)=>{if(this._imageRequest=null,this._loaded=!0,n)this.fire(new e.ErrorEvent(n));else if(r){const{HTMLImageElement:n}=e.window;this.image=r instanceof n?e.exported.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}})}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const n=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let n=1/0,r=1/0,i=-1/0,o=-1/0;for(const e of t)n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x),o=Math.max(o,e.y);const a=Math.max(i-n,o-r),s=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),l=Math.pow(2,s);return new e.CanonicalTileID(s,Math.floor((n+i)/2*l),Math.floor((r+o)/2*l))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const n=e.tileTransform(this.tileID,this.map.transform.projection),[r,i,o,a]=this.coordinates.map(t=>{const r=n.projection.project(t[0],t[1]);return e.getTilePoint(n,r)._round()});this.perspectiveTransform=function(t,n,r,i,o,a,s,l,u,c){const h=Me(0,0,t,0,0,n,t,n),d=Me(r,i,o,a,s,l,u,c);return e.multiply$1(d,e.adjoint(h,h),d),[d[6]/d[8]*t/e.EXTENT,d[7]/d[8]*n/e.EXTENT]}(this.width,this.height,r.x,r.y,i.x,i.y,a.x,a.y,o.x,o.y);const s=this._boundsArray=new e.StructArrayLayout4i8;s.emplaceBack(r.x,r.y,0,0),s.emplaceBack(i.x,i.y,e.EXTENT,0),s.emplaceBack(a.x,a.y,0,e.EXTENT),s.emplaceBack(o.x,o.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(s,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,n=t.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Ae={vector:Se,raster:ke,"raster-dem":class extends ke{constructor(t,n,r,i){super(t,n,r,i),this.type="raster-dem",this.maxzoom=22,this._options=e.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(e,r){e&&(t.state="errored",n(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",n(null))}t.request=e.getImage(this.map._requestManager.transformRequest(r,e.ResourceType.Tile),function(r,o,a,s){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(r)t.state="errored",n(r);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:s});const n=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap&&(null==ae&&(ae=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.window.createImageBitmap),ae),r=1-(o.width-e.prevPowerOfTwo(o.width))/2;r<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=n?o:e.exported.getImageData(o,r),u={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:r};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",u,i.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const n=t.canonical,r=Math.pow(2,n.z),i=(n.x-1+r)%r,o=0===n.x?t.wrap-1:t.wrap,a=(n.x+1+r)%r,s=n.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,o,n.z,i,n.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,n.z,a,n.y).key]={backfilled:!1},n.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,o,n.z,i,n.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,n.z,a,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(t.resourceTiming=n.resourceTiming[this.id]),this.fire(new e.Event("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(t,n){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(r,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(e,i)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):e?n(e):(t.loadVectorData(i,this.map.painter,"reloadTile"===r),n(null))),void 0,"loadTile"===r)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Ce{constructor(e,t,n,r){super(e,t,n,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,e.ResourceType.Source).url);e.getVideo(this.urls,(t,n)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):n&&(this.video=n,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(t){if(this.video){const n=this.video.seekable;tn.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError("sources."+this.id,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ce,canvas:class extends Ce{constructor(t,n,r,i){super(t,n,r,i),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.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(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const n=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(n,this.canvas,n.gl.RGBA,{premultiply:!0}),this._prepareData(n)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.Evented{constructor(t,n,r,i){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=n,this.setEventedParent(i),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new R(this._implementation.bounds,this.minzoom,this.maxzoom)),n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(n,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:n,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:n,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const{x:r,y:i,z:o}=t.tileID.canonical,a=new e.window.AbortController;t.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:o},{signal:a.signal})).then(function(r){return delete t.request,t.aborted?(t.state="unloaded",n(null)):void 0===r?(t.state="errored",n(null)):null===r?(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",n(null)):function(t){return t instanceof e.window.ImageData||t instanceof e.window.HTMLCanvasElement||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLImageElement}(r)?(this.loadTileData(t,r),t.state="loaded",void n(null)):(t.state="errored",n(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(e=>{20!==e.code&&(t.state="errored",n(e))}),t.request.cancel=()=>a.abort()}loadTileData(e,t){ke.loadTileData(e,t,this._map.painter)}unloadTileData(e){ke.unloadTileData(e,this._map.painter)}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:n,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:n,z:r})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Ie=function(t,n,r,i){const o=new Ae[n.type](t,n,r,i);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.bindAll(["load","abort","unload","serialize","prepare"],o),o};function Pe(t,n){const r=e.identity([]);return e.scale(r,r,[.5*t.width,.5*-t.height,1]),e.translate(r,r,[1,-1,0]),e.multiply(r,r,t.calculateProjMatrix(n.toUnwrapped())),Float32Array.from(r)}function Oe(e,t,n,r,i,o,a,s=!1){const l=e.tilesIn(r,a,s);l.sort(Le);const u=[];for(const r of l)u.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,n,e._state,r,i,o,Pe(e.transform,r.tile.tileID),s)});const c=function(e){const t={},n={};for(const r of e){const e=r.queryResults,i=r.wrappedTileID,o=n[i]=n[i]||{};for(const n in e){const r=e[n],i=o[n]=o[n]||{},a=t[n]=t[n]||[];for(const e of r)i[e.featureIndex]||(i[e.featureIndex]=!0,a.push(e))}}return t}(u);for(const t in c)c[t].forEach(t=>{const n=t.feature,r=n.layer;r&&"background"!==r.type&&"sky"!==r.type&&(n.source=r.source,r["source-layer"]&&(n.sourceLayer=r["source-layer"]),n.state=void 0!==n.id?e.getFeatureState(r["source-layer"],n.id):{})});return c}function ze(e,t){const n=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],i={};for(let e=0;e{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Re]}numActive(){return Object.keys(this.active).length}}let Fe;function je(){return Fe||(Fe=new Be),Fe}function Ne(t,n){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return e.refProperties.forEach(e=>{e in n&&(r[e]=n[e])}),r}function Ue(e){e=e.slice();const t=Object.create(null);for(let n=0;n0?(i-a)/s:0;return this.points[o].mult(1-l).add(this.points[n].mult(l))}}class Ke{constructor(e,t,n){const r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let e=0;ethis.width||r<0||t>this.height)return!i&&[];const a=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(let e=0;e0:a}_queryCircle(e,t,n,r,i){const o=e-n,a=e+n,s=t-n,l=t+n;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];const u=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,u,{hitTest:r,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}},i),r?u.length>0:u}query(e,t,n,r,i){return this._query(e,t,n,r,!1,i)}hitTest(e,t,n,r,i){return this._query(e,t,n,r,!0,i)}hitTestCircle(e,t,n,r){return this._queryCircle(e,t,n,!0,r)}_queryCell(e,t,n,r,i,o,a,s){const l=a.seenUids,u=this.boxCells[i];if(null!==u){const i=this.bboxes;for(const c of u)if(!l.box[c]){l.box[c]=!0;const u=4*c;if(e<=i[u+2]&&t<=i[u+3]&&n>=i[u+0]&&r>=i[u+1]&&(!s||s(this.boxKeys[c]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[c],x1:i[u],y1:i[u+1],x2:i[u+2],y2:i[u+3]})}}}const c=this.circleCells[i];if(null!==c){const i=this.circles;for(const u of c)if(!l.circle[u]){l.circle[u]=!0;const c=3*u;if(this._circleAndRectCollide(i[c],i[c+1],i[c+2],e,t,n,r)&&(!s||s(this.circleKeys[u]))){if(a.hitTest)return o.push(!0),!0;{const e=i[c],t=i[c+1],n=i[c+2];o.push({key:this.circleKeys[u],x1:e-n,y1:t-n,x2:e+n,y2:t+n})}}}}}_queryCellCircle(e,t,n,r,i,o,a,s){const l=a.circle,u=a.seenUids,c=this.boxCells[i];if(null!==c){const e=this.bboxes;for(const t of c)if(!u.box[t]){u.box[t]=!0;const n=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!s||s(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[i];if(null!==h){const e=this.circles;for(const t of h)if(!u.circle[t]){u.circle[t]=!0;const n=3*t;if(this._circlesCollide(e[n],e[n+1],e[n+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,n,r,i,o,a,s){const l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),c=this._convertToXCellCoord(n),h=this._convertToYCellCoord(r);for(let d=l;d<=c;d++)for(let l=u;l<=h;l++)if(i.call(this,e,t,n,r,this.xCellCount*l+d,o,a,s))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,n,r,i,o){const a=r-e,s=i-t,l=n+o;return l*l>a*a+s*s}_circleAndRectCollide(e,t,n,r,i,o,a){const s=(o-r)/2,l=Math.abs(e-(r+s));if(l>s+n)return!1;const u=(a-i)/2,c=Math.abs(t-(i+u));if(c>u+n)return!1;if(l<=s||c<=u)return!0;const h=l-s,d=c-u;return h*h+d*d<=n*n}}const Je=0,Qe=1,et=2,tt=Math.tan(85*Math.PI/180);function nt(t,n,r,i,o,a,s){const l=e.create();if(r)if("globe"===a.name){const t=e.calculateGlobeLabelMatrix(o,n);e.multiply(l,l,t)}else{const t=y([],s);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],i||e.rotateZ(l,l,o.angle)}else e.multiply(l,o.labelPlaneMatrix,t);return l}function rt(e,t,n,r,i,o,a){const s=nt(e,t,n,r,i,o,a);return"globe"===o.name&&n||(s[2]=s[6]=s[10]=s[14]=0),s}function it(t,n,r,i,o,a,s){if(r){if("globe"===a.name){const l=nt(t,n,r,i,o,a,s);return e.invert(l,l),e.multiply(l,t,l),l}{const n=e.clone(t),r=e.identity([]);return r[0]=s[0],r[1]=s[1],r[4]=s[2],r[5]=s[3],e.multiply(n,n,r),i||e.rotateZ(n,n,-o.angle),n}}return o.glCoordMatrix}function ot(t,n,r,i){const o=[t,n,r,1];r?e.transformMat4$1(o,o,i):_t(o,o,i);const a=o[3];return o[0]/=a,o[1]/=a,o[2]/=a,o}function at(e,t){return Math.min(.5+e/t*.5,1.5)}function st(e,t){const n=e[0]/e[3],r=e[1]/e[3];return n>=-t[0]&&n<=t[0]&&r>=-t[1]&&r<=t[1]}function lt(t,n,r,i,o,a,s,l,u,c){const h=r.transform,d=i?t.textSizeData:t.iconSizeData,f=e.evaluateSizeForZoom(d,r.transform.zoom),p="globe"===h.projection.name,m=[256/r.width*2+1,256/r.height*2+1],_=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let g=null;p&&(g=i?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=r.transform.width/r.transform.height;let b,w=!1;for(let i=0;iMath.abs(r)?{useVertical:!0}:t===e.WritingMode.vertical?i>0?{needsFlipping:!0}:null:n!==Je&&function(e,t){return 0===e||Math.abs(t/e)>tt}(r,i)?n===Qe?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function ht(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v){const x=n/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x,{lineStartIndex:E,glyphStartIndex:T,numGlyphs:S,segment:k,writingMode:M,flipState:C}=t,A=E+t.lineLength,I=t=>{if(h){const[n,r,i]=t.up,o=c.length;e.updateGlobeVertexNormal(h,o+0,n,r,i),e.updateGlobeVertexNormal(h,o+1,n,r,i),e.updateGlobeVertexNormal(h,o+2,n,r,i),e.updateGlobeVertexNormal(h,o+3,n,r,i)}const[n,r,i]=t.point;e.addDynamicAttributes(c,n,r,i,t.angle)};if(S>1){const e=ut(x,l,b,w,r,d,f,t,u,a,p,_,!1,g,y,v);if(!e)return{notEnoughRoom:!0};if(i&&!r){let[n,r,i]=e.first.point,[o,a,l]=e.last.point;[n,r]=ot(n,r,i,s),[o,a]=ot(o,a,l,s);const u=ct(M,C,(o-n)*m,a-r);if(t.flipState=u&&u.needsFlipping?Qe:et,u)return u}I(e.first);for(let e=T+1;e0?a:ft(f,i,n,1,o,void 0,g,y.canonical),l=ct(M,C,(s[0]-n[0])*m,s[1]-n[1]);if(t.flipState=l&&l.needsFlipping?Qe:et,l)return l}const n=pt(x*l.getoffsetX(T),b,w,r,d,f,k,E,A,u,a,p,_,!1,!1,g,y,v);if(!n)return{notEnoughRoom:!0};I(n)}return{}}function dt(e,t,n,r,i){const{x:o,y:a,z:s}=r.projectTilePoint(e.x,e.y,t);if(!i)return ot(o,a,s,n);const[l,u,c]=i(e);return ot(o+l,a+u,s+c,n)}function ft(t,n,r,i,o,a,s,l){const u=dt(t.sub(n)._unit()._add(t),l,o,s,a);return e.sub(u,r,u),e.normalize(u,u),e.scaleAndAdd(u,r,u,i)}function pt(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y){const v=i?t-n:t+n;let x=v>0?1:-1,b=0;i&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=l+s+(x>0?0:1)|0,E=o,T=o,S=0,k=0;const M=Math.abs(v),C=[],A=[];let I=a,P=I;const O=()=>ft(P,I,T,M-S+1,h,f,_,g.canonical);for(;S+k<=M;){if(w+=x,w=u)return null;if(T=E,P=I,C.push(T),p&&A.push(P),I=new e.Point(c.getx(w),c.gety(w)),E=d[w],!E){const e=dt(I,g.canonical,h,_,f);E=e[3]>0?d[w]=e:O()}S+=k,k=e.distance(T,E)}m&&f&&(d[w]&&(E=O(),k=e.distance(T,E)),d[w]=E);const z=(M-S)/k,L=I.sub(P)._mult(z)._add(P),D=e.sub([],E,T),R=e.scaleAndAdd([],T,D,z);let B=[0,0,1],F=D[0],j=D[1];if(y&&(B=_.upVector(g.canonical,L.x,L.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],n=e.cross([],B,t);e.normalize(t,t),e.normalize(n,n),F=e.dot(D,t),j=e.dot(D,n)}if(r){const t=e.cross([],B,D);e.normalize(t,t),e.scaleAndAdd(R,R,t,r*x)}const N=b+Math.atan2(j,F);return C.push(R),p&&A.push(L),{point:R,angle:N,path:C,tilePath:A,up:B}}function mt(e,t){const n=t.length,r=n+4*e;t.resize(r),t.float32.fill(-1/0,4*n,4*r)}function _t(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e[3]=n[3]*r+n[7]*i+n[15],e}const gt=100;class yt{constructor(e,t,n=new Ke(e.width+200,e.height+200,25),r=new Ke(e.width+200,e.height+200,25)){this.transform=e,this.grid=n,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+gt,this.screenBottomBoundary=e.height+gt,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,n,r,i,o,a,s){let l=n.projectedAnchorX,u=n.projectedAnchorY,c=n.projectedAnchorZ;const h=n.elevation,d=n.tileID,f=e.getProjection();if(h&&d){const[e,t,r]=f.upVector(d.canonical,n.tileAnchorX,n.tileAnchorY),i=f.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*h*i,u+=t*h*i,c+=r*h*i}const p=this.projectAndGetPerspectiveRatio(a,l,u,c,n.tileID,"globe"===f.name||!!h||this.transform.pitch>0,f),m=o*p.perspectiveRatio,_=(n.x1*t+r.x-n.padding)*m+p.point.x,g=(n.y1*t+r.y-n.padding)*m+p.point.y,y=(n.x2*t+r.x+n.padding)*m+p.point.x,v=(n.y2*t+r.y+n.padding)*m+p.point.y,x=p.perspectiveRatio<=.55||p.occluded;return!this.isInsideGrid(_,g,y,v)||!i&&this.grid.hitTest(_,g,y,v,s)||x?{box:[],offscreen:!1,occluded:p.occluded}:{box:[_,g,y,v],offscreen:this.isOffscreen(_,g,y,v),occluded:!1}}placeCollisionCircles(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m){const _=[],g=this.transform.elevation,y=t.getProjection(),v=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,x=new e.Point(r.tileAnchorX,r.tileAnchorY);let{x:b,y:w,z:E}=y.projectTilePoint(x.x,x.y,m.canonical);if(v){const[e,t,n]=v(x);b+=e,w+=t,E+=n}const T="globe"===y.name,S=this.projectAndGetPerspectiveRatio(s,b,w,E,m,T||!!g||this.transform.pitch>0,y),{perspectiveRatio:k}=S,M=(h?a/k:a*k)/e.ONE_EM,C=ot(b,w,E,l),A=S.signedDistanceFromCamera>0?ut(M,o,r.lineOffsetX*M,r.lineOffsetY*M,!1,C,x,r,i,l,{},g&&!h?v:null,h&&!!g,y,m,h):null;let I=!1,P=!1,O=!0;if(A&&!S.occluded){const t=.5*f*k+p,r=new e.Point(-100,-100),i=new e.Point(this.screenRightBoundary,this.screenBottomBoundary),o=new Ye,{first:a,last:s}=A,l=a.path.length;let h=[];for(let e=l-1;e>=1;e--)h.push(a.path[e]);for(let e=1;e(v&&!T&&(n=v(re[3]<=0)&&(h=[]));let g=[];if(h.length>0){let t=1/0,n=-1/0,o=1/0,a=-1/0;for(const e of h)t=Math.min(t,e[0]),o=Math.min(o,e[1]),n=Math.max(n,e[0]),a=Math.max(a,e[1]);n>=r.x&&t<=i.x&&a>=r.y&&o<=i.y&&(g=[h.map(t=>new e.Point(t[0],t[1]))],(ti.x||oi.y)&&(g=e.clipLine(g,r.x,r.y,i.x,i.y)))}for(const e of g){o.reset(e,.25*t);let r=0;r=o.length<=.5*t?1:Math.ceil(o.paddedLength/m)+1;for(let e=0;e0?(e.transformMat4$1(l,l,t),this.fogState&&o&&"globe"!==s.name&&(u=function(t,n,r,i,o,a){const s=a.calculateFogTileMatrix(o),l=[n,r,i];return e.transformMat4(l,l,s),S(t,l,a.pitch,a._fov)}(this.fogState,n,r,i,o.toUnwrapped(),this.transform)>.9)):_t(l,l,t);const c=l[3];return{point:new e.Point((l[0]/c+1)/2*this.transform.width+gt,(-l[1]/c+1)/2*this.transform.height+gt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/c*.5,1.5),signedDistanceFromCamera:c,occluded:a&&l[2]>c||u}}isOffscreen(e,t,n,r){return n=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function Ct(t,n,r,i,o){const{horizontalAlign:a,verticalAlign:s}=e.getAnchorAlignment(t),l=-(a-.5)*n,u=-(s-.5)*r,c=e.evaluateVariableOffset(t,i);return new e.Point(l+c[0]*o,u+c[1]*o)}function At(t,n,r,i,o){const a=new e.Point(t,n);return r&&a._rotate(i?o:-o),a}class It{constructor(e,t,n,r,i){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new yt(this.transform,i),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Mt(n),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,r,i){const o=r.getBucket(n),a=r.latestFeatureIndex;if(!o||!a||n.id!==o.layerIds[0])return;const s=o.layers[0].layout,l=r.collisionBoxArray,u=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),c=r.tileSize/e.EXTENT,h=r.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(f=r.tileID,p=o.getProjection(),m=this.transform,p.name===this.projection?m.calculateProjMatrix(f.toUnwrapped()):vt(m,p,f));var f,p,m;const _="map"===s.get("text-pitch-alignment"),g="map"===s.get("text-rotation-alignment");n.compileFilter();const y=n.dynamicFilter(),v=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(r),b=rt(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),x);let w=null;if(_){const t=it(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),x);w=e.multiply([],this.transform.labelPlaneMatrix,t)}let E=null;y&&r.latestFeatureIndex&&(E={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new kt(o.bucketInstanceId,a,o.sourceLayerIndex,o.index,r.tileID);const T={bucket:o,layout:s,posMatrix:d,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:E,scale:u,textPixelRatio:c,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(i)for(const e of o.sortKeyRanges){const{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=e;t.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:T})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:T})}attemptAnchorPlacement(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g){const{textOffset0:y,textOffset1:v,crossTileID:x}=h,b=[y,v],w=Ct(e,n,r,b,i),E=this.collisionIndex.placeCollisionBox(f,i,t,At(w.x,w.y,o,a,this.transform.angle),c,s,l,u.predicate);if(m){const e=f.getSymbolInstanceIconSize(g,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(f,e,m,At(w.x,w.y,o,a,this.transform.angle),c,s,l,u.predicate).box.length)return}if(E.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(t=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:b,width:n,height:r,anchor:e,textScale:i,prevAnchor:t},this.markUsedJustification(f,e,h,p),f.allowVerticalPlacement&&(this.markUsedOrientation(f,p,h),this.placedOrientations[x]=p),{shift:w,placedGlyphBoxes:E}}}placeLayerBucketPart(t,n,r,i){const{bucket:o,layout:a,posMatrix:s,textLabelPlaneMatrix:l,labelToScreenMatrix:u,clippingData:c,textPixelRatio:h,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:m,collisionGroup:_}=t.parameters,g=a.get("text-optional"),y=a.get("icon-optional"),v=a.get("text-allow-overlap"),x=a.get("icon-allow-overlap"),b="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),E="none"!==a.get("icon-text-fit"),T="viewport-y"===a.get("symbol-z-order");this.transform.setProjection(o.projection);let S=v&&(x||!o.hasIconData()||y),k=x&&(v||!o.hasTextData()||g);!o.collisionArrays&&f&&o.deserializeCollisionBoxes(f),r&&i&&o.updateCollisionDebugBuffers(this.transform.zoom,f);const M=(t,i,f)=>{const{crossTileID:T,numVerticalGlyphVertices:M}=t;if(c){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let i=null;if(c.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];i=c.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,c.dynamicFilter)(r,i,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.Point(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(c.unwrappedTileID)))return this.placements[T]=new Tt(!1,!1,!1,!0),void n.add(T)}if(n.has(T))return;if(d)return void(this.placements[T]=new Tt(!1,!1,!1));let C=!1,A=!1,I=!0,P=!1,O=!1,z=null,L={box:null,offscreen:null,occluded:null},D={box:null,offscreen:null,occluded:null},R=null,B=null,F=null,j=0,N=0,U=0;f.textFeatureIndex?j=f.textFeatureIndex:t.useRuntimeCollisionCircles&&(j=t.featureIndex),f.verticalTextFeatureIndex&&(N=f.verticalTextFeatureIndex);const V=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const t=this.transform.elevation;(t||e.elevation)&&(e.elevation=t?t.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0)},G=f.textBox;if(G){V(G);const n=n=>{let r=e.WritingMode.horizontal;if(o.allowVerticalPlacement&&!n&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[T];e&&(this.placedOrientations[T]=e,r=e,this.markUsedOrientation(o,r,t))}return r},r=(t,n)=>{if(o.allowVerticalPlacement&&M>0&&f.verticalTextBox){for(const r of o.writingModes)if(r===e.WritingMode.vertical?(L=n(),D=L):L=t(),L&&L.box&&L.box.length)break}else L=t()};if(a.get("text-variable-anchor")){let l=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];l.indexOf(e.anchor)>0&&(l=l.filter(t=>t!==e.anchor),l.unshift(e.anchor))}const u=(e,n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),u=(e.x2-e.x1)*a+2*e.padding,c=(e.y2-e.y1)*a+2*e.padding,d=E&&!x?n:null;d&&V(d);let f={box:[],offscreen:!1,occluded:!1};const g=v?2*l.length:l.length;for(let n=0;n=l.length,t,i,o,r,d,p,m);if(g&&(f=g.placedGlyphBoxes,f&&f.box&&f.box.length)){C=!0,z=g.shift;break}}return f};r(()=>u(G,f.iconBox,e.WritingMode.horizontal),()=>{const t=f.verticalTextBox;return t&&V(t),o.allowVerticalPlacement&&!(L&&L.box&&L.box.length)&&M>0&&t?u(t,f.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),L&&(C=L.box,I=L.offscreen,P=L.occluded);const c=n(!(!L||!L.box));if(!C&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[T];e&&(this.variableOffsets[T]=e,this.markUsedJustification(o,e.anchor,t,c))}}else{const a=(n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),l=this.collisionIndex.placeCollisionBox(o,a,n,new e.Point(0,0),v,h,s,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,r,t),this.placedOrientations[T]=r),l};r(()=>a(G,e.WritingMode.horizontal),()=>{const t=f.verticalTextBox;return o.allowVerticalPlacement&&M>0&&t?(V(t),a(t,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),n(!!(L&&L.box&&L.box.length))}}if(R=L,C=R&&R.box&&R.box.length>0,I=R&&R.offscreen,P=R&&R.occluded,t.useRuntimeCollisionCircles){const n=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),i=e.evaluateSizeForFeature(o.textSizeData,p,n),c=a.get("text-padding");B=this.collisionIndex.placeCollisionCircles(o,v,n,o.lineVertexArray,o.glyphOffsetArray,i,s,l,u,r,w,_.predicate,t.collisionCircleDiameter*i/e.ONE_EM,c,this.retainedQueryData[o.bucketInstanceId].tileID),C=v||B.circles.length>0&&!B.collisionDetected,I=I&&B.offscreen,P=B.occluded}if(f.iconFeatureIndex&&(U=f.iconFeatureIndex),f.iconBox){const n=n=>{V(n);const r=E&&z?At(z.x,z.y,b,w,this.transform.angle):new e.Point(0,0),i=o.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,i,n,r,x,h,s,_.predicate)};D&&D.box&&D.box.length&&f.verticalIconBox?(F=n(f.verticalIconBox),A=F.box.length>0):(F=n(f.iconBox),A=F.box.length>0),I=I&&F.offscreen,O=F.occluded}const q=g||0===t.numHorizontalGlyphVertices&&0===M,$=y||0===t.numIconVertices;if(q||$?$?q||(A=A&&C):C=A&&C:A=C=A&&C,C&&R&&R.box&&this.collisionIndex.insertCollisionBox(R.box,a.get("text-ignore-placement"),o.bucketInstanceId,D&&D.box&&N?N:j,_.ID),A&&F&&this.collisionIndex.insertCollisionBox(F.box,a.get("icon-ignore-placement"),o.bucketInstanceId,U,_.ID),B&&(C&&this.collisionIndex.insertCollisionCircles(B.circles,a.get("text-ignore-placement"),o.bucketInstanceId,j,_.ID),r)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new St);for(let e=0;e=0;--t){const n=e[t];M(o.symbolInstances.get(n),n,o.collisionArrays[n])}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:u),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:u),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:u),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:u)}markUsedOrientation(t,n,r){const i=n===e.WritingMode.horizontal||n===e.WritingMode.horizontalOnly?n:0,o=n===e.WritingMode.vertical?n:0,{leftJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:u}=r,c=t.text.placedSymbolArray;a>=0&&(c.get(a).placedOrientation=i),s>=0&&(c.get(s).placedOrientation=i),l>=0&&(c.get(l).placedOrientation=i),u>=0&&(c.get(u).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},o=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=i[e];o?(this.opacities[e]=new Et(o,r,t.text,t.icon,null,t.clipped),n=n||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Et(null,r,t.text,t.icon,t.skipFade,t.clipped),n=n||t.text||t.icon)}for(const e in i){const t=i[e];if(!this.opacities[e]){const i=new Et(t,r,!1,!1);i.isHidden()||(this.opacities[e]=i,n=n||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);n?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const n=new Set;for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n,r.collisionBoxArray)}}updateBucketOpacities(t,n,r){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const i=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),a=new Et(null,0,!1,!1,!0),s=i.get("text-allow-overlap"),l=i.get("icon-allow-overlap"),u=i.get("text-variable-anchor"),c="map"===i.get("text-rotation-alignment"),h="map"===i.get("text-pitch-alignment"),d="none"!==i.get("icon-text-fit"),f=new Et(null,0,s&&(l||!t.hasIconData()||i.get("icon-optional")),l&&(s||!t.hasTextData()||i.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const p=(e,t,n)=>{for(let r=0;r0||l>0,b=g>0,w=this.placedOrientations[_],E=w===e.WritingMode.vertical,T=w===e.WritingMode.horizontal||w===e.WritingMode.horizontalOnly;if(!x&&!b||v.isHidden()||m++,x){const e=jt(v.text);p(t.text,s,E?Nt:e),p(t.text,l,T?Nt:e);const n=v.text.isHidden(),{leftJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:u}=i,c=t.text.placedSymbolArray,h=n||E?1:0;r>=0&&(c.get(r).hidden=h),o>=0&&(c.get(o).hidden=h),a>=0&&(c.get(a).hidden=h),u>=0&&(c.get(u).hidden=n||T?1:0);const d=this.variableOffsets[_];d&&this.markUsedJustification(t,d.anchor,i,w);const f=this.placedOrientations[_];f&&(this.markUsedJustification(t,"left",i,f),this.markUsedOrientation(t,f,i))}if(b){const e=jt(v.icon),{placedIconSymbolIndex:n,verticalPlacedIconSymbolIndex:r}=i,o=t.icon.placedSymbolArray,a=v.icon.isHidden()?1:0;n>=0&&(p(t.icon,g,E?Nt:e),o.get(n).hidden=a),r>=0&&(p(t.icon,i.numVerticalIconVertices,T?Nt:e),o.get(r).hidden=a)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const n=t.collisionArrays[r];if(n){let r=new e.Point(0,0),i=!0;if(n.textBox||n.verticalTextBox){if(u){const e=this.variableOffsets[_];e?(r=Ct(e.anchor,e.width,e.height,e.textOffset,e.textScale),c&&r._rotate(h?this.transform.angle:-this.transform.angle)):i=!1}o&&(i=!v.clipped),n.textBox&&Pt(t.textCollisionBox.collisionVertexArray,v.text.placed,!i||E,r.x,r.y),n.verticalTextBox&&Pt(t.textCollisionBox.collisionVertexArray,v.text.placed,!i||T,r.x,r.y)}const a=i&&Boolean(!T&&n.verticalIconBox);n.iconBox&&Pt(t.iconCollisionBox.collisionVertexArray,v.icon.placed,a,d?r.x:0,d?r.y:0),n.verticalIconBox&&Pt(t.iconCollisionBox.collisionVertexArray,v.icon.placed,!a,d?r.x:0,d?r.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Pt(e,t,n,r,i){e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0)}const Ot=Math.pow(2,25),zt=Math.pow(2,24),Lt=Math.pow(2,17),Dt=Math.pow(2,16),Rt=Math.pow(2,9),Bt=Math.pow(2,8),Ft=Math.pow(2,1);function jt(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,n=Math.floor(127*e.opacity);return n*Ot+t*zt+n*Lt+t*Dt+n*Rt+t*Bt+n*Ft+t}const Nt=0;class Ut{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,t,n,r,i){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex{const t=e.exported.now()-i;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const e=n[t[this._currentPlacementIndex]],i=this.placement.collisionIndex.transform.zoom;if("symbol"===e.type&&(!e.minzoom||e.minzoom<=i)&&(!e.maxzoom||e.maxzoom>i)){if(this._inProgressLayer||(this._inProgressLayer=new Ut(e)),this._inProgressLayer.continuePlacement(r[e.source],this.placement,this._showCollisionBoxes,e,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Gt=512/e.EXTENT/2;class qt{constructor(t,n,r){this.tileID=t,this.bucketInstanceId=r,this.index=new e.KDBush(n.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const i=t.canonical.x*e.EXTENT,o=t.canonical.y*e.EXTENT;for(let e=0;ee.overscaledZ)for(const n in i){const o=i[n];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=i[e.scaledTo(Number(n)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Xt=(t,n)=>e.emitValidationErrors(t,n&&n.filter(e=>"source.canvas"!==e.identifier)),Ht=e.pick(Ve,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Yt=e.pick(Ve,["setCenter","setZoom","setBearing","setPitch"]),Kt={version:8,layers:[],sources:{}},Jt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Qt extends e.Evented{constructor(t,n={}){super(),this.map=t,this.dispatcher=new A(je(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new e.GlyphManager(t._requestManager,n.localFontFamily?e.LocalGlyphMode.all:n.localIdeographFontFamily?e.LocalGlyphMode.ideographs:e.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.crossTileSymbolIndex=new Wt,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",e.getReferrer());const r=this;this._rtlTextPluginCallback=Qt.registerForPluginStateChange(t=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,n)=>{if(e.triggerPluginCompletionEvent(t),n&&n.every(e=>e))for(const e in r._sourceCaches){const t=r._sourceCaches[e],n=t.getSource().type;"vector"!==n&&"geojson"!==n||t.reload()}})}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const n=this._layers[e];n.source===t.id&&this._validateLayer(n)}})}loadURL(t,n={}){this.fire(new e.Event("dataloading",{dataType:"style"}));const r="boolean"==typeof n.validate?n.validate:!e.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,n.accessToken);const i=this.map._requestManager.transformRequest(t,e.ResourceType.Style);this._request=e.getJSON(i,(t,n)=>{this._request=null,t?this.fire(new e.ErrorEvent(t)):n&&this._load(n,r)})}loadJSON(t,n={}){this.fire(new e.Event("dataloading",{dataType:"style"})),this._request=e.exported.frame(()=>{this._request=null,this._load(t,!1!==n.validate)})}loadEmpty(){this.fire(new e.Event("dataloading",{dataType:"style"})),this._load(Kt,!1)}_updateLayerCount(e,t){const n=t?1:-1;e.is3D()&&(this._num3DLayers+=n),"circle"===e.type&&(this._numCircleLayers+=n),"symbol"===e.type&&(this._numSymbolLayers+=n)}_load(t,n){if(n&&Xt(this,e.validateStyle(t)))return;this._loaded=!0,this.stylesheet=e.clone$1(t),this._updateMapProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const r=Ue(this.stylesheet.layers);this._order=r.map(e=>e.id),this._layers={},this._serializedLayers={};for(const t of r){const n=e.createStyleLayer(t);n.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=n,this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new w(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 e.Event("data",{dataType:"style"})),this.fire(new e.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this._updateMapProjection()}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))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(t){this._spriteRequest=function(t,n,r){let i,o,a;const s=e.exported.devicePixelRatio>1?"@2x":"";let l=e.getJSON(n.transformRequest(n.normalizeSpriteURL(t,s,".json"),e.ResourceType.SpriteJSON),(e,t)=>{l=null,a||(a=e,i=t,c())}),u=e.getImage(n.transformRequest(n.normalizeSpriteURL(t,s,".png"),e.ResourceType.SpriteImage),(e,t)=>{u=null,a||(a=e,o=t,c())});function c(){if(a)r(a);else if(i&&o){const t=e.exported.getImageData(o),n={};for(const r in i){const{width:o,height:a,x:s,y:l,sdf:u,pixelRatio:c,stretchX:h,stretchY:d,content:f}=i[r],p=new e.RGBAImage({width:o,height:a});e.RGBAImage.copy(t,p,{x:s,y:l},{x:0,y:0},{width:o,height:a}),n[r]={data:p,pixelRatio:c,sdf:u,stretchX:h,stretchY:d,content:f}}r(null,n)}}return{cancel(){l&&(l.cancel(),l=null),u&&(u.cancel(),u=null)}}}(t,this.map._requestManager,(t,n)=>{if(this._spriteRequest=null,t)this.fire(new e.ErrorEvent(t));else if(n)for(const e in n)this.imageManager.addImage(e,n[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new e.Event("data",{dataType:"style"}))})}_validateLayer(t){const n=this.getSource(t.source);if(!n)return;const r=t.sourceLayer;r&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new e.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const n of e){const e=this._layers[n];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&("function"==typeof e.isLayerDraped?e.isLayerDraped():Jt[e.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(e.length||n.length)&&this._updateWorkerLayers(e,n);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const r={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];r[e]=t.used,t.used=!1}for(const e of this._order){const n=this._layers[e];if(n.recalculate(t,this._availableImages),!n.isHidden(t.zoom)){const e=this._getLayerSourceCache(n);e&&(e.used=!0)}const r=this.map.painter;if(r){const e=n.getProgramIds();if(!e)continue;const i=n.getProgramConfiguration(t.zoom);for(const t of e)r.useProgram(t,i)}}for(const t in r){const n=this._sourceCaches[t];r[t]!==n.used&&n.getSource().fire(new e.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:n.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new e.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(n){if(this._checkLoaded(),Xt(this,e.validateStyle(n)))return!1;(n=e.clone$1(n)).layers=Ue(n.layers);const r=function(e,n){if(!e)return[{command:Ve.setStyle,args:[n]}];let r=[];try{if(!t(e.version,n.version))return[{command:Ve.setStyle,args:[n]}];t(e.center,n.center)||r.push({command:Ve.setCenter,args:[n.center]}),t(e.zoom,n.zoom)||r.push({command:Ve.setZoom,args:[n.zoom]}),t(e.bearing,n.bearing)||r.push({command:Ve.setBearing,args:[n.bearing]}),t(e.pitch,n.pitch)||r.push({command:Ve.setPitch,args:[n.pitch]}),t(e.sprite,n.sprite)||r.push({command:Ve.setSprite,args:[n.sprite]}),t(e.glyphs,n.glyphs)||r.push({command:Ve.setGlyphs,args:[n.glyphs]}),t(e.transition,n.transition)||r.push({command:Ve.setTransition,args:[n.transition]}),t(e.light,n.light)||r.push({command:Ve.setLight,args:[n.light]}),t(e.fog,n.fog)||r.push({command:Ve.setFog,args:[n.fog]}),t(e.projection,n.projection)||r.push({command:Ve.setProjection,args:[n.projection]});const i={},o=[];!function(e,n,r,i){let o;for(o in n=n||{},e=e||{})e.hasOwnProperty(o)&&(n.hasOwnProperty(o)||qe(o,r,i));for(o in n){if(!n.hasOwnProperty(o))continue;const a=n[o];e.hasOwnProperty(o)?t(e[o],a)||("geojson"===e[o].type&&"geojson"===a.type&&Ze(e,n,o)?r.push({command:Ve.setGeoJSONSourceData,args:[o,a.data]}):$e(o,n,r,i)):Ge(o,n,r)}}(e.sources,n.sources,o,i);const a=[];e.layers&&e.layers.forEach(e=>{e.source&&i[e.source]?r.push({command:Ve.removeLayer,args:[e.id]}):a.push(e)});let s=e.terrain;s&&i[s.source]&&(r.push({command:Ve.setTerrain,args:[void 0]}),s=void 0),r=r.concat(o),t(s,n.terrain)||r.push({command:Ve.setTerrain,args:[n.terrain]}),function(e,n,r){n=n||[];const i=(e=e||[]).map(Xe),o=n.map(Xe),a=e.reduce(He,{}),s=n.reduce(He,{}),l=i.slice(),u=Object.create(null);let c,h,d,f,p,m,_;for(c=0,h=0;c!(e.command in Yt));if(0===r.length)return!1;const i=r.filter(e=>!(e.command in Ht));if(i.length>0)throw new Error(`Unimplemented: ${i.map(e=>e.command).join(", ")}.`);return r.forEach(e=>{"setTransition"!==e.command&&"setProjection"!==e.command&&this[e.command].apply(this,e.args)}),this.stylesheet=n,this._updateMapProjection(),!0}addImage(t,n){return this.getImage(t)?this.fire(new e.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,n),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t),this):this.fire(new e.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new e.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,n,r={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(e.validateSource,"sources."+t,n,null,r))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const i=Ie(t,n,this.dispatcher,this);i.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:i.serialize(),sourceId:t}));const o=n=>{const r=(n?"symbol:":"other:")+t,o=this._sourceCaches[r]=new e.SourceCache(r,i,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[t]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==n.type&&"geojson"!==n.type||o(!0),i.onAdd&&i.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const n=this.getSource(t);if(!n)throw new Error("There is no source with this ID");for(const n in this._layers)if(this._layers[n].source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${n}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const r=this._getSourceCaches(t);for(const t of r)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new e.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}_getSources(){const e=[];for(const t in this._otherSourceCaches){const n=this._getSourceCache(t);n&&e.push(n.getSource())}return e}addLayer(t,n,r={}){this._checkLoaded();const i=t.id;if(this.getLayer(i))return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" already exists on this map`)));let o;if("custom"===t.type){if(Xt(this,e.validateCustomStyleLayer(t)))return;o=e.createStyleLayer(t)}else{if("object"==typeof t.source&&(this.addSource(i,t.source),t=e.clone$1(t),t=e.extend(t,{source:i})),this._validate(e.validateLayer,"layers."+i,t,{arrayIndex:-1},r))return;o=e.createStyleLayer(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const a=n?this._order.indexOf(n):this._order.length;if(n&&-1===a)return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(a,0,i),this._layerOrderChanged=!0,this._layers[i]=o;const s=this._getLayerSourceCache(o);if(this._removedLayers[i]&&o.source&&s&&"custom"!==o.type){const e=this._removedLayers[i];delete this._removedLayers[i],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",s.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const r=this._order.indexOf(t);this._order.splice(r,1);const i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(i,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(t,n,r){this._checkLoaded();const i=this.getLayer(t);i?i.minzoom===n&&i.maxzoom===r||(null!=n&&(i.minzoom=n),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(n,r,i={}){this._checkLoaded();const o=this.getLayer(n);if(o){if(!t(o.filter,r))return null==r?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(e.validateFilter,`layers.${o.id}.filter`,r,{layerType:o.type},i)||(o.filter=e.clone$1(r),this._updateLayer(o)))}else this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){const n=this.getLayer(t);return n&&e.clone$1(n.filter)}setLayoutProperty(n,r,i,o={}){this._checkLoaded();const a=this.getLayer(n);a?t(a.getLayoutProperty(r),i)||(a.setLayoutProperty(r,i,o),this._updateLayer(a)):this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,n){const r=this.getLayer(t);if(r)return r.getLayoutProperty(n);this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(n,r,i,o={}){this._checkLoaded();const a=this.getLayer(n);a?t(a.getPaintProperty(r),i)||(a.setPaintProperty(r,i,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[n]=!0):this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){const n=this.getLayer(e);return n&&n.getPaintProperty(t)}setFeatureState(t,n){this._checkLoaded();const r=t.source,i=t.sourceLayer,o=this.getSource(r);if(!o)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.type;if("geojson"===a&&i)return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===a&&!i)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));const s=this._getSourceCaches(r);for(const e of s)e.setFeatureState(i,t.id,n)}removeFeatureState(t,n){this._checkLoaded();const r=t.source,i=this.getSource(r);if(!i)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const o=i.type,a="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!a)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const s=this._getSourceCaches(r);for(const e of s)e.removeFeatureState(a,t.id,n)}getFeatureState(t){this._checkLoaded();const n=t.source,r=t.sourceLayer,i=this.getSource(n);if(i){if("vector"!==i.type||r)return void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(r,t.id);this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new e.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return e.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const n=this._sourceCaches[e].getSource();t[n.id]||(t[n.id]=n.serialize())}return e.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,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:t,layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,n={},r=[];for(let i=this._order.length-1;i>=0;i--){const o=this._order[i];if(t(o)){n[o]=i;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const i=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(n[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()}):this.has3DLayers(),s=P.createFromScreenPoints(t,r);for(const e in this._sourceCaches){const t=this._sourceCaches[e].getSource().id;n.layers&&!i[t]||o.push(Oe(this._sourceCaches[e],this._layers,this._serializedLayers,s,n,r,a,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,n,r,i,o,a){const s={},l=o.queryRenderedSymbols(r),u=[];for(const e of Object.keys(l).map(Number))u.push(a[e]);u.sort(Le);for(const n of u){const r=n.featureIndex.lookupSymbolFeatures(l[n.bucketInstanceId],t,n.bucketIndex,n.sourceLayerIndex,i.filter,i.layers,i.availableImages,e);for(const e in r){const t=s[e]=s[e]||[],i=r[e];i.sort((e,t)=>{const r=n.featureSortOrder;if(r){const n=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-n}return t.featureIndex-e.featureIndex});for(const e of i)t.push(e)}}for(const t in s)s[t].forEach(r=>{const i=r.feature,o=n(e[t]);if(!o)return;const a=o.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=a});return s}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),s.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,n){n&&n.filter&&this._validate(e.validateFilter,"querySourceFeatures.filter",n.filter,null,n);const r=this._getSourceCaches(t);let i=[];for(const e of r)i=i.concat(ze(e,n));return i}addSourceType(e,t,n){return Qt.getSourceType(e)?n(new Error(`A source type called "${e}" already exists.`)):(Qt.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},n):n(null,null))}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();const r=this.light.getLight();let i=!1;for(const n in e)if(!t(e[n],r[n])){i=!0;break}if(!i)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,n),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(n,r=1){if(this._checkLoaded(),!n)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let i=n;if(1===r){if("object"==typeof i.source){const t="terrain-dem-src";this.addSource(t,i.source),i=e.clone$1(i),i=e.extend(i,{source:t})}if(this._validate(e.validateTerrain,"terrain",i))return}if(!this.terrain||this.terrain&&r!==this.terrain.drapeRenderMode){if(!i)return;this._createTerrain(i,r)}else{const n=this.terrain,r=n.get();for(const t of Object.keys(e.spec.terrain))!i.hasOwnProperty(t)&&e.spec.terrain[t].default&&(i[t]=e.spec.terrain[t].default);for(const e in i)if(!t(i[e],r[e])){n.set(i),this.stylesheet.terrain=i;const e=this._setTransitionParameters({duration:0});n.updateTransitions(e);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new C(e,this.map.transform);this.stylesheet.fog=e;const n=this._setTransitionParameters({duration:0});t.updateTransitions(n)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,r=n.get();0===Object.keys(e).length&&n.set(e);for(const i in e)if(!t(e[i],r[i])){n.set(e),this.stylesheet.fog=e;const t=this._setTransitionParameters({duration:0});n.updateTransitions(t);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(t){return{now:e.exported.now(),transition:e.extend(t,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter(e=>this.isLayerDraped(this._layers[e])),t=this._order.filter(e=>!this.isLayerDraped(this._layers[e]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const n=this.terrain=new T(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});n.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,n,r,i,o={}){return(!o||!1!==o.validate)&&Xt(this,t.call(e.validateStyle,e.extend({key:n,style:this.serialize(),value:r,styleSpec:e.spec},i)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),e.reload()}_reloadSources(){for(const e of this._getSources())e.reload&&e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,n,r,i,o=!1){let a=!1,s=!1;const l={};for(const e of this._order){const n=this._layers[e];if("symbol"!==n.type)continue;if(!l[n.source]){const e=this._getLayerSourceCache(n);if(!e)continue;l[n.source]=e.getRenderableIds(!0).map(t=>e.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const r=this.crossTileSymbolIndex.addLayer(n,l[n.source],t.center.lng,t.projection);a=a||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.exported.now(),t.zoom))&&(this.pauseablePlacement=new Vt(t,this._order,o,n,r,i,this.placement,this.fog&&t.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(e.exported.now()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.exported.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,n){this.imageManager.getImages(t.icons,n),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,n){this.glyphManager.getGlyphs(t.stacks,n)}getResource(t,n,r){return e.makeRequest(n,r)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const n=this._getSourceCaches(t);return 0===n.length?(this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t}'`))),!1):n.every(e=>e.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)}}Qt.getSourceType=function(e){return Ae[e]},Qt.setSourceType=function(e,t){Ae[e]=t},Qt.registerForPluginStateChange=e.registerForPluginStateChange;var en="\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",tn="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;}",nn="\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\nconst float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\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) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.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;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",rn="#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",on="#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";let an={},sn={};const ln=[];fn(en,ln),fn(nn,ln),fn(rn,ln),fn(on,ln),an=pn("",nn),sn=pn(on,rn);const un=pn("\n#if __VERSION__ >=300\n#define varying in\n#define gl_FragColor glFragColor\n#define texture2D texture\n#define textureCube texture\nout vec4 glFragColor;\n#endif\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;}highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}","\n#if __VERSION__ >=300\n#define attribute in\n#define varying out\n#define texture2D texture\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."),cn=en,hn="\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 dn={background:pn("uniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nvarying vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\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;\n#ifdef LIGHTING_3D_MODE\nuniform vec4 u_color;varying vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(u_color);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:pn("uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:pn("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 LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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;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);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;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);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);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();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;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:pn("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:pn("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);vec3 pos;\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;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=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:pn("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:pn("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:pn("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:pn("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:pn("#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 LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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:pn("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 LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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:pn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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 float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(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:pn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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 float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:pn("varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\nvoid main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvec3 normal=v_normal;\n#endif\nfloat z;vec4 color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);\n#else\ncolor=v_color;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef ZERO_ROOF_RADIUS\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#endif\ncolor.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\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;uniform float u_edge_radius;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#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\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\nvec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;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));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nv_normal=normal;\n#endif\nbase=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : 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\nfloat ele=0.0;float h=0.0;float c_ele;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=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*h);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);\n#ifdef RENDER_SHADOWS\nv_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(color,NdotL);\n#else\nv_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_color*=u_opacity;\n#ifdef ZERO_ROOF_RADIUS\nv_roof_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef LIGHTING_3D_MODE\nv_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));\n#else\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:pn("uniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,v_NdotL)*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\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 float u_tile_units_to_pixels;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;varying vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;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=(pattern_br-pattern_tl)/pixel_ratio;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\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=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=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_NdotL=NdotL;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:pn("#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+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=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+e+e+h)-(a+d+d+f),(f+g+g+h)-(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:pn("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 LIGHTING_3D_MODE\ngl_FragColor=apply_lighting(gl_FragColor);\n#endif\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:pn("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;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nuniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\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=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\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);trimmed=0.0;}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\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\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);\n#ifdef RENDER_LINE_BORDER_AUTO\nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}\n#else\nout_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha);\n#endif\n}\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 float u_tile_units_to_pixels;varying vec2 v_tex;\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\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\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 scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.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:pn("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;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\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.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=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting(color);\n#endif\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\n#pragma mapbox: define lowp float pixel_ratio\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\n#pragma mapbox: initialize lowp float pixel_ratio\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:pn("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 LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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:pn("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);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);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;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_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);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_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 TERRAIN\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\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:pn("#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);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);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;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_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);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_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 TERRAIN\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\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:pn("#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);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);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;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_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 TERRAIN\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\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:pn("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\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;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nconst float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=wireframeOffset;\n#endif\nv_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}"),terrainDepth:pn("#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;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:pn("\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}",tn),skyboxGradient:pn("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}",tn),skyboxCapture:pn("\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:pn("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() {vec4 color;\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);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\ncolor=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;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_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 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:pn("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);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_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);float horizon_angle;\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));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\nhorizon_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 fn(e,t){const n=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of n)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const n=e.split(" ");for(const e of n)t.includes(e)||t.push(e)}}function pn(e,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),i={},o=[...ln];return fn(e,o),fn(t,o),{fragmentSource:e=e.replace(n,(e,t,n,r,o)=>(i[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = u_${o};\n#endif\n`)),vertexSource:t=t.replace(n,(e,t,n,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return i[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${a} a_${o};\nvarying ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${a} a_${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = a_${o};\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`}),staticAttributes:r,usedDefines:o}}class mn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,n,r,i,o,a){this.context=e;let s=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!s&&e{const i=n.paint.get("hillshade-shadow-color"),o=n.paint.get("hillshade-highlight-color"),a=n.paint.get("hillshade-accent-color");let s=n.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===n.paint.get("hillshade-illumination-anchor")&&(s-=e.transform.angle);const l=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:_n(0,t.tileID),u_light:[n.paint.get("hillshade-exaggeration"),s],u_shadow:i,u_highlight:o,u_accent:a}})(t,r,i,t.terrain?n.projMatrix:null);t.prepareDrawProgram(l,h,n.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:p,tileBoundsSegments:m}=t.getTileBoundsBuffers(r);h.draw(l,u.TRIANGLES,o,a,s,e.CullFaceMode.disabled,d,i.id,f,p,m)}function yn(t,n,r){if(!n.needsDEMTextureUpload)return;const i=t.context,o=i.gl;i.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||t.getTileTexture(r.stride);const a=r.getPixels();n.demTexture?n.demTexture.update(a,{premultiply:!1}):n.demTexture=new e.Texture(i,a,o.RGBA,{premultiply:!1}),n.needsDEMTextureUpload=!1}function vn(t,n,r,i,o,a){const s=t.context,l=s.gl;if(!n.dem)return;const u=n.dem;if(s.activeTexture.set(l.TEXTURE1),yn(t,n,u),!n.demTexture)return;n.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const c=u.dim;s.activeTexture.set(l.TEXTURE0);let h=n.fbo;if(!h){const t=new e.Texture(s,{width:c,height:c,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=n.fbo=s.createFramebuffer(c,c,!0),h.colorAttachment.set(t.texture)}s.bindFramebuffer.set(h.framebuffer),s.viewport.set([0,0,c,c]);const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:p}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(s,l.TRIANGLES,i,o,a,e.CullFaceMode.disabled,((t,n)=>{const r=n.stride,i=e.create();return e.ortho(i,0,e.EXTENT,-e.EXTENT,0,0,1),e.translate(i,i,[0,-e.EXTENT,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:n.unpackVector}})(n.tileID,u),r.id,d,f,p),n.needsHillshadePrepare=!1}const xn=t=>({u_matrix:new e.UniformMatrix4f(t),u_image0:new e.Uniform1i(t),u_skirt_height:new e.Uniform1f(t)}),bn=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),wn=(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:n,u_zoom_transition:i,u_merc_center:o,u_image0:0,u_frustum_tl:a,u_frustum_tr:s,u_frustum_br:l,u_frustum_bl:u,u_globe_pos:c,u_globe_radius:h,u_viewport:d,u_grid_matrix:p?Float32Array.from(p):new Float32Array(9),u_skirt_height:f});function En(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Tn=new class{constructor(){this.operations={}}newMorphing(e,t,n,r,i){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==n.tileID.key&&(t.queued=n)}else this.operations[e]={startTime:r,phase:0,duration:i,from:t,to:n,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const n=this.operations[t];for(n.phase=(e-n.startTime)/n.duration;n.phase>=1||!this._validOp(n);)if(!this._nextOp(n,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},Sn={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function kn(e){return 6*Math.pow(1.5,22-e)}function Mn(e,t){const n=1<({u_matrix:e});function An(t,n,r,i,o){if(o>0){const a=e.exported.now(),s=(a-t.timeAdded)/o,l=n?(a-n.timeAdded)/o:-1,u=r.getSource(),c=i.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),h=!n||Math.abs(n.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),d=h&&t.refreshedUponExpiration?1:e.clamp(h?s:1-l,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),n?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class In extends e.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},n=new A(je(),null),r=Ie("mock-dem",t,n,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Pn extends e.SourceCache{constructor(e){const t=Ie("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new A(je(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,n,r){if(t.freezeTileCoverage)return;this.transform=t;const i=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((n,r)=>{if(n[r.key]="",!this._tiles[r.key]){const n=new e.Tile(r,this._source.tileSize*r.overscaleFactor(),t.tileZoom);n.state="loaded",this._tiles[r.key]=n}return n},{});for(const e in this._tiles)e in i||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const n=Object.values(t);this.renderCachePool.push(...n),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class On extends e.OverscaledTileID{constructor(e,t,n){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=n}}class zn extends e.Elevation{constructor(t,n){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,i,o]=function(t){const n=new e.StructArrayLayout2i4,r=new e.StructArrayLayout3ui6,i=131;n.reserve(17161),r.reserve(33800);const o=e.EXTENT/128,a=e.EXTENT+o/2,s=a+o;for(let t=-o;ta||t<0||t>a?24575:0,o=e.clamp(Math.round(r),0,e.EXTENT),s=e.clamp(Math.round(t),0,e.EXTENT);n.emplaceBack(o+i,s)}const l=(e,t)=>{const n=t*i+e;r.emplaceBack(n+1,n,n+i),r.emplaceBack(n+i,n+i+1,n+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach(e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)}),[n,r,32768]}(),a=t.context;this.gridBuffer=a.createVertexBuffer(r,e.posAttributes.members),this.gridIndexBuffer=a.createIndexBuffer(i),this.gridSegments=e.SegmentVector.simpleSegment(0,0,r.length,i.length),this.gridNoSkirtSegments=e.SegmentVector.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Pn(n.map),this.orthoMatrix=e.create(),e.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.EXTENT,0,e.EXTENT,0,1);const s=a.gl;this._overlapStencilMode=new e.StencilMode({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=n,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new In(n.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,n,r){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const i=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(i.get("source")),this._exaggeration=i.get("exaggeration");const o=()=>{this.sourceCache.used&&e.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 t=this.getScaledDemTileSize();this.sourceCache.update(n,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),n.updateElevation(!0,r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(n),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&e.warnOnce(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${t.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const n=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const i=this.proxyCoords=n.getIds().map(e=>{const t=n.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t});!function(t,n){const r=n.transform.pointCoordinate(n.transform.getCameraPoint()),i=new e.Point(r.x,r.y);t.sort((t,n)=>{if(n.overscaledZ-t.overscaledZ)return n.overscaledZ-t.overscaledZ;const r=new e.Point(t.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const a=this._style._sourceCaches;for(const e in a){const n=a[e];if(!n.used)continue;if(n!==this.sourceCache&&this.resetTileLookupCache(n.id),this._setupProxiedCoordsForOrtho(n,t[e],o),n.usedForTerrain)continue;const r=t[e];n.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[n.id]=i.map(e=>new On(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(i),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=e.exported.now();const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const n=t.tileID.key;n in s||(this._visibleDemTiles.push(t),s[n]=n)}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)})}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const n in this.terrainTileForTile){const r=this.terrainTileForTile[n],i=r.dem;!i||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),yn(this.painter,r,i))}}_prepareDemTileUniforms(e,t,n,r){if(!t||null==t.demTexture)return!1;const i=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-i.z),a=r||"";return n["u_dem_tl"+a]=[i.x*o%1,i.y*o%1],n["u_dem_scale"+a]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,n=t.gl;if(!this._emptyDepthBufferTexture){const r=new e.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.Texture(t,r,n.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce((t,n)=>{if(!n.dem)return t;const r=n.dem.tree.minimums[0];return r>0&&e++,t+r},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,n=t.gl;t.activeTexture.set(n.TEXTURE2);const r=this._getLoadedAreaMinimum(),i=new e.RGBAImage({width:1,height:1},new Uint8Array(e.DEMData.pack(r,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(i,{premultiply:!1}):o=this._emptyDEMTexture=new e.Texture(t,i,n.RGBA,{premultiply:!1}),o}setupElevationDraw(t,n,r){const i=this.painter.context,o=i.gl,a=(s=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:e.DEMData.getUnpackVector(s),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});var s;a.u_dem_size=this.sourceCache.getSource().tileSize,a.u_exaggeration=this.exaggeration();let l=null,u=null,c=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,n=r.morphing.dstDemTile;c=r.morphing.phase,e&&n&&(this._prepareDemTileUniforms(t,e,a,"_prev")&&(u=e),this._prepareDemTileUniforms(t,n,a)&&(l=n))}if(u&&l?(i.activeTexture.set(o.TEXTURE2),l.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),i.activeTexture.set(o.TEXTURE4),u.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),a.u_dem_lerp=c):(l=this.terrainTileForTile[t.tileID.key],i.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(t,l,a)?l.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),i.activeTexture.set(o.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(a.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),a.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&l){const t=(1<{if(u===e)return;const r=[Sn[e],"PROJECTION_GLOBE_VIEW"];d&&r.push("CUSTOM_ANTIALIASING"),n&&r.push(Sn[c]),l=t.useProgram("globeRaster",null,r),u=e},p=t.colorModeForRenderPass(),m=new e.DepthMode(s.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);Tn.update(o);const _=e.calculateGlobeMercatorMatrix(h),g=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],y=c?[!1,!0]:[!1],v=t.globeSharedBuffers,x=[h.width*e.exported.devicePixelRatio,h.height*e.exported.devicePixelRatio],b=Float32Array.from(h.globeMatrix),w={useDenormalizedUpVectorScale:!0};if(y.forEach(c=>{const h=t.transform,d=kn(h.zoom)*n.exaggeration();u=-1;const y=c?s.LINES:s.TRIANGLES;for(const u of i){const i=r.getTile(u),E=e.StencilMode.disabled,T=n.prevTerrainTileForTile[u.key],S=n.terrainTileForTile[u.key];En(T,S)&&Tn.newMorphing(u.key,T,S,o,250),a.activeTexture.set(s.TEXTURE0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const k=Tn.getMorphValuesForProxy(u.key),M=k?1:0;k&&e.extend$1(w,{morphing:{srcDemTile:k.from,dstDemTile:k.to,phase:e.easeCubicInOut(k.phase)}});const C=e.tileCornersToBounds(u.canonical),A=e.getLatitudinalLod(C.getCenter().lat),I=e.getGridMatrix(u.canonical,C,A,h.worldSize/h._pixelsPerMercatorPixel),P=e.globeNormalizeECEF(e.globeTileBounds(u.canonical)),O=wn(h.projMatrix,b,_,P,e.globeToMercatorTransition(h.zoom),g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,d,I);if(f(M,c),n.setupElevationDraw(i,l,w),t.prepareDrawProgram(a,l,u.toUnwrapped()),v){const[n,r,i]=c?v.getWirefameBuffers(t.context,A):v.getGridBuffers(A,0!==d);l.draw(a,y,m,E,p,e.CullFaceMode.backCCW,O,"globe_raster",n,r,i)}}}),v){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&o.push("CUSTOM_ANTIALIASING"),l=t.useProgram("globeRaster",null,o);for(const o of i){const{x:i,y:u,z:c}=o.canonical,d=0===u,f=u===(1<t.draw(a,s.TRIANGLES,m,e.StencilMode.disabled,p,e.CullFaceMode.disabled,wn(h.projMatrix,v,v,T,0,g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,0),"globe_pole_raster",n,b,E);n.setupElevationDraw(u,l,w),t.prepareDrawProgram(a,l,o.toUnwrapped()),d&&S(l,_),f&&(v=e.scale(e.create(),v,[1,-1,1]),S(l,y))}}}}(t,n,r,i,o);else{const a=t.context,s=a.gl;let l,u;const c=t.options.showTerrainWireframe?2:0,h=(e,n)=>{if(u===e)return;const r=[Sn[e]];n&&r.push(Sn[c]),l=t.useProgram("terrainRaster",null,r),u=e},d=t.colorModeForRenderPass(),f=new e.DepthMode(s.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);Tn.update(o);const p=t.transform,m=kn(p.zoom)*n.exaggeration();(c?[!1,!0]:[!1]).forEach(c=>{u=-1;const _=c?s.LINES:s.TRIANGLES,[g,y]=c?n.getWirefameBuffer():[n.gridIndexBuffer,n.gridSegments];for(const u of i){const i=r.getTile(u),v=e.StencilMode.disabled,x=n.prevTerrainTileForTile[u.key],b=n.terrainTileForTile[u.key];En(x,b)&&Tn.newMorphing(u.key,x,b,o,250),a.activeTexture.set(s.TEXTURE0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST);const w=Tn.getMorphValuesForProxy(u.key),E=w?1:0;let T;w&&(T={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:e.easeCubicInOut(w.phase)}});const S=bn(u.projMatrix,Mn(u.canonical,p.renderWorldCopies)?m/10:m);h(E,c),n.setupElevationDraw(i,l,T),t.prepareDrawProgram(a,l,u.toUnwrapped()),l.draw(a,_,f,v,d,e.CullFaceMode.backCCW,S,"terrain_raster",n.gridBuffer,g,y)}})}}(n,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,n.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const n=this.painter,r=this.painter.context,i=this.proxySourceCache,o=this.proxiedCoords[i.id],a=this._drapedRenderBatches.shift(),s=[],l=n.style.order;let u=0;for(const c of o){const o=i.getTileByID(c.proxyTileKey),h=i.proxyCachedFBO[c.key]?i.proxyCachedFBO[c.key][t]:void 0,d=void 0!==h?i.renderCache[h]:this.pool[u++],f=void 0!==h;if(o.texture=d.tex,f&&!d.dirty){s.push(o.tileID);continue}let p;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.Color.transparent,stencil:0}),d.dirty=!1);for(let e=a.start;e<=a.end;++e){const t=n.style._layers[l[e]];if(t.isHidden(n.transform.zoom))continue;const i=n.style._getLayerSourceCache(t),o=i?this.proxyToSource[c.key][i.id]:[c];if(!o)continue;const a=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(i?i.id:null)&&(this._setupStencil(d,o,t,i),p=i?i.id:null),n.renderLayer(n,i,t,a)}this.renderedToTile?(d.dirty=!0,s.push(o.tileID)):f||--u,5===u&&(u=0,this.renderToBackBuffer(s))}return this.renderToBackBuffer(s),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,n.width,n.height]),a.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let n,r=0,i=0,o=!1;for(let a=0;ae.dem).forEach(t=>{e=Math.min(e,t.dem.tree.minimums[0])}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,n){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter(e=>e.dem).map(r=>{const i=r.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const i of r){if(null==i.t)return null;const r=i.tile.dem.tree.raycast(i.minx,i.miny,i.maxx,i.maxy,e,t,n);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,n=t.gl,r=this.drapeBufferSize;t.activeTexture.set(n.TEXTURE0);const i=new e.Texture(t,{width:r[0],height:r[1],data:null},n.RGBA);i.bind(n.LINEAR,n.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!1);return o.colorAttachment.set(i.texture),o.depthAttachment=new we(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&n.texParameterf(n.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:i,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._layers[e],n=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!n&&t.shouldRedrape():!n&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style._getSources())if(e instanceof Se){t=!0;break}if(!t)return;const n={};for(let t=0;tt.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let n=0;n=0;i--){const o=n[i];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const n=e[o.key],i=this.proxyToSource[o.key];let a=0;for(const e in i){const t=i[e],o=n[e];if(!o||o.length!==t.length||t.some((t,n)=>t!==o[n]||r[e]&&r[e].hasOwnProperty(t.key))){a=-1;break}++a}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=a<0||a!==Object.values(n).length}}const i=[...this._drapedRenderBatches];i.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of i)for(const r of n){if(t.proxyCachedFBO[r.key])continue;let n=t.renderCachePool.pop();void 0===n&&t.renderCache.length<50&&(n=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==n&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=n,t.renderCache[n].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,n,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const i=this.painter.context,o=i.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let a;if(n.isTileClipped())a=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);a=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+a>255&&(i.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,this._overlapStencilMode.ref=this._stencilRef,n.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.StencilMode.disabled}_renderTileClippingMasks(t,n){const r=this.painter,i=this.painter.context,o=i.gl;r._tileClippingMaskIDs={},i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=r.useProgram("clippingMask");for(const s of t){const t=r._tileClippingMaskIDs[s.key]=--n;a.draw(i,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Cn(s.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(t){const n=this.painter.transform;if(t.x<0||t.x>n.width||t.y<0||t.y>n.height)return null;const r=[t.x,t.y,1,1];e.transformMat4$1(r,r,n.pixelMatrixInverse),e.scale$1(r,r,1/r[3]),r[0]/=n.worldSize,r[1]/=n.worldSize;const i=n._camera.position,o=e.mercatorZfromAltitude(1,n.center.lat),a=[i[0],i[1],i[2]/o,0],s=e.subtract([],r.slice(0,3),a);e.normalize(s,s);const l=this.raycast(a,s,this._exaggeration);return null!==l&&l?(e.scaleAndAdd(a,a,s,l),a[3]=a[2],a[2]*=o,a):null}drawDepth(){const t=this.painter,n=t.context,r=this.proxySourceCache,i=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===i&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=n.gl,r=n.createFramebuffer(i,o,!0);n.activeTexture.set(t.TEXTURE0);const a=new e.Texture(n,{width:i,height:o,data:null},t.RGBA);a.bind(t.NEAREST,t.CLAMP_TO_EDGE),r.colorAttachment.set(a.texture);const s=n.createRenderbuffer(n.gl.DEPTH_COMPONENT16,i,o);r.depthAttachment.set(s),this._depthFBO=r,this._depthTexture=a}n.bindFramebuffer.set(this._depthFBO.framebuffer),n.viewport.set([0,0,i,o]),function(t,n,r,i){if("globe"===t.transform.projection.name)return;const o=t.context,a=o.gl;o.clear({depth:1});const s=t.useProgram("terrainDepth"),l=new e.DepthMode(a.LESS,e.DepthMode.ReadWrite,t.depthRangeFor3D);for(const t of i){const i=r.getTile(t),u=bn(t.projMatrix,0);n.setupElevationDraw(i,s),s.draw(o,a.TRIANGLES,l,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.backCCW,u,"terrain_depth",n.gridBuffer,n.gridIndexBuffer,n.gridNoSkirtSegments)}}(t,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,n){if(e.getSource()instanceof Ce)return this._setupProxiedCoordsForImageSource(e,t,n);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],i=this.proxyCoords;for(let t=0;t(e.min.x=Math.min(e.min.x,t.x-s.x),e.min.y=Math.min(e.min.y,t.y-s.y),e.max.x=Math.max(e.max.x,t.x-s.x),e.max.y=Math.max(e.max.y,t.y-s.y),e),{min:new e.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,n)=>{const r=t.wrap+t.canonical.x/(1<a+l.max.x||i+os+l.max.y};for(let e=0;ee.key===n.tileID.key);if(e)return e}if(n.tileID.key!==t.key){const r=t.canonical.z-n.tileID.canonical.z;let o,a,s;i=e.create();const l=n.tileID.wrap-t.wrap<0?(o=e.EXTENT>>r,a=o*((n.tileID.canonical.x<=i){const r=t.canonical.z-i;n.getSource().reparseOverscaled?(s=Math.max(t.canonical.z+2,n.transform.tileZoom),a=new e.OverscaledTileID(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(s=i,a=new e.OverscaledTileID(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r))}a.key!==t.key&&(u.push(a.key),r=n.getTile(a))}const c=e=>{u.forEach(t=>{i[t]=e}),u.length=0};for(s-=1;s>=l&&(!r||!r.hasData());s--){r&&c(r.tileID.key);const e=a.calculateScaledKey(s);if(r=n.getTileByID(e),r&&r.hasData())break;const t=i[e];if(null===t)break;void 0===t?u.push(e):r=n.getTileByID(t)}return c(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let n=this._tilesDirty[e];n||(n=this._tilesDirty[e]={}),n[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let n=0;const r=new e.StructArrayLayout2ui4,i=131;for(let e=1;e<129;e++){for(let t=1;t<129;t++)n=e*i+t,r.emplaceBack(n,n+1),r.emplaceBack(n,n+i),r.emplaceBack(n+1,n+i),128===e&&r.emplaceBack(n+i,n+i+1);r.emplaceBack(n+1,n+1+i)}return r}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=e.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Ln{static cacheKey(e,t,n,r){let i=`${t}${r?r.cacheKey:""}`;for(const t of n)e.usedDefines.includes(t)&&(i+="/"+t);return i}constructor(t,n,r,i,o,a){const s=t.gl;this.program=s.createProgram();const l=function(e){const t=[];for(let n=0;n"#define "+e));const d=t.isWebGL2?"#version 300 es\n":"",f=d+h.concat(t.extStandardDerivatives&&0===d.length?"#extension GL_OES_standard_derivatives : enable\n".concat(hn):hn,hn,cn,un.fragmentSource,sn.fragmentSource,r.fragmentSource).join("\n"),p=d+h.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",cn,un.vertexSource,sn.vertexSource,an.vertexSource,r.vertexSource).join("\n"),m=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(m,f),s.compileShader(m),s.attachShader(this.program,m);const _=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())this.failedToCreate=!0;else{s.shaderSource(_,p),s.compileShader(_),s.attachShader(this.program,_),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.Uniform1i(t),u_dem_prev:new e.Uniform1i(t),u_dem_unpack:new e.Uniform4f(t),u_dem_tl:new e.Uniform2f(t),u_dem_scale:new e.Uniform1f(t),u_dem_tl_prev:new e.Uniform2f(t),u_dem_scale_prev:new e.Uniform1f(t),u_dem_size:new e.Uniform1f(t),u_dem_lerp:new e.Uniform1f(t),u_exaggeration:new e.Uniform1f(t),u_depth:new e.Uniform1i(t),u_depth_size_inv:new e.Uniform2f(t),u_meter_to_dem:new e.Uniform1f(t),u_label_plane_matrix_inv:new e.UniformMatrix4f(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.Uniform3f(t),u_tile_tr_up:new e.Uniform3f(t),u_tile_br_up:new e.Uniform3f(t),u_tile_bl_up:new e.Uniform3f(t),u_tile_up_scale:new e.Uniform1f(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.UniformMatrix4f(t),u_fog_range:new e.Uniform2f(t),u_fog_color:new e.Uniform4f(t),u_fog_horizon_blend:new e.Uniform1f(t),u_fog_temporal_offset:new e.Uniform1f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_globe_transition:new e.Uniform1f(t),u_is_globe:new e.Uniform1i(t),u_viewport:new e.Uniform2f(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const n=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const n=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const n=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}draw(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(n),e.setStencilMode(r),e.setColorMode(i),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);f&&f.setUniforms(this.program,e,this.binderUniforms,h,{zoom:d});const _={[m.LINES]:2,[m.TRIANGLES]:3,[m.LINE_STRIP]:1}[t];for(const n of c.get()){const r=n.vaos||(n.vaos={});(r[s]||(r[s]=new mn)).bind(e,this,l,f?f.getPaintVertexBuffers():[],u,n.vertexOffset,p||[]),m.drawElements(t,n.primitiveLength*_,m.UNSIGNED_SHORT,n.primitiveOffset*_*2)}}}function Dn(e,t){const n=Math.pow(2,t.tileID.overscaledZ),r=t.tileSize*Math.pow(2,e.transform.tileZoom)/n,i=r*(t.tileID.canonical.x+t.tileID.wrap*n),o=r*t.tileID.canonical.y;return{u_image:0,u_texsize:t.imageAtlasTexture.size,u_tile_units_to_pixels:1/I(t,1,e.transform.tileZoom),u_pixel_coord_upper:[i>>16,o>>16],u_pixel_coord_lower:[65535&i,65535&o]}}const Rn=e.create(),Bn=(t,n,r,i,o,a,s,l,u,c,h)=>{const d=n.style.light,f=d.properties.get("position"),p=[f.x,f.y,f.z],m=e.create$1();"viewport"===d.properties.get("anchor")&&(e.fromRotation(m,-n.transform.angle),e.transformMat3(p,p,m));const _=d.properties.get("color"),g=n.transform,y={u_matrix:t,u_lightpos:p,u_lightintensity:d.properties.get("intensity"),u_lightcolor:[_.r,_.g,_.b],u_vertical_gradient:+r,u_opacity:i,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Rn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:a};return"globe"===g.projection.name&&(y.u_tile_id=[s.canonical.x,s.canonical.y,1<{const f=Bn(t,n,r,i,o,a,s,u,c,h,d),p={u_height_factor:-Math.pow(2,s.overscaledZ)/l.tileSize/8};return e.extend(f,Dn(n,l),p)},jn=e=>({u_matrix:e}),Nn=(t,n,r)=>e.extend(jn(t),Dn(n,r)),Un=(e,t)=>({u_matrix:e,u_world:t}),Vn=(t,n,r,i)=>e.extend(Nn(t,n,r),{u_world:i}),Gn=e.create(),qn=(t,n,r,i,o,a)=>{const s=t.transform,l="globe"===s.projection.name;let u;if("map"===a.paint.get("circle-pitch-alignment"))if(l){const t=e.globePixelsToTileUnits(s.zoom,n.canonical)*s._pixelsPerMercatorPixel;u=Float32Array.from([t,0,0,t])}else u=s.calculatePixelsToTileUnitsMatrix(r);else u=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:s.cameraToCenterDistance,u_matrix:t.translatePosMatrix(n.projMatrix,r,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_device_pixel_ratio:e.exported.devicePixelRatio,u_extrude_scale:u,u_inv_rot_matrix:Gn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){c.u_inv_rot_matrix=i,c.u_merc_center=o,c.u_tile_id=[n.canonical.x,n.canonical.y,1<{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},Zn=(t,n,r,i)=>{const o=e.EXTENT/r.tileSize;return{u_matrix:t,u_camera_to_center_distance:n.getCameraToCenterDistance(i),u_extrude_scale:[n.pixelsToGLUnits[0]/o,n.pixelsToGLUnits[1]/o]}},Wn=(e,t,n=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:n}),Xn=e.create(),Hn=(t,n,r,i,o,a,s)=>{const l=t.transform,u="globe"===l.projection.name,c=u?e.globePixelsToTileUnits(l.zoom,n.canonical)*l._pixelsPerMercatorPixel:I(r,1,a),h={u_matrix:n.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:Xn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(u){h.u_inv_rot_matrix=i,h.u_merc_center=o,h.u_tile_id=[n.canonical.x,n.canonical.y,1<{const s=e.transform,l=s.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Qn(e,t,n,r),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:er(n)?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Jn(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:a}},Kn=(e,t,n,r,i)=>{const o=e.transform;return{u_matrix:Qn(e,t,n,r),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:Jn(t,o),u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Jn(e,t){return 1/I(e,1,t.tileZoom)}function Qn(e,t,n,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}function er(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const tr=(e,t,n,r,i,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:n,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:(s=i.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=i.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:nr(i.paint.get("raster-hue-rotate")),u_perspective_transform:o};var a,s};function nr(e){e*=Math.PI/180;const t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const rr=e.create(),ir=(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_)=>{const g=o.transform,y={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:n?n.uSizeT:0,u_size:n?n.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:a,u_label_plane_matrix:s,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+i,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:rr,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:rr,u_up_vector:[0,-1,0]};return"globe"===_.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<e.extend(ir(t,n,r,i,o,a,s,l,u,c,d,f,p,m,_,g),{u_gamma_scale:i?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.exported.devicePixelRatio,u_is_halo:+h}),ar=(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_)=>e.extend(or(t,n,r,i,o,a,s,l,!0,u,!0,h,d,f,p,m,_),{u_texsize_icon:c,u_texture_icon:1}),sr=(e,t,n)=>({u_matrix:e,u_opacity:t,u_color:n}),lr=(t,n,r,i,o)=>e.extend(function(e,t,n){const r=t.imageManager.getPattern(e.toString()),{width:i,height:o}=t.imageManager.getPixelSize(),a=Math.pow(2,n.tileID.overscaledZ),s=n.tileSize*Math.pow(2,t.transform.tileZoom)/a,l=s*(n.tileID.canonical.x+n.tileID.wrap*a),u=s*n.tileID.canonical.y;return{u_image:0,u_pattern_tl:r.tl,u_pattern_br:r.br,u_texsize:[i,o],u_pattern_size:r.displaySize,u_tile_units_to_pixels:1/I(n,1,t.transform.tileZoom),u_pixel_coord_upper:[l>>16,u>>16],u_pixel_coord_lower:[65535&l,65535&u]}}(i,r,o),{u_matrix:t,u_opacity:n}),ur={fillExtrusion:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t)}),fillExtrusionPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_height_factor:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t)}),fill:t=>({u_matrix:new e.UniformMatrix4f(t)}),fillPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),fillOutline:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t)}),fillOutlinePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),circle:t=>({u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),collisionBox:t=>({u_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.Uniform2f(t)}),collisionCircle:t=>({u_matrix:new e.UniformMatrix4f(t),u_inv_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_viewport_size:new e.Uniform2f(t)}),debug:t=>({u_color:new e.UniformColor(t),u_matrix:new e.UniformMatrix4f(t),u_overlay:new e.Uniform1i(t),u_overlay_scale:new e.Uniform1f(t)}),clippingMask:t=>({u_matrix:new e.UniformMatrix4f(t)}),heatmap:t=>({u_extrude_scale:new e.Uniform1f(t),u_intensity:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),heatmapTexture:t=>({u_image:new e.Uniform1i(t),u_color_ramp:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t)}),hillshade:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_latrange:new e.Uniform2f(t),u_light:new e.Uniform2f(t),u_shadow:new e.UniformColor(t),u_highlight:new e.UniformColor(t),u_accent:new e.UniformColor(t)}),hillshadePrepare:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_dimension:new e.Uniform2f(t),u_zoom:new e.Uniform1f(t),u_unpack:new e.Uniform4f(t)}),line:t=>({u_matrix:new e.UniformMatrix4f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_units_to_pixels:new e.Uniform2f(t),u_dash_image:new e.Uniform1i(t),u_gradient_image:new e.Uniform1i(t),u_image_height:new e.Uniform1f(t),u_texsize:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t),u_trim_offset:new e.Uniform2f(t)}),linePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_texsize:new e.Uniform2f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_units_to_pixels:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t)}),raster:t=>({u_matrix:new e.UniformMatrix4f(t),u_tl_parent:new e.Uniform2f(t),u_scale_parent:new e.Uniform1f(t),u_fade_t:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_image0:new e.Uniform1i(t),u_image1:new e.Uniform1i(t),u_brightness_low:new e.Uniform1f(t),u_brightness_high:new e.Uniform1f(t),u_saturation_factor:new e.Uniform1f(t),u_contrast_factor:new e.Uniform1f(t),u_spin_weights:new e.Uniform3f(t),u_perspective_transform:new e.Uniform2f(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_texture:new e.Uniform1i(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_is_halo:new e.Uniform1i(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texsize_icon:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_texture_icon:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_is_halo:new e.Uniform1i(t)}),background:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_color:new e.UniformColor(t)}),backgroundPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_pattern_tl:new e.Uniform2f(t),u_pattern_br:new e.Uniform2f(t),u_texsize:new e.Uniform2f(t),u_pattern_size:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),terrainRaster:xn,terrainDepth:xn,skybox:t=>({u_matrix:new e.UniformMatrix4f(t),u_sun_direction:new e.Uniform3f(t),u_cubemap:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxGradient:t=>({u_matrix:new e.UniformMatrix4f(t),u_color_ramp:new e.Uniform1i(t),u_center_direction:new e.Uniform3f(t),u_radius:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxCapture:t=>({u_matrix_3f:new e.UniformMatrix3f(t),u_sun_direction:new e.Uniform3f(t),u_sun_intensity:new e.Uniform1f(t),u_color_tint_r:new e.Uniform4f(t),u_color_tint_m:new e.Uniform4f(t),u_luminance:new e.Uniform1f(t)}),globeRaster:t=>({u_proj_matrix:new e.UniformMatrix4f(t),u_globe_matrix:new e.UniformMatrix4f(t),u_normalize_matrix:new e.UniformMatrix4f(t),u_merc_matrix:new e.UniformMatrix4f(t),u_zoom_transition:new e.Uniform1f(t),u_merc_center:new e.Uniform2f(t),u_image0:new e.Uniform1i(t),u_grid_matrix:new e.UniformMatrix3f(t),u_skirt_height:new e.Uniform1f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_viewport:new e.Uniform2f(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_horizon:new e.Uniform1f(t),u_transition:new e.Uniform1f(t),u_fadeout_range:new e.Uniform1f(t),u_color:new e.Uniform4f(t),u_high_color:new e.Uniform4f(t),u_space_color:new e.Uniform4f(t),u_star_intensity:new e.Uniform1f(t),u_star_density:new e.Uniform1f(t),u_star_size:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t),u_horizon_angle:new e.Uniform1f(t),u_rotation_matrix:new e.UniformMatrix4f(t)})};let cr;function hr(t,n,r,i,o,a,s){const l=t.context,u=l.gl,c=t.transform,h=t.useProgram("collisionBox"),d=[];let f=0,p=0;for(let m=0;m0){const t=e.create(),n=x;e.mul(t,y.placementInvProjMatrix,c.glCoordMatrix),e.mul(t,t,y.placementViewportMatrix),d.push({circleArray:w,circleOffset:p,transform:n,invTransform:t,projection:y.getProjection()}),f+=w.length/4,p=f}b&&(t.terrain&&t.terrain.setupElevationDraw(g,h),h.draw(l,u.LINES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,Zn(x,c,g,y.getProjection()),r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,c.zoom,null,[b.collisionVertexBuffer,b.collisionVertexBufferExt]))}if(!s||!d.length)return;const m=t.useProgram("collisionCircle"),_=new e.StructArrayLayout2f1f2i16;_.resize(4*f),_._trim();let g=0;for(const e of d)for(let t=0;t=0&&(m[x.associatedIconIndex]={x:S,y:k,z:M,angle:O})}else mt(E,f)}if(h){p.clear();const n=t.icon.placedSymbolArray;for(let t=0;te.sortKey-t.sortKey);for(const e of k){const n=e.state;if(t.terrain&&t.terrain.setupElevationDraw(n.tile,n.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:n.labelPlaneMatrixInv}),f.activeTexture.set(p.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,p.CLAMP_TO_EDGE),n.atlasTextureIcon&&(f.activeTexture.set(p.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),n.isSDF){const i=n.uniformValues;n.hasHalo&&(i.u_is_halo=1,gr(n.buffers,e.segments,r,t,n.program,w,h,d,i)),i.u_is_halo=0}gr(n.buffers,e.segments,r,t,n.program,w,h,d,n.uniformValues)}}function gr(t,n,r,i,o,a,s,l,u){const c=i.context,h=[t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.globeExtVertexBuffer];o.draw(c,c.gl.TRIANGLES,a,s,l,e.CullFaceMode.disabled,u,r.id,t.layoutVertexBuffer,t.indexBuffer,n,r.paint,i.transform.zoom,t.programConfigurations.get(r.id),h)}function yr(t,n,r,i,o,a,s){const l=t.context.gl,u=r.paint.get("fill-pattern"),c=u&&u.constantOr(1);let h,d,f,p,m;s?(d=c&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=l.LINES):(d=c?"fillPattern":"fill",h=l.TRIANGLES);for(const _ of i){const i=n.getTile(_);if(c&&!i.patternsLoaded())continue;const g=i.getBucket(r);if(!g)continue;t.prepareDrawTile();const y=g.programConfigurations.get(r.id),v=t.useProgram(d,y);c&&(t.context.activeTexture.set(l.TEXTURE0),i.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),y.updatePaintBuffers());const x=u.constantOr(null);if(x&&i.imageAtlas){const e=i.imageAtlas.patternPositions[x.toString()];e&&y.setConstantPatternPositions(e)}const b=t.translatePosMatrix(_.projMatrix,i,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if(s){p=g.indexBuffer2,m=g.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===d&&c?Vn(b,t,i,e):Un(b,e)}else p=g.indexBuffer,m=g.segments,f=c?Nn(b,t,i):jn(b);t.prepareDrawProgram(t.context,v,_.toUnwrapped()),v.draw(t.context,h,o,t.stencilModeForClipping(_),a,e.CullFaceMode.disabled,f,r.id,g.layoutVertexBuffer,p,m,r.paint,t.transform.zoom,y)}}function vr(t,n,r,i,o,a,s){const l=t.context,u=l.gl,c=t.transform,h=r.paint.get("fill-extrusion-pattern"),d=h.constantOr(1),f=r.paint.get("fill-extrusion-opacity"),p=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),r.paint.get("fill-extrusion-ambient-occlusion-radius")],m=r.layout.get("fill-extrusion-edge-radius"),_=m>0&&!r.paint.get("fill-extrusion-rounded-roof"),g=_?0:m,y="globe"===c.projection.name?e.fillExtrusionHeightLift():0,v="globe"===c.projection.name,x=v?e.globeToMercatorTransition(c.zoom):0,b=[e.mercatorXfromLng(c.center.lng),e.mercatorYfromLat(c.center.lat)],w=[];v&&w.push("PROJECTION_GLOBE_VIEW"),p[0]>0&&w.push("FAUX_AO"),_&&w.push("ZERO_ROOF_RADIUS");for(const m of i){const i=n.getTile(m),_=i.getBucket(r);if(!_||_.projection.name!==c.projection.name)continue;const E=_.programConfigurations.get(r.id),T=t.useProgram(d?"fillExtrusionPattern":"fillExtrusion",E,w);if(t.terrain){const e=t.terrain;if(t.style.terrainSetForDrapingOnly())e.setupElevationDraw(i,T,{useMeterToDem:!0});else{if(!_.enableTerrain)continue;if(e.setupElevationDraw(i,T,{useMeterToDem:!0}),xr(l,n,m,_,r,e),!_.centroidVertexBuffer){const e=T.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}}}d&&(t.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),E.updatePaintBuffers());const S=h.constantOr(null);if(S&&i.imageAtlas){const e=i.imageAtlas.patternPositions[S.toString()];e&&E.setConstantPatternPositions(e)}const k=t.translatePosMatrix(m.projMatrix,i,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),M=c.projection.createInversionMatrix(c,m.canonical),C=r.paint.get("fill-extrusion-vertical-gradient"),A=d?Fn(k,t,C,f,p,g,m,i,y,x,b,M):Bn(k,t,C,f,p,g,m,y,x,b,M);t.prepareDrawProgram(l,T,m.toUnwrapped());const I=[];t.terrain&&I.push(_.centroidVertexBuffer),v&&I.push(_.layoutVertexExtBuffer),T.draw(l,l.gl.TRIANGLES,o,a,s,e.CullFaceMode.backCCW,A,r.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,r.paint,t.transform.zoom,E,I)}}function xr(t,n,r,i,o,a){const s=[t=>{let n=t.canonical.x-1,r=t.wrap;return n<0&&(n=(1<{let n=t.canonical.x+1,r=t.wrap;return n===1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<{const t=n.getSource().minzoom,r=e=>{const t=n.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},i=[0,-1,1];for(const n of i){if(e.overscaledZ+n(u[0]=Math.min(t.min.y,n.min.y),u[1]=Math.max(t.max.y,n.max.y),u[2]=e.EXTENT-n.min.x>t.max.x?n.min.x-e.EXTENT:t.max.x,u),h=(t,n)=>(u[0]=Math.min(t.min.x,n.min.x),u[1]=Math.max(t.max.x,n.max.x),u[2]=e.EXTENT-n.min.y>t.max.y?n.min.y-e.EXTENT:t.max.y,u),d=[(e,t)=>c(e,t),(e,t)=>c(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],f=new e.Point(0,0);let p,m,_;const g=(t,n,i,o,s)=>{const l=[[o?i:t,o?t:i,0],[o?i:n,o?n:i,0]],u=s<0?e.EXTENT+s:s,c=[o?u:(t+n)/2,o?(t+n)/2:u,0];return 0===i&&s<0||0!==i&&s>0?a.getForTilePoints(_,[c],!0,m):l.push(c),a.getForTilePoints(r,l,!0,p),Math.max(l[0][2],l[1][2],c[2])/a.exaggeration()};for(let t=0;t<4;t++){const n=(t<2?1:5)-t,o=i.borders[t];if(0===o.length)continue;const u=_=s[t](r),c=l(u);if(!(c&&c instanceof e.FillExtrusionBucket&&c.enableTerrain))continue;if(i.borderDoneWithNeighborZ[t]===c.canonical.z&&c.borderDoneWithNeighborZ[n]===i.canonical.z)continue;if(m=a.findDEMTileFor(u),!m||!m.dem)continue;if(!p){const e=a.findDEMTileFor(r);if(!e||!e.dem)return;p=e}const h=c.borders[n];let y=0;const v=c.borderDoneWithNeighborZ[n]!==i.canonical.z;if(i.canonical.z===c.canonical.z){for(let r=0;rs[0]+3));)v&&c.encodeCentroid(void 0,l,!1),y++;if(l&&ys[1]-3)&&(o++,++y!==h.length);)l=c.featuresOnBorder[h[y]];if(l=c.featuresOnBorder[h[r]],a.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(y=r),i.encodeCentroid(void 0,a,!1),v&&c.encodeCentroid(void 0,l,!1);continue}const u=d[t](a,l),p=t%2?e.EXTENT-1:0;f.x=g(u[0],Math.min(e.EXTENT-1,u[1]),p,t<2,u[2]),f.y=0,i.encodeCentroid(f,a,!1),v&&c.encodeCentroid(f,l,!1)}else i.encodeCentroid(void 0,a,!1)}i.borderDoneWithNeighborZ[t]=c.canonical.z,i.needsCentroidUpdate=!0,v&&(c.borderDoneWithNeighborZ[n]=i.canonical.z,c.needsCentroidUpdate=!0)}else{for(const e of o)i.encodeCentroid(void 0,i.featuresOnBorder[e],!1);if(v){for(const e of h)c.encodeCentroid(void 0,c.featuresOnBorder[e],!1);c.borderDoneWithNeighborZ[n]=i.canonical.z,c.needsCentroidUpdate=!0}i.borderDoneWithNeighborZ[t]=c.canonical.z,i.needsCentroidUpdate=!0}}(i.needsCentroidUpdate||!i.centroidVertexBuffer&&0!==i.centroidVertexArray.length)&&i.uploadCentroid(t)}const br=new e.Color(1,0,0,1),wr=new e.Color(0,1,0,1),Er=new e.Color(0,0,1,1),Tr=new e.Color(1,0,1,1),Sr=new e.Color(0,1,1,1);function kr(t,n,r){const i=t.context,o=t.transform,a=i.gl,s="globe"===o.projection.name,l=s?["PROJECTION_GLOBE_VIEW"]:null;let u=r.projMatrix;if(s&&e.globeToMercatorTransition(o.zoom)>0){const t=e.transitionTileAABBinECEF(r.canonical,o),n=e.globeDenormalizeECEF(t);u=e.multiply(new Float32Array(16),o.globeMatrix,n),e.multiply(u,o.projMatrix,u)}const c=t.useProgram("debug",null,l),h=n.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(h,c);const d=e.DepthMode.disabled,f=e.StencilMode.disabled,p=t.colorModeForRenderPass(),m="$debug";i.activeTexture.set(a.TEXTURE0),t.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),s?h._makeGlobeTileDebugBuffers(t.context,o):h._makeDebugTileBoundsBuffers(t.context,o.projection);const _=h._tileDebugBuffer||t.debugBuffer,g=h._tileDebugIndexBuffer||t.debugIndexBuffer,y=h._tileDebugSegments||t.debugSegments;c.draw(i,a.LINE_STRIP,d,f,p,e.CullFaceMode.disabled,Wn(u,e.Color.red),m,_,g,y,null,null,null,[h._globeTileDebugBorderBuffer]);const v=h.latestRawTileData,x=Math.floor((v&&v.byteLength||0)/1024),b=n.getTile(r).tileSize,w=512/Math.min(b,512)*(r.overscaledZ/o.zoom)*.5;let E=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(E+=" => "+r.overscaledZ),E+=` ${x}kb`,function(e,t){e.initDebugOverlayCanvas();const n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,n.width,n.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,E);const T=h._tileDebugTextBuffer||t.debugBuffer,S=h._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,k=h._tileDebugTextSegments||t.debugSegments;c.draw(i,a.TRIANGLES,d,f,e.ColorMode.alphaBlended,e.CullFaceMode.disabled,Wn(u,e.Color.transparent,w),m,T,S,k,null,null,null,[h._globeTileDebugTextBuffer])}function Mr(e,t,n,r){Ar(e,0,t+n/2,e.transform.width,n,r)}function Cr(e,t,n,r){Ar(e,t-n/2,0,n,e.transform.height,r)}function Ar(t,n,r,i,o,a){const s=t.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(n*e.exported.devicePixelRatio,r*e.exported.devicePixelRatio,i*e.exported.devicePixelRatio,o*e.exported.devicePixelRatio),s.clear({color:a}),l.disable(l.SCISSOR_TEST)}const Ir=e.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Pr}=Ir;function Or(e,t,n,r){e.emplaceBack(t,n,r)}class zr{constructor(t){this.vertexArray=new e.StructArrayLayout3f12,this.indices=new e.StructArrayLayout3ui6,Or(this.vertexArray,-1,-1,1),Or(this.vertexArray,1,-1,1),Or(this.vertexArray,-1,1,1),Or(this.vertexArray,1,1,1),Or(this.vertexArray,-1,-1,-1),Or(this.vertexArray,1,-1,-1),Or(this.vertexArray,-1,1,-1),Or(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=t.createVertexBuffer(this.vertexArray,Pr),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.SegmentVector.simpleSegment(0,0,36,12)}}function Lr(t,n,r,i,o,a){const s=t.gl,l=n.paint.get("sky-atmosphere-color"),u=n.paint.get("sky-atmosphere-halo-color"),c=n.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,n,r,i)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:n,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[i.r,i.g,i.b,i.a],u_luminance:5e-5}))(e.fromMat4(e.create$1(),i),o,c,l,u);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+a,n.skyboxTexture,0),r.draw(t,s.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.frontCW,h,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const Dr=e.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Rr{constructor(t){const n=new e.StructArrayLayout5f20;n.emplaceBack(-1,1,1,0,0),n.emplaceBack(1,1,1,1,0),n.emplaceBack(1,-1,1,1,1),n.emplaceBack(-1,-1,1,0,1);const r=new e.StructArrayLayout3ui6;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(n,Dr.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=e.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Br={symbol:function(t,n,r,i,o){if("translucent"!==t.renderPass)return;const a=e.StencilMode.disabled,s=t.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(t,n,r,i,o,a,s){const l=n.transform,u="map"===o,c="map"===a;for(const n of t){const t=i.getTile(n),o=t.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const a=e.evaluateSizeForZoom(o.textSizeData,l.zoom),h=bt(n,o.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),f=nt(h,t.tileID.canonical,c,u,l,o.getProjection(),d),p="none"!==r.layout.get("icon-text-fit")&&o.hasIconData();if(a){const r=Math.pow(2,l.zoom-t.tileID.overscaledZ);pr(o,u,c,s,e.symbolSize,l,f,n,r,a,p)}}}(i,t,r,n,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&_r(t,n,r,i,!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"),a,s),0!==r.paint.get("text-opacity").constantOr(1)&&_r(t,n,r,i,!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"),a,s),n.map.showCollisionBoxes&&(hr(t,n,r,i,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),hr(t,n,r,i,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===a.constantOr(1)||0===s.constantOr(1)))return;const u=t.context,c=u.gl,h=t.transform,d=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),f=e.StencilMode.disabled,p=t.colorModeForRenderPass(),m="globe"===h.projection.name,_=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],g=[];for(let o=0;oe.sortKey-t.sortKey);const y={useDepthForOcclusion:!m};for(const n of g){const{programConfiguration:i,program:o,layoutVertexBuffer:a,globeExtVertexBuffer:s,indexBuffer:l,uniformValues:m,tile:_}=n.state,g=n.segments;t.terrain&&t.terrain.setupElevationDraw(_,o,y),t.prepareDrawProgram(u,o,_.tileID.toUnwrapped()),o.draw(u,c.TRIANGLES,d,f,p,e.CullFaceMode.disabled,m,r.id,a,l,g,r.paint,h.zoom,i,[s])}},heatmap:function(t,n,r,i){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,a=o.gl,s=e.StencilMode.disabled,l=new e.ColorMode([a.ONE,a.ONE],e.Color.transparent,[!0,!0,!0,!0]);!function(e,t,n,r){const i=e.gl,o=t.width*r,a=t.height*r;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,o,a]);let s=n.heatmapFbo;if(!s||s&&(s.width!==o||s.height!==a)){s&&s.destroy();const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),s=n.heatmapFbo=e.createFramebuffer(o,a,!1),function(e,t,n,r,i,o){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,e.isWebGL2&&e.extRenderToTextureHalfFloat?a.RGBA16F:a.RGBA,i,o,0,a.RGBA,e.extRenderToTextureHalfFloat?e.isWebGL2?a.HALF_FLOAT:e.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),r.colorAttachment.set(n)}(e,0,t,s,o,a)}else i.bindTexture(i.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)}(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.Color.transparent});const u=t.transform,c="globe"===u.projection.name,h=c?["PROJECTION_GLOBE_VIEW"]:null,d=c?e.CullFaceMode.frontCCW:e.CullFaceMode.disabled,f=[e.mercatorXfromLng(u.center.lng),e.mercatorYfromLat(u.center.lat)];for(let p=0;p({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,n),n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,n.paint,t.transform.zoom)}(t,r))},line:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),a=r.paint.get("line-width");if(0===o.constantOr(1)||0===a.constantOr(1))return;const s=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),l=t.colorModeForRenderPass(),u=t.terrain&&t.terrain.renderingToTexture?1:e.exported.devicePixelRatio,c=r.paint.get("line-dasharray"),h=c.constantOr(1),d=r.layout.get("line-cap"),f=r.paint.get("line-pattern"),p=f.constantOr(1),m=r.paint.get("line-gradient"),_=p?"linePattern":"line",g=t.context,y=g.gl,v=(e=>{const t=[];er(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const n=e.paint.get("line-trim-offset");0===n[0]&&0===n[1]||t.push("RENDER_LINE_TRIM_OFFSET");const r=e.paint.get("line-pattern").constantOr(1),i=1!==e.paint.get("line-opacity").constantOr(1);return!r&&i&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(r);let x=v.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(x=!1);for(const o of i){const i=n.getTile(o);if(p&&!i.patternsLoaded())continue;const a=i.getBucket(r);if(!a)continue;t.prepareDrawTile();const b=a.programConfigurations.get(r.id),w=t.useProgram(_,b,v),E=f.constantOr(null);if(E&&i.imageAtlas){const e=i.imageAtlas.patternPositions[E.toString()];e&&b.setConstantPatternPositions(e)}const T=c.constantOr(null),S=d.constantOr(null);if(!p&&T&&S&&i.lineAtlas){const e=i.lineAtlas.getDash(T,S);e&&b.setConstantPatternPositions(e)}let[k,M]=r.paint.get("line-trim-offset");if("round"===S||"square"===S){const e=1;k!==M&&(0===k&&(k-=e),1===M&&(M+=e))}const C=t.terrain?o.projMatrix:null,A=p?Kn(t,i,r,C,u):Yn(t,i,r,C,a.lineClipsArray.length,u,[k,M]);if(m){const i=a.gradients[r.id];let s=i.texture;if(r.gradientVersion!==i.version){let l=256;if(r.stepInterpolant){const r=n.getSource().maxzoom,i=o.canonical.z===r?Math.ceil(1<{w.draw(g,y.TRIANGLES,s,n,l,e.CullFaceMode.disabled,A,r.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,r.paint,t.transform.zoom,b,[a.layoutVertexBuffer2])};if(x){const n=t.stencilModeForClipping(o).ref;0===n&&t.terrain&&g.clear({stencil:0});const r={func:y.EQUAL,mask:255};A.u_alpha_discard_threshold=.8,I(new e.StencilMode(r,n,255,y.KEEP,y.KEEP,y.INVERT)),A.u_alpha_discard_threshold=0,I(new e.StencilMode(r,n,255,y.KEEP,y.KEEP,y.KEEP))}else I(t.stencilModeForClipping(o))}x&&(t.resetStencilClippingMasks(),t.terrain&&g.clear({stencil:0}))},fill:function(t,n,r,i){const o=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const s=t.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(e.Color.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const o=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly);yr(t,n,r,i,o,s,!1)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const o=t.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,e.DepthMode.ReadOnly);yr(t,n,r,i,o,s,!0)}},"fill-extrusion":function(t,n,r,i){const o=r.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===t.renderPass){const a=new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);if(1!==o||r.paint.get("fill-extrusion-pattern").constantOr(1))vr(t,n,r,i,a,e.StencilMode.disabled,e.ColorMode.disabled),vr(t,n,r,i,a,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const o=t.colorModeForRenderPass();vr(t,n,r,i,a,e.StencilMode.disabled,o)}}},hillshade:function(t,n,r,i){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const o=t.context,a=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),s=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture,[u,c]="translucent"!==t.renderPass||l?[{},i]:t.stencilConfigForOverlap(i);for(const i of c){const o=n.getTile(i);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)vn(t,o,r,a,e.StencilMode.disabled,s);else if("translucent"===t.renderPass){const e=l&&t.terrain?t.terrain.stencilModeForRTTOverlap(i):u[i.overscaledZ];gn(t,i,o,r,a,e,s)}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,n,r,i,o,a){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;if(!i.length)return;const s=t.context,l=s.gl,u=n.getSource(),c=t.useProgram("raster"),h=t.colorModeForRenderPass(),d=t.terrain&&t.terrain.renderingToTexture,[f,p]=u instanceof Ce||d?[{},i]:t.stencilConfigForOverlap(i),m=p[p.length-1].overscaledZ,_=!t.options.moving;for(const i of p){const o=d?e.DepthMode.disabled:t.depthModeForSublayer(i.overscaledZ-m,1===r.paint.get("raster-opacity")?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly,l.LESS),p=i.toUnwrapped(),g=n.getTile(i);if(d&&(!g||!g.hasData()))continue;const y=d?i.projMatrix:t.transform.calculateProjMatrix(p,_),v=t.terrain&&d?t.terrain.stencilModeForRTTOverlap(i):f[i.overscaledZ],x=a?0:r.paint.get("raster-fade-duration");g.registerFadeDuration(x);const b=n.findLoadedParent(i,0),w=An(g,b,n,t.transform,x);let E,T;t.terrain&&t.terrain.prepareDrawTile();const S="nearest"===r.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;s.activeTexture.set(l.TEXTURE0),g.texture.bind(S,l.CLAMP_TO_EDGE),s.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),E=Math.pow(2,b.tileID.overscaledZ-g.tileID.overscaledZ),T=[g.tileID.canonical.x*E%1,g.tileID.canonical.y*E%1]):g.texture.bind(S,l.CLAMP_TO_EDGE),g.texture.useMipmap&&s.extTextureFilterAnisotropic&&t.transform.pitch>20&&l.texParameterf(l.TEXTURE_2D,s.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,s.extTextureFilterAnisotropicMax);const k=tr(y,T||[0,0],E||1,w,r,u instanceof Ce?u.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(s,c,p),u instanceof Ce)u.boundsBuffer&&u.boundsSegments&&c.draw(s,l.TRIANGLES,o,e.StencilMode.disabled,h,e.CullFaceMode.disabled,k,r.id,u.boundsBuffer,t.quadTriangleIndexBuffer,u.boundsSegments);else{const{tileBoundsBuffer:n,tileBoundsIndexBuffer:i,tileBoundsSegments:a}=t.getTileBoundsBuffers(g);c.draw(s,l.TRIANGLES,o,v,h,e.CullFaceMode.disabled,k,r.id,n,i,a)}}t.resetStencilClippingMasks()},background:function(t,n,r,i){const o=r.paint.get("background-color"),a=r.paint.get("background-opacity");if(0===a)return;const s=t.context,l=s.gl,u=t.transform,c=u.tileSize,h=r.paint.get("background-pattern");if(t.isPatternMissing(h))return;const d=!h&&1===o.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==d)return;const f=e.StencilMode.disabled,p=t.depthModeForSublayer(0,"opaque"===d?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly),m=t.colorModeForRenderPass(),_=t.useProgram(h?"backgroundPattern":"background");let g,y=i;y||(g=t.getBackgroundTiles(),y=Object.values(g).map(e=>e.tileID)),h&&(s.activeTexture.set(l.TEXTURE0),t.imageManager.bind(t.context));for(const d of y){const y=d.toUnwrapped(),v=i?d.projMatrix:t.transform.calculateProjMatrix(y);t.prepareDrawTile();const x=n?n.getTile(d):g?g[d.key]:new e.Tile(d,c,u.zoom,t),b=h?lr(v,a,t,h,{tileID:d,tileSize:c}):sr(v,a,o);t.prepareDrawProgram(s,_,y);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:E,tileBoundsSegments:T}=t.getTileBoundsBuffers(x);_.draw(s,l.TRIANGLES,p,f,m,e.CullFaceMode.disabled,b,r.id,w,E,T)}},sky:function(t,n,r){const i=t.transform,o="mercator"===i.projection.name||"globe"===i.projection.name?1:e.smoothstep(7,8,i.zoom),a=r.paint.get("sky-opacity")*o;if(0===a)return;const s=t.context,l=r.paint.get("sky-type"),u=new e.DepthMode(s.gl.LEQUAL,e.DepthMode.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&(function(t,n,r,i){const o=t.context,a=o.gl;let s=n.skyboxFbo;if(!s){s=n.skyboxFbo=o.createFramebuffer(32,32,!1),n.skyboxGeometry=new zr(o),n.skyboxTexture=o.gl.createTexture(),a.bindTexture(a.TEXTURE_CUBE_MAP,n.skyboxTexture),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR);for(let e=0;e<6;++e)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,a.RGBA,32,32,0,a.RGBA,a.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(s.framebuffer),o.viewport.set([0,0,32,32]);const l=n.getCenter(t,!0),u=t.useProgram("skyboxCapture"),c=new Float64Array(16);e.identity(c),e.rotateY(c,c,.5*-Math.PI),Lr(o,n,u,c,l,0),e.identity(c),e.rotateY(c,c,.5*Math.PI),Lr(o,n,u,c,l,1),e.identity(c),e.rotateX(c,c,.5*-Math.PI),Lr(o,n,u,c,l,2),e.identity(c),e.rotateX(c,c,.5*Math.PI),Lr(o,n,u,c,l,3),e.identity(c),Lr(o,n,u,c,l,4),e.identity(c),e.rotateY(c,c,Math.PI),Lr(o,n,u,c,l,5),o.viewport.set([0,0,t.width,t.height])}(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,n,r,i,o){const a=t.context,s=a.gl,l=t.transform,u=t.useProgram("skybox");a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,n.skyboxTexture);const c=((e,t,n,r,i)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:i}))(l.skyboxMatrix,n.getCenter(t,!1),0,i,o);t.prepareDrawProgram(a,u),u.draw(a,s.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,c,"skybox",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,r,u,a,c):"gradient"===l&&"sky"===t.renderPass&&function(t,n,r,i,o){const a=t.context,s=a.gl,l=t.transform,u=t.useProgram("skyboxGradient");n.skyboxGeometry||(n.skyboxGeometry=new zr(a)),a.activeTexture.set(s.TEXTURE0);let c=n.colorRampTexture;c||(c=n.colorRampTexture=new e.Texture(a,n.colorRamp,s.RGBA)),c.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=((t,n,r,i,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:n,u_radius:e.degToRad(r),u_opacity:i,u_temporal_offset:o}))(l.skyboxMatrix,n.getCenter(t,!1),n.paint.get("sky-gradient-radius"),i,o);t.prepareDrawProgram(a,u),u.draw(a,s.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,h,"skyboxGradient",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,r,u,a,c)},debug:function(e,t,n){for(let r=0;rr)return void(this.transform.fogCullDistSq=null);const i=n+.78*(r-n);this.transform.fogCullDistSq=i*i}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,n){if(this.width=t*e.exported.devicePixelRatio,this.height=n*e.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,n=new e.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(e.EXTENT,0),n.emplaceBack(0,e.EXTENT),n.emplaceBack(e.EXTENT,e.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(n,e.posAttributes.members),this.tileExtentSegments=e.SegmentVector.simpleSegment(0,0,4,2);const r=new e.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(e.EXTENT,0),r.emplaceBack(0,e.EXTENT),r.emplaceBack(e.EXTENT,e.EXTENT),this.debugBuffer=t.createVertexBuffer(r,e.posAttributes.members),this.debugSegments=e.SegmentVector.simpleSegment(0,0,4,5);const i=new e.StructArrayLayout2i4;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(-1,1),i.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(i,e.posAttributes.members),this.viewportSegments=e.SegmentVector.simpleSegment(0,0,4,2);const o=new e.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(e.EXTENT,0,e.EXTENT,0),o.emplaceBack(0,e.EXTENT,0,e.EXTENT),o.emplaceBack(e.EXTENT,e.EXTENT,e.EXTENT,e.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.boundsAttributes.members),this.mercatorBoundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);const a=new e.StructArrayLayout3ui6;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const s=new e.StructArrayLayout1ui2;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(s),this.emptyTexture=new e.Texture(t,new e.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.create();const l=this.context.gl;this.stencilClearMode=new e.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.window.performance.now()),this.atmosphereBuffer=new Rr(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(t,n.TRIANGLES,e.DepthMode.disabled,this.stencilClearMode,e.ColorMode.disabled,e.CullFaceMode.disabled,Cn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,n,r){if(!n||this.currentStencilSource===n.id||!t.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of r)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=n.id;const i=this.context,o=i.gl;this.nextStencilID+r.length>256&&this.clearStencil(),i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of r){const r=n.getTile(t),s=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:u,tileBoundsSegments:c}=this.getTileBoundsBuffers(r);a.draw(i,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},s,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Cn(t.projMatrix),"$clipping",l,u,c)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new e.StencilMode({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const n=this.context.gl;return new e.StencilMode({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,r=t.sort((e,t)=>t.overscaledZ-e.overscaledZ),i=r[r.length-1].overscaledZ,o=r[0].overscaledZ-i+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let r=0;r=0;this.currentLayer--){const e=this.style._layers[r[this.currentLayer]],n=t._getLayerSourceCache(e);if(e.isSky())continue;const i=n?a[n.id]:void 0;this._renderTileClippingMasks(e,n,i),this.renderLayer(this,n,e,i)}if(this.style.fog&&this.transform.projection.supportsFog&&function(t,n){const r=t.context,i=r.gl,o=t.transform,a=new e.DepthMode(i.LEQUAL,e.DepthMode.ReadOnly,[0,1]),s=t.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=e.globeToMercatorTransition(o.zoom),u=n.properties.get("color").toArray01(),c=n.properties.get("high-color").toArray01(),h=n.properties.get("space-color").toArray01PremultipliedAlpha(),d=e.identity$1([]);e.rotateY$1(d,d,-e.degToRad(o._center.lng)),e.rotateX$1(d,d,e.degToRad(o._center.lat)),e.rotateZ$1(d,d,o.angle),e.rotateX$1(d,d,-o._pitch);const f=e.fromQuat(new Float32Array(16),d),p=e.mapValue(n.properties.get("star-intensity"),0,1,0,.25),m=5e-4,_=e.mapValue(n.properties.get("horizon-blend"),0,1,m,.25),g=e.globeUseCustomAntiAliasing(t,r,o)&&_===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=t.frameCounter/1e3%1,v=e.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(g,2)),b=Math.acos(x/v),w=((t,n,r,i,o,a,s,l,u,c,h,d,f,p)=>({u_frustum_tl:t,u_frustum_tr:n,u_frustum_br:r,u_frustum_bl:i,u_horizon:o,u_transition:a,u_fadeout_range:s,u_color:l,u_high_color:u,u_space_color:c,u_star_intensity:h,u_star_size:5*e.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:d,u_horizon_angle:f,u_rotation_matrix:p}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,l,_,u,c,h,p,y,b,f);t.prepareDrawProgram(r,s);const E=t.atmosphereBuffer;E&&s.draw(r,i.TRIANGLES,a,e.StencilMode.disabled,e.ColorMode.alphaBlended,e.CullFaceMode.backCW,w,"skybox",E.vertexBuffer,E.indexBuffer,E.segments)}(this,this.style.fog),this.renderPass="sky",(e.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const r=t._getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&(!n||n.getSource().maxzoom0?t.pop():null}isPatternMissing(e){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.terrain&&0===this.terrain.exaggeration(),n=this.style&&this.style.fog,r=[];return this.terrainRenderModeElevated()&&r.push("TERRAIN"),"globe"===this.transform.projection.name&&r.push("GLOBE"),t&&r.push("ZERO_EXAGGERATION"),n&&!e&&0!==n.getOpacity(this.transform.pitch)&&r.push("FOG"),e&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}useProgram(e,t,n){this.cache=this.cache||{};const r=n||[],i=this.currentGlobalDefines().concat(r),o=Ln.cacheKey(dn[e],e,i,t);return this.cache[o]||(this.cache[o]=new Ln(this.context,e,dn[e],t,ur[e],i)),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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=e.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.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(t,n,r){if(this.terrain&&this.terrain.renderingToTexture)return;const i=this.style.fog;if(i){const o=i.getOpacity(this.transform.pitch),a=((t,n,r,i,o,a,s,l,u,c,h)=>{const d=t.transform,f=n.properties.get("color").toArray01();f[3]=i;const p=t.frameCounter/1e3%1;return{u_fog_matrix:r?d.calculateFogTileMatrix(r):t.identityMat,u_fog_range:n.getFovAdjustedRange(d._fov),u_fog_color:f,u_fog_horizon_blend:n.properties.get("horizon-blend"),u_fog_temporal_offset:p,u_frustum_tl:o,u_frustum_tr:a,u_frustum_br:s,u_frustum_bl:l,u_globe_pos:u,u_globe_radius:c,u_viewport:h,u_globe_transition:e.globeToMercatorTransition(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,i,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*e.exported.devicePixelRatio,this.transform.height*e.exported.devicePixelRatio]);n.setFogUniformValues(t,a)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,n=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const i of r)n[i.key]=t[i.key]||new e.Tile(i,512,this.transform.tileZoom,this);return n}clearBackgroundTiles(){this._backgroundTiles={}}}class jr{constructor(e=0,t=0,n=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(t,n,r){return null!=n.top&&null!=t.top&&(this.top=e.number(t.top,n.top,r)),null!=n.bottom&&null!=t.bottom&&(this.bottom=e.number(t.bottom,n.bottom,r)),null!=n.left&&null!=t.left&&(this.left=e.number(t.left,n.left,r)),null!=n.right&&null!=t.right&&(this.right=e.number(t.right,n.right,r)),this}getCenter(t,n){const r=e.clamp((this.left+t-this.right)/2,0,t),i=e.clamp((this.top+n-this.bottom)/2,0,n);return new e.Point(r,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new jr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Nr(t,n){const r=e.getColumn(t,3);e.fromQuat(t,n),e.setColumn(t,3,r)}function Ur(t,n){const r=e.identity$1([]);return e.rotateZ$1(r,r,-n),e.rotateX$1(r,r,-t),r}function Vr(t,n){const r=[t[0],t[1],0],i=[n[0],n[1],0];if(e.length(r)>=1e-15){const t=e.normalize([],r);e.scale$2(i,t,e.dot(i,t)),n[0]=i[0],n[1]=i[1]}const o=e.cross([],n,t);if(e.len(o)<1e-15)return null;const a=Math.atan2(-o[1],o[0]);return Ur(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),a)}class Gr{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const n=t instanceof e.MercatorCoordinate?t:new e.MercatorCoordinate(t[0],t[1],t[2]);this._renderWorldCopies&&(n.x=e.wrap(n.x,0,1)),this._position=n}else this._position=null}lookAtPoint(t,n){if(this.orientation=null,!this.position)return;const r=this.position,i=this._elevation?this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t)):0,o=e.MercatorCoordinate.fromLngLat(t,i),a=[o.x-r.x,o.y-r.y,o.z-r.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=Vr(a,n)}setPitchBearing(t,n){this.orientation=Ur(e.degToRad(t),e.degToRad(-n))}}class qr{constructor(t,n){this._transform=e.identity([]),this.orientation=n,this.position=t}get mercatorPosition(){const t=this.position;return new e.MercatorCoordinate(t[0],t[1],t[2])}get position(){const t=e.getColumn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var n;t&&e.setColumn(this._transform,3,[(n=t)[0],n[1],n[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.identity$1([]),t&&Nr(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Ur(e,t),Nr(this._transform,this._orientation)}forward(){const t=e.getColumn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.getColumn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.getColumn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,n){const r=new Float64Array(16);return e.invert(r,this.getWorldToCamera(t,n)),r}getWorldToCameraPosition(t,n,r){const i=this.position;e.scale$2(i,i,-t);const o=new Float64Array(16);return e.fromScaling(o,[r,r,r]),e.translate(o,o,i),o[10]*=n,o}getWorldToCamera(t,n){const r=new Float64Array(16),i=new Float64Array(4),o=this.position;return e.conjugate(i,this._orientation),e.scale$2(o,o,-t),e.fromQuat(r,i),e.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=n,r[9]*=n,r[10]*=n,r[11]*=n,r}getCameraToClipPerspective(t,n,r,i){const o=new Float64Array(16);return e.perspective(o,t,n,r,i),o}getDistanceToElevation(t,n=!1){const r=0===t?0:e.mercatorZfromAltitude(t,n?e.latFromMercatorY(this.position[1]):this.position[1]),i=this.forward();return(r-this.position[2])/i[2]}clone(){return new qr([...this.position],[...this.orientation])}}function $r(t,n){const r=Wr(t.projection,t.zoom,t.width,t.height),i=function(t,n,r,i,o){const a=new e.LngLat(r.lng-180*Xr,r.lat),s=new e.LngLat(r.lng+180*Xr,r.lat),l=t.project(a.lng,a.lat),u=t.project(s.lng,s.lat),c=-Math.atan2(u.y-l.y,u.x-l.x),h=e.MercatorCoordinate.fromLngLat(r);h.y=e.clamp(h.y,-1+Xr,1-Xr);const d=h.toLngLat(),f=t.project(d.lng,d.lat),p=e.MercatorCoordinate.fromLngLat(d);p.x+=Xr;const m=p.toLngLat(),_=t.project(m.lng,m.lat),g=Yr(_.x-f.x,_.y-f.y,c),y=e.MercatorCoordinate.fromLngLat(d);y.y+=Xr;const v=y.toLngLat(),x=t.project(v.lng,v.lat),b=Yr(x.x-f.x,x.y-f.y,c),w=Math.abs(g.x)/Math.abs(b.y),E=e.identity([]);e.rotateZ(E,E,-c*(1-(o?0:i)));const T=e.identity([]);return e.scale(T,T,[1,1-(1-w)*i,1]),T[4]=-b.x/b.y*i,e.rotateZ(T,T,c),e.multiply(T,E,T),T}(t.projection,0,t.center,r,n),o=Zr(t);return e.scale(i,i,[o,o,1]),i}function Zr(t){const n=t.projection,r=Wr(t.projection,t.zoom,t.width,t.height),i=Hr(n,t.center),o=Hr(n,e.LngLat.convert(n.center));return Math.pow(2,i*r+(1-r)*o)}function Wr(t,n,r,i,o=1/0){const a=t.range;if(!a)return 0;const s=Math.min(o,Math.max(r,i)),l=Math.log(s/1024)/Math.LN2;return e.smoothstep(a[0]+l,a[1]+l,n)}const Xr=1/4e4;function Hr(t,n){const r=e.clamp(n.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),i=new e.LngLat(n.lng-180*Xr,r),o=new e.LngLat(n.lng+180*Xr,r),a=t.project(i.lng,r),s=t.project(o.lng,r),l=e.MercatorCoordinate.fromLngLat(i),u=e.MercatorCoordinate.fromLngLat(o),c=s.x-a.x,h=s.y-a.y,d=u.x-l.x,f=u.y-l.y,p=Math.sqrt((d*d+f*f)/(c*c+h*h));return Math.log(p)/Math.LN2}function Yr(e,t,n){const r=Math.cos(n),i=Math.sin(n);return{x:e*r-t*i,y:e*i+t*r}}class Kr{constructor(t,n,r,i,o,a,s){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==i?60:i,this.setProjection(a),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new e.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 jr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new qr,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new Kr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e,t=!1){const n=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||n)&&this._updateCameraOnTerrain(),(e||n)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.pick(this.projection,["name","center","parallels"])}setProjection(n){this.projectionOptions=n||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=e.getProjection(this.projectionOptions);const i=!t(r,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.getProjection({name:"mercator"});const n=t!==this.projection.name;return n&&this._calcMatrices(),n}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.Point(this.width,this.height)}get bearing(){return e.wrap(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const n=-t*Math.PI/180;var r;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(r=new e.ARRAY_TYPE(4),e.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=e.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.degToRad(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-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 e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.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 t=this._elevation,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let i=0,o=0;for(let a=0;at.maxzoom&&(n=t.maxzoom);const a=this.locationCoordinate(this.center),s=this.center.lat,l=1<{const n=1/4e4,r=new e.MercatorCoordinate(t.x+n,t.y,t.z),i=new e.MercatorCoordinate(t.x,t.y+n,t.z),o=t.toLngLat(),a=r.toLngLat(),s=i.toLngLat(),l=this.locationCoordinate(o),u=this.locationCoordinate(a),c=this.locationCoordinate(s),h=Math.hypot(u.x-l.x,u.y-l.y),d=Math.hypot(c.x-l.x,c.y-l.y);return Math.sqrt(h*d)*b/n},E=t=>{const n=v,r=x;return{aabb:e.tileAABB(this,l,0,0,0,t,r,n,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:n,wrap:t,fullyVisible:!1}},T=[];let S=[];const k=n,M=t.reparseOverscaled?r:n,C=e=>e*e,A=C((m-this._centerAltitude)*p),I=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),n=e.aabb;t?(n.min[2]=t.min,n.max[2]=t.max,n.center[2]=(n.min[2]+n.max[2])/2):(e.shouldSplit=P(e),e.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},P=t=>{if(t.zoom=.9)return!0}else if(i&&(a=C(t.aabb.distanceZ(_)*p)),this.projection.isReprojectedInTileSpace&&r<=5){const n=Math.pow(2,t.zoom),r=w(new e.MercatorCoordinate((t.x+.5)/n,(t.y+.5)/n));l=r>.85?1:r}const u=n*n+o*o+a;return u{if(t*C(.707)0;){const r=T.pop(),a=r.x,s=r.y;let h=r.fullyVisible;if(!h){const e=r.aabb.intersects(d);if(0===e)continue;h=2===e}if(r.zoom!==k&&P(r))for(let t=0;t<4;t++){const n=(a<<1)+t%2,u=(s<<1)+(t>>1),d={aabb:o?r.aabb.quadrant(t):e.tileAABB(this,l,r.zoom+1,n,u,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:n,y:u,wrap:r.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};i&&!c&&(d.tileID=new e.OverscaledTileID(r.zoom+1===k?M:r.zoom+1,r.wrap,r.zoom+1,n,u),I(d)),T.push(d)}else{const i=r.zoom===k?M:r.zoom;if(t.minzoom&&t.minzoom>i)continue;const o=u[0]-(.5+a+(r.wrap<{const o=[0,0,0,1],a=[e.EXTENT,e.EXTENT,0,1],s=this.calculateFogTileMatrix(i.tileID.toUnwrapped());e.transformMat4$1(o,o,s),e.transformMat4$1(a,a,s);const l=e.getAABBPointSquareDist(o,a);if(0===l)return!0;let u=!1;const c=this._elevation;if(c&&l>n&&0!==r){const n=this.calculateProjMatrix(i.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=c.getMinMaxForTile(i.tileID)),o||(o={min:x,max:v});const a=e.furthestTileCorner(this.rotation),s=[a[0]*e.EXTENT,a[1]*e.EXTENT,o.max];e.transformMat4(s,s,n),u=(1-s[1])*this.height*.5e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const n=e.clamp(t.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),r=this.projection.project(t.lng,n);return new e.Point(r.x*this.worldSize,r.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,n){let r,i;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;r=(n.x-o.x)/e,i=(n.y-o.y)/e}else{const e=this.pointCoordinate(n),t=this.pointCoordinate(o);r=e.x-t.x,i=e.y-t.y}const a=this.locationCoordinate(t);this.setLocation(new e.MercatorCoordinate(a.x-r,a.y-i))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,n){const r=n?e.mercatorZfromAltitude(n,t.lat):void 0,i=this.projection.project(t.lng,t.lat);return new e.MercatorCoordinate(i.x,i.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,n){const r=null!=n?n:this._centerAltitude,i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.transformMat4$1(i,i,this.pixelMatrixInverse),e.transformMat4$1(o,o,this.pixelMatrixInverse);const a=o[3];e.scale$1(i,i,1/i[3]),e.scale$1(o,o,1/a);const s=i[2],l=o[2];return{p0:i,p1:o,t:s===l?0:(r-s)/(l-s)}}screenPointToMercatorRay(t){const n=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.transformMat4$1(n,n,this.pixelMatrixInverse),e.transformMat4$1(r,r,this.pixelMatrixInverse),e.scale$1(n,n,1/n[3]),e.scale$1(r,r,1/r[3]),n[2]=e.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,r[2]=e.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,e.scale$1(n,n,1/this.worldSize),e.scale$1(r,r,1/this.worldSize),new e.Ray([n[0],n[1],n[2]],e.normalize([],e.sub([],r,n)))}rayIntersectionCoordinate(t){const{p0:n,p1:r,t:i}=t,o=e.mercatorZfromAltitude(n[2],this._center.lat),a=e.mercatorZfromAltitude(r[2],this._center.lat);return new e.MercatorCoordinate(e.number(n[0],r[0],i)/this.worldSize,e.number(n[1],r[1],i)/this.worldSize,e.number(o,a,i))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.MercatorCoordinate(n[0],n[1],n[2]);let r=0,i=this.horizonLineFromTop();if(t.y>i)return this.pointCoordinate(t);const o=.02*i,a=t.clone();for(let t=0;t<10&&i-r>o;t++){a.y=e.number(r,i,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(i=a.y,n=t):r=a.y}return n?new e.MercatorCoordinate(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(t);const n=this.pointCoordinate(t);return n.y>=0&&n.y<=1}_coordinatePoint(t,n){const r=n&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,i=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.transformMat4$1(i,i,this.pixelMatrix),i[3]>0?new e.Point(i[0]/i[3],i[1]/i[3]):new e.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:n}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,i=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.Point(n,t)),a=this.pointLocation3D(new e.Point(i,t)),s=this.pointLocation3D(new e.Point(i,r)),l=this.pointLocation3D(new e.Point(n,r));let u=Math.min(o.lng,a.lng,s.lng,l.lng),c=Math.max(o.lng,a.lng,s.lng,l.lng),h=Math.min(o.lat,a.lat,s.lat,l.lat),d=Math.max(o.lat,a.lat,s.lat,l.lat);const f=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,m=(t,n,r,i,o)=>{const a=(t+r)/2,s=(n+i)/2,l=new e.Point(a,s),{lng:_,lat:g}=this.pointLocation3D(l),y=Math.max(0,u-_,h-g,_-c,g-d);u=Math.min(u,_),c=Math.max(c,_),h=Math.min(h,g),d=Math.max(d,g),(of)&&(m(t,n,a,s,o+1),m(a,s,r,i,o+1))};if(m(n,t,i,t,1),m(i,t,i,r,1),m(i,r,n,r,1),m(n,r,n,t,1),"globe"===this.projection.name){const[t,n]=e.polesInViewport(this);t?(d=90,c=180,u=-180):n&&(h=-90,c=180,u=-180)}return new e.LngLatBounds(new e.LngLat(u,h),new e.LngLat(c,d))}_getBoundsRectangular(t,n){const{top:r,left:i}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,a=this.width-this._edgeInsets.right,s=new e.Point(i,r),l=new e.Point(a,r),u=new e.Point(a,o),c=new e.Point(i,o);let h=this.pointCoordinate(s,t),d=this.pointCoordinate(l,t);const f=this.pointCoordinate(u,n),p=this.pointCoordinate(c,n),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.MercatorCoordinate((1-p.y)/m(p,h)+p.x,1):h.y<0&&d.y<=1&&(h=new e.MercatorCoordinate(-p.y/m(p,h)+p.x,0)),d.y>1&&h.y>=0?d=new e.MercatorCoordinate((1-f.y)/m(f,d)+f.x,1):d.y<0&&h.y<=1&&(d=new e.MercatorCoordinate(-f.y/m(f,d)+f.x,0)),(new e.LngLatBounds).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(f))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const n=t.dem.tree;e.min=Math.min(e.min,n.minimums[0]),e.max=Math.max(e.max,n.maximums[0])}return e},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,n=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.MAX_MERCATOR_LATITUDE,this.maxLat=e.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngh&&(s=h-u),h-ct&&(a=t-l),t-e.5?x-1:x,b>.5?b-1:b,0]),this.alignedProjMatrix=w,s=e.create(),e.scale(s,s,[this.width/2,-this.height/2,1]),e.translate(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=e.create(),e.scale(s,s,[1,-1,1]),e.translate(s,s,[-1,-1,0]),e.scale(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=e.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=e.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=e.calculateGlobeMatrix(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.transformMat4(t,t,o),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=s;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,n=this.cameraPixelsPerMeter,r=this._camera.position,i=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,n];e.scale$2(o,o,i),e.scale$2(r,r,-1),e.multiply$2(r,r,o);const a=e.create();e.translate(a,a,r),e.scale(a,a,o),this.mercatorFogMatrix=a,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,n,i)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),r=this.point,i=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-n[0]*i,r.y/this.worldSize-n[1]*i,e/this.worldSize*this._centerAltitude-n[2]*i]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],i=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),i>0&&(o=Math.min((n-r)/i,1)),this._camera.position=e.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,n=this._camera.forward(),{pitch:r,bearing:i}=this._camera.getPitchBearing(),o=e.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,a=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.degToRad(this._maxPitch)),s=Math.max((t[2]-o)/Math.cos(r),a),l=this._zoomFromMercatorZ(s);e.scaleAndAdd(t,t,n,s),this._pitch=e.clamp(r,e.degToRad(this.minPitch),e.degToRad(this.maxPitch)),this.angle=e.wrap(i,-Math.PI,Math.PI),this._setZoom(e.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.MercatorCoordinate(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let n=0,r=e.GLOBE_ZOOM_THRESHOLD_MAX,i=0,o=1/0;for(;r-n>1e-6&&r>n;){const e=n+.5*(r-n),a=this.tileSize*Math.pow(2,e),s=this.getCameraToCenterDistance(this.projection,e,a),l=this.scaleZoom(s/(t*this.tileSize)),u=Math.abs(e-l);uu||n.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.Point(0,0),new e.Point(this.width,this.height))}zoomDeltaToMovement(t,n){const r=e.length(e.sub([],this._camera.position,t)),i=this._zoomFromMercatorZ(r)+n;return r-this._mercatorZfromZoom(i)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,n,r],i){const o=[t,n,r,1];e.transformMat4$1(o,o,i);const a=o[3]=Math.max(o[3],1e-6);return o[0]/=a,o[1]/=a,o[2]/=a,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.Point(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.Point(0,t))}}getCameraToCenterDistance(e,t=this.zoom,n=this.worldSize){const r=Wr(e,t,this.width,this.height,1024),i=e.pixelSpaceConversion(this.center.lat,n,r);return.5/Math.tan(.5*this._fov)*this.height*i}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.multiply(t,t,this.globeMatrix),t}}function Jr(e,t){let n=!1,r=null;const i=()=>{r=null,n&&(e(),r=setTimeout(i,t),n=!1)};return()=>(n=!0,r||i(),r)}class Qr{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Jr(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const t=this._map;if(!t)return"";const n=ei(t);if(this._hashName){const t=this._hashName;let r=!1;const i=e.window.location.hash.slice(1).split("&").map(e=>{const i=e.split("=")[0];return i===t?(r=!0,`${i}=${n}`):e}).filter(e=>e);return r||i.push(`${t}=${n}`),"#"+i.join("&")}return"#"+n}_getCurrentHash(){const t=e.window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map(e=>e.split("=")).forEach(t=>{t[0]===this._hashName&&(e=t)}),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(e))){const n=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:n,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=e.window.location.href.replace(/(#.+)?$/,this.getHashString());e.window.history.replaceState(e.window.history.state,null,t)}}function ei(e,t){const n=e.getCenter(),r=Math.round(100*e.getZoom())/100,i=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,i),a=Math.round(n.lng*o)/o,s=Math.round(n.lat*o)/o,l=e.getBearing(),u=e.getPitch();let c=t?`/${a}/${s}/${r}`:`${r}/${s}/${a}`;return(l||u)&&(c+="/"+Math.round(10*l)/10),u&&(c+="/"+Math.round(u)),c}const ti={linearity:.3,easing:e.bezier(0,0,.3,1)},ni=e.extend({deceleration:2500,maxSpeed:1400},ti),ri=e.extend({deceleration:20,maxSpeed:1400},ti),ii=e.extend({deceleration:1e3,maxSpeed:360},ti),oi=e.extend({deceleration:1e3,maxSpeed:90},ti);class ai{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=e.exported.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new e.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){const o=li(n.pan.mag(),r,e.extend({},ni,t||{}));i.offset=n.pan.mult(o.amount/n.pan.mag()),i.center=this._map.transform.center,si(i,o)}if(n.zoom){const e=li(n.zoom,r,ri);i.zoom=this._map.transform.zoom+e.amount,si(i,e)}if(n.bearing){const t=li(n.bearing,r,ii);i.bearing=this._map.transform.bearing+e.clamp(t.amount,-179,179),si(i,t)}if(n.pitch){const e=li(n.pitch,r,oi);i.pitch=this._map.transform.pitch+e.amount,si(i,e)}if(i.zoom||i.bearing){const e=void 0===n.pinchAround?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),i.noMoveStart=!0,i}}function si(e,t){(!e.duration||e.durationn.unproject(e)),s=o.reduce((e,t,n,r)=>e.add(t.div(r.length)),new e.Point(0,0));super(t,{points:o,point:s,lngLats:a,lngLat:n.unproject(s),originalEvent:r}),this._defaultPrevented=!1}}class hi extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class di{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new hi(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ui(e.type,this._map,e))}mouseup(e){this._map.fire(new ui(e.type,this._map,e))}preclick(t){const n=e.extend({},t);n.type="preclick",this._map.fire(new ui(n.type,this._map,n))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new ui(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new ui(e.type,this._map,e))}mouseover(e){this._map.fire(new ui(e.type,this._map,e))}mouseout(e){this._map.fire(new ui(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ci(e.type,this._map,e))}touchmove(e){this._map.fire(new ci(e.type,this._map,e))}touchend(e){this._map.fire(new ci(e.type,this._map,e))}touchcancel(e){this._map.fire(new ci(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class fi{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new ui(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ui("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new ui(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pi{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(c(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const n=t,r=this._startPos,i=this._lastPos;if(!r||!i||i.equals(n)||!this._box&&n.dist(r){this._box&&(this._box.style.transform=`translate(${a}px,${l}px)`,this._box.style.width=s-a+"px",this._box.style.height=u-l+"px")})}mouseupWindow(t,n){if(!this._active)return;const r=this._startPos,i=n;if(r&&0===t.button){if(this.reset(),f(),r.x!==i.x||r.y!==i.y)return this._map.fire(new e.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,i,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}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(t,n){return this._map.fire(new e.Event(t,{originalEvent:n}))}}function mi(e,t){const n={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const n=new e.Point(0,0);for(const e of t)n._add(e);return n.div(t.length)}(n),this.touches=mi(r,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;const r=mi(n,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class gi{constructor(e){this.singleTap=new _i(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){const r=this.singleTap.touchend(e,t,n);if(r){const t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class yi{constructor(){this._zoomIn=new gi({numTouches:1,numTaps:2}),this._zoomOut=new gi({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,t,n){const r=this._zoomIn.touchend(e,t,n),i=this._zoomOut.touchend(e,t,n);return r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):i?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(i)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const vi={0:1,2:2};class xi{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const n=_(e);this._correctButton(e,n)&&(this._lastPoint=t,this._eventButton=n)}mousemoveWindow(e,t){const n=this._lastPoint;if(n)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const n=vi[t];return void 0===e.buttons||(e.buttons&n)!==n}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(n)0&&(this._active=!0);const i=mi(r,n),o=new e.Point(0,0),a=new e.Point(0,0);let s=0;for(const e in i){const t=i[e],n=this._touches[e];n&&(o._add(t),a._add(t.sub(n)),s++,i[e]=t)}if(this._touches=i,s{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class Si{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,n){return{}}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[i,o]=r,a=ki(n,t,i),s=ki(n,t,o);if(!a||!s)return;const l=this._aroundCenter?null:a.add(s).div(2);return this._move([a,s],l,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;const[r,i]=this._firstTwoTouches,o=ki(n,t,r),a=ki(n,t,i);o&&a||(this._active&&f(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function ki(e,t,n){for(let r=0;rMath.abs(e.x)}class Oi extends Si{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,Pi(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,n,r){const i=this._lastPoints;if(!i)return;const o=t[0].sub(i[0]),a=t[1].sub(i[1]);return this._map._cooperativeGestures&&!e.isFullscreen()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(o,a,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+a.y)/2*-.5})}gestureBeginsVertically(e,t,n){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return null==this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Pi(e)&&Pi(t)&&o}}const zi={panStep:100,bearingStep:15,pitchStep:10};class Li{constructor(){const e=zi;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,n=0,r=0,i=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?n=-1:(e.preventDefault(),i=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),i=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(n=0,r=0),{cameraAnimation:a=>{const s=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Di,zoom:t?Math.round(s)+t*(e.shiftKey?2:1):s,bearing:a.getBearing()+n*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-i*this._panStep,-o*this._panStep],center:a.getCenter()},{originalEvent:e})}}}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 Di(e){return e*(2-e)}const Ri=4.000244140625;class Bi{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=t.deltaMode===e.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=e.exported.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%Ri==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){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 t=p(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,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 t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const n=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Ri?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const i=n(),o=Math.pow(2,i),a="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(a*r))),"wheel"===this._type&&(this._startZoom=i,this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:n(),i=this._startZoom,o=this._easing;let a,s=!1;if("wheel"===this._type&&i&&o){const t=Math.min((e.exported.now()-this._lastWheelEventTime)/200,1),n=o(t);a=e.number(i,r,n),t<1?this._frameId||(this._frameId=!0):s=!0}else a=r,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!s,zoomDelta:a-n(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=e.ease;if(this._prevEase){const t=this._prevEase,r=(e.exported.now()-t.start)/t.duration,i=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(i*i+1e-4)*.01,a=Math.sqrt(.0729-o*o);n=e.bezier(o,a,.25,1)}return this._prevEase={start:e.exported.now(),duration:t,easing:n},n}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(e.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")}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class Fi{constructor(e,t){this._clickZoom=e,this._tapZoom=t}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 ji{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:n.getZoom()+(e.shiftKey?-1:1),around:n.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ni{constructor(){this._tap=new gi({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,n){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=t[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(e,t,n))}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(e,t,n)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ui{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},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 Vi{constructor(e,t,n){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=n}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 Gi{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),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 qi=e=>e.zoom||e.drag||e.pitch||e.rotate;class $i extends e.Event{}class Zi{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,n){const r=e.sub([],n,t);this.radius=e.length(r[2]<0?e.div([],r,this.constants):[r[0],r[1],0])}projectRay(t){e.div(t,t,this.constants),e.normalize(t,t),e.mul$1(t,t,this.constants);const n=e.scale$2([],t,this.radius);if(n[2]>0){const t=e.scale$2([],[0,0,1],e.dot(n,[0,0,1])),r=e.scale$2([],e.normalize([],[n[0],n[1],0]),this.radius),i=e.add([],n,e.scale$2([],e.sub([],e.add([],r,t),n),2));n[0]=i[0],n[1]=i[1]}return n}}function Wi(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Xi{constructor(t,n){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ai(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Zi,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),e.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],[e.window.document,"mousemove",{capture:!0}],[e.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],[e.window,"blur",void 0]];for(const[t,n,r]of this._listeners)t.addEventListener(n,t===e.window.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[t,n,r]of this._listeners)t.removeEventListener(n,t===e.window.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){const t=this._map,n=t.getCanvasContainer();this._add("mapEvent",new di(t,e));const r=t.boxZoom=new pi(t,e);this._add("boxZoom",r);const i=new yi,o=new ji;t.doubleClickZoom=new Fi(o,i),this._add("tapZoom",i),this._add("clickZoom",o);const a=new Ni;this._add("tapDragZoom",a);const s=t.touchPitch=new Oi(t);this._add("touchPitch",s);const l=new wi(e),u=new Ei(e);t.dragRotate=new Vi(e,l,u),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);const c=new bi(e),h=new Ti(t,e);t.dragPan=new Ui(n,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new Ii,f=new Ci;t.touchZoomRotate=new Gi(n,f,d,a),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),this._add("blockableMapEvent",new fi(t));const p=t.scrollZoom=new Bi(t,this);this._add("scrollZoom",p,["mousePan"]);const m=t.keyboard=new Li;this._add("keyboard",m);for(const n of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[n]&&t[n].enable(e[n])}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!qi(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,n){for(const r in e)if(r!==n&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,e.type+"Window")}_getMapTouches(e){const t=[];for(const n of e)this._el.contains(n.target)&&t.push(n);return t}handleEvent(e,t){this._updatingCamera=!0;const n="renderFrame"===e.type,r=n?void 0:e,i={needsRenderFrame:!1},o={},a={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?m(this._el,s):n?void 0:p(this._el,e);for(const{handlerName:n,handler:u,allowed:c}of this._handlers){if(!u.isEnabled())continue;let h;this._blockedByActive(a,c,n)?u.reset():u[t||e.type]&&(h=u[t||e.type](e,l,s),this.mergeHandlerResult(i,o,h,n,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||u.isActive())&&(a[n]=u)}const u={};for(const e in this._previousActiveHandlers)a[e]||(u[e]=r);this._previousActiveHandlers=a,(Object.keys(u).length||Wi(i))&&(this._changes.push([i,o,u]),this._triggerRenderFrame()),(Object.keys(a).length||Wi(i))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=i;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))}mergeHandlerResult(t,n,r,i,o){if(!r)return;e.extend(t,r);const a={handlerName:i,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(n.zoom=a),void 0!==r.panDelta&&(n.drag=a),void 0!==r.pitchDelta&&(n.pitch=a),void 0!==r.bearingDelta&&(n.rotate=a)}_applyChanges(){const t={},n={},r={};for(const[i,o,a]of this._changes)i.panDelta&&(t.panDelta=(t.panDelta||new e.Point(0,0))._add(i.panDelta)),i.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+i.pitchDelta),void 0!==i.around&&(t.around=i.around),void 0!==i.aroundCoord&&(t.aroundCoord=i.aroundCoord),void 0!==i.pinchAround&&(t.pinchAround=i.pinchAround),i.noInertia&&(t.noInertia=i.noInertia),e.extend(n,o),e.extend(r,a);this._updateMapTransform(t,n,r),this._changes=[]}_updateMapTransform(t,n,r){const i=this._map,o=i.transform,a=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Wi(t)){const e=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&i._stop(!0),!Wi(t))return void this._fireEvents(n,r,!0);let{panDelta:s,zoomDelta:l,bearingDelta:u,pitchDelta:c,around:h,aroundCoord:d,pinchAround:f}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==f&&(h=f),(l||(e=>n[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=a(o.pointCoordinate3D(h)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",i._stop(!0),h=h||i.transform.centerPoint,u&&(o.bearing+=u),c&&(o.pitch+=c),o._updateCameraState();const p=[0,0,0];if(s)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(s)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){s=s.rotate(-o.angle);const n=o._pixelsPerMercatorPixel/o.worldSize;p[0]=-s.x*e.mercatorScale(e.latFromMercatorY(t.y))*n,p[1]=-s.y*e.mercatorScale(o.center.lat)*n}else{const e=o.pointCoordinate(h.sub(s));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y)}}const m=o.zoom,_=[0,0,0];if(l){const t=a(d||o.pointCoordinate3D(h)),n={dir:e.normalize([],e.sub([],t,o._camera.position))};if(n.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e.scale$2(_,n.dir,r)}}const g=e.add(p,p,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,r,!0)}_fireEvents(t,n,r){const i=qi(this._eventsInProgress),o=qi(t),a={};for(const e in t){const{originalEvent:n}=t[e];this._eventsInProgress[e]||(a[e+"start"]=n),this._eventsInProgress[e]=t[e]}!i&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in a)this._fireEvent(e,a[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:n}=t[e];this._fireEvent(e,n)}const s={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=n[t]||r,s[e+"end"]=l)}for(const e in s)this._fireEvent(e,s[e]);const u=qi(this._eventsInProgress);if(r&&(i||o)&&!u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new $i("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Hi="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Yi extends e.Evented{constructor(t,n){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this._respectPrefersReducedMotion=!1!==n.respectPrefersReducedMotion,e.bindAll(["_renderFrameCallback"],this)}getCenter(){return new e.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,n,r){return t=e.Point.convert(t).mult(-1),this.panTo(this.transform.center,e.extend({offset:t},n),r)}panTo(t,n,r){return this.easeTo(e.extend({center:t},n),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,n,r){return this.easeTo(e.extend({zoom:t},n),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,n,r){return this.easeTo(e.extend({bearing:t},n),r)}resetNorth(t,n){return this.rotateTo(0,e.extend({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(e.extend({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?n/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,n,r,i,o,a){const s=t.clone(),l=this._extendCameraOptions(a);s.bearing=i,s.pitch=o;const u=e.LngLat.convert(n),c=e.LngLat.convert(r),h=.5*(u.lat+c.lat),d=.5*(u.lng+c.lng),f=e.latLngToECEF(h,d),p=e.normalize([],f),m=e.normalize([],e.cross([],p,[0,1,0])),_=e.cross([],m,p),g=[m[0],m[1],m[2],0,_[0],_[1],_[2],0,p[0],p[1],p[2],0,0,0,0,1],y=[f,e.latLngToECEF(u.lat,u.lng),e.latLngToECEF(c.lat,u.lng),e.latLngToECEF(c.lat,c.lng),e.latLngToECEF(u.lat,c.lng),e.latLngToECEF(h,u.lng),e.latLngToECEF(h,c.lng),e.latLngToECEF(u.lat,d),e.latLngToECEF(c.lat,d)];let v=e.Aabb.fromPoints(y.map(t=>[e.dot(m,t),e.dot(_,t),e.dot(p,t)]));const x=e.transformMat4([],v.center,g);0===e.squaredLength(x)&&e.set(x,0,0,1),e.normalize(x,x),e.scale$2(x,x,e.GLOBE_RADIUS),s.center=e.ecefToLatLng(x);const b=s.getWorldToCameraMatrix(),w=e.invert(new Float64Array(16),b);v=e.Aabb.applyTransform(v,e.multiply([],b,g)),e.transformMat4(x,x,b);const E=.5*(v.max[2]-v.min[2]),T=this._minimumAABBFrustumDistance(s,v),S=e.scale$2([],[0,0,1],E),k=e.add(S,x,S),M=T+(0===s.pitch?0:e.distance(x,k)),C=s.globeCenterInViewSpace,A=e.sub([],x,[C[0],C[1],C[2]]);e.normalize(A,A),e.scale$2(A,A,M);const I=e.add([],x,A);e.transformMat4(I,I,w);const P=e.earthRadius/e.GLOBE_RADIUS,O=e.length(I),z=e.mercatorZfromAltitude(Math.max(O*P-e.earthRadius,Number.EPSILON),0),L=Math.min(s.zoomFromMercatorZAdjusted(z),l.maxZoom);return L>.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(s.setProjection({name:"mercator"}),s.zoom=L,this._cameraForBounds(s,n,r,i,o,a)):{center:s.center,zoom:L,bearing:i,pitch:o}}queryTerrainElevation(t,n){const r=this.transform.elevation;return r?(n=e.extend({},{exaggerated:!0},n),r.getAtPoint(e.MercatorCoordinate.fromLngLat(t),null,n.exaggerated)):null}_cameraForBounds(t,n,r,i,o,a){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,n,r,i,o,a);const s=t.clone(),l=this._extendCameraOptions(a),u=s.padding;s.bearing=i,s.pitch=o;const c=e.LngLat.convert(n),h=e.LngLat.convert(r),d=new e.LngLat(c.lng,h.lat),f=new e.LngLat(h.lng,c.lat),p=s.project(c),m=s.project(h),_=this.queryTerrainElevation(c),g=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),v=this.queryTerrainElevation(f),x=[[p.x,p.y,Math.min(_||0,g||0,y||0,v||0)],[m.x,m.y,Math.max(_||0,g||0,y||0,v||0)]];let b=e.Aabb.fromPoints(x);const w=s.getWorldToCameraMatrix(),E=e.invert(new Float64Array(16),w);b=e.Aabb.applyTransform(b,w);const T=e.sub([],b.max,b.min),S=u.left||0,k=u.right||0,M=u.bottom||0,C=u.top||0,{left:A,right:I,top:P,bottom:O}=l.padding,z=.5*(S+k),L=.5*(C+M),D=Math.min(s.scaleZoom(s.scale*Math.min((s.width-(S+k+A+I))/T[0],(s.height-(M+C+O+P))/T[1])),l.maxZoom),R=s.scale/s.zoomScale(D);b=new e.Aabb([b.min[0]-(A+z)*R,b.min[1]-(O+L)*R,b.min[2]],[b.max[0]+(I+z)*R,b.max[1]+(P+L)*R,b.max[2]]);const B=.5*T[2],F=this._minimumAABBFrustumDistance(s,b),j=[0,0,1,0];e.transformMat4$1(j,j,w),e.normalize$2(j,j);const N=e.scale$2([],j,F+B),U=e.add([],b.center,N),V=("number"==typeof l.offset.x&&"number"==typeof l.offset.y?new e.Point(l.offset.x,l.offset.y):e.Point.convert(l.offset)).rotate(-e.degToRad(i));b.center[0]-=V.x*R,b.center[1]+=V.y*R,e.transformMat4(b.center,b.center,E),e.transformMat4(U,U,E);const G=[b.center[0],b.center[1],U[2]*s.pixelsPerMeter];e.scale$2(G,G,1/s.worldSize);const q=e.lngFromMercatorX(G[0]),$=e.latFromMercatorY(G[1]),Z=Math.min(s._zoomFromMercatorZ(G[2]),l.maxZoom),W=new e.LngLat(q,$);return s.mercatorFromTransition&&Z<.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(s.setProjection({name:"globe"}),s.zoom=Z,this._cameraForBounds(s,n,r,i,o,a)):{center:W,zoom:Z,bearing:i,pitch:o}}fitBounds(e,t,n){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,n)}fitScreenCoordinates(t,n,r,i,o){const a=e.Point.convert(t),s=e.Point.convert(n),l=new e.Point(Math.min(a.x,s.x),Math.min(a.y,s.y)),u=new e.Point(Math.max(a.x,s.x),Math.max(a.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(a,s))return this;const c=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(u),d=this.transform.pointLocation3D(new e.Point(l.x,u.y)),f=this.transform.pointLocation3D(new e.Point(u.x,l.y)),p=[Math.min(c.lng,h.lng,d.lng,f.lng),Math.min(c.lat,h.lat,d.lat,f.lat)],m=[Math.max(c.lng,h.lng,d.lng,f.lng),Math.max(c.lat,h.lat,d.lat,f.lat)],_=i&&i.pitch?i.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,p,m,r,_,i);return this._fitInternal(g,i,o)}_fitInternal(t,n,r){return t?(delete(n=e.extend(t,n)).padding,n.linear?this.easeTo(n,r):this.flyTo(n,r)):this}jumpTo(t,n){this.stop();const r=t.preloadOnly?this.transform.clone():this.transform;let i=!1,o=!1,a=!1;return"zoom"in t&&r.zoom!==+t.zoom&&(i=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.LngLat.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(a=!0,r.pitch=+t.pitch),null==t.padding||r.isPaddingEqual(t.padding)||(r.padding=t.padding),t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),i&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),o&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),a&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.warnOnce(Hi),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,n){const r=this.transform;if(!r.projection.supportsFreeCamera)return e.warnOnce(Hi),this;this.stop();const i=r.zoom,o=r.pitch,a=r.bearing;r.setFreeCameraOptions(t);const s=i!==r.zoom,l=o!==r.pitch,u=a!==r.bearing;return this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),s&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),u&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),l&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)),this}easeTo(t,n){this._stop(!1,t.easeId),(!1===(t=e.extend({offset:[0,0],duration:500,easing:e.ease},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?+t.zoom:i,u="bearing"in t?this._normalizeBearing(t.bearing,o):o,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:r.padding,d=e.Point.convert(t.offset);let f,p,m;if("globe"===r.projection.name){const n=e.MercatorCoordinate.fromLngLat(r.center),i=d.rotate(-r.angle);n.x+=i.x/r.worldSize,n.y+=i.y/r.worldSize;const o=n.toLngLat(),a=e.LngLat.convert(t.center||o);this._normalizeCenter(a),f=r.centerPoint.add(i),p=new e.Point(n.x,n.y).mult(r.worldSize),m=new e.Point(e.mercatorXfromLng(a.lng),e.mercatorYfromLat(a.lat)).mult(r.worldSize).sub(p)}else{f=r.centerPoint.add(d);const n=r.pointLocation(f),i=e.LngLat.convert(t.center||n);this._normalizeCenter(i),p=r.project(n),m=r.project(i).sub(p)}const _=r.zoomScale(l-i);let g,y;t.around&&(g=e.LngLat.convert(t.around),y=r.locationPoint(g));const v=this._zooming||l!==i,x=this._rotating||o!==u,b=this._pitching||c!==a,w=!r.isPaddingEqual(h),E=r=>E=>{if(v&&(r.zoom=e.number(i,l,E)),x&&(r.bearing=e.number(o,u,E)),b&&(r.pitch=e.number(a,c,E)),w&&(r.interpolatePadding(s,h,E),f=r.centerPoint.add(d)),g)r.setLocationAtPoint(g,y);else{const e=r.zoomScale(r.zoom-i),t=l>i?Math.min(2,_):Math.max(.5,_),n=Math.pow(t,1-E),o=r.unproject(p.add(m.mult(E*n)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,f)}return t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(E,t.duration,r);return this._preloadTiles(e),this}const T={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=t.easeId,this._prepareEase(n,t.noMoveStart,T),this._ease(E(r),e=>{r.recenterOnTerrain(),this._afterEase(n,e)},t),this}_prepareEase(t,n,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",n||r.moving||this.fire(new e.Event("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.Event("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.Event("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.Event("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.Event("move",t)),this._zooming&&this.fire(new e.Event("zoom",t)),this._rotating&&this.fire(new e.Event("rotate",t)),this._pitching&&this.fire(new e.Event("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,i=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.Event("zoomend",t)),i&&this.fire(new e.Event("rotateend",t)),o&&this.fire(new e.Event("pitchend",t)),this.fire(new e.Event("moveend",t))}flyTo(t,n){if(this._prefersReducedMotion(t)){const r=e.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,n)}this.stop(),t=e.extend({offset:[0,0],speed:1.2,curve:1.42,easing:e.ease},t);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?e.clamp(+t.zoom,r.minZoom,r.maxZoom):i,u="bearing"in t?this._normalizeBearing(t.bearing,o):o,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:r.padding,d=r.zoomScale(l-i),f=e.Point.convert(t.offset);let p=r.centerPoint.add(f);const m=r.pointLocation(p),_=e.LngLat.convert(t.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let v=t.curve;const x=Math.max(r.width,r.height),b=x/d,w=y.mag();if("minZoom"in t){const n=e.clamp(Math.min(t.minZoom,i,l),r.minZoom,r.maxZoom),o=x/r.zoomScale(n-i);v=Math.sqrt(o/w*2)}const E=v*v;function T(e){const t=(b*b-x*x+(e?-1:1)*E*E*w*w)/(2*(e?b:x)*E*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function k(e){return(Math.exp(e)+Math.exp(-e))/2}const M=T(0);let C=function(e){return k(M)/k(M+v*e)},A=function(e){return x*((k(M)*(S(t=M+v*e)/k(t))-S(M))/E)/w;var t},I=(T(1)-M)/v;if(Math.abs(w)<1e-6||!isFinite(I)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,n);const e=bt.maxDuration&&(t.duration=0);const P=o!==u,O=c!==a,z=!r.isPaddingEqual(h),L=r=>d=>{const m=d*I,v=1/C(m);r.zoom=1===d?l:i+r.scaleZoom(v),P&&(r.bearing=e.number(o,u,d)),O&&(r.pitch=e.number(a,c,d)),z&&(r.interpolatePadding(s,h,d),p=r.centerPoint.add(f));const x=1===d?_:r.unproject(g.add(y.mult(A(m))).mult(v));return r.setLocationAtPoint(r.renderWorldCopies?x.wrap():x,p),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(L,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=O,this._padding=z,this._prepareEase(n,!1),this._ease(L(r),()=>this._afterEase(n),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,n,r){!1===r.animate||0===r.duration?(t(1),n()):(this._easeStart=e.exported.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.exported.now()-this._easeStart)/this._easeOptions.duration,1),n=this._onEaseFrame;n&&n(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,n){t=e.wrap(t,-180,180);const r=Math.abs(t-n);return Math.abs(t-360-n)180?-360:n<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.exported.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,n){const r=Math.ceil(15*t/1e3),i=[],o=e(n.clone());for(let e=0;e<=r;e++){const t=o(e/r);i.push(t.clone())}return i}}class Ki{constructor(t={}){this.options=t,e.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,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"),t&&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===t&&(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(e,t){const n=this._map._getUIString("AttributionControl."+t);e.setAttribute("aria-label",n),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}_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 t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.config.ACCESS_TOKEN}];if(t){const r=n.reduce((e,t,r)=>(t.value&&(e+=`${t.key}=${t.value}${re.length-t.length),e=e.filter((t,n)=>{for(let r=n+1;r=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const n=e.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,e.length?(this._innerContainer.innerHTML=n,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 Ji{constructor(){e.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),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(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const n=e[t].getSource();if(n.hasOwnProperty("mapbox_logo")&&!n.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class Qi{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(const t of n)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function eo(t,n,r){if(t=new e.LngLat(t.lng,t.lat),n){const i=new e.LngLat(t.lng-360,t.lat),o=new e.LngLat(t.lng+360,t.lat),a=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),s=r.locationPoint(t).distSqr(n),l=n.x<0||n.y<0||n.x>r.width||n.y>r.height;r.locationPoint(i).distSqr(n)180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const to={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 no extends e.Evented{constructor(t,n){if(super(),(t instanceof e.window.HTMLElement||n)&&(t=e.extend({element:t},n)),e.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.Point.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const n=41,r=27,i=a("svg",{display:"block",height:n*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${n}`},this._element),s=a("radialGradient",{id:"shadowGradient"},a("defs",{},i));a("stop",{offset:"10%","stop-opacity":.4},s),a("stop",{offset:"100%","stop-opacity":.05},s),a("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},i),a("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"},i),a("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"},i),a("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},i),this._offset=e.Point.convert(t&&t.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",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()});const r=this._element.classList;for(const e in to)r.remove("mapboxgl-marker-anchor-"+e);r.add("mapboxgl-marker-anchor-"+this._anchor),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){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")),e){if(!("offset"in e.options)){const t=38.1,n=13.5,r=Math.sqrt(Math.pow(n,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-n+r)],"bottom-right":[-r,-1*(t-n+r)],left:[n,-1*(t-n)],right:[-n,-1*(t-n)]}:this._offset}this._popup=e,e._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(e){const t=e.code,n=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==n&&13!==n||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const n=e.unproject(t),r=e.getFreeCameraOptions();if(!r.position)return!1;const i=r.position.toLngLat();return i.distanceTo(n)<.9*i.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const n=this._pos;if(!n||n.x<0||n.x>t.transform.width||n.y<0||n.y>t.transform.height)return void this._clearFadeTimer();const r=t.unproject(n);let i;t._showingGlobe()&&e.isLngLatBehindGlobe(t.transform,this._lngLat)?i=0:(i=1-t._queryFogOpacity(r),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(i*=this._occludedOpacity)),this._element.style.opacity=""+i,this._element.style.pointerEvents=i>0?"auto":"none",this._popup&&this._popup._setOpacity(i),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${to[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,n=this._map,r=this.getPitchAlignment();if(!n||!t||"map"!==r)return"";if(!n._showingGlobe()){const e=n.getPitch();return e?`rotateX(${e}deg)`:""}const i=e.radToDeg(e.globeTiltAtLngLat(n.transform,this._lngLat)),o=t.sub(e.globeCenterToScreenPoint(n.transform)),a=Math.abs(o.x)+Math.abs(o.y);if(0===a)return"";const s=i/a;return`rotateX(${-o.y*s}deg) rotateY(${o.x*s}deg)`}_calculateZTransform(){const t=this._pos,n=this._map;if(!n||!t)return"";let r=0;const i=this.getRotationAlignment();if("map"===i)if(n._showingGlobe()){const t=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),i=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);r=e.radToDeg(Math.atan2(i.y,i.x))-90}else r=-n.getBearing();else if("horizon"===i){const i=e.smoothstep(4,6,n.getZoom()),o=e.globeCenterToScreenPoint(n.transform);o.y+=i*n.transform.height;const a=t.sub(o),s=e.radToDeg(Math.atan2(a.y,a.x));r=(s>90?s-270:s+90)*(1-i)}return r+=this._rotation,r?`rotateZ(${r}deg)`:""}_update(t){e.window.cancelAnimationFrame(this._updateFrameId);const n=this._map;n&&(n.transform.renderWorldCopies&&(this._lngLat=eo(this._lngLat,this._pos,n.transform)),this._pos=n.project(this._lngLat),!0===t?this._updateFrameId=e.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),n._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(n._showingGlobe()||n.getTerrain()||n.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=e.Point.convert(t),this._update(),this}_onMove(t){const n=this._map;if(!n)return;const r=this._pointerdownPos,i=this._positionDelta;if(r&&i){if(!this._isDragging){const e=this._clickTolerance||n._clickTolerance;if(t.point.dist(r)=this._endTime)return this._end;const n=e.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,n){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+n}}const so={"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"},lo={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,performanceMetricsCollection:!0,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,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},uo={showCompass:!0,showZoom:!0,visualizePitch:!1};class co{constructor(t,n,r=!1){this._clickTolerance=10,this.element=n,this.mouseRotate=new wi({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new Ei({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),c()}move(e,t){const n=this.map,r=this.mouseRotate.mousemoveWindow(e,t),i=r&&r.bearingDelta;if(i&&n.setBearing(n.getBearing()+i),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),i=r&&r.pitchDelta;i&&n.setPitch(n.getPitch()+i)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),e.window.removeEventListener("mousemove",this.mousemove),e.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),p(this.element,t)),e.window.addEventListener("mousemove",this.mousemove),e.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,p(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=m(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.isSafariWithAntialiasingBug(e.window)&&(t.antialias=!1,e.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Kr(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._useWebGL2=t.useWebGL2,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Qi,this._domRenderTaskQueue=new Qi,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.uniqueId(),this._locale=e.extend({},so,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ao(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.window.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof e.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_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!==e.window&&(e.window.addEventListener("online",this._onWindowOnline,!1),e.window.addEventListener("resize",this._onWindowResize,!1),e.window.addEventListener("orientationchange",this._onWindowResize,!1),e.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Xi(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Qr("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.extend({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new Ki({customAttribution:t.customAttribution})),this._logoControl=new Ji,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.Event(t.dataType+"data",t))}),this.on("dataloading",t=>{this.fire(new e.Event(t.dataType+"dataloading",t))})}_getMapId(){return this._mapId}addControl(t,n){if(void 0===n&&(n=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const i=this._controlPositions[n];return-1!==n.indexOf("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(t);return n>-1&&this._controls.splice(n,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 n=!this._moving;return n&&this.fire(new e.Event("movestart",t)).fire(new e.Event("move",t)),this.fire(new e.Event("resize",t)),n&&this.fire(new e.Event("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.LngLatBounds.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.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(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(t){return"auto"===t?e.window.navigator.language:Array.isArray(t)?0===t.length?void 0:t.map(t=>"auto"===t?e.window.navigator.language:t):t}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style._reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,n=t.projection.name;let r;"globe"===n&&t.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?(t.setMercatorFromTransition(),r=!0):"mercator"===n&&t.zoom=e.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),n){this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(t){return this.transform.locationPoint3D(e.LngLat.convert(t))}unproject(t){return this.transform.pointLocation3D(e.Point.convert(t))}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}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,n){if("mouseenter"===e||"mouseover"===e){let r=!1;const i=i=>{const o=t.filter(e=>this.getLayer(e)),a=o.length?this.queryRenderedFeatures(i.point,{layers:o}):[];a.length?r||(r=!0,n.call(this,new ui(e,this,i.originalEvent,{features:a}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const i=i=>{const o=t.filter(e=>this.getLayer(e));(o.length?this.queryRenderedFeatures(i.point,{layers:o}):[]).length?r=!0:r&&(r=!1,n.call(this,new ui(e,this,i.originalEvent)))},o=t=>{r&&(r=!1,n.call(this,new ui(e,this,t.originalEvent)))};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}{const r=e=>{const r=t.filter(e=>this.getLayer(e)),i=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:new Set(t),listener:n,delegates:{[e]:r}}}}on(e,t,n){if(void 0===n)return super.on(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,n){if(void 0===n)return super.once(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,n);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,n){if(void 0===n)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const r=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0},i=this._delegatedListeners?this._delegatedListeners[e]:void 0;return i&&(e=>{for(let i=0;i{t?this.fire(new e.ErrorEvent(t)):r&&this._updateDiff(r,n)})}else"object"==typeof t&&this._updateDiff(t,n)}_updateDiff(t,n){try{this.style.setState(t)&&this._update(!0)}catch(r){e.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(t,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.warnOnce("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const n=e[t]._tiles;for(const e in n){const t=n[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,n){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,n)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,n,{pixelRatio:r=1,sdf:i=!1,stretchX:o,stretchY:a,content:s}={}){if(this._lazyInitEmptyStyle(),n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap){const{width:l,height:u,data:c}=e.exported.getImageData(n);this.style.addImage(t,{data:new e.RGBAImage({width:l,height:u},c),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0})}else if(void 0===n.width||void 0===n.height)this.fire(new e.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:u}=n,c=n;this.style.addImage(t,{data:new e.RGBAImage({width:l,height:u},new Uint8Array(c.data)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0,userImage:c}),c.onAdd&&c.onAdd(this,t)}}updateImage(t,n){const r=this.style.getImage(t);if(!r)return void this.fire(new e.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap?e.exported.getImageData(n):n,{width:o,height:a}=i;void 0!==o&&void 0!==a?o===r.data.width&&a===r.data.height?(r.data.replace(i.data,!(n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap)),this.style.updateImage(t,r)):this.fire(new e.ErrorEvent(new Error(`The width and height of the updated image (${o}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new e.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(t){return t?!!this.style.getImage(t):(this.fire(new e.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,n){e.getImage(this._requestManager.transformRequest(t,e.ResourceType.Image),(t,r)=>{n(t,r instanceof e.window.HTMLImageElement?e.exported.getImageData(r):r)})}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t,n={}){return this.style.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n,r={}){return this.style.setPaintProperty(e,t,n,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n,r={}){return this.style.setLayoutProperty(e,t,n,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300;let r,i,o,a=this._container;for(;a&&(!i||!o);){const t=e.window.getComputedStyle(a).transform;t&&"none"!==t&&(r=t.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(i=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(o=r[3])),a=a.parentElement}this._containerWidth=i?Math.abs(t/i):t,this._containerHeight=o?Math.abs(n/o):n}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=o("canvas","mapboxgl-canvas",t),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 n=this._controlContainer=o("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{r[e]=o("div","mapboxgl-ctrl-"+e,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,n){const r=e.exported.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(n),this._canvas.style.width=t+"px",this._canvas.style.height=n+"px"}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.extend({},n.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._useWebGL2&&this._canvas.getContext("webgl2",t),i=r||this._canvas.getContext("webgl",t)||this._canvas.getContext("experimental-webgl",t);i?(this._useWebGL2&&!r&&e.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),e.storeAuthState(i,!0),this.painter=new Fr(i,this.transform,!!r),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.exported$1.testSupport(i)):this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.Event("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.Event("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.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(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let n;const r=this.painter.context.extTimerQuery,i=e.exported.now();if(this.listens("gpu-timing-frame")&&(n=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,n)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],e.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],e.window.performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,n=this.transform.pitch,r=e.exported.now(),i=new e.EvaluationParameters(t,{now:r,fadeDuration:o,pitch:n,transition:this.style.getTransition()});this.style.update(i)}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(i),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(i),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,o,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:o,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 e.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const t=e.exported.now()-i;r.endQueryEXT(r.TIME_ELAPSED_EXT,n),setTimeout(()=>{const o=r.getQueryObjectEXT(n,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(n),this.fire(new e.Event("gpu-timing-frame",{cpuTime:t,gpuTime:o})),e.window.performance.mark("frame-gpu",{startTime:i,detail:{gpuTime:o}})},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const n=this.painter.queryGpuTimers(t);this.fire(new e.Event("gpu-timing-layer",{layerTimes:n}))},50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const n=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.Event("gpu-timing-deferred-render",{gpuTime:n}))},50)}const s=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(s||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(i,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.Event("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0,e.LivePerformanceUtils.mark(e.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&e.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const n=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation(),i=!1;this.transform.elevation&&(i=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-r);if(o>1){if(this._isInitialLoad||i)return this._averageElevation.jumpTo(r),n(r);this._averageElevation.easeTo(r,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(r),n(r)}return!!this._averageElevation.isEasing(e)&&n(this._averageElevation.getValue(e))}_authenticate(){e.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{if(t&&(t.message===e.AUTH_ERR_MSG||401===t.status)){const t=this.painter.context.gl;e.storeAuthState(t,!1),this._logoControl instanceof Ji&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.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/")))}}),e.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const n=this.painter.context.gl,r=n.createFramebuffer();function i(e){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0);const t=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,t),t}return n.bindFramebuffer(n.FRAMEBUFFER,r),this._canvasPixelComparison(i(e),t.canvasCopies.map(i),t.timeStamps)}_canvasPixelComparison(e,t,n){let r=n[1]-n[0];const i=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)}))}_preloadTiles(t){const n=this.style?Object.values(this.style._sourceCaches):[];return e.asyncAll(n,(e,n)=>e._preloadTiles(t,n),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===e.window.document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update())}_setCacheLimits(t,n){e.setCacheLimits(t,n)}get version(){return e.version}},NavigationControl:class{constructor(t){this.options=e.extend({},uo,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e})}),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))}),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),n=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new co(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const n=o("button",e,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(e,t){if(!this._map)return;const n=this._map._getUIString("NavigationControl."+t);e.setAttribute("aria-label",n),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends e.Evented{constructor(t){super(),this.options=e.extend({geolocation:e.window.navigator.geolocation},ho,t),e.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Jr(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,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(t){const n=(e=!!this.options.geolocation)=>{this._supportsGeolocation=e,t(e)};void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==e.window.navigator.permissions?e.window.navigator.permissions.query({name:"geolocation"}).then(e=>n("denied"!==e.state)).catch(()=>n()):n()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),n=e.coords;return!!t&&(n.longitudet.getEast()||n.latitudet.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(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.Event("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("geolocate",t)),this._finish()}}_updateCamera(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,i=this._map.getBearing(),o=e.extend({bearing:i},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,n=e.mercatorZfromAltitude(1,t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*n);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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.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 e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.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===t){e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}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 no({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new no({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.Event("trackuserlocationend")))})}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.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 e.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 e.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 e.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 e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),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 t=()=>{e.window.addEventListener("ondeviceorientationabsolute"in e.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.window.DeviceMotionEvent&&"function"==typeof e.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(e=>{"granted"===e&&t()}).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.window.removeEventListener("deviceorientation",this._onDeviceOrientation),e.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:Ki,ScaleControl:class{constructor(t){this.options=e.extend({},fo,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,n=t._containerHeight/2,r=t._containerWidth/2-e/2,i=t.unproject([r,n]),o=t.unproject([r+e,n]),a=i.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"meter")}_setScale(e,t,n){this._map._requestDomTask(()=>{const r=function(e){const t=Math.pow(10,(""+Math.floor(e)).length-1);let n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(n),t*n}(t),i=r/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==n?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:n}).format(r):`${r} ${po[n]}`,this._container.style.width=e*i+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.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(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.window.HTMLElement?this._container=t.container:e.warnOnce("Full screen control 'container' must be a DOM element.")),e.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,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",e.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.window.document.fullscreenEnabled&&!e.window.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(e.window.document.fullscreenElement||e.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()?e.window.document.exitFullscreen?e.window.document.exitFullscreen():e.window.document.webkitCancelFullScreen&&e.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.Evented{constructor(t){super(),this.options=e.extend(Object.create(ro),t),e.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.LngLat.convert(t),this._pos=null,this._trackPointer=!1,this._update();const n=this._map;return n&&(n.on("move",this._update),n.off("mousemove",this._onMouseEvent),n._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.window.document.createTextNode(t))}setHTML(t){const n=e.window.document.createDocumentFragment(),r=e.window.document.createElement("body");let i;for(r.innerHTML=t;i=r.firstChild,i;)n.appendChild(i);return this.setDOMContent(n)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,n=this._container,r=this._pos;if(!t||!n||!r)return"bottom";const i=n.offsetWidth,o=n.offsetHeight,a=r.xt.transform.width-i/2;if(r.y+et.transform.height-o){if(a)return"bottom-left";if(s)return"bottom-right"}return a?"left":s?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push("mapboxgl-popup-anchor-"+this._anchor),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const n=this._map,r=this._content;if(!n||!this._lngLat&&!this._trackPointer||!r)return;let i=this._container;if(i||(i=this._container=o("div","mapboxgl-popup",n.getContainer()),this._tip=o("div","mapboxgl-popup-tip",i),i.appendChild(r)),this.options.maxWidth&&i.style.maxWidth!==this.options.maxWidth&&(i.style.maxWidth=this.options.maxWidth),n.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=eo(this._lngLat,this._pos,n.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:n.project(this._lngLat),r=oo(this.options.offset),i=this._anchor=this._getAnchor(r.y),o=oo(this.options.offset,i),a=e.add(o).round();n._requestDomTask(()=>{this._container&&i&&(this._container.style.transform=`${to[i]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&n._showingGlobe()){const t=e.isLngLatBehindGlobe(n.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(io);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=""+e),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:no,Style:Qt,LngLat:e.LngLat,LngLatBounds:e.LngLatBounds,Point:e.Point,MercatorCoordinate:e.MercatorCoordinate,FreeCameraOptions:Gr,Evented:e.Evented,config:e.config,prewarm:function(){je().acquire(Re)},clearPrewarmedResources:function(){const e=Fe;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Re),Fe=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 e.config.ACCESS_TOKEN},set accessToken(t){e.config.ACCESS_TOKEN=t},get baseApiUrl(){return e.config.API_URL},set baseApiUrl(t){e.config.API_URL=t},get workerCount(){return Be.workerCount},set workerCount(e){Be.workerCount=e},get maxParallelImageRequests(){return e.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.clearTileCache(t)},workerUrl:"",workerClass:null,setNow:e.exported.setNow,restoreNow:e.exported.restoreNow};return mo})),r}()}).call(this,n(27))},function(e,t,n){"use strict";!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE){0;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}}(),e.exports=n(46)},function(e,t,n){"use strict";function r(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,l,"next",e)}function l(e){r(a,i,o,s,l,"throw",e)}s(void 0)}))}}n.d(t,"a",(function(){return i}))},function(e,t,n){"use strict";function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t96?d:f},m=function(e,t,n){var r;if(t){var i=t.shouldForwardProp;r=e.__emotion_forwardProp&&i?function(t){return e.__emotion_forwardProp(t)&&i(t)}:i}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},_=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return Object(u.c)(t,n,r),Object(h.a)((function(){return Object(u.b)(t,n,r)})),null},g=(n(55),function e(t,n){var o,a,s=t.__emotion_real===t,h=s&&t.__emotion_base||t;void 0!==n&&(o=n.label,a=n.target);var d=m(t,n,s),f=d||p(h),g=!f("as");return function(){var y=arguments,v=s&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==o&&v.push("label:"+o+";"),null==y[0]||void 0===y[0].raw)v.push.apply(v,y);else{0,v.push(y[0][0]);for(var x=y.length,b=1;b2||B(A)>3?"":" "}function V(e,t){for(;--t&&z()&&!(A<48||A>102||A>57&&A<65||A>70&&A<97););return R(e,D()+(t<6&&32==L()&&32==z()))}function G(e,t){for(;z()&&e+A!==57&&(e+A!==84||47!==L()););return"/*"+R(t,C-1)+"*"+d(47===e?e:z())}function q(e){for(;!B(L());)z();return R(e,C)}function $(e){return j(function e(t,n,r,i,o,a,s,l,u){var c=0,h=0,f=s,p=0,m=0,_=0,x=1,w=1,T=1,M=0,P="",O=o,R=a,B=i,F=P;for(;w;)switch(_=M,M=z()){case 40:if(108!=_&&58==v(F,f-1)){-1!=y(F+=g(N(M),"&","&\f"),"&\f")&&(T=-1);break}case 34:case 39:case 91:F+=N(M);break;case 9:case 10:case 13:case 32:F+=U(_);break;case 92:F+=V(D()-1,7);continue;case 47:switch(L()){case 42:case 47:E(W(G(z(),D()),n,r),u);break;default:F+="/"}break;case 123*x:l[c++]=b(F)*T;case 125*x:case 59:case 0:switch(M){case 0:case 125:w=0;case 59+h:-1==T&&(F=g(F,/\f/g,"")),m>0&&b(F)-f&&E(m>32?X(F+";",i,r,f-1):X(g(F," ","")+";",i,r,f-2),u);break;case 59:F+=";";default:if(E(B=Z(F,n,r,c,h,o,l,P,O=[],R=[],f),a),123===M)if(0===h)e(F,n,B,B,O,a,f,l,R);else switch(99===p&&110===v(F,3)?100:p){case 100:case 108:case 109:case 115:e(t,B,B,i&&E(Z(t,B,B,0,0,o,l,P,o,O=[],f),R),o,R,f,l,i?O:R);break;default:e(F,B,B,B,[""],R,0,l,R)}}c=h=m=0,x=T=1,P=F="",f=s;break;case 58:f=1+b(F),m=_;default:if(x<1)if(123==M)--x;else if(125==M&&0==x++&&125==(A=C>0?v(I,--C):0,k--,10===A&&(k=1,S--),A))continue;switch(F+=d(M),M*x){case 38:T=h>0?1:(F+="\f",-1);break;case 44:l[c++]=(b(F)-1)*T,T=1;break;case 64:45===L()&&(F+=N(z())),p=L(),h=f=b(P=F+=q(D())),M++;break;case 45:45===_&&2==b(F)&&(x=0)}}return a}("",null,null,null,[""],e=F(e),0,[0],e))}function Z(e,t,n,r,i,o,a,s,u,c,d){for(var f=i-1,p=0===i?o:[""],_=w(p),y=0,v=0,b=0;y0?p[E]+" "+T:g(T,/&\f/g,p[E])))&&(u[b++]=S);return P(e,t,n,0===i?l:s,u,c,d)}function W(e,t,n){return P(e,t,n,s,d(A),x(e,2,-2),0)}function X(e,t,n,r){return P(e,t,n,u,x(e,0,r),x(e,r+1,-1),r)}function H(e,t){for(var n="",r=w(e),i=0;i-1&&!e.return)switch(e.type){case u:e.return=function e(t,n){switch(p(t,n)){case 5103:return a+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return a+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return a+t+o+t+i+t+t;case 6828:case 4268:return a+t+i+t+t;case 6165:return a+t+i+"flex-"+t+t;case 5187:return a+t+g(t,/(\w+).+(:[^]+)/,a+"box-$1$2"+i+"flex-$1$2")+t;case 5443:return a+t+i+"flex-item-"+g(t,/flex-|-self/,"")+t;case 4675:return a+t+i+"flex-line-pack"+g(t,/align-content|flex-|-self/,"")+t;case 5548:return a+t+i+g(t,"shrink","negative")+t;case 5292:return a+t+i+g(t,"basis","preferred-size")+t;case 6060:return a+"box-"+g(t,"-grow","")+a+t+i+g(t,"grow","positive")+t;case 4554:return a+g(t,/([^-])(transform)/g,"$1"+a+"$2")+t;case 6187:return g(g(g(t,/(zoom-|grab)/,a+"$1"),/(image-set)/,a+"$1"),t,"")+t;case 5495:case 3959:return g(t,/(image-set\([^]*)/,a+"$1$`$1");case 4968:return g(g(t,/(.+:)(flex-)?(.*)/,a+"box-pack:$3"+i+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+a+t+t;case 4095:case 3583:case 4068:case 2532:return g(t,/(.+)-inline(.+)/,a+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(b(t)-1-n>6)switch(v(t,n+1)){case 109:if(45!==v(t,n+4))break;case 102:return g(t,/(.+:)(.+)-([^]+)/,"$1"+a+"$2-$3$1"+o+(108==v(t,n+3)?"$3":"$2-$3"))+t;case 115:return~y(t,"stretch")?e(g(t,"stretch","fill-available"),n)+t:t}break;case 4949:if(115!==v(t,n+1))break;case 6444:switch(v(t,b(t)-3-(~y(t,"!important")&&10))){case 107:return g(t,":",":"+a)+t;case 101:return g(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+a+(45===v(t,14)?"inline-":"")+"box$3$1"+a+"$2$3$1"+i+"$2box$3")+t}break;case 5936:switch(v(t,n+11)){case 114:return a+t+i+g(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return a+t+i+g(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return a+t+i+g(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return a+t+i+t+t}return t}(e.value,e.length);break;case c:return H([O(e,{value:g(e.value,"@","@"+a)})],r);case l:if(e.length)return T(e.props,(function(t){switch(_(t,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return H([O(e,{props:[g(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return H([O(e,{props:[g(t,/:(plac\w+)/,":"+a+"input-$1")]}),O(e,{props:[g(t,/:(plac\w+)/,":-moz-$1")]}),O(e,{props:[g(t,/:(plac\w+)/,i+"input-$1")]})],r)}return""}))}}],ie=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var i=e.stylisPlugins||re;var o,a,s={},l=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n1?t-1:0),r=1;re.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var N=Symbol("mobx-stored-annotations");function U(e){return Object.assign((function(t,n){V(t,n,e)}),e)}function V(e,t,n){I(e,N)||w(e,N,L({},e[N])),function(e){return"override"===e.annotationType_}(n)||(e[N][t]=n)}var G=Symbol("mobx administration"),q=function(){function e(e){void 0===e&&(e="Atom"),this.name_=void 0,this.isPendingUnobservation_=!1,this.isBeingObserved_=!1,this.observers_=new Set,this.diffValue_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Ue.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},t.reportObserved=function(){return dt(this)},t.reportChanged=function(){ct(),ft(this),at.stateVersion=at.stateVersionr&&(r=s.dependenciesState_)}n.length=i,e.newObserving_=null,o=t.length;for(;o--;){var l=t[o];0===l.diffValue_&<(l,e),l.diffValue_=0}for(;i--;){var u=n[i];1===u.diffValue_&&(u.diffValue_=0,st(u,e))}r!==Ue.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}(e),tt(r),i}function Ye(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)lt(t[n],e);e.dependenciesState_=Ue.NOT_TRACKING_}function Ke(e){var t=Je();try{return e()}finally{Qe(t)}}function Je(){var e=at.trackingDerivation;return at.trackingDerivation=null,e}function Qe(e){at.trackingDerivation=e}function et(e){var t=at.allowStateReads;return at.allowStateReads=e,t}function tt(e){at.allowStateReads=e}function nt(e){if(e.dependenciesState_!==Ue.UP_TO_DATE_){e.dependenciesState_=Ue.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=Ue.UP_TO_DATE_}}var rt=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0,this.stateVersion=Number.MIN_SAFE_INTEGER},it=!0,ot=!1,at=function(){var e=o();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(it=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==(new rt).version&&(it=!1),it?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new rt):(setTimeout((function(){ot||r(35)}),1),new rt)}();function st(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function lt(e,t){e.observers_.delete(t),0===e.observers_.size&&ut(e)}function ut(e){!1===e.isPendingUnobservation_&&(e.isPendingUnobservation_=!0,at.pendingUnobservations.push(e))}function ct(){at.inBatch++}function ht(){if(0==--at.inBatch){_t();for(var e=at.pendingUnobservations,t=0;t0&&ut(e),!1)}function ft(e){e.lowestObserverState_!==Ue.STALE_&&(e.lowestObserverState_=Ue.STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ue.UP_TO_DATE_&&e.onBecomeStale_(),e.dependenciesState_=Ue.STALE_})))}var pt=function(){function e(e,t,n,r){void 0===e&&(e="Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=Ue.NOT_TRACKING_,this.diffValue_=0,this.runId_=0,this.unboundDepsCount_=0,this.isDisposed_=!1,this.isScheduled_=!1,this.isTrackPending_=!1,this.isRunning_=!1,this.isTracing_=Ve.NONE,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}var t=e.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled_||(this.isScheduled_=!0,at.pendingReactions.push(this),_t())},t.isScheduled=function(){return this.isScheduled_},t.runReaction_=function(){if(!this.isDisposed_){ct(),this.isScheduled_=!1;var e=at.trackingContext;if(at.trackingContext=this,We(this)){this.isTrackPending_=!0;try{this.onInvalidate_()}catch(e){this.reportExceptionInDerivation_(e)}}at.trackingContext=e,ht()}},t.track=function(e){if(!this.isDisposed_){ct();0,this.isRunning_=!0;var t=at.trackingContext;at.trackingContext=this;var n=He(this,e,void 0);at.trackingContext=t,this.isRunning_=!1,this.isTrackPending_=!1,this.isDisposed_&&Ye(this),Ze(n)&&this.reportExceptionInDerivation_(n.cause),ht()}},t.reportExceptionInDerivation_=function(e){var t=this;if(this.errorHandler_)this.errorHandler_(e,this);else{if(at.disableErrorBoundaries)throw e;var n="[mobx] uncaught error in '"+this+"'";at.suppressReactionErrors||console.error(n,e),at.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed_||(this.isDisposed_=!0,this.isRunning_||(ct(),Ye(this),ht()))},t.getDisposer_=function(e){var t=this,n=function n(){t.dispose(),null==e||null==e.removeEventListener||e.removeEventListener("abort",n)};return null==e||null==e.addEventListener||e.addEventListener("abort",n),n[G]=this,n},t.toString=function(){return"Reaction["+this.name_+"]"},t.trace=function(e){void 0===e&&(e=!1)},e}();var mt=function(e){return e()};function _t(){at.inBatch>0||at.isRunningReactions||mt(gt)}function gt(){at.isRunningReactions=!0;for(var e=at.pendingReactions,t=0;e.length>0;){100==++t&&(console.error("[mobx] cycle in reaction: "+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r",t,e):g(n)?Le(t,n,e):y(n)?V(t,n,e?bt:vt):y(t)?U(Y(e?"autoAction":"action",{name:t,autoAction:e})):void 0}}var Tt=Et(!1);Object.assign(Tt,vt);var St=Et(!0);function kt(e){return g(e)&&!0===e.isMobxAction}function Mt(e,t){var n,r,i,o,a;void 0===t&&(t=h);var s,l=null!=(n=null==(r=t)?void 0:r.name)?n:"Autorun";if(!t.scheduler&&!t.delay)s=new pt(l,(function(){this.track(d)}),t.onError,t.requiresObservable);else{var u=At(t),c=!1;s=new pt(l,(function(){c||(c=!0,u((function(){c=!1,s.isDisposed_||s.track(d)})))}),t.onError,t.requiresObservable)}function d(){e(s)}return null!=(i=t)&&null!=(o=i.signal)&&o.aborted||s.schedule_(),s.getDisposer_(null==(a=t)?void 0:a.signal)}Object.assign(St,bt),Tt.bound=U(xt),St.bound=U(wt);var Ct=function(e){return e()};function At(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:Ct}function It(e,t,n){return Pt("onBUO",e,t,n)}function Pt(e,t,n,r){var i="function"==typeof r?jn(t,n):jn(t),o=g(r)?r:n,a=e+"L";return i[a]?i[a].add(o):i[a]=new Set([o]),function(){var e=i[a];e&&(e.delete(o),0===e.size&&delete i[a])}}function Ot(e,t,n,r){var i=P(t),o=En(e,r)[G];ct();try{C(i).forEach((function(e){o.extend_(e,i[e],!n||(!(e in n)||n[e]))}))}finally{ht()}return e}var zt=0;function Lt(){this.message="FLOW_CANCELLED"}Lt.prototype=Object.create(Error.prototype);var Dt=ee("flow"),Rt=ee("flow.bound",{bound:!0}),Bt=Object.assign((function(e,t){if(y(t))return V(e,t,Dt);var n=e,r=n.name||"",i=function(){var e,t=this,i=arguments,o=++zt,a=Tt(r+" - runid: "+o+" - init",n).apply(t,i),s=void 0,l=new Promise((function(t,n){var i=0;function l(e){var t;s=void 0;try{t=Tt(r+" - runid: "+o+" - yield "+i++,a.next).call(a,e)}catch(e){return n(e)}c(t)}function u(e){var t;s=void 0;try{t=Tt(r+" - runid: "+o+" - yield "+i++,a.throw).call(a,e)}catch(e){return n(e)}c(t)}function c(e){if(!g(null==e?void 0:e.then))return e.done?t(e.value):(s=Promise.resolve(e.value)).then(l,u);e.then(c,n)}e=n,l(void 0)}));return l.cancel=Tt(r+" - runid: "+o+" - cancel",(function(){try{s&&Ft(s);var t=a.return(void 0),n=Promise.resolve(t.value);n.then(_,_),Ft(n),e(new Lt)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),Dt);function Ft(e){g(e.cancel)&&e.cancel()}function jt(e){return!0===(null==e?void 0:e.isMobXFlow)}function Nt(e,t){return!!e&&(void 0!==t?!!kn(e)&&e[G].values_.has(t):kn(e)||!!e[G]||$(e)||yt(e)||qe(e))}function Ut(e){return Nt(e)}function Vt(e,t){void 0===t&&(t=void 0),ct();try{return e.apply(t)}finally{ht()}}function Gt(e){return e[G]}Bt.bound=U(Rt);var qt={has:function(e,t){return Gt(e).has_(t)},get:function(e,t){return Gt(e).get_(t)},set:function(e,t,n){var r;return!!y(t)&&(null==(r=Gt(e).set_(t,n,!0))||r)},deleteProperty:function(e,t){var n;return!!y(t)&&(null==(n=Gt(e).delete_(t,!0))||n)},defineProperty:function(e,t,n){var r;return null==(r=Gt(e).defineProperty_(t,n))||r},ownKeys:function(e){return Gt(e).ownKeys_()},preventExtensions:function(e){r(13)}};function $t(e){return void 0!==e.interceptors_&&e.interceptors_.length>0}function Zt(e,t){var n=e.interceptors_||(e.interceptors_=[]);return n.push(t),m((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Wt(e,t){var n=Je();try{for(var i=[].concat(e.interceptors_||[]),o=0,a=i.length;o0}function Ht(e,t){var n=e.changeListeners_||(e.changeListeners_=[]);return n.push(t),m((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Yt(e,t){var n=Je(),r=e.changeListeners_;if(r){for(var i=0,o=(r=r.slice()).length;i0?e.map(this.dehancer):e},t.intercept_=function(e){return Zt(this,e)},t.observe_=function(e,t){return void 0===t&&(t=!1),t&&e({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),Ht(this,e)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(e){("number"!=typeof e||isNaN(e)||e<0)&&r("Out of range: "+e);var t=this.values_.length;if(e!==t)if(e>t){for(var n=new Array(e-t),i=0;i0&&Bn(e+t+1)},t.spliceWithArray_=function(e,t,n){var r=this;this.atom_;var i=this.values_.length;if(void 0===e?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=1===arguments.length?i-e:null==t?0:Math.max(0,Math.min(t,i-e)),void 0===n&&(n=c),$t(this)){var o=Wt(this,{object:this.proxy_,type:"splice",index:e,removedCount:t,added:n});if(!o)return c;t=o.removedCount,n=o.added}if(n=0===n.length?n:n.map((function(e){return r.enhancer_(e,void 0)})),this.legacyMode_){var a=n.length-t;this.updateArrayLength_(i,a)}var s=this.spliceItemsIntoValues_(e,t,n);return 0===t&&0===n.length||this.notifyArraySplice_(e,n,s),this.dehanceValues_(s)},t.spliceItemsIntoValues_=function(e,t,n){var r;if(n.length<1e4)return(r=this.values_).splice.apply(r,[e,t].concat(n));var i=this.values_.slice(e,e+t),o=this.values_.slice(e+t);this.values_.length+=n.length-t;for(var a=0;a=this.values_.length))return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e]);console.warn("[mobx] Out of bounds read: "+e)},t.set_=function(e,t){var n=this.values_;if(this.legacyMode_&&e>n.length&&r(17,e,n.length),e2?n-2:0),i=2;i-1&&(this.splice(n,1),!0)}};function rn(e,t){"function"==typeof Array.prototype[e]&&(nn[e]=t(e))}function on(e){return function(){var t=this[G];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function an(e){return function(t,n){var r=this,i=this[G];return i.atom_.reportObserved(),i.dehanceValues_(i.values_)[e]((function(e,i){return t.call(n,e,i,r)}))}}function sn(e){return function(){var t=this,n=this[G];n.atom_.reportObserved();var r=n.dehanceValues_(n.values_),i=arguments[0];return arguments[0]=function(e,n,r){return i(e,n,r,t)},r[e].apply(r,arguments)}}rn("concat",on),rn("flat",on),rn("includes",on),rn("indexOf",on),rn("join",on),rn("lastIndexOf",on),rn("slice",on),rn("toString",on),rn("toLocaleString",on),rn("every",an),rn("filter",an),rn("find",an),rn("findIndex",an),rn("flatMap",an),rn("forEach",an),rn("map",an),rn("some",an),rn("reduce",sn),rn("reduceRight",sn);var ln,un,cn=T("ObservableArrayAdministration",en);function hn(e){return v(e)&&cn(e[G])}var dn={},fn="add";ln=Symbol.iterator,un=Symbol.toStringTag;var pn,mn,_n=function(){function e(e,t,n){var i=this;void 0===t&&(t=X),void 0===n&&(n="ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[G]=dn,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,g(Map)||r(18),this.keysAtom_=Z("ObservableMap.keys()"),this.data_=new Map,this.hasMap_=new Map,Re(!0,(function(){i.merge(e)}))}var t=e.prototype;return t.has_=function(e){return this.data_.has(e)},t.has=function(e){var t=this;if(!at.trackingDerivation)return this.has_(e);var n=this.hasMap_.get(e);if(!n){var r=n=new Ne(this.has_(e),H,"ObservableMap.key?",!1);this.hasMap_.set(e,r),It(r,(function(){return t.hasMap_.delete(e)}))}return n.get()},t.set=function(e,t){var n=this.has_(e);if($t(this)){var r=Wt(this,{type:n?Jt:fn,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this},t.delete=function(e){var t=this;if((this.keysAtom_,$t(this))&&!Wt(this,{type:"delete",object:this,name:e}))return!1;if(this.has_(e)){var n=Xt(this),r=n?{observableKind:"map",debugObjectName:this.name_,type:"delete",object:this,oldValue:this.data_.get(e).value_,name:e}:null;return Vt((function(){var n;t.keysAtom_.reportChanged(),null==(n=t.hasMap_.get(e))||n.setNewValue_(!1),t.data_.get(e).setNewValue_(void 0),t.data_.delete(e)})),n&&Yt(this,r),!0}return!1},t.updateValue_=function(e,t){var n=this.data_.get(e);if((t=n.prepareNewValue_(t))!==at.UNCHANGED){var r=Xt(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:Jt,object:this,oldValue:n.value_,name:e,newValue:t}:null;0,n.setNewValue_(t),r&&Yt(this,i)}},t.addValue_=function(e,t){var n=this;this.keysAtom_,Vt((function(){var r,i=new Ne(t,n.enhancer_,"ObservableMap.key",!1);n.data_.set(e,i),t=i.value_,null==(r=n.hasMap_.get(e))||r.setNewValue_(!0),n.keysAtom_.reportChanged()}));var r=Xt(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:fn,object:this,name:e,newValue:t}:null;r&&Yt(this,i)},t.get=function(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)},t.dehanceValue_=function(e){return void 0!==this.dehancer?this.dehancer(e):e},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var e=this,t=this.keys();return $n({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:e.get(i)}}})},t.entries=function(){var e=this,t=this.keys();return $n({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},t[ln]=function(){return this.entries()},t.forEach=function(e,t){for(var n,r=j(this);!(n=r()).done;){var i=n.value,o=i[0],a=i[1];e.call(t,a,o,this)}},t.merge=function(e){var t=this;return gn(e)&&(e=new Map(e)),Vt((function(){x(e)?function(e){var t=Object.keys(e);if(!M)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter((function(t){return u.propertyIsEnumerable.call(e,t)}))):t}(e).forEach((function(n){return t.set(n,e[n])})):Array.isArray(e)?e.forEach((function(e){var n=e[0],r=e[1];return t.set(n,r)})):S(e)?(e.constructor!==Map&&r(19,e),e.forEach((function(e,n){return t.set(n,e)}))):null!=e&&r(20,e)})),this},t.clear=function(){var e=this;Vt((function(){Ke((function(){for(var t,n=j(e.keys());!(t=n()).done;){var r=t.value;e.delete(r)}}))}))},t.replace=function(e){var t=this;return Vt((function(){for(var n,i=function(e){if(S(e)||gn(e))return e;if(Array.isArray(e))return new Map(e);if(x(e)){var t=new Map;for(var n in e)t.set(n,e[n]);return t}return r(21,e)}(e),o=new Map,a=!1,s=j(t.data_.keys());!(n=s()).done;){var l=n.value;if(!i.has(l))if(t.delete(l))a=!0;else{var u=t.data_.get(l);o.set(l,u)}}for(var c,h=j(i.entries());!(c=h()).done;){var d=c.value,f=d[0],p=d[1],m=t.data_.has(f);if(t.set(f,p),t.data_.has(f)){var _=t.data_.get(f);o.set(f,_),m||(a=!0)}}if(!a)if(t.data_.size!==o.size)t.keysAtom_.reportChanged();else for(var g=t.data_.keys(),y=o.keys(),v=g.next(),b=y.next();!v.done;){if(v.value!==b.value){t.keysAtom_.reportChanged();break}v=g.next(),b=y.next()}t.data_=o})),this},t.toString=function(){return"[object ObservableMap]"},t.toJSON=function(){return Array.from(this)},t.observe_=function(e,t){return Ht(this,e)},t.intercept_=function(e){return Zt(this,e)},z(e,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:un,get:function(){return"Map"}}]),e}(),gn=T("ObservableMap",_n);var yn={};pn=Symbol.iterator,mn=Symbol.toStringTag;var vn=function(){function e(e,t,n){void 0===t&&(t=X),void 0===n&&(n="ObservableSet"),this.name_=void 0,this[G]=yn,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,g(Set)||r(22),this.atom_=Z(this.name_),this.enhancer_=function(e,r){return t(e,r,n)},e&&this.replace(e)}var t=e.prototype;return t.dehanceValue_=function(e){return void 0!==this.dehancer?this.dehancer(e):e},t.clear=function(){var e=this;Vt((function(){Ke((function(){for(var t,n=j(e.data_.values());!(t=n()).done;){var r=t.value;e.delete(r)}}))}))},t.forEach=function(e,t){for(var n,r=j(this);!(n=r()).done;){var i=n.value;e.call(t,i,i,this)}},t.add=function(e){var t=this;if((this.atom_,$t(this))&&!Wt(this,{type:fn,object:this,newValue:e}))return this;if(!this.has(e)){Vt((function(){t.data_.add(t.enhancer_(e,void 0)),t.atom_.reportChanged()}));var n=Xt(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:fn,object:this,newValue:e}:null;0,n&&Yt(this,r)}return this},t.delete=function(e){var t=this;if($t(this)&&!Wt(this,{type:"delete",object:this,oldValue:e}))return!1;if(this.has(e)){var n=Xt(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:"delete",object:this,oldValue:e}:null;return Vt((function(){t.atom_.reportChanged(),t.data_.delete(e)})),n&&Yt(this,r),!0}return!1},t.has=function(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))},t.entries=function(){var e=0,t=Array.from(this.keys()),n=Array.from(this.values());return $n({next:function(){var r=e;return e+=1,rOn){for(var t=On;t=0&&r++}t=qn(t),n=qn(n);var l="[object Array]"===s;if(!l){if("object"!=typeof t||"object"!=typeof n)return!1;var u=t.constructor,c=n.constructor;if(u!==c&&!(g(u)&&u instanceof u&&g(c)&&c instanceof c)&&"constructor"in t&&"constructor"in n)return!1}if(0===r)return!1;r<0&&(r=-1);o=o||[];var h=(i=i||[]).length;for(;h--;)if(i[h]===t)return o[h]===n;if(i.push(t),o.push(n),l){if((h=t.length)!==n.length)return!1;for(;h--;)if(!e(t[h],n[h],r-1,i,o))return!1}else{var d,f=Object.keys(t);if(h=f.length,Object.keys(n).length!==h)return!1;for(;h--;)if(d=f[h],!I(n,d)||!e(t[d],n[d],r-1,i,o))return!1}return i.pop(),o.pop(),!0}(e,t,n)}function qn(e){return hn(e)?e.slice():S(e)||gn(e)||k(e)||xn(e)?Array.from(e.entries()):e}function $n(e){return e[Symbol.iterator]=Zn,e}function Zn(){return this}["Symbol","Map","Set"].forEach((function(e){void 0===o()[e]&&r("MobX requires global '"+e+"' to be available or polyfilled")})),"object"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:function(e){return console.warn("[mobx.spy] Is a no-op in production builds"),function(){}},extras:{getDebugName:Un},$mobx:G})}).call(this,n(21))},function(e,t,n){"use strict";function r(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){var t=new WeakMap;return function(n){if(t.has(n))return t.get(n);var r=e(n);return t.set(n,r),r}}},function(e,t,n){"use strict";var r=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)};var i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?c((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function a(e,t,n){return e.concat(t).map((function(e){return o(e,n)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function l(e,t){try{return t in e}catch(e){return!1}}function u(e,t,n){var r={};return n.isMergeableObject(e)&&s(e).forEach((function(t){r[t]=o(e[t],n)})),s(t).forEach((function(i){(function(e,t){return l(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(l(e,i)&&n.isMergeableObject(t[i])?r[i]=function(e,t){if(!t.customMerge)return c;var n=t.customMerge(e);return"function"==typeof n?n:c}(i,n)(e[i],t[i],n):r[i]=o(t[i],n))})),r}function c(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||a,n.isMergeableObject=n.isMergeableObject||r,n.cloneUnlessOtherwiseSpecified=o;var i=Array.isArray(t);return i===Array.isArray(e)?i?n.arrayMerge(e,t,n):u(e,t,n):o(t,n)}c.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return c(e,n,t)}),{})};var h=c;e.exports=h},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t=0||(i[n]=e[n]);return i}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";var r=n(4);function i(e,t,n){if(null!==e)for(var r,o,a,s,l,u,c,h,d=0,f=0,p=e.type,m="FeatureCollection"===p,_="Feature"===p,g=m?e.features.length:1,y=0;y=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}(t),n.properties);case"Polygon":var o=[];i(t,(function(e){o.push(e)}));var l,u,c,h,d,f,p,m,_=s(t,{properties:n.properties}),g=_.geometry.coordinates,y=0,v=0,x=0,b=o.map((function(e){return[e[0]-g[0],e[1]-g[1]]}));for(l=0;l3?Object(r.f)([o]):null}(t);return E?e(E,{properties:n.properties}):s(t,{properties:n.properties})}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(26),i=n.n(r),o=function(e,t){return i()(e,t)}},function(e,t,n){"use strict";var r=n(53),i={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function l(e){return r.isMemo(e)?a:s[e.$$typeof]||i}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=a;var u=Object.defineProperty,c=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,p=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(p){var i=f(n);i&&i!==p&&e(t,i,r)}var a=c(n);h&&(a=a.concat(h(n)));for(var s=l(t),m=l(n),_=0;_1)for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&(i-=1)),[360*i,100*o,100*u]},o.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const i=o.rgb.hsl(e)[0],a=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[i,100*a,100*r]},o.rgb.cmyk=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.min(1-t,1-n,1-r);return[100*((1-t-i)/(1-i)||0),100*((1-n-i)/(1-i)||0),100*((1-r-i)/(1-i)||0),100*i]},o.rgb.keyword=function(e){const t=i[e];if(t)return t;let n,o=1/0;for(const t of Object.keys(r)){const i=r[t],l=(s=i,((a=e)[0]-s[0])**2+(a[1]-s[1])**2+(a[2]-s[2])**2);l.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;return[100*(.4124*t+.3576*n+.1805*r),100*(.2126*t+.7152*n+.0722*r),100*(.0193*t+.1192*n+.9505*r)]},o.rgb.lab=function(e){const t=o.rgb.xyz(e);let n=t[0],r=t[1],i=t[2];n/=95.047,r/=100,i/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;return[116*r-16,500*(n-r),200*(r-i)]},o.hsl.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;let i,o,a;if(0===n)return a=255*r,[a,a,a];i=r<.5?r*(1+n):r+n-r*n;const s=2*r-i,l=[0,0,0];for(let e=0;e<3;e++)o=t+1/3*-(e-1),o<0&&o++,o>1&&o--,a=6*o<1?s+6*(i-s)*o:2*o<1?i:3*o<2?s+(i-s)*(2/3-o)*6:s,l[e]=255*a;return l},o.hsl.hsv=function(e){const t=e[0];let n=e[1]/100,r=e[2]/100,i=n;const o=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,i*=o<=1?o:2-o;return[t,100*(0===r?2*i/(o+i):2*n/(r+n)),100*((r+n)/2)]},o.hsv.rgb=function(e){const t=e[0]/60,n=e[1]/100;let r=e[2]/100;const i=Math.floor(t)%6,o=t-Math.floor(t),a=255*r*(1-n),s=255*r*(1-n*o),l=255*r*(1-n*(1-o));switch(r*=255,i){case 0:return[r,l,a];case 1:return[s,r,a];case 2:return[a,r,l];case 3:return[a,s,r];case 4:return[l,a,r];case 5:return[r,a,s]}},o.hsv.hsl=function(e){const t=e[0],n=e[1]/100,r=e[2]/100,i=Math.max(r,.01);let o,a;a=(2-n)*r;const s=(2-n)*i;return o=n*i,o/=s<=1?s:2-s,o=o||0,a/=2,[t,100*o,100*a]},o.hwb.rgb=function(e){const t=e[0]/360;let n=e[1]/100,r=e[2]/100;const i=n+r;let o;i>1&&(n/=i,r/=i);const a=Math.floor(6*t),s=1-r;o=6*t-a,0!=(1&a)&&(o=1-o);const l=n+o*(s-n);let u,c,h;switch(a){default:case 6:case 0:u=s,c=l,h=n;break;case 1:u=l,c=s,h=n;break;case 2:u=n,c=s,h=l;break;case 3:u=n,c=l,h=s;break;case 4:u=l,c=n,h=s;break;case 5:u=s,c=n,h=l}return[255*u,255*c,255*h]},o.cmyk.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,i=e[3]/100;return[255*(1-Math.min(1,t*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},o.xyz.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100;let i,o,a;return i=3.2406*t+-1.5372*n+-.4986*r,o=-.9689*t+1.8758*n+.0415*r,a=.0557*t+-.204*n+1.057*r,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[255*i,255*o,255*a]},o.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];t/=95.047,n/=100,r/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;return[116*n-16,500*(t-n),200*(n-r)]},o.lab.xyz=function(e){let t,n,r;n=(e[0]+16)/116,t=e[1]/500+n,r=n-e[2]/200;const i=n**3,o=t**3,a=r**3;return n=i>.008856?i:(n-16/116)/7.787,t=o>.008856?o:(t-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,t*=95.047,n*=100,r*=108.883,[t,n,r]},o.lab.lch=function(e){const t=e[0],n=e[1],r=e[2];let i;i=360*Math.atan2(r,n)/2/Math.PI,i<0&&(i+=360);return[t,Math.sqrt(n*n+r*r),i]},o.lch.lab=function(e){const t=e[0],n=e[1],r=e[2]/360*2*Math.PI;return[t,n*Math.cos(r),n*Math.sin(r)]},o.rgb.ansi16=function(e,t=null){const[n,r,i]=e;let a=null===t?o.rgb.hsv(e)[2]:t;if(a=Math.round(a/50),0===a)return 30;let s=30+(Math.round(i/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===a&&(s+=60),s},o.hsv.ansi16=function(e){return o.rgb.ansi16(o.hsv.rgb(e),e[2])},o.rgb.ansi256=function(e){const t=e[0],n=e[1],r=e[2];if(t===n&&n===r)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},o.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const n=.5*(1+~~(e>50));return[(1&t)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*255]},o.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},o.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},o.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let n=t[0];3===t[0].length&&(n=n.split("").map(e=>e+e).join(""));const r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},o.rgb.hcg=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.max(Math.max(t,n),r),o=Math.min(Math.min(t,n),r),a=i-o;let s,l;return s=a<1?o/(1-a):0,l=a<=0?0:i===t?(n-r)/a%6:i===n?2+(r-t)/a:4+(t-n)/a,l/=6,l%=1,[360*l,100*a,100*s]},o.hsl.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n);let i=0;return r<1&&(i=(n-.5*r)/(1-r)),[e[0],100*r,100*i]},o.hsv.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=t*n;let i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],100*r,100*i]},o.hcg.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;if(0===n)return[255*r,255*r,255*r];const i=[0,0,0],o=t%1*6,a=o%1,s=1-a;let l=0;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=s,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=s,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=s}return l=(1-n)*r,[255*(n*i[0]+l),255*(n*i[1]+l),255*(n*i[2]+l)]},o.hcg.hsv=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);let r=0;return n>0&&(r=t/n),[e[0],100*r,100*n]},o.hcg.hsl=function(e){const t=e[1]/100,n=e[2]/100*(1-t)+.5*t;let r=0;return n>0&&n<.5?r=t/(2*n):n>=.5&&n<1&&(r=t/(2*(1-n))),[e[0],100*r,100*n]},o.hcg.hwb=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);return[e[0],100*(n-t),100*(1-n)]},o.hwb.hcg=function(e){const t=e[1]/100,n=1-e[2]/100,r=n-t;let i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],100*r,100*i]},o.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},o.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},o.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},o.gray.hsl=function(e){return[0,0,e[0]]},o.gray.hsv=o.gray.hsl,o.gray.hwb=function(e){return[0,100,e[0]]},o.gray.cmyk=function(e){return[0,0,0,e[0]]},o.gray.lab=function(e){return[e[0],0,0]},o.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(n.length)+n},o.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},function(e,t,n){var r,i,o; +*/!function(){"use strict";var n={}.hasOwnProperty;function i(){for(var e=[],t=0;t=4;++r,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(i){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}(i)+l,styles:i,next:d}}},function(e,t,n){(function(t){e.exports=function(){"use strict";var e,n,r;function i(t,i){if(e)if(n){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 = {}; ("+e+")(sharedChunk); ("+n+")(sharedChunk); self.onerror = null;",a={};e(a),r=i(a),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(r.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else n=i;else e=i}return i(0,(function(e){var n="undefined"!=typeof self?self:{},r="2.15.0";let i;const o={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==i){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{i=null!=t.env.API_URL_REGEX?new RegExp(t.env.API_URL_REGEX):e}catch(t){i=e}}return i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!o.API_URL)return null;try{const e=new URL(o.API_URL);return"api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return 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},a={supported:!1,testSupport:function(e){!u&&l&&(c?h(e):s=e)}};let s,l,u=!1,c=!1;function h(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,l),e.isContextLost())return;a.supported=!0}catch(e){}e.deleteTexture(t),u=!0}n.document&&(l=n.document.createElement("img"),l.onload=function(){s&&h(s),s=null,c=!0},l.onerror=function(){u=!0,s=null},l.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const d="01";function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p=m;function m(e,t,n,r){this.cx=3*e,this.bx=3*(n-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=n,this.p2y=r}m.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)i?a=n:s=n,n=.5*(s-a)+a;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var g=f(p),_=y;function y(e,t){this.x=e,this.y=t}y.prototype={clone:function(){return new y(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},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(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround:function(e,t){var n=Math.cos(e),r=Math.sin(e),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-r*(this.y-t.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},y.convert=function(e){return e instanceof y?e:Array.isArray(e)?new y(e[0],e[1]):e};var v=f(_);const x=Math.PI/180,b=180/Math.PI;function w(e){return e*x}function E(e){return e*b}const T=[[0,0],[1,0],[1,1],[0,1]];function S(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function A(e,t,n,r){const i=new g(e,t,n,r);return function(e){return i.solve(e)}}const k=A(.25,.1,.25,1);function M(e,t,n){return Math.min(n,Math.max(t,e))}function C(e,t,n){return(n=M((n-e)/(t-e),0,1))*n*(3-2*n)}function I(e,t,n){const r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function P(e,t,n){if(!e.length)return n(null,[]);let r=e.length;const i=new Array(e.length);let o=null;e.forEach((e,a)=>{t(e,(e,t)=>{e&&(o=e),i[a]=t,0==--r&&n(o,i)})})}function O(e){const t=[];for(const n in e)t.push(e[n]);return t}function z(e,...t){for(const n of t)for(const t in n)e[t]=n[t];return e}let L=1;function D(){return L++}function R(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function B(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function F(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function j(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function U(e,t){return-1!==e.indexOf(t,e.length-t.length)}function N(e,t,n){const r={};for(const i in e)r[i]=t.call(n||this,e[i],i,e);return r}function V(e,t,n){const r={};for(const i in e)t.call(n||this,e[i],i,e)&&(r[i]=e[i]);return r}function G(e){return Array.isArray(e)?e.map(G):"object"==typeof e&&e?N(e,G):e}const q={};function $(e){q[e]||("undefined"!=typeof console&&console.warn(e),q[e]=!0)}function Z(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function W(e){let t=0;for(let n,r,i=0,o=e.length,a=o-1;i@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,n,r,i)=>{const o=r||i;return t[n]=!o||o.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let Y=null;function K(e){if(null==Y){const t=e.navigator?e.navigator.userAgent:null;Y=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Y}function J(e){try{const t=n[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function Q(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const ee="mapbox-tiles";let te,ne,re=500,ie=50;function oe(){try{return n.caches}catch(e){}}function ae(){oe()&&!te&&(te=n.caches.open(ee))}function se(e){const t=e.indexOf("?");if(t<0)return e;const n=function(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}(e).filter(e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]});return n.length?`${e.slice(0,t)}?${n.join("&")}`:e.slice(0,t)}let le=1/0;const ue={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(ue);class ce extends Error{constructor(e,t,n){401===t&&be(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const he=X()?()=>self.worker&&self.worker.referrer:()=>("blob:"===n.location.protocol?n.parent:n).location.href,de=function(e,t){if(!(/^file:/.test(r=e.url)||/^file:/.test(he())&&!/^\w+:/.test(r))){if(n.fetch&&n.Request&&n.AbortController&&n.Request.prototype.hasOwnProperty("signal"))return function(e,t){const r=new n.AbortController,i=new n.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:he(),referrerPolicy:e.referrerPolicy,signal:r.signal});let o=!1,a=!1;const s=(l=i.url).indexOf("sku=")>0&&be(l);var l;"json"===e.type&&i.headers.set("Accept","application/json");const u=(r,o,l)=>{if(a)return;if(r&&"SecurityError"!==r.message&&$(r.toString()),o&&l)return c(o);const u=Date.now();n.fetch(i).then(n=>{if(n.ok){const e=s?n.clone():null;return c(n,e,u)}return t(new ce(n.statusText,n.status,e.url))}).catch(n=>{"AbortError"!==n.name&&t(new Error(`${n.message} ${e.url}`))})},c=(r,s,l)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then(e=>{a||(s&&l&&function(e,t,r){if(ae(),!te)return;const i={status:t.status,statusText:t.statusText,headers:new n.Headers};t.headers.forEach((e,t)=>i.headers.set(t,e));const o=H(t.headers.get("Cache-Control")||"");if(o["no-store"])return;o["max-age"]&&i.headers.set("Expires",new Date(r+1e3*o["max-age"]).toUTCString());const a=i.headers.get("Expires");a&&(new Date(a).getTime()-r<42e4||function(e,t){if(void 0===ne)try{new Response(new ReadableStream),ne=!0}catch(e){ne=!1}ne?t(e.body):e.blob().then(t)}(t,t=>{const r=new n.Response(t,i);ae(),te&&te.then(t=>t.put(se(e.url),r)).catch(e=>$(e.message))}))}(i,s,l),o=!0,t(null,e,r.headers.get("Cache-Control"),r.headers.get("Expires")))}).catch(e=>{a||t(new Error(e.message))})};return s?function(e,t){if(ae(),!te)return t(null);const n=se(e.url);te.then(e=>{e.match(n).then(r=>{const i=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),n=H(e.headers.get("Cache-Control")||"");return t>Date.now()&&!n["no-cache"]}(r);e.delete(n),i&&e.put(n,r.clone()),t(null,r,i)}).catch(t)}).catch(t)}(i,u):u(null,null),{cancel:()=>{a=!0,o||r.abort()}}}(e,t);if(X()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var r;return function(e,t){const r=new n.XMLHttpRequest;r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{t(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===e.type)try{n=JSON.parse(r.response)}catch(e){return t(e)}t(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else t(new ce(r.statusText,r.status,e.url))},r.send(e.body),{cancel:()=>r.abort()}}(e,t)},fe=function(e,t){return de(z(e,{type:"arrayBuffer"}),t)};function pe(e){const t=n.document.createElement("a");return t.href=e,t.protocol===n.document.location.protocol&&t.host===n.document.location.host}const me="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let ge,_e;ge=[],_e=0;const ye=function(e,t){if(a.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),_e>=o.MAX_PARALLEL_IMAGE_REQUESTS){const n={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return ge.push(n),n}_e++;let r=!1;const i=()=>{if(!r)for(r=!0,_e--;ge.length&&_e{i(),e?t(e):r&&(n.createImageBitmap?function(e,t){const r=new n.Blob([new Uint8Array(e)],{type:"image/png"});n.createImageBitmap(r).then(e=>{t(null,e)}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(r,(e,n)=>t(e,n,o,a)):function(e,t){const r=new n.Image,i=n.URL;r.onload=()=>{t(null,r),i.revokeObjectURL(r.src),r.onload=null,n.requestAnimationFrame(()=>{r.src=me})},r.onerror=()=>t(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 n.Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?i.createObjectURL(o):me}(r,(e,n)=>t(e,n,o,a)))});return{cancel:()=>{s.cancel(),i()}}},ve="NO_ACCESS_TOKEN";function xe(e){return 0===e.indexOf("mapbox:")}function be(e){return o.API_URL_REGEX.test(e)}function we(e){return o.API_CDN_URL_REGEX.test(e)}function Ee(e){return o.API_STYLE_REGEX.test(e)&&!Te(e)}function Te(e){return o.API_SPRITE_REGEX.test(e)}const Se=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Ae(e){const t=e.match(Se);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function ke(e){const t=e.params.length?"?"+e.params.join("&"):"";return`${e.protocol}://${e.authority}${e.path}${t}`}const Me="mapbox.eventData";function Ce(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(n.atob(t[1]).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(e){return null}}class Ie{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=Ce(o.ACCESS_TOKEN);let r="";return r=t&&t.u?n.btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t)))):o.ACCESS_TOKEN||"",e?`${Me}.${e}:${r}`:`${Me}:${r}`}fetchEventData(){const e=J("localStorage"),t=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{const e=n.localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const i=n.localStorage.getItem(r);i&&(this.anonId=i)}catch(e){$("Unable to read from LocalStorage")}}saveEventData(){const e=J("localStorage"),t=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{n.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&n.localStorage.setItem(t,JSON.stringify(this.eventData))}catch(e){$("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,n,r){if(!o.EVENTS_URL)return;const i=Ae(o.EVENTS_URL);i.params.push("access_token="+(r||o.ACCESS_TOKEN||""));const a={event:this.type,created:new Date(e).toISOString()},s=t?z(a,t):a,l={url:ke(i),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=function(e,t){return de(z(e,{method:"POST"}),t)}(l,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const Pe=new class extends Ie{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){o.EVENTS_URL&&o.ACCESS_TOKEN&&Array.isArray(e)&&e.some(e=>xe(e)||be(e))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Ce(o.ACCESS_TOKEN),n=t?t.u:o.ACCESS_TOKEN;let i=n!==this.eventData.tokenU;F(this.anonId)||(this.anonId=R(),i=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(a),n=(a-this.eventData.lastSuccess)/864e5;i=i||n>=1||n<-1||e.getDate()!==t.getDate()}else i=!0;i?this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:d,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=a,this.eventData.tokenU=n)},e):this.processRequests()}},Oe=Pe.postTurnstileEvent.bind(Pe),ze=new class extends Ie{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,n,r){this.skuToken=t,this.errorCb=r,o.EVENTS_URL&&(n||o.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(ve)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),F(this.anonId)||(this.anonId=R()),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:d,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e))}},Le=ze.postMapLoadEvent.bind(ze),De=new class extends Ie{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){o.EVENTS_URL&&(e||o.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,performanceData:i}=this.queue.shift(),o=function(e){const t=n.performance.getEntriesByType("resource"),i=n.performance.getEntriesByType("mark"),o=function(e){const t={};if(e)for(const n in e)if("other"!==n)for(const r of e[n]){const e=n+"ResolveRangeMin",i=n+"ResolveRangeMax",o=n+"RequestCount",a=n+"RequestCachedCount";t[e]=Math.min(t[e]||1/0,r.startTime),t[i]=Math.max(t[i]||-1/0,r.responseEnd);const s=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==r.transferSize&&0===r.transferSize&&s(a),s(o)}return t}(function(e,t){const n={};if(e)for(const r of e){const e=t(r);void 0===n[e]&&(n[e]=[]),n[e].push(r)}return n}(t,Ve)),a=n.devicePixelRatio,s=n.navigator.connection||n.navigator.mozConnection||n.navigator.webkitConnection,l={counters:[],metadata:[],attributes:[]},u=(e,t,n)=>{null!=n&&e.push({name:t,value:n.toString()})};for(const e in o)u(l.counters,e,o[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(u(l.counters,"interactionRangeMin",e.interactionRange[0]),u(l.counters,"interactionRangeMax",e.interactionRange[1])),i)for(const e of Object.keys(Ue)){const t=Ue[e],n=i.find(e=>e.name===t);n&&u(l.counters,t,n.startTime)}return u(l.counters,"visibilityHidden",e.visibilityHidden),u(l.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(Ee(e)){const t=e.split("/").slice(-2);if(2===t.length)return`mapbox://styles/${t[0]}/${t[1]}`}}}(t)),u(l.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),u(l.attributes,"fogEnabled",e.fogEnabled?"true":"false"),u(l.attributes,"projection",e.projection),u(l.attributes,"zoom",e.zoom),u(l.metadata,"devicePixelRatio",a),u(l.metadata,"connectionEffectiveType",s?s.effectiveType:void 0),u(l.metadata,"navigatorUserAgent",n.navigator.userAgent),u(l.metadata,"screenWidth",n.screen.width),u(l.metadata,"screenHeight",n.screen.height),u(l.metadata,"windowWidth",n.innerWidth),u(l.metadata,"windowHeight",n.innerHeight),u(l.metadata,"mapWidth",e.width/a),u(l.metadata,"mapHeight",e.height/a),u(l.metadata,"webglRenderer",e.renderer),u(l.metadata,"webglVendor",e.vendor),u(l.metadata,"sdkVersion",r),u(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(i);for(const e of o.metadata);for(const e of o.counters);for(const e of o.attributes);this.postEvent(t,o,()=>{},e)}},Re=De.postPerformanceEvent.bind(De),Be=new class extends Ie{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,n,r){if(!o.API_URL||!o.SESSION_PATH)return;const i=Ae(o.API_URL+o.SESSION_PATH);i.params.push("sku="+(t||"")),i.params.push("access_token="+(r||o.ACCESS_TOKEN||""));const a={url:ke(i),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return de(z(e,{method:"GET"}),t)}(a,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(e,t,n,r){this.skuToken=t,this.errorCb=r,o.SESSION_PATH&&o.API_URL&&(n||o.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(ve)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||this.getSession(n,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}},Fe=Be.getSessionAPI.bind(Be),je=new Set,Ue={create:"create",load:"load",fullLoad:"fullLoad"},Ne={mark(e){n.performance.mark(e)},measure(e,t,r){n.performance.measure(e,t,r)}};function Ve(e){const t=e.name.split("?")[0];return we(t)&&t.includes("mapbox-gl.js")?"javascript":we(t)&&t.includes("mapbox-gl.css")?"css":function(e){return o.API_FONTS_REGEX.test(e)}(t)?"fontRange":Te(t)?"sprite":Ee(t)?"style":function(e){return o.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}const Ge=n.performance;function qe(e){const t=e?e.url.toString():void 0;return Ge.getEntriesByName(t)}let $e,Ze,We,Xe;const He={now:()=>void 0!==We?We:n.performance.now(),setNow(e){We=e},restoreNow(){We=void 0},frame(e){const t=n.requestAnimationFrame(e);return{cancel:()=>n.cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:r,height:i}=e;Xe||(Xe=n.document.createElement("canvas"));const o=Xe.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return(r>Xe.width||i>Xe.height)&&(Xe.width=r,Xe.height=i),o.clearRect(-t,-t,r+2*t,i+2*t),o.drawImage(e,0,0,r,i),o.getImageData(-t,-t,r+2*t,i+2*t)},resolveURL:e=>($e||($e=n.document.createElement("a")),$e.href=e,$e.href),get devicePixelRatio(){return n.devicePixelRatio},get prefersReducedMotion(){return!!n.matchMedia&&(null==Ze&&(Ze=n.matchMedia("(prefers-reduced-motion: reduce)")),Ze.matches)}};function Ye(e,t,n){n[e]&&-1!==n[e].indexOf(t)||(n[e]=n[e]||[],n[e].push(t))}function Ke(e,t,n){if(n&&n[e]){const r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}class Je{constructor(e,t={}){z(this,t),this.type=e}}class Qe extends Je{constructor(e,t={}){super("error",z({error:e},t))}}class et{on(e,t){return this._listeners=this._listeners||{},Ye(e,t,this._listeners),this}off(e,t){return Ke(e,t,this._listeners),Ke(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ye(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new Je(e,t||{}));const n=e.type;if(this.listens(n)){e.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const n of t)n.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of r)Ke(n,t,this._oneTimeListeners),t.call(this,e);const i=this._eventedParent;i&&(z(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof Qe&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var tt=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"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"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":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"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":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"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"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"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":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"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":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"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"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function nt(e,...t){for(const n of t)for(const t in n)e[t]=n[t];return e}function rt(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function it(e){if(Array.isArray(e))return e.map(it);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const n in e)t[n]=it(e[n]);return t}return rt(e)}class ot extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var at=ot;class st{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,n]of t)this.bindings[e]=n}concat(e){return new st(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(e+" not found in scope.")}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var lt=st;const ut={kind:"null"},ct={kind:"number"},ht={kind:"string"},dt={kind:"boolean"},ft={kind:"color"},pt={kind:"object"},mt={kind:"value"},gt={kind:"collator"},_t={kind:"formatted"},yt={kind:"resolvedImage"};function vt(e,t){return{kind:"array",itemType:e,N:t}}function xt(e){if("array"===e.kind){const t=xt(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const bt=[ut,ct,ht,dt,ft,_t,pt,vt(mt),yt];function wt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!wt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of bt)if(!wt(e,t))return null}return`Expected ${xt(e)} but found ${xt(t)} instead.`}function Et(e,t){return t.some(t=>t.kind===e.kind)}function Tt(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}var St,At={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 kt(e){return(e=Math.round(e))<0?0:e>255?255:e}function Mt(e){return kt("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function Ct(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function It(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}try{St={}.parseCSSColor=function(e){var t,n=e.replace(/ /g,"").toLowerCase();if(n in At)return At[n].slice();if("#"===n[0])return 4===n.length?(t=parseInt(n.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===n.length&&(t=parseInt(n.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=n.indexOf("("),i=n.indexOf(")");if(-1!==r&&i+1===n.length){var o=n.substr(0,r),a=n.substr(r+1,i-(r+1)).split(","),s=1;switch(o){case"rgba":if(4!==a.length)return null;s=Ct(a.pop());case"rgb":return 3!==a.length?null:[Mt(a[0]),Mt(a[1]),Mt(a[2]),s];case"hsla":if(4!==a.length)return null;s=Ct(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,u=Ct(a[1]),c=Ct(a[2]),h=c<=.5?c*(u+1):c+u-c*u,d=2*c-h;return[kt(255*It(d,h,l+1/3)),kt(255*It(d,h,l)),kt(255*It(d,h,l-1/3)),s];default:return null}}return null}}catch(e){}class Pt{constructor(e,t,n,r=1){this.r=e,this.g=t,this.b=n,this.a=r}static parse(e){if(!e)return;if(e instanceof Pt)return e;if("string"!=typeof e)return;const t=St(e);return t?new Pt(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,n,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(n)},${r})`}toArray(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*n/r,r]}toArray01(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,n/r,r]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:n,a:r}=this;return[e,t,n,r]}}Pt.black=new Pt(0,0,0,1),Pt.white=new Pt(1,1,1,1),Pt.transparent=new Pt(0,0,0,0),Pt.red=new Pt(1,0,0,1),Pt.blue=new Pt(0,0,1,1);var Ot=Pt;class zt{constructor(e,t,n){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Lt{constructor(e,t,n,r,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i}}class Dt{constructor(e){this.sections=e}static fromString(e){return new Dt([new Lt(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Dt?e:Dt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const n={};t.fontStack&&(n["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(n["font-scale"]=t.scale),t.textColor&&(n["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(n)}return e}}class Rt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Rt({name:e,available:!1}):null}serialize(){return["image",this.name]}}function Bt(e,t,n,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,n,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,n,r]:[e,t,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ft(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof Ot)return!0;if(e instanceof zt)return!0;if(e instanceof Dt)return!0;if(e instanceof Rt)return!0;if(Array.isArray(e)){for(const t of e)if(!Ft(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Ft(e[t]))return!1;return!0}return!1}function jt(e){if(null===e)return ut;if("string"==typeof e)return ht;if("boolean"==typeof e)return dt;if("number"==typeof e)return ct;if(e instanceof Ot)return ft;if(e instanceof zt)return gt;if(e instanceof Dt)return _t;if(e instanceof Rt)return yt;if(Array.isArray(e)){const t=e.length;let n;for(const t of e){const e=jt(t);if(n){if(n===e)continue;n=mt;break}n=e}return vt(n||mt,t)}return pt}function Ut(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ot||e instanceof Dt||e instanceof Rt?e.toString():JSON.stringify(e)}class Nt{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ft(e[1]))return t.error("invalid value");const n=e[1];let r=jt(n);const i=t.expectedType;return"array"!==r.kind||0!==r.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(r=i),new Nt(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Ot?["rgba"].concat(this.value.toArray()):this.value instanceof Dt?this.value.serialize():this.value}}var Vt=Nt,Gt=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const qt={string:ht,number:ct,boolean:dt,object:pt};class $t{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let n,r=1;const i=e[0];if("array"===i){let i,o;if(e.length>2){const n=e[1];if("string"!=typeof n||!(n in qt)||"object"===n)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=qt[n],r++}else i=mt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}n=vt(i,o)}else n=qt[i];const o=[];for(;re.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const n=e.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){t.push(n.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map(e=>e.serialize()))}}var Zt=$t;class Wt{constructor(e){this.type=_t,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&"object"==typeof n)return t.error("First argument must be an image or text section.");const r=[];let i=!1;for(let n=1;n<=e.length-1;++n){const o=e[n];if(i&&"object"==typeof o&&!Array.isArray(o)){i=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,ct),!e))return null;let n=null;if(o["text-font"]&&(n=t.parse(o["text-font"],1,vt(ht)),!n))return null;let a=null;if(o["text-color"]&&(a=t.parse(o["text-color"],1,ft),!a))return null;const s=r[r.length-1];s.scale=e,s.font=n,s.textColor=a}else{const o=t.parse(e[n],1,mt);if(!o)return null;const a=o.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new Wt(r)}evaluate(e){return new Dt(this.sections.map(t=>{const n=t.content.evaluate(e);return jt(n)===yt?new Lt("",n,null,null,null):new Lt(Ut(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const n={};t.scale&&(n["font-scale"]=t.scale.serialize()),t.font&&(n["text-font"]=t.font.serialize()),t.textColor&&(n["text-color"]=t.textColor.serialize()),e.push(n)}return e}}class Xt{constructor(e){this.type=yt,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,ht);return n?new Xt(n):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),n=Rt.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Ht={"to-boolean":dt,"to-color":ft,"to-number":ct,"to-string":ht};class Yt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[0];if(("to-boolean"===n||"to-string"===n)&&2!==e.length)return t.error("Expected one argument.");const r=Ht[n],i=[];for(let n=1;n4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Bt(t[0],t[1],t[2],t[3]),!n))return new Ot(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Gt(n||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const n of this.args){if(t=n.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new Gt(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Dt.fromString(Ut(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?Rt.fromString(Ut(this.args[0].evaluate(e))):Ut(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Wt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Xt(this.args[0]).serialize();const e=["to-"+this.type.kind];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Kt=Yt;const Jt=["Unknown","Point","LineString","Polygon"];var Qt=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&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Jt[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 e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:n,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Ot.parse(e)),t}};class en{constructor(e,t,n,r){this.name=e,this.type=t,this._evaluate=n,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const n=e[0],r=en.definitions[n];if(!r)return t.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let s=null;for(const[r,o]of a){s=new Mn(t.registry,t.path,null,t.scope);const a=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(xt).join(", ")})`:`(${xt(t.type)}...)`;var t}).join(" | "),r=[];for(let n=1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function sn(e,t){const n=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=Math.pow(2,t.z);return[Math.round(n*i*rn),Math.round(r*i*rn)]}function ln(e,t,n){const r=e[0]-t[0],i=e[1]-t[1],o=e[0]-n[0],a=e[1]-n[1];return r*a-o*i==0&&r*o<=0&&i*a<=0}function un(e,t){let n=!1;for(let a=0,s=t.length;a(r=e)[1]!=(o=s[t+1])[1]>r[1]&&r[0]<(o[0]-i[0])*(r[1]-i[1])/(o[1]-i[1])+i[0]&&(n=!n)}}var r,i,o;return n}function cn(e,t){for(let n=0;n0&&s<0||a<0&&s>0}function dn(e,t,n){for(const u of n)for(let n=0;nn[2]){const t=.5*r;let i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;0===i&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}on(t,e)}function yn(e,t,n,r){const i=Math.pow(2,r.z)*rn,o=[r.x*rn,r.y*rn],a=[];if(!e)return a;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];_n(r,t,n,i),a.push(r)}return a}function vn(e,t,n,r){const i=Math.pow(2,r.z)*rn,o=[r.x*rn,r.y*rn],a=[];if(!e)return a;for(const n of e){const e=[];for(const r of n){const n=[r.x+o[0],r.y+o[1]];on(t,n),e.push(n)}a.push(e)}if(t[2]-t[0]<=i/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const e of a)for(const r of e)_n(r,t,n,i)}var s;return a}class xn{constructor(e,t){this.type=dt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ft(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e{t&&!wn(e)&&(t=!1)}),t}function En(e){if(e instanceof tn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!En(e)&&(t=!1)}),t}function Tn(e,t){if(e instanceof tn&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild(e=>{n&&!Tn(e,t)&&(n=!1)}),n}class Sn{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const n=e[1];return t.scope.has(n)?new Sn(n,t.scope.get(n)):t.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var An=Sn;class kn{constructor(e,t=[],n,r=new lt,i=[]){this.registry=e,this.path=t,this.key=t.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=i,this.expectedType=n}parse(e,t,n,r,i={}){return t?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return"assert"===n?new Zt(t,[e]):"coerce"===n?new Kt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=e[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 i=this.registry[r];if(i){let r=i.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,i=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==i.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==i.kind&&"string"!==i.kind){if(this.checkSubtype(e,i))return null}else r=n(r,e,t.typeAnnotation||"coerce");else r=n(r,e,t.typeAnnotation||"assert")}if(!(r instanceof Vt)&&"resolvedImage"!==r.type.kind&&function e(t){if(t instanceof An)return e(t.boundExpression);if(t instanceof tn&&"error"===t.name)return!1;if(t instanceof nn)return!1;if(t instanceof bn)return!1;const n=t instanceof Kt||t instanceof Zt;let r=!0;return t.eachChild(t=>{r=n?r&&e(t):r&&t instanceof Vt}),!!r&&wn(t)&&Tn(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}(r)){const t=new Qt;try{r=new Vt(r.type,r.evaluate(t))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,n){const r="number"==typeof e?this.path.concat(e):this.path,i=n?this.scope.concat(n):this.scope;return new kn(this.registry,r,t||null,i,this.errors)}error(e,...t){const n=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new at(n,e))}checkSubtype(e,t){const n=wt(e,t);return n&&this.error(n),n}}var Mn=kn;function Cn(e,t){const n=e.length-1;let r,i,o=0,a=n,s=0;for(;o<=a;)if(s=Math.floor((o+a)/2),r=e[s],i=e[s+1],r<=t){if(s===n||tt))throw new Gt("Input is not a number.");a=s-1}return 0}class In{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const n=t.parse(e[1],1,ct);if(!n)return null;const r=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let n=1;n=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const u=t.parse(a,l,i);if(!u)return null;i=i||u.type,r.push([o,u])}return new In(i,n,r)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[Cn(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var Pn=In;function On(e,t,n){return e*(1-n)+t*n}var zn=Object.freeze({__proto__:null,array:function(e,t,n){return e.map((e,r)=>On(e,t[r],n))},color:function(e,t,n){return new Ot(On(e.r,t.r,n),On(e.g,t.g,n),On(e.b,t.b,n),On(e.a,t.a,n))},number:On});const Ln=6/29,Dn=3*Ln*Ln,Rn=Math.PI/180,Bn=180/Math.PI;function Fn(e){return e>.008856451679035631?Math.pow(e,1/3):e/Dn+4/29}function jn(e){return e>Ln?e*e*e:Dn*(e-4/29)}function Un(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Nn(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Vn(e){const t=Nn(e.r),n=Nn(e.g),r=Nn(e.b),i=Fn((.4124564*t+.3575761*n+.1804375*r)/.95047),o=Fn((.2126729*t+.7151522*n+.072175*r)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-Fn((.0193339*t+.119192*n+.9503041*r)/1.08883)),alpha:e.a}}function Gn(e){let t=(e.l+16)/116,n=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*jn(t),n=.95047*jn(n),r=1.08883*jn(r),new Ot(Un(3.2404542*n-1.5371385*t-.4985314*r),Un(-.969266*n+1.8760108*t+.041556*r),Un(.0556434*n-.2040259*t+1.0572252*r),e.alpha)}function qn(e,t,n){const r=t-e;return e+n*(r>180||r<-180?r-360*Math.round(r/360):r)}const $n={forward:Vn,reverse:Gn,interpolate:function(e,t,n){return{l:On(e.l,t.l,n),a:On(e.a,t.a,n),b:On(e.b,t.b,n),alpha:On(e.alpha,t.alpha,n)}}},Zn={forward:function(e){const{l:t,a:n,b:r}=Vn(e),i=Math.atan2(r,n)*Bn;return{h:i<0?i+360:i,c:Math.sqrt(n*n+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Rn,n=e.c;return Gn({l:e.l,a:Math.cos(t)*n,b:Math.sin(t)*n,alpha:e.alpha})},interpolate:function(e,t,n){return{h:qn(e.h,t.h,n),c:On(e.c,t.c,n),l:On(e.l,t.l,n),alpha:On(e.alpha,t.alpha,n)}}};var Wn=Object.freeze({__proto__:null,hcl:Zn,lab:$n});class Xn{constructor(e,t,n,r,i){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let i=0;if("exponential"===e.name)i=Hn(t,e.base,n,r);else if("linear"===e.name)i=Hn(t,1,n,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;i=new g(o[0],o[1],o[2],o[3]).solve(Hn(t,1,n,r))}return i}static parse(e,t){let[n,r,i,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error("Unknown interpolation type "+String(r[0]),1,0);{const e=r.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,ct),!i)return null;const a=[];let s=null;"interpolate-hcl"===n||"interpolate-lab"===n?s=ft:t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);for(let e=0;e=n)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=t.parse(r,l,s);if(!u)return null;s=s||u.type,a.push([n,u])}return"number"===s.kind||"color"===s.kind||"array"===s.kind&&"number"===s.itemType.kind&&"number"==typeof s.N?new Xn(s,n,r,i,a):t.error(`Type ${xt(s)} is not interpolatable.`)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;if(r>=t[i-1])return n[i-1].evaluate(e);const o=Cn(t,r),a=Xn.interpolationFactor(this.interpolation,r,t[o],t[o+1]),s=n[o].evaluate(e),l=n[o+1].evaluate(e);return"interpolate"===this.operator?zn[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?Zn.reverse(Zn.interpolate(Zn.forward(s),Zn.forward(l),a)):$n.reverse($n.interpolate($n.forward(s),$n.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="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 t=[this.operator,e,this.input.serialize()];for(let e=0;ewt(r,e.type));return new Kn(o?mt:n,i)}evaluate(e){let t,n=null,r=0;for(const i of this.args){if(r++,n=i.evaluate(e),n&&n instanceof Rt&&!n.available&&(t||(t=n),n=null,r===this.args.length))return t;if(null!==n)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Jn=Kn;class Qn{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const n=[];for(let r=1;r=n.length)throw new Gt(`Array index out of bounds: ${t} > ${n.length-1}.`);if(t!==Math.floor(t))throw new Gt(`Array index must be an integer, but found ${t} instead.`);return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var nr=tr;class rr{constructor(e,t){this.type=dt,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,mt),r=t.parse(e[2],2,mt);return n&&r?Et(n.type,[dt,ht,ct,ut,mt])?new rr(n,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${xt(n.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(null==n)return!1;if(!Tt(t,["boolean","string","number","null"]))throw new Gt(`Expected first argument to be of type boolean, string, number or null, but found ${xt(jt(t))} instead.`);if(!Tt(n,["string","array"]))throw new Gt(`Expected second argument to be of type array or string, but found ${xt(jt(n))} instead.`);return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var ir=rr;class or{constructor(e,t,n){this.type=ct,this.needle=e,this.haystack=t,this.fromIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,mt),r=t.parse(e[2],2,mt);if(!n||!r)return null;if(!Et(n.type,[dt,ht,ct,ut,mt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${xt(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,ct);return i?new or(n,r,i):null}return new or(n,r)}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!Tt(t,["boolean","string","number","null"]))throw new Gt(`Expected first argument to be of type boolean, string, number or null, but found ${xt(jt(t))} instead.`);if(!Tt(n,["string","array"]))throw new Gt(`Expected second argument to be of type array or string, but found ${xt(jt(n))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return n.indexOf(t,r)}return n.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var ar=or;class sr{constructor(e,t,n,r,i,o){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let n,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const i={},o=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,jt(e)))return null}else n=jt(e);if(void 0!==i[String(e)])return u.error("Branch labels must be unique.");i[String(e)]=o.length}const c=t.parse(l,a,r);if(!c)return null;r=r||c.type,o.push(c)}const a=t.parse(e[1],1,mt);if(!a)return null;const s=t.parse(e[e.length-1],e.length-1,r);return s?"value"!==a.type.kind&&t.concat(1).checkSubtype(n,a.type)?null:new sr(n,r,a,i,o,s):null}evaluate(e){const t=this.input.evaluate(e);return(jt(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),n=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=n.length,n.push([this.cases[e],[e]])):n[t][1].push(e)}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of n)e.push(1===r.length?i(r[0]):r.map(i)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var lr=sr;class ur{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r=[];for(let i=1;it.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var cr=ur;class hr{constructor(e,t,n,r){this.type=e,this.input=t,this.beginIndex=n,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,mt),r=t.parse(e[2],2,ct);if(!n||!r)return null;if(!Et(n.type,[vt(mt),ht,mt]))return t.error(`Expected first argument to be of type array or string, but found ${xt(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,ct);return i?new hr(n.type,n,r,i):null}return new hr(n.type,n,r)}evaluate(e){const t=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!Tt(t,["string","array"]))throw new Gt(`Expected first argument to be of type array or string, but found ${xt(jt(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(n,r)}return t.slice(n)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var dr=hr;function fr(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function pr(e,t,n,r){return 0===r.compare(t,n)}function mr(e,t,n){const r="=="!==e&&"!="!==e;return class i{constructor(e,t,n){this.type=dt,this.lhs=e,this.rhs=t,this.collator=n,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const n=e[0];let o=t.parse(e[1],1,mt);if(!o)return null;if(!fr(n,o.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${xt(o.type)}'.`);let a=t.parse(e[2],2,mt);if(!a)return null;if(!fr(n,a.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${xt(a.type)}'.`);if(o.type.kind!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${xt(o.type)}' and '${xt(a.type)}'.`);r&&("value"===o.type.kind&&"value"!==a.type.kind?o=new Zt(a.type,[o]):"value"!==o.type.kind&&"value"===a.type.kind&&(a=new Zt(o.type,[a])));let s=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,gt),!s)return null}return new i(o,a,s)}evaluate(i){const o=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const t=jt(o),n=jt(a);if(t.kind!==n.kind||"string"!==t.kind&&"number"!==t.kind)throw new Gt(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=jt(o),n=jt(a);if("string"!==e.kind||"string"!==n.kind)return t(i,o,a)}return this.collator?n(i,o,a,this.collator.evaluate(i)):t(i,o,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize())}),t}}}const gr=mr("==",(function(e,t,n){return t===n}),pr),_r=mr("!=",(function(e,t,n){return t!==n}),(function(e,t,n,r){return!pr(0,t,n,r)})),yr=mr("<",(function(e,t,n){return t",(function(e,t,n){return t>n}),(function(e,t,n,r){return r.compare(t,n)>0})),xr=mr("<=",(function(e,t,n){return t<=n}),(function(e,t,n,r){return r.compare(t,n)<=0})),br=mr(">=",(function(e,t,n){return t>=n}),(function(e,t,n,r){return r.compare(t,n)>=0}));class wr{constructor(e,t,n,r,i,o){this.type=ht,this.number=e,this.locale=t,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,ct);if(!n)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let i=null;if(r.locale&&(i=t.parse(r.locale,1,ht),!i))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,ht),!o))return null;let a=null;if(r.unit&&(a=t.parse(r.unit,1,ht),!a))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,ct),!s))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,ct),!l)?null:new wr(n,i,o,a,s,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Er{constructor(e){this.type=ct,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const n=t.parse(e[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?t.error(`Expected argument of type string or array, but found ${xt(n.type)} instead.`):new Er(n):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Gt(`Expected value to be of type string or array, but found ${xt(jt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}const Tr={"==":gr,"!=":_r,">":vr,"<":yr,">=":br,"<=":xr,array:Zt,at:nr,boolean:Zt,case:cr,coalesce:Jn,collator:nn,format:Wt,image:Xt,in:ir,"index-of":ar,interpolate:Yn,"interpolate-hcl":Yn,"interpolate-lab":Yn,length:Er,let:er,literal:Vt,match:lr,number:Zt,"number-format":wr,object:Zt,slice:dr,step:Pn,string:Zt,"to-boolean":Kt,"to-color":Kt,"to-number":Kt,"to-string":Kt,var:An,within:bn};function Sr(e,[t,n,r,i]){t=t.evaluate(e),n=n.evaluate(e),r=r.evaluate(e);const o=i?i.evaluate(e):1,a=Bt(t,n,r,o);if(a)throw new Gt(a);return new Ot(t/255*o,n/255*o,r/255*o,o)}function Ar(e,t){return e in t}function kr(e,t){const n=t[e];return void 0===n?null:n}function Mr(e){return{type:e}}tn.register(Tr,{error:[{kind:"error"},[ht],(e,[t])=>{throw new Gt(t.evaluate(e))}],typeof:[ht,[mt],(e,[t])=>xt(jt(t.evaluate(e)))],"to-rgba":[vt(ct,4),[ft],(e,[t])=>t.evaluate(e).toArray()],rgb:[ft,[ct,ct,ct],Sr],rgba:[ft,[ct,ct,ct,ct],Sr],has:{type:dt,overloads:[[[ht],(e,[t])=>Ar(t.evaluate(e),e.properties())],[[ht,pt],(e,[t,n])=>Ar(t.evaluate(e),n.evaluate(e))]]},get:{type:mt,overloads:[[[ht],(e,[t])=>kr(t.evaluate(e),e.properties())],[[ht,pt],(e,[t,n])=>kr(t.evaluate(e),n.evaluate(e))]]},"feature-state":[mt,[ht],(e,[t])=>kr(t.evaluate(e),e.featureState||{})],properties:[pt,[],e=>e.properties()],"geometry-type":[ht,[],e=>e.geometryType()],id:[mt,[],e=>e.id()],zoom:[ct,[],e=>e.globals.zoom],pitch:[ct,[],e=>e.globals.pitch||0],"distance-from-center":[ct,[],e=>e.distanceFromCenter()],"heatmap-density":[ct,[],e=>e.globals.heatmapDensity||0],"line-progress":[ct,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[ct,[],e=>e.globals.skyRadialProgress||0],accumulated:[mt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ct,Mr(ct),(e,t)=>{let n=0;for(const r of t)n+=r.evaluate(e);return n}],"*":[ct,Mr(ct),(e,t)=>{let n=1;for(const r of t)n*=r.evaluate(e);return n}],"-":{type:ct,overloads:[[[ct,ct],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[ct],(e,[t])=>-t.evaluate(e)]]},"/":[ct,[ct,ct],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[ct,[ct,ct],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[ct,[],()=>Math.LN2],pi:[ct,[],()=>Math.PI],e:[ct,[],()=>Math.E],"^":[ct,[ct,ct],(e,[t,n])=>Math.pow(t.evaluate(e),n.evaluate(e))],sqrt:[ct,[ct],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ct,[ct],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ct,[ct],(e,[t])=>Math.log(t.evaluate(e))],log2:[ct,[ct],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ct,[ct],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ct,[ct],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ct,[ct],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ct,[ct],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ct,[ct],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ct,[ct],(e,[t])=>Math.atan(t.evaluate(e))],min:[ct,Mr(ct),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ct,Mr(ct),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ct,[ct],(e,[t])=>Math.abs(t.evaluate(e))],round:[ct,[ct],(e,[t])=>{const n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[ct,[ct],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ct,[ct],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[dt,[ht,mt],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[dt,[mt],(e,[t])=>e.id()===t.value],"filter-type-==":[dt,[ht],(e,[t])=>e.geometryType()===t.value],"filter-<":[dt,[ht,mt],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r{const n=e.id(),r=t.value;return typeof n==typeof r&&n":[dt,[ht,mt],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[dt,[mt],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[dt,[ht,mt],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[dt,[mt],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[dt,[ht,mt],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[dt,[mt],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[dt,[mt],(e,[t])=>t.value in e.properties()],"filter-has-id":[dt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[dt,[vt(ht)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[dt,[vt(mt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[dt,[ht,vt(mt)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[dt,[ht,vt(mt)],(e,[t,n])=>function(e,t,n,r){for(;n<=r;){const i=n+r>>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}(e.properties()[t.value],n.value,0,n.value.length-1)],all:{type:dt,overloads:[[[dt,dt],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[Mr(dt),(e,t)=>{for(const n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:dt,overloads:[[[dt,dt],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[Mr(dt),(e,t)=>{for(const n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[dt,[dt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[dt,[ht],(e,[t])=>{const n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[ht,[ht],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[ht,[ht],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[ht,Mr(mt),(e,t)=>t.map(t=>Ut(t.evaluate(e))).join("")],"resolved-locale":[ht,[gt],(e,[t])=>t.evaluate(e).resolvedLocale()]});var Cr=Tr;function Ir(e){return{result:"success",value:e}}function Pr(e){return{result:"error",value:e}}function Or(e){return"data-driven"===e["property-type"]}function zr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Lr(e){return!!e.expression&&e.expression.interpolated}function Dr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Rr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Br(e){return e}function Fr(e,t,n){return void 0!==e?e:void 0!==t?t:void 0!==n?n:void 0}function jr(e,t,n,r,i){return Fr(typeof n===i?r[n]:void 0,e.default,t.default)}function Ur(e,t,n){if("number"!==Dr(n))return Fr(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];const i=Cn(e.stops.map(e=>e[0]),n);return e.stops[i][1]}function Nr(e,t,n){const r=void 0!==e.base?e.base:1;if("number"!==Dr(n))return Fr(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];const o=Cn(e.stops.map(e=>e[0]),n),a=function(e,t,n,r){const i=r-n,o=e-n;return 0===i?0:1===t?o/i:(Math.pow(t,o)-1)/(Math.pow(t,i)-1)}(n,r,e.stops[o][0],e.stops[o+1][0]),s=e.stops[o][1],l=e.stops[o+1][1];let u=zn[t.type]||Br;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Wn[e.colorSpace];u=(e,n)=>t.reverse(t.interpolate(t.forward(e),t.forward(n),a))}return"function"==typeof s.evaluate?{evaluate(...e){const t=s.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==n)return u(t,n,a)}}:u(s,l,a)}function Vr(e,t,n){return"color"===t.type?n=Ot.parse(n):"formatted"===t.type?n=Dt.fromString(n.toString()):"resolvedImage"===t.type?n=Rt.fromString(n.toString()):Dr(n)===t.type||"enum"===t.type&&t.values[n]||(n=void 0),Fr(n,e.default,t.default)}class Gr{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new Qt,this._defaultValue=t?function(e){return"color"===e.type&&(Rr(e.default)||Array.isArray(e.default))?new Ot(0,0,0,0):"color"===e.type?Ot.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,n,r,i,o,a,s){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=n,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,n,r,i,o,a,s){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Gt(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function qr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Cr}function $r(e,t){const n=new Mn(Cr,[],t?function(e){const t={color:ft,string:ht,number:ct,enum:ht,boolean:dt,formatted:_t,resolvedImage:yt};return"array"===e.type?vt(t[e.value]||mt,e.length):t[e.type]}(t):void 0),r=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?Ir(new Gr(r,t)):Pr(n.errors)}class Zr{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!En(t.expression)}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}}class Wr{constructor(e,t,n,r){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent="camera"!==e&&!En(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}interpolationFactor(e,t,n){return this.interpolationType?Yn.interpolationFactor(this.interpolationType,e,t,n):0}}function Xr(e,t){if("error"===(e=$r(e,t)).result)return e;const n=e.value.expression,r=wn(n);if(!r&&!Or(t))return Pr([new at("","data expressions not supported")]);const i=Tn(n,["zoom","pitch","distance-from-center"]);if(!i&&!zr(t))return Pr([new at("","zoom expressions not supported")]);const o=function e(t){let n=null;if(t instanceof er)n=e(t.result);else if(t instanceof Jn){for(const r of t.args)if(n=e(r),n)break}else(t instanceof Pn||t instanceof Yn)&&t.input instanceof tn&&"zoom"===t.input.name&&(n=t);return n instanceof at||t.eachChild(t=>{const r=e(t);r instanceof at?n=r:!n&&r?n=new at("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&r&&n!==r&&(n=new at("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),n}(n);return o||i?o instanceof at?Pr([o]):o instanceof Yn&&!Lr(t)?Pr([new at("",'"interpolate" expressions cannot be used with this property')]):Ir(o?new Wr(r?"camera":"composite",e.value,o.labels,o instanceof Yn?o.interpolation:void 0):new Zr(r?"constant":"source",e.value)):Pr([new at("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Hr{constructor(e,t){this._parameters=e,this._specification=t,nt(this,function e(t,n){const r="color"===n.type,i=t.stops&&"object"==typeof t.stops[0][0],o=i||!(i||void 0!==t.property),a=t.type||(Lr(n)?"exponential":"interval");if(r&&((t=nt({},t)).stops&&(t.stops=t.stops.map(e=>[e[0],Ot.parse(e[1])])),t.default=Ot.parse(t.default?t.default:n.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Wn[t.colorSpace])throw new Error("Unknown color space: "+t.colorSpace);let s,l,u;if("exponential"===a)s=Nr;else if("interval"===a)s=Ur;else if("categorical"===a){s=jr,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0]}else{if("identity"!==a)throw new Error(`Unknown function type "${a}"`);s=Vr}if(i){const r={},i=[];for(let e=0;ee[0]),evaluate:({zoom:e},r)=>Nr({stops:o,base:t.base},n,e).evaluate(e,r)}}if(o){const e="exponential"===a?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:e,interpolationFactor:Yn.interpolationFactor.bind(void 0,e),zoomStops:t.stops.map(e=>e[0]),evaluate:({zoom:e})=>s(t,n,e,l,u)}}return{kind:"source",evaluate(e,r){const i=r&&r.properties?r.properties[t.property]:void 0;return void 0===i?Fr(t.default,n.default):s(t,n,i,l,u)}}}(this._parameters,this._specification))}static deserialize(e){return new Hr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}class Yr{constructor(e,t,n,r){this.message=(e?e+": ":"")+n,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function Kr(e){const t=e.key,n=e.value,r=e.valueSpec||{},i=e.objectElementValidators||{},o=e.style,a=e.styleSpec;let s=[];const l=Dr(n);if("object"!==l)return[new Yr(t,n,`object expected, ${l} found`)];for(const e in n){const l=e.split(".")[0];let u;i[l]?u=i[l]:r[l]?u=ki:i["*"]?u=i["*"]:r["*"]&&(u=ki),u?s=s.concat(u({key:(t?t+".":t)+e,value:n[e],valueSpec:r[l]||r["*"],style:o,styleSpec:a,object:n,objectKey:e},n)):s.push(new Yr(t,n[e],`unknown property "${e}"`))}for(const e in r)i[e]||r[e].required&&void 0===r[e].default&&void 0===n[e]&&s.push(new Yr(t,n,`missing required property "${e}"`));return s}function Jr(e){const t=e.value,n=e.valueSpec,r=e.style,i=e.styleSpec,o=e.key,a=e.arrayElementValidator||ki;if("array"!==Dr(t))return[new Yr(o,t,`array expected, ${Dr(t)} found`)];if(n.length&&t.length!==n.length)return[new Yr(o,t,`array length ${n.length} expected, length ${t.length} found`)];if(n["min-length"]&&t.lengthi)return[new Yr(t,n,`${n} is greater than the maximum value ${i}`)]}return[]}function ei(e){const t=e.valueSpec,n=rt(e.value.type);let r,i,o,a={};const s="categorical"!==n&&void 0===e.value.property,l=!s,u="array"===Dr(e.value.stops)&&"array"===Dr(e.value.stops[0])&&"object"===Dr(e.value.stops[0][0]),c=Kr({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return[new Yr(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Jr({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Dr(r)&&0===r.length&&t.push(new Yr(e.key,r,"array must have at least one stop")),t},default:function(e){return ki({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===n&&s&&c.push(new Yr(e.key,e.value,'missing required property "property"')),"identity"===n||e.value.stops||c.push(new Yr(e.key,e.value,'missing required property "stops"')),"exponential"===n&&e.valueSpec.expression&&!Lr(e.valueSpec)&&c.push(new Yr(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Or(e.valueSpec)?c.push(new Yr(e.key,e.value,"property functions not supported")):s&&!zr(e.valueSpec)&&c.push(new Yr(e.key,e.value,"zoom functions not supported"))),"categorical"!==n&&!u||void 0!==e.value.property||c.push(new Yr(e.key,e.value,'"property" property is required')),c;function h(e){let n=[];const r=e.value,s=e.key;if("array"!==Dr(r))return[new Yr(s,r,`array expected, ${Dr(r)} found`)];if(2!==r.length)return[new Yr(s,r,`array length 2 expected, length ${r.length} found`)];if(u){if("object"!==Dr(r[0]))return[new Yr(s,r,`object expected, ${Dr(r[0])} found`)];if(void 0===r[0].zoom)return[new Yr(s,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new Yr(s,r,"object stop key must have value")];const t=rt(r[0].zoom);if("number"!=typeof t)return[new Yr(s,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new Yr(s,r[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,i=void 0,a={}),n=n.concat(Kr({key:s+"[0]",value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Qr,value:d}}))}else n=n.concat(d({key:s+"[0]",value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return qr(it(r[1]))?n.concat([new Yr(s+"[1]",r[1],"expressions are not allowed in function stops.")]):n.concat(ki({key:s+"[1]",value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const s=Dr(e.value),l=rt(e.value),u=null!==e.value?e.value:o;if(r){if(s!==r)return[new Yr(e.key,u,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if("number"!==s&&"string"!==s&&"boolean"!==s&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new Yr(e.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==n){let r=`number expected, ${s} found`;return Or(t)&&void 0===n&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Yr(e.key,u,r)]}return"categorical"!==n||"number"!==s||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===s&&"number"==typeof l&&"number"==typeof i&&void 0!==i&&lnew Yr(`${e.key}${t.key}`,e.value,t.message));const n=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!n.outputDefined())return[new Yr(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!En(n))return[new Yr(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return function e(t,n){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(n.valueSpec&&n.valueSpec.expression)for(const e of n.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const i=[];return t instanceof tn&&r.has(t.name)?[new Yr(n.key,n.value,`["${t.name}"] expression is not supported in a filter for a ${n.object.type} layer with id: ${n.object.id}`)]:(t.eachChild(t=>{i.push(...e(t,n))}),i)}(n,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Tn(n,["zoom","feature-state"]))return[new Yr(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!wn(n))return[new Yr(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ni(e){const t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?-1===r.values.indexOf(rt(n))&&i.push(new Yr(t,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(rt(n))&&i.push(new Yr(t,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),i}function ri(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!ri(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function ii(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};ri(e)||(e=ui(e));const n=e;let r=!0;try{r=function(e){if(!oi(e))return e;let t=it(e);return function e(t){let n=!1;const r=[];if("case"===t[0]){for(let e=1;ee(t))}(t),t}(n)}catch(e){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(n,null,2)}\n `)}const i=tt["filter_"+t],o=$r(r,i);let a=null;if("error"===o.result)throw new Error(o.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=(e,t,n)=>o.value.evaluate(e,t,{},n);let s=null,l=null;if(r!==n){const e=$r(n,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));s=(t,n,r,i,o)=>e.value.evaluate(t,n,{},r,void 0,void 0,i,o),l=!wn(e.value.expression)}return{filter:a,dynamicFilter:s||void 0,needGeometry:li(r),needFeature:!!l}}function oi(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t",">=","<","<=","to-boolean"]);function si(e,t){return et?1:0}function li(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?ci(e[1],e[2],t):"any"===t?(n=e.slice(1),["any"].concat(n.map(ui))):"all"===t?["all"].concat(e.slice(1).map(ui)):"none"===t?["all"].concat(e.slice(1).map(ui).map(fi)):"in"===t?hi(e[1],e.slice(2)):"!in"===t?fi(hi(e[1],e.slice(2))):"has"===t?di(e[1]):"!has"===t?fi(di(e[1])):"within"!==t||e;var n}function ci(e,t,n){switch(e){case"$type":return["filter-type-"+n,t];case"$id":return["filter-id-"+n,t];default:return["filter-"+n,e,t]}}function hi(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(si)]]:["filter-in-small",e,["literal",t]]}}function di(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function fi(e){return["!",e]}function pi(e){return ri(it(e.value))?ti(nt({},e,{expressionContext:"filter",valueSpec:e.styleSpec["filter_"+(e.layerType||"fill")]})):function e(t){const n=t.value,r=t.key;if("array"!==Dr(n))return[new Yr(r,n,`array expected, ${Dr(n)} found`)];const i=t.styleSpec;let o,a=[];if(n.length<1)return[new Yr(r,n,"filter array must have at least 1 element")];switch(a=a.concat(ni({key:r+"[0]",value:n[0],valueSpec:i.filter_operator,style:t.style,styleSpec:t.styleSpec})),rt(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===rt(n[1])&&a.push(new Yr(r,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":3!==n.length&&a.push(new Yr(r,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&(o=Dr(n[1]),"string"!==o&&a.push(new Yr(r+"[1]",n[1],`string expected, ${o} found`)));for(let e=2;e{e in n&&t.push(new Yr(r,n[e],`"${e}" is prohibited for ref layers`))}),i.layers.forEach(t=>{rt(t.id)===s&&(e=t)}),e?e.ref?t.push(new Yr(r,n.ref,"ref cannot reference another ref layer")):a=rt(e.type):"string"==typeof s&&t.push(new Yr(r,n.ref,`ref layer "${s}" not found`))}else if("background"!==a&&"sky"!==a)if(n.source){const e=i.sources&&i.sources[n.source],o=e&&rt(e.type);e?"vector"===o&&"raster"===a?t.push(new Yr(r,n.source,`layer "${n.id}" requires a raster source`)):"raster"===o&&"raster"!==a?t.push(new Yr(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==o||n["source-layer"]?"raster-dem"===o&&"hillshade"!==a?t.push(new Yr(r,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!n.paint||!n.paint["line-gradient"]&&!n.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new Yr(r,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Yr(r,n,`layer "${n.id}" must specify a "source-layer"`)):t.push(new Yr(r,n.source,`source "${n.source}" not found`))}else t.push(new Yr(r,n,'missing required property "source"'));return t=t.concat(Kr({key:r,value:n,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ki({key:r+".type",value:n.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:n,objectKey:"type"}),filter:e=>pi(nt({layerType:a},e)),layout:e=>Kr({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>_i(nt({layerType:a},e))}}),paint:e=>Kr({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>gi(nt({layerType:a},e))}})}})),t}function vi(e){const t=e.value,n=e.key,r=Dr(t);return"string"!==r?[new Yr(n,t,`string expected, ${r} found`)]:[]}const xi={promoteId:function({key:e,value:t}){if("string"===Dr(t))return vi({key:e,value:t});{const n=[];for(const r in t)n.push(...vi({key:`${e}.${r}`,value:t[r]}));return n}}};function bi(e){const t=e.value,n=e.key,r=e.styleSpec,i=e.style;if(!t.type)return[new Yr(n,t,'"type" is required')];const o=rt(t.type);let a;switch(o){case"vector":case"raster":case"raster-dem":return a=Kr({key:n,value:t,valueSpec:r["source_"+o.replace("-","_")],style:e.style,styleSpec:r,objectElementValidators:xi}),a;case"geojson":if(a=Kr({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,objectElementValidators:xi}),t.cluster)for(const e in t.clusterProperties){const[r,i]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...ti({key:`${n}.${e}.map`,value:i,expressionContext:"cluster-map"})),a.push(...ti({key:`${n}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Kr({key:n,value:t,valueSpec:r.source_video,style:i,styleSpec:r});case"image":return Kr({key:n,value:t,valueSpec:r.source_image,style:i,styleSpec:r});case"canvas":return[new Yr(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ni({key:n+".type",value:t.type,valueSpec:{values:wi(r)},style:i,styleSpec:r})}}function wi(e){return e.source.reduce((t,n)=>{const r=e[n];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values))),t},[])}function Ei(e){const t=e.value,n=e.styleSpec,r=n.light,i=e.style;let o=[];const a=Dr(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new Yr("light",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?ki({key:e,value:t[e],valueSpec:n.transition,style:i,styleSpec:n}):r[e]?ki({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}):[new Yr(e,t[e],`unknown property "${e}"`)])}return o}function Ti(e){const t=e.value,n=e.key,r=e.style,i=e.styleSpec,o=i.terrain;let a=[];const s=Dr(t);if(void 0===t)return a;if("object"!==s)return a=a.concat([new Yr("terrain",t,`object expected, ${s} found`)]),a;for(const e in t){const n=e.match(/^(.*)-transition$/);a=a.concat(n&&o[n[1]]&&o[n[1]].transition?ki({key:e,value:t[e],valueSpec:i.transition,style:r,styleSpec:i}):o[e]?ki({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:i}):[new Yr(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=r.sources&&r.sources[t.source],i=e&&rt(e.type);e?"raster-dem"!==i&&a.push(new Yr(n,t.source,`terrain cannot be used with a source of type ${String(i)}, it only be used with a "raster-dem" source type`)):a.push(new Yr(n,t.source,`source "${t.source}" not found`))}else a.push(new Yr(n,t,'terrain is missing required property "source"'));return a}function Si(e){const t=e.value,n=e.style,r=e.styleSpec,i=r.fog;let o=[];const a=Dr(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new Yr("fog",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&i[a[1]]&&i[a[1]].transition?ki({key:e,value:t[e],valueSpec:r.transition,style:n,styleSpec:r}):i[e]?ki({key:e,value:t[e],valueSpec:i[e],style:n,styleSpec:r}):[new Yr(e,t[e],`unknown property "${e}"`)])}return o}const Ai={"*":()=>[],array:Jr,boolean:function(e){const t=e.value,n=e.key,r=Dr(t);return"boolean"!==r?[new Yr(n,t,`boolean expected, ${r} found`)]:[]},number:Qr,color:function(e){const t=e.key,n=e.value,r=Dr(n);return"string"!==r?[new Yr(t,n,`color expected, ${r} found`)]:null===St(n)?[new Yr(t,n,`color expected, "${n}" found`)]:[]},enum:ni,filter:pi,function:ei,layer:yi,object:Kr,source:bi,light:Ei,terrain:Ti,fog:Si,string:vi,formatted:function(e){return 0===vi(e).length?[]:ti(e)},resolvedImage:function(e){return 0===vi(e).length?[]:ti(e)},projection:function(e){const t=e.value,n=e.styleSpec,r=n.projection,i=e.style;let o=[];const a=Dr(t);if("object"===a)for(const e in t)o=o.concat(ki({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}));else"string"!==a&&(o=o.concat([new Yr("projection",t,`object or string expected, ${a} found`)]));return o}};function ki(e){const t=e.value,n=e.valueSpec,r=e.styleSpec;return n.expression&&Rr(rt(t))?ei(e):n.expression&&qr(it(t))?ti(e):n.type&&Ai[n.type]?Ai[n.type](e):Kr(nt({},e,{valueSpec:n.type?r[n.type]:n}))}function Mi(e){const t=e.value,n=e.key,r=vi(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new Yr(n,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new Yr(n,t,'"glyphs" url must include a "{range}" token'))),r}function Ci(e,t=tt){return Oi(ki({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:Mi,"*":()=>[]}}))}const Ii=e=>Oi(gi(e)),Pi=e=>Oi(_i(e));function Oi(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function zi(e,t){let n=!1;if(t&&t.length)for(const r of t)e.fire(new Qe(new Error(r.message))),n=!0;return n}var Li=Di;function Di(e,t,n){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(n=i[2]);for(var o=0;o=c[f+0]&&r>=c[f+1])?(a[d]=!0,o.push(u[d])):a[d]=!1}}},Di.prototype._forEachCell=function(e,t,n,r,i,o,a,s){for(var l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(n),h=this._convertToCellCoord(r),d=l;d<=c;d++)for(var f=u;f<=h;f++){var p=this.d*f+d;if((!s||s(this._convertFromCellCoord(d),this._convertFromCellCoord(f),this._convertFromCellCoord(d+1),this._convertFromCellCoord(f+1)))&&i.call(this,e,t,n,r,p,o,a,s))return}},Di.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},Di.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},Di.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,n=0,r=0;r=0||(i[n]=Ni(e[n],t)));e instanceof Error&&(i.message=e.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(i.$name=r),i}throw new Error("can't serialize object of type "+typeof e)}function Vi(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||ji(e)||Ui(e)||ArrayBuffer.isView(e)||e instanceof n.ImageData)return e;if(Array.isArray(e))return e.map(Vi);if("object"==typeof e){const t=e.$name||"Object",{klass:n}=Bi[t];if(!n)throw new Error("can't deserialize unregistered class "+t);if(n.deserialize)return n.deserialize(e);const r=Object.create(n.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=Vi(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const Gi=e=>e>=128&&e<=255,qi=e=>e>=1536&&e<=1791,$i=e=>e>=1872&&e<=1919,Zi=e=>e>=2208&&e<=2303,Wi=e=>e>=4352&&e<=4607,Xi=e=>e>=5120&&e<=5759,Hi=e=>e>=6016&&e<=6143,Yi=e=>e>=6320&&e<=6399,Ki=e=>e>=8192&&e<=8303,Ji=e=>e>=8448&&e<=8527,Qi=e=>e>=8528&&e<=8591,eo=e=>e>=8960&&e<=9215,to=e=>e>=9216&&e<=9279,no=e=>e>=9280&&e<=9311,ro=e=>e>=9312&&e<=9471,io=e=>e>=9632&&e<=9727,oo=e=>e>=9728&&e<=9983,ao=e=>e>=11008&&e<=11263,so=e=>e>=11904&&e<=12031,lo=e=>e>=12032&&e<=12255,uo=e=>e>=12272&&e<=12287,co=e=>e>=12288&&e<=12351,ho=e=>e>=12352&&e<=12447,fo=e=>e>=12448&&e<=12543,po=e=>e>=12544&&e<=12591,mo=e=>e>=12592&&e<=12687,go=e=>e>=12688&&e<=12703,_o=e=>e>=12704&&e<=12735,yo=e=>e>=12736&&e<=12783,vo=e=>e>=12784&&e<=12799,xo=e=>e>=12800&&e<=13055,bo=e=>e>=13056&&e<=13311,wo=e=>e>=13312&&e<=19903,Eo=e=>e>=19904&&e<=19967,To=e=>e>=19968&&e<=40959,So=e=>e>=40960&&e<=42127,Ao=e=>e>=42128&&e<=42191,ko=e=>e>=43360&&e<=43391,Mo=e=>e>=44032&&e<=55215,Co=e=>e>=55216&&e<=55295,Io=e=>e>=57344&&e<=63743,Po=e=>e>=63744&&e<=64255,Oo=e=>e>=64336&&e<=65023,zo=e=>e>=65040&&e<=65055,Lo=e=>e>=65072&&e<=65103,Do=e=>e>=65104&&e<=65135,Ro=e=>e>=65136&&e<=65279,Bo=e=>e>=65280&&e<=65519;function Fo(e){for(const t of e)if(No(t.charCodeAt(0)))return!0;return!1}function jo(e){for(const t of e)if(!Uo(t.charCodeAt(0)))return!1;return!0}function Uo(e){return!(qi(e)||$i(e)||Zi(e)||Oo(e)||Ro(e))}function No(e){return!(746!==e&&747!==e&&(e<4352||!(_o(e)||po(e)||Lo(e)&&!(e>=65097&&e<=65103)||Po(e)||bo(e)||so(e)||yo(e)||!(!co(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||wo(e)||To(e)||xo(e)||mo(e)||ko(e)||Co(e)||Wi(e)||Mo(e)||ho(e)||uo(e)||go(e)||lo(e)||vo(e)||fo(e)&&12540!==e||!(!Bo(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!Do(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||Xi(e)||Yi(e)||zo(e)||Eo(e)||So(e)||Ao(e))))}function Vo(e){return!(No(e)||function(e){return!!(Gi(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||Ki(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||Ji(e)||Qi(e)||eo(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||to(e)&&9251!==e||no(e)||ro(e)||io(e)||oo(e)&&!(e>=9754&&e<=9759)||ao(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||co(e)||fo(e)||Io(e)||Lo(e)||Do(e)||Bo(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function Go(e){return e>=1424&&e<=2303||Oo(e)||Ro(e)}function qo(e,t){return!(!t&&Go(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||Hi(e))}function $o(e){for(const t of e)if(Go(t.charCodeAt(0)))return!0;return!1}const Zo="deferred",Wo="loading",Xo="loaded";let Ho=null,Yo="unavailable",Ko=null;const Jo=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Yo="error"),Ho&&Ho(e)};function Qo(){ea.fire(new Je("pluginStateChange",{pluginStatus:Yo,pluginURL:Ko}))}const ea=new et,ta=function(){return Yo},na=function(){if(Yo!==Zo||!Ko)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Yo=Wo,Qo(),Ko&&fe({url:Ko},e=>{e?Jo(e):(Yo=Xo,Qo())})},ra={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Yo===Xo||null!=ra.applyArabicShaping,isLoading:()=>Yo===Wo,setState(e){Yo=e.pluginStatus,Ko=e.pluginURL},isParsed:()=>null!=ra.applyArabicShaping&&null!=ra.processBidirectionalText&&null!=ra.processStyledBidirectionalText,getPluginURL:()=>Ko};class ia{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const n of e)if(!qo(n.charCodeAt(0),t))return!1;return!0}(e,ra.isLoaded())}}class oa{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(Rr(e))return new Hr(e,t);if(qr(e)){const n=Xr(e,t);if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));return n.value}{let n=e;return"string"==typeof e&&"color"===t.type&&(n=Ot.parse(e)),{kind:"constant",evaluate:()=>n}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class aa{constructor(e){this.property=e,this.value=new oa(e,void 0)}transitioned(e,t){return new la(this.property,this.value,t,z({},e.transition,this.transition),e.now)}untransitioned(){return new la(this.property,this.value,null,{},0)}}class sa{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return G(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new aa(this._values[e].property)),this._values[e].value=new oa(this._values[e].property,null===t?void 0:G(t))}getTransition(e){return G(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new aa(this._values[e].property)),this._values[e].transition=G(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const n=this.getValue(t);void 0!==n&&(e[t]=n);const r=this.getTransition(t);void 0!==r&&(e[t+"-transition"]=r)}return e}transitioned(e,t){const n=new ua(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){const e=new ua(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class la{constructor(e,t,n,r,i){const o=r.delay||0,a=r.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+o,this.end=this.begin+a,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){const r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),o=this.prior;if(o){if(r>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(rthis.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_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 ba(e,t=1){let n=0,r=0;return{members:e.map(e=>{const i=ya[e.type].BYTES_PER_ELEMENT,o=n=wa(n,Math.max(t,i)),a=e.components||1;return r=Math.max(r,i),n+=i*a,{name:e.name,type:e.type,components:a,offset:o}}),size:wa(n,Math.max(r,t)),alignment:t}}function wa(e,t){return Math.ceil(e/t)*t}class Ea extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=n,e}}Ea.prototype.bytesPerElement=4,Fi(Ea,"StructArrayLayout2i4");class Ta extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}}Ta.prototype.bytesPerElement=6,Fi(Ta,"StructArrayLayout3i6");class Sa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=n,this.int16[o+2]=r,this.int16[o+3]=i,e}}Sa.prototype.bytesPerElement=8,Fi(Sa,"StructArrayLayout4i8");class Aa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.uint8[u+4]=r,this.uint8[u+5]=i,this.uint8[u+6]=o,this.uint8[u+7]=a,this.float32[c+2]=s,e}}Aa.prototype.bytesPerElement=12,Fi(Aa,"StructArrayLayout2i4ub1f12");class ka extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.float32[o+3]=i,e}}ka.prototype.bytesPerElement=16,Fi(ka,"StructArrayLayout4f16");class Ma extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=6*e,s=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=n,this.uint16[a+2]=r,this.uint16[a+3]=i,this.float32[s+2]=o,e}}Ma.prototype.bytesPerElement=12,Fi(Ma,"StructArrayLayout4ui1f12");class Ca extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=n,this.uint16[o+2]=r,this.uint16[o+3]=i,e}}Ca.prototype.bytesPerElement=8,Fi(Ca,"StructArrayLayout4ui8");class Ia extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,e}}Ia.prototype.bytesPerElement=12,Fi(Ia,"StructArrayLayout6i12");class Pa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,n,r,i,o,a,s,l,u,c,h)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=12*e;return this.int16[f+0]=t,this.int16[f+1]=n,this.int16[f+2]=r,this.int16[f+3]=i,this.uint16[f+4]=o,this.uint16[f+5]=a,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=d,e}}Pa.prototype.bytesPerElement=24,Fi(Pa,"StructArrayLayout4i4ui4i24");class Oa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.float32[l+2]=i,this.float32[l+3]=o,this.float32[l+4]=a,e}}Oa.prototype.bytesPerElement=20,Fi(Oa,"StructArrayLayout3i3f20");class za extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}za.prototype.bytesPerElement=4,Fi(za,"StructArrayLayout1ul4");class La extends xa{_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(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,n,r,i,o,a,s,l,u,c,h,d)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f){const p=20*e,m=10*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=r,this.int16[p+3]=i,this.int16[p+4]=o,this.float32[m+3]=a,this.float32[m+4]=s,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[p+14]=c,this.uint32[m+8]=h,this.uint16[p+18]=d,this.uint16[p+19]=f,e}}La.prototype.bytesPerElement=40,Fi(La,"StructArrayLayout5i4f1i1ul2ui40");class Da extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.int16[l+2]=r,this.int16[l+4]=i,this.int16[l+5]=o,this.int16[l+6]=a,this.int16[l+7]=s,e}}Da.prototype.bytesPerElement=16,Fi(Da,"StructArrayLayout3i2i2i16");class Ra extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=4*e,s=8*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.int16[s+6]=i,this.int16[s+7]=o,e}}Ra.prototype.bytesPerElement=16,Fi(Ra,"StructArrayLayout2f1f2i16");class Ba extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=12*e,a=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=n,this.float32[a+1]=r,this.float32[a+2]=i,e}}Ba.prototype.bytesPerElement=12,Fi(Ba,"StructArrayLayout2ub2f12");class Fa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}Fa.prototype.bytesPerElement=12,Fi(Fa,"StructArrayLayout3f12");class ja extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}}ja.prototype.bytesPerElement=6,Fi(ja,"StructArrayLayout3ui6");class Ua extends xa{_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(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_,y,v,x)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_,y,v,x,b){const w=30*e,E=15*e,T=60*e;return this.int16[w+0]=t,this.int16[w+1]=n,this.int16[w+2]=r,this.float32[E+2]=i,this.float32[E+3]=o,this.uint16[w+8]=a,this.uint16[w+9]=s,this.uint32[E+5]=l,this.uint32[E+6]=u,this.uint32[E+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=f,this.float32[E+10]=p,this.float32[E+11]=m,this.uint8[T+48]=g,this.uint8[T+49]=_,this.uint8[T+50]=y,this.uint32[E+13]=v,this.int16[w+28]=x,this.uint8[T+58]=b,e}}Ua.prototype.bytesPerElement=60,Fi(Ua,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Na extends xa{_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(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_,y,v,x,b,w,E,T,S,A,k,M,C){const I=this.length;return this.resize(I+1),this.emplace(I,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_,y,v,x,b,w,E,T,S,A,k,M,C)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_,y,v,x,b,w,E,T,S,A,k,M,C,I){const P=38*e,O=19*e;return this.int16[P+0]=t,this.int16[P+1]=n,this.int16[P+2]=r,this.float32[O+2]=i,this.float32[O+3]=o,this.int16[P+8]=a,this.int16[P+9]=s,this.int16[P+10]=l,this.int16[P+11]=u,this.int16[P+12]=c,this.int16[P+13]=h,this.uint16[P+14]=d,this.uint16[P+15]=f,this.uint16[P+16]=p,this.uint16[P+17]=m,this.uint16[P+18]=g,this.uint16[P+19]=_,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]=E,this.uint16[P+26]=T,this.uint16[P+27]=S,this.uint16[P+28]=A,this.uint32[O+15]=k,this.float32[O+16]=M,this.float32[O+17]=C,this.float32[O+18]=I,e}}Na.prototype.bytesPerElement=76,Fi(Na,"StructArrayLayout3i2f6i15ui1ul3f76");class Va extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Va.prototype.bytesPerElement=4,Fi(Va,"StructArrayLayout1f4");class Ga extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,this.float32[a+4]=o,e}}Ga.prototype.bytesPerElement=20,Fi(Ga,"StructArrayLayout5f20");class qa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=n,this.uint16[o+3]=r,this.uint16[o+4]=i,e}}qa.prototype.bytesPerElement=12,Fi(qa,"StructArrayLayout1ul3ui12");class $a extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}}$a.prototype.bytesPerElement=4,Fi($a,"StructArrayLayout2ui4");class Za extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}Za.prototype.bytesPerElement=2,Fi(Za,"StructArrayLayout1ui2");class Wa extends xa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=n,e}}Wa.prototype.bytesPerElement=8,Fi(Wa,"StructArrayLayout2f8");class Xa extends va{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]}}Xa.prototype.size=40;class Ha extends La{get(e){return new Xa(this,e)}}Fi(Ha,"CollisionBoxArray");class Ya extends va{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(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}Ya.prototype.size=60;class Ka extends Ua{get(e){return new Ya(this,e)}}Fi(Ka,"PlacedSymbolArray");class Ja extends va{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(e){this._structArray.uint32[this._pos4+15]=e}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]}}Ja.prototype.size=76;class Qa extends Na{get(e){return new Ja(this,e)}}Fi(Qa,"SymbolInstanceArray");class es extends Va{getoffsetX(e){return this.float32[1*e+0]}}Fi(es,"GlyphOffsetArray");class ts extends Ea{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Fi(ts,"SymbolLineVertexArray");class ns extends va{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]}}ns.prototype.size=12;class rs extends qa{get(e){return new ns(this,e)}}Fi(rs,"FeatureIndexArray");class is extends $a{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Fi(is,"FillExtrusionCentroidArray");const os=ba([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),as=ba([{name:"a_dash",components:4,type:"Uint16"}]);var ss={exports:{}},ls={exports:{}};ls.exports=function(e,t){var n,r,i,o,a,s,l,u;for(r=e.length-(n=3&e.length),i=t,a=3432918353,s=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};var us=ls.exports,cs={exports:{}};cs.exports=function(e,t){for(var n,r=e.length,i=t^r,o=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:i^=(255&e.charCodeAt(o+2))<<16;case 2:i^=(255&e.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var hs=us,ds=cs.exports;ss.exports=hs,ss.exports.murmur3=hs,ss.exports.murmur2=ds;var fs=f(ss.exports);class ps{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(ms(e)),this.positions.push(t,n,r)}getPositions(e){const t=ms(e);let n=0,r=this.ids.length-1;for(;n>1;this.ids[e]>=t?r=e:n=e+1}const i=[];for(;this.ids[n]===t;)i.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return i}static serialize(e,t){const n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return function e(t,n,r,i){for(;r>1];let a=r-1,s=i+1;for(;;){do{a++}while(t[a]o);if(a>=s)break;gs(t,a,s),gs(n,3*a,3*s),gs(n,3*a+1,3*s+1),gs(n,3*a+2,3*s+2)}s-r"u_"+e),this.type=n}setUniform(e,t,n,r,i){t.set(e,i,r.constantOr(this.value))}getBinding(e,t){return"color"===this.type?new xs(e):new ys(e)}}class As{constructor(e,t){this.uniformNames=t.map(e=>"u_"+e),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,t,n,r,i){const o="u_pattern"===i||"u_dash"===i?this.pattern:"u_pixel_ratio"===i?this.pixelRatio:null;o&&t.set(e,i,o)}getBinding(e,t){return"u_pattern"===t||"u_dash"===t?new vs(e):new ys(e)}}class ks{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:"a_"+e,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,n,r,i,o){const a=this.paintVertexArray.length,s=this.expression.evaluate(new ia(0),t,{},i,r,o);this.paintVertexArray.resize(e),this._setPaintValue(a,e,s)}updatePaintArray(e,t,n,r,i){const o=this.expression.evaluate({zoom:0},n,r,void 0,i);this._setPaintValue(e,t,o)}_setPaintValue(e,t,n){if("color"===this.type){const r=Ts(n);for(let n=e;n`u_${e}_t`),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:"a_"+e,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,t,n,r,i,o){const a=this.expression.evaluate(new ia(this.zoom),t,{},i,r,o),s=this.expression.evaluate(new ia(this.zoom+1),t,{},i,r,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,a,s)}updatePaintArray(e,t,n,r,i){const o=this.expression.evaluate({zoom:this.zoom},n,r,void 0,i),a=this.expression.evaluate({zoom:this.zoom+1},n,r,void 0,i);this._setPaintValue(e,t,o,a)}_setPaintValue(e,t,n,r){if("color"===this.type){const i=Ts(n),o=Ts(r);for(let n=e;n!0)){this.binders={},this._buffers=[];const r=[];for(const i in e.paint._values){if(!n(i))continue;const o=e.paint.get(i);if(!(o instanceof ha&&Or(o.property.specification)))continue;const a=zs(i,e.type),s=o.value,l=o.property.specification.type,u=!!o.property.useIntegerZoom,c="line-dasharray"===i||i.endsWith("pattern"),h="line-dasharray"===i&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==s.kind||h)if("source"===s.kind||h||c){const t=Rs(i,l,"source");this.binders[i]=c?new Cs(s,a,l,t,e.id):new ks(s,a,l,t),r.push("/a_"+i)}else{const e=Rs(i,l,"composite");this.binders[i]=new Ms(s,a,l,u,t,e),r.push("/z_"+i)}else this.binders[i]=c?new As(s.value,a):new Ss(s.value,a,l),r.push("/u_"+i)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof ks||t instanceof Ms?t.maxValue:0}populatePaintArrays(e,t,n,r,i,o){for(const a in this.binders){const s=this.binders[a];(s instanceof ks||s instanceof Ms||s instanceof Cs)&&s.populatePaintArray(e,t,n,r,i,o)}}setConstantPatternPositions(e){for(const t in this.binders){const n=this.binders[t];n instanceof As&&n.setConstantPatternPositions(e)}}updatePaintArrays(e,t,n,r,i,o){let a=!1;for(const s in e){const l=t.getPositions(s);for(const t of l){const l=n.feature(t.index);for(const n in this.binders){const u=this.binders[n];if((u instanceof ks||u instanceof Ms||u instanceof Cs)&&!0===u.expression.isStateDependent){const c=r.paint.get(n);u.expression=c.value,u.updatePaintArray(t.start,t.end,l,e[s],i,o),a=!0}}}}return a}defines(){const e=[];for(const t in this.binders){const n=this.binders[t];(n instanceof Ss||n instanceof As)&&e.push(...n.uniformNames.map(e=>"#define HAS_UNIFORM_"+e))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const n=this.binders[t];if(n instanceof ks||n instanceof Ms||n instanceof Cs)for(let t=0;t!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Is(r,t,n);this.needsUpload=!1,this._featureMap=new ps,this._bufferOffset=0}populatePaintArrays(e,t,n,r,i,o,a){for(const n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r,i,o,a);void 0!==t.id&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r,i){for(const o of n)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,r,i)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const Os={"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","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function zs(e,t){return Os[e]||[e.replace(t+"-","").replace(/-/g,"_")]}const Ls={"line-pattern":{source:Ma,composite:Ma},"fill-pattern":{source:Ma,composite:Ma},"fill-extrusion-pattern":{source:Ma,composite:Ma},"line-dasharray":{source:Ca,composite:Ca}},Ds={color:{source:Wa,composite:ka},number:{source:Va,composite:Wa}};function Rs(e,t,n){const r=Ls[e];return r&&r[n]||Ds[t][n]}Fi(Ss,"ConstantBinder"),Fi(As,"PatternConstantBinder"),Fi(ks,"SourceExpressionBinder"),Fi(Cs,"PatternCompositeBinder"),Fi(Ms,"CompositeExpressionBinder"),Fi(Is,"ProgramConfiguration",{omit:["_buffers"]}),Fi(Ps,"ProgramConfigurationSet");const Bs="-transition";class Fs extends et{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new ca(t.layout)),t.paint)){this._transitionablePaint=new sa(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new da(t.paint)}}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,n={}){null!=t&&this._validate(Pi,`layers.${this.id}.layout.${e}`,e,t,n)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return U(e,Bs)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,n={}){if(null!=t&&this._validate(Ii,`layers.${this.id}.paint.${e}`,e,t,n))return!1;if(U(e,Bs))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const n=this._transitionablePaint._values[e],r=n.value.isDataDriven(),i=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const o=this._transitionablePaint._values[e].value,a=o.isDataDriven(),s=U(e,"pattern")||"line-dasharray"===e;return a||r||s||this._handleOverridablePaintPropertyUpdate(e,i,o)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,n){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),V(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,n,r,i={}){return(!i||!1!==i.validate)&&zi(this,e.call(Ci,{key:t,layerType:this.type,objectKey:n,value:r,styleSpec:tt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof ha&&Or(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=ii(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const js=ba([{name:"a_pos",components:2,type:"Int16"}],4),Us=ba([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Ns{constructor(e=[]){this.segments=e}prepareSegment(e,t,n,r){let i=this.segments[this.segments.length-1];return e>Ns.MAX_VERTEX_ARRAY_LENGTH&&$(`Max vertices per segment is ${Ns.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!i||i.vertexLength+e>Ns.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r)&&(i={vertexOffset:t.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==r&&(i.sortKey=r),this.segments.push(i)),i}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,n,r){return new Ns([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}Ns.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Fi(Ns,"SegmentVector");var Vs=8192;class Gs{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof yu?new yu(e.lng,e.lat):yu.convert(e),this}setSouthWest(e){return this._sw=e instanceof yu?new yu(e.lng,e.lat):yu.convert(e),this}extend(e){const t=this._sw,n=this._ne;let r,i;if(e instanceof yu)r=e,i=e;else{if(!(e instanceof Gs))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Gs.convert(e)):this.extend(yu.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(yu.convert(e)):this;if(r=e._sw,i=e._ne,!r||!i)return this}return t||n?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),n.lng=Math.max(i.lng,n.lng),n.lat=Math.max(i.lat,n.lat)):(this._sw=new yu(r.lng,r.lat),this._ne=new yu(i.lng,i.lat)),this}getCenter(){return new yu((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 yu(this.getWest(),this.getNorth())}getSouthEast(){return new yu(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(e){const{lng:t,lat:n}=yu.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}static convert(e){return!e||e instanceof Gs?e:new Gs(e)}}var qs=1e-6,$s="undefined"!=typeof Float32Array?Float32Array:Array;function Zs(){var e=new $s(9);return $s!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Ws(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=n[0],f=n[1],p=n[2],m=n[3],g=n[4],_=n[5],y=n[6],v=n[7],x=n[8];return e[0]=d*r+f*a+p*u,e[1]=d*i+f*s+p*c,e[2]=d*o+f*l+p*h,e[3]=m*r+g*a+_*u,e[4]=m*i+g*s+_*c,e[5]=m*o+g*l+_*h,e[6]=y*r+v*a+x*u,e[7]=y*i+v*s+x*c,e[8]=y*o+v*l+x*h,e}function Xs(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Hs(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],g=t[14],_=t[15],y=n*s-r*a,v=n*l-i*a,x=n*u-o*a,b=r*l-i*s,w=r*u-o*s,E=i*u-o*l,T=c*m-h*p,S=c*g-d*p,A=c*_-f*p,k=h*g-d*m,M=h*_-f*m,C=d*_-f*g,I=y*C-v*M+x*k+b*A-w*S+E*T;return I?(e[0]=(s*C-l*M+u*k)*(I=1/I),e[1]=(i*M-r*C-o*k)*I,e[2]=(m*E-g*w+_*b)*I,e[3]=(d*w-h*E-f*b)*I,e[4]=(l*A-a*C-u*S)*I,e[5]=(n*C-i*A+o*S)*I,e[6]=(g*x-p*E-_*v)*I,e[7]=(c*E-d*x+f*v)*I,e[8]=(a*M-s*A+u*T)*I,e[9]=(r*A-n*M-o*T)*I,e[10]=(p*w-m*x+_*y)*I,e[11]=(h*x-c*w-f*y)*I,e[12]=(s*S-a*k-l*T)*I,e[13]=(n*k-r*S+i*T)*I,e[14]=(m*v-p*b-g*y)*I,e[15]=(c*b-h*v+d*y)*I,e):null}function Ys(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],m=t[12],g=t[13],_=t[14],y=t[15],v=n[0],x=n[1],b=n[2],w=n[3];return e[0]=v*r+x*s+b*h+w*m,e[1]=v*i+x*l+b*d+w*g,e[2]=v*o+x*u+b*f+w*_,e[3]=v*a+x*c+b*p+w*y,e[4]=(v=n[4])*r+(x=n[5])*s+(b=n[6])*h+(w=n[7])*m,e[5]=v*i+x*l+b*d+w*g,e[6]=v*o+x*u+b*f+w*_,e[7]=v*a+x*c+b*p+w*y,e[8]=(v=n[8])*r+(x=n[9])*s+(b=n[10])*h+(w=n[11])*m,e[9]=v*i+x*l+b*d+w*g,e[10]=v*o+x*u+b*f+w*_,e[11]=v*a+x*c+b*p+w*y,e[12]=(v=n[12])*r+(x=n[13])*s+(b=n[14])*h+(w=n[15])*m,e[13]=v*i+x*l+b*d+w*g,e[14]=v*o+x*u+b*f+w*_,e[15]=v*a+x*c+b*p+w*y,e}function Ks(e,t,n){var r,i,o,a,s,l,u,c,h,d,f,p,m=n[0],g=n[1],_=n[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],h=t[8],d=t[9],f=t[10],p=t[11],e[0]=r=t[0],e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=h,e[9]=d,e[10]=f,e[11]=p,e[12]=r*m+s*g+h*_+t[12],e[13]=i*m+l*g+d*_+t[13],e[14]=o*m+u*g+f*_+t[14],e[15]=a*m+c*g+p*_+t[15]),e}function Js(e,t,n){var r=n[0],i=n[1],o=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Qs(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*i+u*r,e[5]=a*i+c*r,e[6]=s*i+h*r,e[7]=l*i+d*r,e[8]=u*i-o*r,e[9]=c*i-a*r,e[10]=h*i-s*r,e[11]=d*i-l*r,e}function el(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[8],c=t[9],h=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i-u*r,e[1]=a*i-c*r,e[2]=s*i-h*r,e[3]=l*i-d*r,e[8]=o*r+u*i,e[9]=a*r+c*i,e[10]=s*r+h*i,e[11]=l*r+d*i,e}function tl(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function nl(e,t,n){var r,i,o,a=n[0],s=n[1],l=n[2],u=Math.hypot(a,s,l);return u0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function gl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function _l(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2];return e[0]=i*l-o*s,e[1]=o*a-r*l,e[2]=r*s-i*a,e}function yl(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/(a=a||1),e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,e}function vl(e,t,n){var r=n[0],i=n[1],o=n[2],a=t[0],s=t[1],l=t[2],u=i*l-o*s,c=o*a-r*l,h=r*s-i*a,d=i*h-o*c,f=o*u-r*h,p=r*c-i*u,m=2*n[3];return c*=m,h*=m,f*=2,p*=2,e[0]=a+(u*=m)+(d*=2),e[1]=s+c+f,e[2]=l+h+p,e}var xl,bl=ul,wl=cl,El=al;function Tl(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function Sl(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=r*a,e[2]=i*a,e[3]=o*a,e}function Al(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,e}function kl(){var e=new $s(4);return $s!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Ml(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Cl(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e}function Il(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e}il(),xl=new $s(4),$s!=Float32Array&&(xl[0]=0,xl[1]=0,xl[2]=0,xl[3]=0);var Pl=Sl;il(),sl(1,0,0),sl(0,1,0),kl(),kl(),Zs();const Ol=ba([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:zl}=Ol,Ll=ba([{name:"a_pos_3",components:3,type:"Int16"}]);var Dl=ba([{name:"a_pos",type:"Int16",components:2}]);class Rl{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,n){const r=gl(t,this.dir);if(Math.abs(r)<1e-6)return!1;const i=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return n[0]=this.pos[0]+this.dir[0]*i,n[1]=this.pos[1]+this.dir[1]*i,n[2]=this.pos[2]+this.dir[2]*i,!0}closestPointOnSphere(e,t,n){if(function(e,t){var n=e[0],r=e[1],i=e[2],o=t[0],a=t[1],s=t[2];return Math.abs(n-o)<=qs*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=qs*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=qs*Math.max(1,Math.abs(i),Math.abs(s))}(this.pos,e)||0===t)return n[0]=n[1]=n[2]=0,!1;const[r,i,o]=this.dir,a=this.pos[0]-e[0],s=this.pos[1]-e[1],l=this.pos[2]-e[2],u=r*r+i*i+o*o,c=2*(a*r+s*i+l*o),h=c*c-4*u*(a*a+s*s+l*l-t*t);if(h<0){const e=Math.max(-c/2,0),u=a+r*e,h=s+i*e,d=l+o*e,f=Math.hypot(u,h,d);return n[0]=u*t/f,n[1]=h*t/f,n[2]=d*t/f,!1}{const e=(-c-Math.sqrt(h))/(2*u);if(e<0){const e=Math.hypot(a,s,l);return n[0]=a*t/e,n[1]=s*t/e,n[2]=l*t/e,!1}return n[0]=a+r*e,n[1]=s+i*e,n[2]=l+o*e,!0}}}class Bl{constructor(e,t,n,r,i){this.TL=e,this.TR=t,this.BR=n,this.BL=r,this.horizon=i}static fromInvProjectionMatrix(e,t,n){const r=[-1,1,1],i=[1,1,1],o=[1,-1,1],a=[-1,-1,1],s=yl(r,r,e),l=yl(i,i,e),u=yl(o,o,e),c=yl(a,a,e);return new Bl(s,l,u,c,t/n)}}class Fl{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,n,r){const i=Math.pow(2,n),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(n=>{const o=Al([],n,e),a=1/o[3]/t*i;return function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}(o,o,[a,a,r?1/o[3]:a,a])}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=ml([],_l([],bl([],o[e[0]],o[e[1]]),bl([],o[e[2]],o[e[1]]))),n=-gl(t,o[e[1]]);return t.concat(n)});return new Fl(o,a)}}class jl{static fromPoints(e){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const r of e)hl(t,t,r),dl(n,n,r);return new jl(t,n)}static applyTransform(e,t){const n=e.getCorners();for(let e=0;e=0;if(0===o)return 0;o!==t.length&&(n=!1)}if(n)return 2;for(let t=0;t<3;t++){let n=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let i=0;ithis.max[t]-this.min[t])return 0}return 1}}const Ul=Vs/Math.PI/2,Nl=[64,32,16],Vl=-Ul,Gl=Ul,ql=[new jl([Vl,Vl,Vl],[Gl,Gl,Gl]),new jl([Vl,Vl,Vl],[0,0,Gl]),new jl([0,Vl,Vl],[Gl,0,Gl]),new jl([Vl,0,Vl],[0,Gl,Gl]),new jl([0,0,Vl],[Gl,Gl,Gl])];function $l(e){return e*Ul/mu}function Zl(e,t,n,r=!0){const i=fl([],e._camera.position,e.worldSize),o=[t,n,1,1];Al(o,o,e.pixelMatrixInverse),Tl(o,o,1/o[3]);const a=ml([],bl([],o,i)),s=e.globeMatrix,l=[s[12],s[13],s[14]],u=bl([],l,i),c=al(u),h=ml([],u),d=e.worldSize/(2*Math.PI),f=gl(h,a),p=Math.asin(d/c);if(p1?null:function(e,t,n,r){const i=Math.sin(n);return e*(Math.sin((1-r)*n)/i)+t*(Math.sin(r*n)/i)}(e.a[t],e.b[t],e.angle,M(n,0,1))+e.center[t]}function Hl(e){if(e.z<=1)return ql[e.z+2*e.y+e.x];const t=eu(Ql(e));return jl.fromPoints(t)}function Yl(e,t,n){return fl(e,e,1-n),pl(e,e,t,n)}function Kl(e,t){const n=uu(t.zoom);if(0===n)return Hl(e);const r=Ql(e),i=eu(r),o=xu(r.getWest())*t.worldSize,a=xu(r.getEast())*t.worldSize,s=bu(r.getNorth())*t.worldSize,l=bu(r.getSouth())*t.worldSize,u=[o,s,0],c=[a,s,0],h=[o,l,0],d=[a,l,0],f=Hs([],t.globeMatrix);return yl(u,u,f),yl(c,c,f),yl(h,h,f),yl(d,d,f),i[0]=Yl(i[0],h,n),i[1]=Yl(i[1],d,n),i[2]=Yl(i[2],c,n),i[3]=Yl(i[3],u,n),jl.fromPoints(i)}function Jl(e,t,n){for(const r of e)yl(r,r,t),fl(r,r,n)}function Ql({x:e,y:t,z:n}){const r=1/(1<Math.PI/2*1.01}const du=w(85),fu=Math.cos(du),pu=Math.sin(du),mu=6371008.8,gu=2*Math.PI*mu;class _u{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new _u(I(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return mu*Math.acos(Math.min(i,1))}toBounds(e=0){const t=360*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return new Gs(new _u(this.lng-n,this.lat-t),new _u(this.lng+n,this.lat+t))}toEcef(e){const t=$l(e);return nu(this.lat,this.lng,Ul+t)}static convert(e){if(e instanceof _u)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new _u(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new _u(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}var yu=_u;function vu(e){return gu*Math.cos(e*Math.PI/180)}function xu(e){return(180+e)/360}function bu(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function wu(e,t){return e/vu(t)}function Eu(e){return 360*e-180}function Tu(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Su(e,t){return e*vu(Tu(t))}const Au=85.051129;function ku(e){return 1/Math.cos(e*Math.PI/180)}class Mu{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e,t=0){const n=yu.convert(e);return new Mu(xu(n.lng),bu(n.lat),wu(t,n.lat))}toLngLat(){return new yu(Eu(this.x),Tu(this.y))}toAltitude(){return Su(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/gu*ku(Tu(this.y))}}function Cu(e,t,n,r,i,o,a,s,l){const u=(t+r)/2,c=(n+i)/2,h=new v(u,c);s(h),function(e,t,n,r,i,o){const a=n-i,s=r-o;return Math.abs((r-t)*a-(n-e)*s)/Math.hypot(a,s)}(h.x,h.y,o.x,o.y,a.x,a.y)>=l?(Cu(e,t,n,u,c,o,h,s,l),Cu(e,u,c,r,i,h,a,s,l)):e.push(a)}function Iu(e,t,n){let r=e[0],i=r.x,o=r.y;t(r);const a=[r];for(let s=1;se.x+1||re.y+1)&&$("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Ru(e,t,n){const r=e.loadGeometry(),i=e.extent,o=Vs/i;if(t&&n&&n.projection.isReprojectedInTileSpace){const o=1<{const n=Eu((t.x+e.x/i)/o),r=Tu((t.y+e.y/i)/o),c=u.project(n,r);e.x=(c.x*a-s)*i,e.y=(c.y*a-l)*i};for(let t=0;t=i||n.y<0||n.y>=i||(c(n),e.push(n));r[t]=e}}for(const e of r)for(const t of e)Du(t,o);return r}function Bu(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Ru(e):[]}}function Fu(e,t,n,r,i){e.emplaceBack(2*t+(r+1)/2,2*n+(i+1)/2)}function ju(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class Uu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Ea,this.indexArray=new ja,this.segments=new Ns,this.programConfigurations=new Ps(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){const i=this.layers[0],o=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:t,id:i,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Bu(t,e);if(!this.layers[0]._featureFilter.filter(new ia(this.zoom),u,n))continue;const c=a?a.evaluate(u,{},n):void 0,h={id:i,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?u.geometry:Ru(t,n,r),patterns:{},sortKey:c};o.push(h)}a&&o.sort((e,t)=>e.sortKey-t.sortKey);let s=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Ia,s=r.projection);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:a}=r,l=e[o].feature;this.addFeature(r,i,o,t.availableImages,n,s),t.featureIndex.insert(l,i,o,a,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,js.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Us.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,n,r,i,o){for(const n of t)for(const t of n){const n=t.x,r=t.y;if(n<0||n>=Vs||r<0||r>=Vs)continue;if(o){const e=o.projectTilePoint(n,r,i),t=o.upVector(i,n,r),a=this.globeExtVertexArray;ju(a,e,t),ju(a,e,t),ju(a,e,t),ju(a,e,t)}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;Fu(this.layoutVertexArray,n,r,-1,-1),Fu(this.layoutVertexArray,n,r,1,-1),Fu(this.layoutVertexArray,n,r,1,1),Fu(this.layoutVertexArray,n,r,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+2,s+3),a.vertexLength+=4,a.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},r,i)}}function Nu(e,t){for(let n=0;n1){if($u(e,t))return!0;for(let r=0;r1?n:n.sub(t)._mult(i)._add(t))}function Hu(e,t){let n,r,i,o=!1;for(let a=0;at.y!=i.y>t.y&&t.x<(i.x-r.x)*(t.y-r.y)/(i.y-r.y)+r.x&&(o=!o)}return o}function Yu(e,t){let n=!1;for(let r=0,i=e.length-1;rt.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}function Ku(e,t,n,r,i){for(const o of e)if(t<=o.x&&n<=o.y&&r>=o.x&&i>=o.y)return!0;const o=[new v(t,n),new v(t,i),new v(r,i),new v(r,n)];if(e.length>2)for(const t of o)if(Yu(e,t))return!0;for(let t=0;ti.x&&t.x>i.x||e.yi.y&&t.y>i.y)return!1;const o=Z(e,t,n[0]);return o!==Z(e,t,n[1])||o!==Z(e,t,n[2])||o!==Z(e,t,n[3])}function Qu(e,t,n){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function ec(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function tc(e,t,n,r,i){if(!t[0]&&!t[1])return e;const o=v.convert(t)._mult(i);"viewport"===n&&o._rotate(-r);const a=[];for(let t=0;t0){const e=n.projection.upVector(u,h.x,h.y);f.x+=e[0]*c*d,f.y+=e[1]*c*d,f.z+=e[2]*c*d}const p=o?h:ac(f.x,f.y,f.z,r),m=o?e.tilespaceRays.map(e=>uc(e,d)):e.queryGeometry.screenGeometry,g=Al([],[f.x,f.y,f.z,1],r);if(!a&&o?l*=g[3]/n.cameraToCenterDistance:a&&!o&&(l*=n.cameraToCenterDistance/g[3]),o){const e=Tu((t.y/Vs+u.y)/(1<e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=e.data,s=t.data;for(let l=0;l{t[e.evaluationKey]=o;const a=e.expression.evaluate(t);i.data[n+r+0]=Math.floor(255*a.r/a.a),i.data[n+r+1]=Math.floor(255*a.g/a.a),i.data[n+r+2]=Math.floor(255*a.b/a.a),i.data[n+r+3]=Math.floor(255*a.a)};if(e.clips)for(let t=0,i=0;t80*n){r=o=e[0],i=a=e[1];for(var p=n;po&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-r,a-i))?32767/u:0}return Sc(d,f,n,r,i,u,0),f}function Ec(e,t,n,r,i){var o,a;if(i===Wc(e,t,n,r)>0)for(o=t;o=t;o-=r)a=qc(o,e[o],e[o+1],a);return a&&Fc(a,a.next)&&($c(a),a=a.next),a}function Tc(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!Fc(r,r.next)&&0!==Bc(r.prev,r,r.next))r=r.next;else{if($c(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function Sc(e,t,n,r,i,o,a){if(e){!a&&o&&function(e,t,n,r){var i=e;do{0===i.z&&(i.z=zc(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,a,s,l,u=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?kc(e,r,i,o):Ac(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),$c(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?Sc(e=Mc(Tc(e),t,n),t,n,r,i,o,2):2===a&&Cc(e,t,n,r,i,o):Sc(Tc(e),t,n,r,i,o,1);break}}}function Ac(e){var t=e.prev,n=e,r=e.next;if(Bc(t,n,r)>=0)return!1;for(var i=t.x,o=n.x,a=r.x,s=t.y,l=n.y,u=r.y,c=io?i>a?i:a:o>a?o:a,f=s>l?s>u?s:u:l>u?l:u,p=r.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&Dc(i,s,o,l,a,u,p.x,p.y)&&Bc(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function kc(e,t,n,r){var i=e.prev,o=e,a=e.next;if(Bc(i,o,a)>=0)return!1;for(var s=i.x,l=o.x,u=a.x,c=i.y,h=o.y,d=a.y,f=sl?s>u?s:u:l>u?l:u,g=c>h?c>d?c:d:h>d?h:d,_=zc(f,p,t,n,r),y=zc(m,g,t,n,r),v=e.prevZ,x=e.nextZ;v&&v.z>=_&&x&&x.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Dc(s,c,l,h,u,d,v.x,v.y)&&Bc(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Dc(s,c,l,h,u,d,x.x,x.y)&&Bc(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=_;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=g&&v!==i&&v!==a&&Dc(s,c,l,h,u,d,v.x,v.y)&&Bc(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=g&&x!==i&&x!==a&&Dc(s,c,l,h,u,d,x.x,x.y)&&Bc(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Mc(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!Fc(i,o)&&jc(i,r,r.next,o)&&Vc(i,o)&&Vc(o,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),$c(r),$c(r.next),r=e=o),r=r.next}while(r!==e);return Tc(r)}function Cc(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Rc(a,s)){var l=Gc(a,s);return a=Tc(a,a.next),l=Tc(l,l.next),Sc(a,t,n,r,i,o,0),void Sc(l,t,n,r,i,o,0)}s=s.next}a=a.next}while(a!==e)}function Ic(e,t){return e.x-t.x}function Pc(e,t){var n=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a&&(a=s,n=r.x=r.x&&r.x>=c&&i!==r.x&&Dc(on.x||r.x===n.x&&Oc(n,r)))&&(n=r,d=l)),r=r.next}while(r!==u);return n}(e,t);if(!n)return t;var r=Gc(n,e);return Tc(r,r.next),Tc(n,n.next)}function Oc(e,t){return Bc(e.prev,e,t.prev)<0&&Bc(t.next,e,e.next)<0}function zc(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Lc(e){var t=e,n=e;do{(t.x=(e-a)*(o-s)&&(e-a)*(r-s)>=(n-a)*(t-s)&&(n-a)*(o-s)>=(i-a)*(r-s)}function Rc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&jc(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Vc(e,t)&&Vc(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Bc(e.prev,e,t.prev)||Bc(e,t.prev,t))||Fc(e,t)&&Bc(e.prev,e,e.next)>0&&Bc(t.prev,t,t.next)>0)}function Bc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Fc(e,t){return e.x===t.x&&e.y===t.y}function jc(e,t,n,r){var i=Nc(Bc(e,t,n)),o=Nc(Bc(e,t,r)),a=Nc(Bc(n,r,e)),s=Nc(Bc(n,r,t));return i!==o&&a!==s||!(0!==i||!Uc(e,n,t))||!(0!==o||!Uc(e,r,t))||!(0!==a||!Uc(n,e,r))||!(0!==s||!Uc(n,t,r))}function Uc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Nc(e){return e>0?1:e<0?-1:0}function Vc(e,t){return Bc(e.prev,e,e.next)<0?Bc(e,t,e.next)>=0&&Bc(e,e.prev,t)>=0:Bc(e,t,e.prev)<0||Bc(e,e.next,t)<0}function Gc(e,t){var n=new Zc(e.i,e.x,e.y),r=new Zc(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function qc(e,t,n,r){var i=new Zc(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function $c(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Zc(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Wc(e,t,n,r){for(var i=0,o=t,a=n-r;o0&&n.holes.push(r+=e[i-1].length)}return n};var Xc=f(bc.exports);function Hc(e,t,n,r,i){!function e(t,n,r,i,o){for(;i>r;){if(i-r>600){var a=i-r+1,s=n-r+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(s-a/2<0?-1:1);e(t,n,Math.max(r,Math.floor(n-s*u/a+c)),Math.min(i,Math.floor(n+(a-s)*u/a+c)),o)}var h=t[n],d=r,f=i;for(Yc(t,r,n),o(t[i],h)>0&&Yc(t,r,i);d0;)f--}0===o(t[r],h)?Yc(t,r,f):Yc(t,++f,i),f<=n&&(r=f+1),n<=f&&(i=f-1)}}(e,t,n||0,r||e.length-1,i||Kc)}function Yc(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Kc(e,t){return et?1:0}function Jc(e,t){const n=e.length;if(n<=1)return[e];const r=[];let i,o;for(let t=0;t1)for(let e=0;ee.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ea,this.indexArray=new ja,this.indexArray2=new $a,this.programConfigurations=new Ps(e.layers,e.zoom),this.segments=new Ns,this.segments2=new Ns,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection}populate(e,t,n,r){this.hasPattern=eh("fill",this.layers,t);const i=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:a,id:s,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Bu(a,e);if(!this.layers[0]._featureFilter.filter(new ia(this.zoom),c,n))continue;const h=i?i.evaluate(c,{},n,t.availableImages):void 0,d={id:s,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Ru(a,n,r),patterns:{},sortKey:h};o.push(d)}i&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:a}=r;if(this.hasPattern){const e=th("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,{},t.availableImages);t.featureIndex.insert(e[o].feature,i,o,a,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}addFeatures(e,t,n,r,i){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xc),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,n,r,i,o=[]){for(const e of Jc(t,500)){let t=0;for(const n of e)t+=n.length;const n=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=n.vertexLength,i=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(i.length/2);const n=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=n.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),i.push(t[0].x),i.push(t[0].y);for(let e=1;e>3}if(i--,1===r||2===r)o+=e.readSVarint(),a+=e.readSVarint(),1===r&&(t&&s.push(t),t=[]),t.push(new ch(o,a));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&s.push(t),s},dh.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,n=1,r=0,i=0,o=0,a=1/0,s=-1/0,l=1/0,u=-1/0;e.pos>3}if(r--,1===n||2===n)(i+=e.readSVarint())s&&(s=i),(o+=e.readSVarint())u&&(u=o);else if(7!==n)throw new Error("unknown command "+n)}return[a,l,s,u]},dh.prototype.toGeoJSON=function(e,t,n){var r,i,o=this.extent*Math.pow(2,n),a=this.extent*e,s=this.extent*t,l=this.loadGeometry(),u=dh.types[this.type];function c(e){for(var t=0;t>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(n))}_h.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new mh(this._pbf,t,this.extent,this._keys,this._values)};var vh=gh;function xh(e,t,n){if(3===e){var r=new vh(n,n.readVarint()+n.pos);r.length&&(t[r.name]=r)}}var bh=uh.VectorTile=function(e,t){this.layers=e.readFields(xh,{},t)},wh=uh.VectorTileFeature=hh;function Eh(e,t,n,r){const i=[],o=0===r?(e,t,n,r,i,o)=>{e.push(new v(o,n+(o-t)/(r-t)*(i-n)))}:(e,t,n,r,i,o)=>{e.push(new v(t+(o-n)/(i-n)*(r-t),o))};for(const a of e){const e=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let e=0;et&&o(a,s,l,u,c,t):h>n?d=t&&o(a,s,l,u,c,t),d>n&&h<=n&&o(a,s,l,u,c,n)}let s=i[i.length-1];const l=0===r?s.x:s.y;l>=t&&l<=n&&a.push(s),a.length&&(s=a[a.length-1],a[0].x===s.x&&a[0].y===s.y||a.push(a[0]),e.push(a))}e.length&&i.push(e)}return i}uh.VectorTileLayer=gh;const Th=wh.types,Sh=Math.pow(2,13);function Ah(e,t,n,r,i,o,a,s){e.emplaceBack((t<<1)+a,(n<<1)+o,(Math.floor(r*Sh)<<1)+i,Math.round(s))}function kh(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class Mh{constructor(){this.acc=new v(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new v(e.x,e.y),this.max=new v(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const n=this.min,r=this.max;e.xr.x&&(r.x=e.x),e.yr.y&&(r.y=e.y),((0===e.x||e.x===Vs)&&e.x===t.x)!=((0===e.y||e.y===Vs)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,On(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Vs!=e.x>Vs&&this.addBorderIntersection(1,On(t.y,e.y,(Vs-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,On(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Vs!=e.y>Vs&&this.addBorderIntersection(3,On(t.x,e.x,(Vs-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){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 n=this.borders[e];tn[1]&&(n[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const n=0===e.x?0:1;this.addBorderIntersection(n,t.y),this.addBorderIntersection(n,e.y)}else{const n=0===e.y?2:3;this.addBorderIntersection(n,t.x),this.addBorderIntersection(n,e.x)}}centroid(){const e=this.polyCount.reduce((e,t)=>e+t.edges,0);return 0!==e?this.acc.div(e)._round():new v(0,0)}span(){return new v(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0)}}class Ch{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new Sa,this.centroidVertexArray=new is,this.indexArray=new ja,this.programConfigurations=new Ps(e.layers,e.zoom),this.segments=new Ns,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.enableTerrain=e.enableTerrain}populate(e,t,n,r){this.features=[],this.hasPattern=eh("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<=0;e--){const t=d[e];(0===t.length||(f=t[0]).every(e=>e.x<=0)||f.every(e=>e.x>=Vs)||f.every(e=>e.y<=0)||f.every(e=>e.y>=Vs))&&d.splice(e,1)}var f;let p;if(u)p=Bh(d,s,r);else{p=[];for(const e of d)p.push({polygon:e,bounds:s})}const m=h?this.edgeRadius:0;for(const{polygon:e,bounds:t}of p){let n=0,i=0;for(const t of e)h&&!t[0].equals(t[t.length-1])&&t.push(t[0]),i+=h?t.length-1:t.length;const o=this.segments.prepareSegment((h?5:4)*i,this.layoutVertexArray,this.indexArray);if(h){const t=[],i=[];n=o.vertexLength;for(const n of e){let a,s;n.length&&n!==e[0]&&i.push(t.length/2),a=n[1].sub(n[0])._perp()._unit();for(let e=1;e4&&Lh(i[i.length-2],i[0],i[1]),f=m?Ph(i[i.length-2],i[0],i[1],m):0;a=i[1].sub(i[0])._perp()._unit();let p=!0;for(let g=1,_=0;g0?1:0,T=y.dist(v);if(_+T>32768&&(_=0),m){s=x.sub(v)._perp()._unit();let e=Oh(y,v,x,Ih(a,s),m);isNaN(e)&&(e=0);const t=v.sub(y)._unit();y=y.add(t.mult(f))._round(),v=v.add(t.mult(-e))._round(),f=e,a=s}const S=o.vertexLength,A=i.length>4&&Lh(y,v,x);let k=Dh(_,d,p);if(Ah(this.layoutVertexArray,y.x,y.y,w,E,0,0,k),Ah(this.layoutVertexArray,y.x,y.y,w,E,0,1,k),_+=T,k=Dh(_,A,!p),d=A,Ah(this.layoutVertexArray,v.x,v.y,w,E,0,0,k),Ah(this.layoutVertexArray,v.x,v.y,w,E,0,1,k),o.vertexLength+=4,this.indexArray.emplaceBack(S+0,S+1,S+2),this.indexArray.emplaceBack(S+1,S+3,S+2),o.primitiveLength+=2,m){const r=n+(1===g?i.length-2:g-2),a=1===g?n:r+1;if(this.indexArray.emplaceBack(S+1,r,S+3),this.indexArray.emplaceBack(r,a,S+3),o.primitiveLength+=2,void 0===e&&(e=S),!zh(x,i[g],t)){const t=g===i.length-1?e:o.vertexLength;this.indexArray.emplaceBack(S+2,S+3,t),this.indexArray.emplaceBack(S+3,t+1,t),this.indexArray.emplaceBack(S+3,a,t+1),o.primitiveLength+=3}p=!p}if(u){const e=this.layoutVertexExtArray,t=l.projectTilePoint(y.x,y.y,r),n=l.projectTilePoint(v.x,v.y,r),i=l.upVector(r,y.x,y.y),o=l.upVector(r,v.x,v.y);kh(e,t,i),kh(e,t,i),kh(e,n,o),kh(e,n,o)}}h&&(n+=i.length-1)}}if(c&&c.polyCount.length>0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const e=c.borders,t=this.featuresOnBorder.push(c)-1;for(let n=0;n<4;n++)e[n][0]!==Number.MAX_VALUE&&this.borders[n].push(t)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((t,n)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}encodeCentroid(e,t,n=!0){let r,i;if(e)if(0!==e.y){const n=t.span()._mult(this.tileToMeter);r=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(n.x/10)),i=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(n.y/10))}else r=Math.ceil(7*(e.x+450)),i=0;else r=0,i=+n;let o=n?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;tn[1].x&&t.x>n[1].x||e.yn[1].y&&t.y>n[1].y}function Lh(e,t,n){if(e.x<0||e.x>=Vs||t.x<0||t.x>=Vs||n.x<0||n.x>=Vs)return!1;const r=n.sub(t),i=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&i.x*o.x+i.y*o.y<0}function Dh(e,t,n){const r=t?2|e:-3&e;return n?1|r:-2&r}function Rh(){const e=Math.PI/32,t=Math.tan(e),n=mu;return n*Math.sqrt(1+2*t*t)-n}function Bh(e,t,n){const r=1<{for(const n of e)a.push({polygon:n,bounds:t})},l=Math.ceil(Math.log2(n)),u=Math.ceil(Math.log2(r)),c=l-u,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?f.push({polygons:d,bounds:e,depth:t+1}):s(d,e)}if(p.length){const e=[new v(0===n?c:r.x,1===n?c:r.y),a];h.length>t+1?f.push({polygons:p,bounds:e,depth:t+1}):s(p,e)}}return a}(e,t,Math.ceil((o-i)/11.25),Math.ceil((a-s)/11.25),1,(e,t,i)=>{if(0===e)return.5*(t+i);{const e=Tu((n.y+t/Vs)/r);return(bu(.5*(Tu((n.y+i/Vs)/r)+e))*r-n.y)*Vs}})}Fi(Ch,"FillExtrusionBucket",{omit:["layers","features"]}),Fi(Mh,"PartMetadata");const Fh=new ga({"fill-extrusion-edge-radius":new fa(tt["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var jh={paint:new ga({"fill-extrusion-opacity":new fa(tt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new pa(tt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new fa(tt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new fa(tt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new pa(tt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new pa(tt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new pa(tt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new fa(tt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new fa(tt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new fa(tt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new fa(tt["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:Fh};function Uh(e,t,n){var r=2*Math.PI*6378137/256/Math.pow(2,n);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Nh{constructor(e,t,n){this.z=e,this.x=t,this.y=n,this.key=qh(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const n=function(e,t,n){var r=Uh(256*e,256*(t=Math.pow(2,n)-t-1),n),i=Uh(256*(e+1),256*(t+1),n);return r[0]+","+r[1]+","+i[0]+","+i[1]}(this.x,this.y,this.z),r=function(e,t,n){let r,i="";for(let o=e;o>0;o--)r=1<this.canonical.z?new Gh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Gh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return qh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return qh(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Gh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new Gh(t,this.wrap,t,n,r),new Gh(t,this.wrap,t,n+1,r),new Gh(t,this.wrap,t,n,r+1),new Gh(t,this.wrap,t,n+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new Aa,this.layoutVertexArray2=new ka,this.indexArray=new ja,this.programConfigurations=new Ps(e.layers,e.zoom),this.segments=new Ns,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){this.hasPattern=eh("line",this.layers,t);const i=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:a,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Bu(t,e);if(!this.layers[0]._featureFilter.filter(new ia(this.zoom),u,n))continue;const c=i?i.evaluate(u,{},n):void 0,h={id:a,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?u.geometry:Ru(t,n,r),patterns:{},sortKey:c};o.push(h)}i&&o.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:a,featureIndex:s}=t,l=this.addConstantDashes(a);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:u}=r;if(l&&this.addFeatureDashes(r,a),this.hasPattern){const e=th("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,a.positions,t.availableImages);s.insert(e[o].feature,i,o,u,this.index)}}addConstantDashes(e){let t=!1;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,i=n.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==i.kind)t=!0;else{const t=i.value,n=r.value;if(!n)continue;e.addDash(n,t)}}return t}addFeatureDashes(e,t){const n=this.zoom;for(const r of this.layers){const i=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===o.kind)continue;let a,s;if("constant"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:n},e);s="constant"===o.kind?o.value:o.evaluate({zoom:n},e),t.addDash(a,s),e.patterns[r.id]=t.getKey(a,s)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}addFeatures(e,t,n,r,i){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Jh)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yh),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,n,r,i,o){const a=this.layers[0].layout,s=a.get("line-join").evaluate(e,{}),l=a.get("line-cap").evaluate(e,{}),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const n of t)this.addLine(n,e,s,l,u,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r)}addLine(e,t,n,r,i,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[s-1].equals(e[s-2]);)s--;let l=0;for(;l0;if(b&&t>l){const e=h.dist(d);if(e>2*u){const t=h.sub(h.sub(d)._mult(u/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,p,0,0,c),d=t}}const E=d&&f;let T=E?n:a?"butt":r;if(E&&"round"===T&&(vi&&(T="bevel"),"bevel"===T&&(v>2&&(T="flipbevel"),v100)g=m.mult(-1);else{const e=v*p.add(m).mag()/p.sub(m).mag();g._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(h,g,0,0,c),this.addCurrentVertex(h,g.mult(-1),0,0,c)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(v*v-1),t=w?e:0,n=w?0:e;if(d&&this.addCurrentVertex(h,p,t,n,c),"fakeround"===T){const e=Math.round(180*x/Math.PI/20);for(let t=1;t2*u){const t=h.add(f.sub(h)._mult(u/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,c),h=t}}}}addCurrentVertex(e,t,n,r,i,o=!1){const a=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*n,t.y-t.x*n,o,!1,n,i),this.addHalfVertex(e,a,s,o,!0,-r,i)}addHalfVertex({x:e,y:t},n,r,i,o,a,s){this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(t<<1)+(o?1:0),Math.round(63*n)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),s.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}Fi(td,"LineBucket",{omit:["layers","patternFeatures"]});const nd=new ga({"line-cap":new pa(tt.layout_line["line-cap"]),"line-join":new pa(tt.layout_line["line-join"]),"line-miter-limit":new fa(tt.layout_line["line-miter-limit"]),"line-round-limit":new fa(tt.layout_line["line-round-limit"]),"line-sort-key":new pa(tt.layout_line["line-sort-key"])});var rd={paint:new ga({"line-opacity":new pa(tt.paint_line["line-opacity"]),"line-color":new pa(tt.paint_line["line-color"]),"line-translate":new fa(tt.paint_line["line-translate"]),"line-translate-anchor":new fa(tt.paint_line["line-translate-anchor"]),"line-width":new pa(tt.paint_line["line-width"]),"line-gap-width":new pa(tt.paint_line["line-gap-width"]),"line-offset":new pa(tt.paint_line["line-offset"]),"line-blur":new pa(tt.paint_line["line-blur"]),"line-dasharray":new pa(tt.paint_line["line-dasharray"]),"line-pattern":new pa(tt.paint_line["line-pattern"]),"line-gradient":new ma(tt.paint_line["line-gradient"]),"line-trim-offset":new fa(tt.paint_line["line-trim-offset"])}),layout:nd};const id=new class extends pa{possiblyEvaluate(e,t){return t=new ia(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=z({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,r)}}(rd.paint.properties["line-width"].specification);function od(e,t){return t>0?t+2*e:e}id.useIntegerZoom=!0;const ad=ba([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),sd=ba([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),ld=ba([{name:"a_projected_pos",components:4,type:"Float32"}],4);ba([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const ud=ba([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),cd=ba([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);ba([{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 hd=ba([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),dd=ba([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ba([{name:"triangle",components:3,type:"Uint16"}]),ba([{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"}]),ba([{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"}]),ba([{type:"Float32",name:"offsetX"}]),ba([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const fd=128;function pd(e,t){const{expression:n}=t;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new ia(e+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=n;let i=0;for(;i{e.text=function(e,t,n){const r=t.layout.get("text-transform").evaluate(n,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),ra.applyArabicShaping&&(e=ra.applyArabicShaping(e)),e}(e.text,t,n)}),e}const vd={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function xd(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function bd(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var wd=Sd,Ed=function(e,t,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,c=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-c)-1,f>>=-c,c+=s;c>0;o=256*o+e[t+h],h+=d,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+e[t+h],h+=d,c-=8);if(0===o)o=1-u;else{if(o===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,r),o-=u}return(f?-1:1)*a*Math.pow(2,o-r)},Td=function(e,t,n,r,i,o){var a,s,l,u=8*o-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(s=0,a=c):a+h>=1?(s=(t*l-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[n+f]=255&s,f+=p,s/=256,i-=8);for(a=a<0;e[n+f]=255&a,f+=p,a/=256,u-=8);e[n+f-p]|=128*m}; +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function Sd(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}Sd.Varint=0,Sd.Fixed64=1,Sd.Bytes=2,Sd.Fixed32=5;var Ad=4294967296,kd=1/Ad,Md="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Cd(e){return e.type===Sd.Bytes?e.readVarint()+e.pos:e.pos+1}function Id(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Pd(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function Od(e,t){for(var n=0;n>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Gd(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}Sd.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos>3,o=this.pos;this.type=7&r,e(i,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Nd(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Gd(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Nd(this.buf,this.pos)+Nd(this.buf,this.pos+4)*Ad;return this.pos+=8,e},readSFixed64:function(){var e=Nd(this.buf,this.pos)+Gd(this.buf,this.pos+4)*Ad;return this.pos+=8,e},readFloat:function(){var e=Ed(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Ed(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,n,r=this.buf;return t=127&(n=r[this.pos++]),n<128?t:(t|=(127&(n=r[this.pos++]))<<7,n<128?t:(t|=(127&(n=r[this.pos++]))<<14,n<128?t:(t|=(127&(n=r[this.pos++]))<<21,n<128?t:function(e,t,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return Id(e,r,t);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return Id(e,r,t);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return Id(e,r,t);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return Id(e,r,t);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return Id(e,r,t);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return Id(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(n=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Md?function(e,t,n){return Md.decode(e.subarray(t,n))}(this.buf,t,e):function(e,t,n){for(var r="",i=t;i239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(o=e[i+1]))&&(u=(31&l)<<6|63&o)<=127&&(u=null):3===c?(a=e[i+2],128==(192&(o=e[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&o)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=e[i+2],s=e[i+3],128==(192&(o=e[i+1]))&&128==(192&a)&&128==(192&s)&&((u=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==Sd.Bytes)return e.push(this.readVarint(t));var n=Cd(this);for(e=e||[];this.pos127;);else if(t===Sd.Bytes)this.pos=this.readVarint()+this.pos;else if(t===Sd.Fixed32)this.pos+=4;else{if(t!==Sd.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t268435455||e<0?function(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,n.buf[n.pos]=127&(e>>>=7)}(n,0,t),function(e,t){var n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var r,i,o=0;o55295&&r<57344){if(!i){r>56319||o+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&Pd(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),Td(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Td(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n=128&&Pd(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,Sd.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,Od,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,zd,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Rd,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Ld,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Dd,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Bd,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Fd,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,jd,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Ud,t)},writeBytesField:function(e,t){this.writeTag(e,Sd.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,Sd.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,Sd.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,Sd.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,Sd.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,Sd.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,Sd.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,Sd.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,Sd.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,Sd.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var qd=f(wd);function $d(e,t,n){t.glyphs=[],1===e&&n.readMessage(Zd,t)}function Zd(e,t,n){if(3===e){const{id:e,bitmap:r,width:i,height:o,left:a,top:s,advance:l}=n.readMessage(Wd,{});t.glyphs.push({id:e,bitmap:new pc({width:i+6,height:o+6},r),metrics:{width:i,height:o,left:a,top:s,advance:l}})}else 4===e?t.ascender=n.readSVarint():5===e&&(t.descender=n.readSVarint())}function Wd(e,t,n){1===e?t.id=n.readVarint():2===e?t.bitmap=n.readBytes():3===e?t.width=n.readVarint():4===e?t.height=n.readVarint():5===e?t.left=n.readSVarint():6===e?t.top=n.readSVarint():7===e&&(t.advance=n.readVarint())}function Xd(e){let t=0,n=0;for(const r of e)t+=r.w*r.h,n=Math.max(n,r.w);e.sort((e,t)=>t.h-e.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}];let i=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const n=r[e];if(!(t.w>n.w||t.h>n.h)){if(t.x=n.x,t.y=n.y,o=Math.max(o,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===n.w&&t.h===n.h){const t=r.pop();ee.hasImage(t)),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),t),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),t)}patchUpdatedImage(e,t,n){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,i]=e.tl;n.update(t.data,void 0,{x:r,y:i})}}Fi(Hd,"ImagePosition"),Fi(Yd,"ImageAtlas");const Kd={horizontal:1,vertical:2,horizontalOnly:3};class Jd{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const n=new Jd;return n.scale=e||1,n.fontStack=t,n}static forImage(e){const t=new Jd;return t.imageName=e,t}}class Qd{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const n=new Qd;for(let r=0;r=0&&n>=e&&tf[this.text.charCodeAt(n)];n--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const n=new Qd;return n.text=this.text.substring(e,t),n.sectionIndex=this.sectionIndex.slice(e,t),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Jd.forText(e.scale,e.fontStack||t));const n=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ef(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=Qd.fromFeature(e,i);h===Kd.vertical&&m.verticalizePunctuation(d);let g=[];const _=function(e,t,n,r,i,o){if(!e)return[];const a=[],s=function(e,t,n,r,i,o){let a=0;for(let n=0;n=0;let u=0;for(let n=0;n0&&o>b&&(b=o)}else{const e=n[s.fontStack];if(!e)continue;e[m]&&(T=e[m]);const r=t[s.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(v=o.metrics,A=8203!==m?24:0,g){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,n=(e+t)*_;w-n/2;){if(a--,a<0)return!1;s-=e[a].dist(o),o=e[a]}s+=e[a].dist(e[a+1]),a++;const l=[];let u=0;for(;sr;)u-=l.shift().angleDelta;if(u>i)return!1;a++,s+=t.dist(n)}return!0}function pf(e){let t=0;for(let n=0;nu){const c=(u-l)/o,h=On(r.x,i.x,c),d=On(r.y,i.y,c),f=new df(h,d,0,i.angleTo(r),n);return!a||ff(e,f,s,a,t)?f:void 0}l+=o}}function yf(e,t,n,r,i,o,a,s,l){const u=mf(r,o,a),c=gf(r,i),h=c*a,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&y=0&&f+c<=h){const n=new df(_,y,0,m,e);n._round(),i&&!ff(t,n,a,i,o)||p.push(n)}}d+=l}return l||p.length||s||(p=e(t,d/2,r,i,o,a,s,!0,u)),p}(e,d?t/2*s%t:(c/2+2*o)*a*s%t,t,u,n,h,d,!1,l)}function vf(e,t,n,r,i){const o=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new v(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new v(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=i&&u.y>=i||(a.y>=i?a=new v(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round():u.y>=i&&(u=new v(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round()),l&&a.equals(l[l.length-1])||(l=[a],o.push(l)),l.push(u)))))}}return o}Fi(df,"Anchor");const xf=1e20;function bf(e,t,n,r,i,o,a,s,l){for(let u=t;u-1);l++,o[l]=s,a[l]=u,a[l+1]=xf}for(let s=0,l=0;s{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let i=r.glyphs[t];if(void 0!==i)return void n(null,{stack:e,id:t,glyph:i});if(i=this._tinySDF(r,e,t),i)return r.glyphs[t]=i,void n(null,{stack:e,id:t,glyph:i});const o=Math.floor(t/256);if(256*o>65535)return void n(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void n(null,{stack:e,id:t,glyph:i});let a=r.requests[o];a||(a=r.requests[o]=[],Tf.loadGlyphRange(e,o,this.url,this.requestManager,(e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[o]=!0}for(const n of a)n(e,t);delete r.requests[o]})),a.push((r,i)=>{r?n(r):i&&n(null,{stack:e,id:t,glyph:i.glyphs[t]||null})})},(e,n)=>{if(e)t(e);else if(n){const e={};for(const{stack:t,id:r,glyph:i}of n)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[r]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==Ef.none&&(this.localGlyphMode===Ef.all?!!this.localFontFamily:!!this.localFontFamily&&(To(e)||Mo(e)||ho(e)||fo(e)||co(e)))}_tinySDF(e,t,n){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(n))return;let i=e.tinySDF;if(!i){let n="400";/bold/i.test(t)?n="900":/medium/i.test(t)?n="500":/light/i.test(t)&&(n="200"),i=e.tinySDF=new Tf.TinySDF({fontFamily:r,fontWeight:n,fontSize:48,buffer:6,radius:16}),i.fontWeight=n}if(this.localGlyphs[i.fontWeight][n])return this.localGlyphs[i.fontWeight][n];const o=String.fromCharCode(n),{data:a,width:s,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:d,glyphAdvance:f}=i.draw(o);return this.localGlyphs[i.fontWeight][n]={id:n,bitmap:new pc({width:s,height:l},a),metrics:{width:u/2,height:c/2,left:h/2,top:d/2-27,advance:f/2,localGlyph:!0}}}}function Sf(e,t,n,r){const i=[],o=e.image,a=o.pixelRatio,s=o.paddedRect.w-2,l=o.paddedRect.h-2,u=e.right-e.left,c=e.bottom-e.top,h=o.stretchX||[[0,s]],d=o.stretchY||[[0,l]],f=(e,t)=>e+t[1]-t[0],p=h.reduce(f,0),m=d.reduce(f,0),g=s-p,_=l-m;let y=0,x=p,b=0,w=m,E=0,T=g,S=0,A=_;if(o.content&&r){const e=o.content;y=Af(h,0,e[0]),b=Af(d,0,e[1]),x=Af(h,e[0],e[2]),w=Af(d,e[1],e[3]),E=e[0]-y,S=e[1]-b,T=e[2]-e[0]-x,A=e[3]-e[1]-w}const k=(r,i,s,l)=>{const h=Mf(r.stretch-y,x,u,e.left),d=Cf(r.fixed-E,T,r.stretch,p),f=Mf(i.stretch-b,w,c,e.top),g=Cf(i.fixed-S,A,i.stretch,m),_=Mf(s.stretch-y,x,u,e.left),k=Cf(s.fixed-E,T,s.stretch,p),M=Mf(l.stretch-b,w,c,e.top),C=Cf(l.fixed-S,A,l.stretch,m),I=new v(h,f),P=new v(_,f),O=new v(_,M),z=new v(h,M),L=new v(d/a,g/a),D=new v(k/a,C/a),R=t*Math.PI/180;if(R){const e=Math.sin(R),t=Math.cos(R),n=[t,-e,e,t];I._matMult(n),P._matMult(n),z._matMult(n),O._matMult(n)}const B=r.stretch+r.fixed,F=i.stretch+i.fixed;return{tl:I,tr:P,bl:z,br:O,tex:{x:o.paddedRect.x+1+B,y:o.paddedRect.y+1+F,w:s.stretch+s.fixed-B,h:l.stretch+l.fixed-F},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:D,minFontScaleX:T/a/u,minFontScaleY:A/a/c,isSDF:n}};if(r&&(o.stretchX||o.stretchY)){const e=kf(h,g,p),t=kf(d,_,m);for(let n=0;n{if(e)i(e);else if(t){const e={},n=function(e){return new qd(e).readFields($d,{})}(t);for(const t of n.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:n.ascender,descender:n.descender})}})},Tf.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=n;const s=this.size=e+4*t,l=this._createCanvas(s),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${o} ${e}px ${i}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(n),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),u=s+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),d=new Uint8ClampedArray(h),f={data:d,width:u,height:c,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===l)return f;const{ctx:p,buffer:m,gridInner:g,gridOuter:_}=this;p.clearRect(m,m,s,l),p.fillText(e,m,m+a);const y=p.getImageData(m,m,s,l);_.fill(xf,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[r]=e<0?e*e:0}}bf(_,0,0,u,c,u,this.f,this.v,this.z),bf(g,m,m,s,l,u,this.f,this.v,this.z);for(let e=0;e0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,r=t[e];for(;e>0;){const i=e-1>>1,o=t[i];if(n(r,o)>=0)break;t[e]=o,e=i}t[e]=r}_down(e){const{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e=0)break;t[e]=o,e=r}t[e]=i}}function Of(e,t){return et?1:0}function zf(e,t=1,n=!1){let r=1/0,i=1/0,o=-1/0,a=-1/0;const s=e[0];for(let e=0;eo)&&(o=t.x),(!e||t.y>a)&&(a=t.y)}const l=Math.min(o-r,a-i);let u=l/2;const c=new Pf([],Lf);if(0===l)return new v(r,i);for(let t=r;th.d||!h.d)&&(h=r,n&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-h.d<=t||(u=r.h/2,c.push(new Df(r.p.x-u,r.p.y-u,u,e)),c.push(new Df(r.p.x+u,r.p.y-u,u,e)),c.push(new Df(r.p.x-u,r.p.y+u,u,e)),c.push(new Df(r.p.x+u,r.p.y+u,u,e)),d+=4)}return n&&(console.log("num probes: "+d),console.log("best distance: "+h.d)),h.p}function Lf(e,t){return t.max-e.max}class Df{constructor(e,t,n,r){this.p=new v(e,t),this.h=n,this.d=function(e,t){let n=!1,r=1/0;for(let i=0;ie.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n),r=Math.min(r,Xu(e,i,s))}}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}}const Rf=Number.POSITIVE_INFINITY,Bf=Math.sqrt(2);function Ff(e,[t,n]){let r=0,i=0;if(n===Rf){t<0&&(t=0);const n=t/Bf;switch(e){case"top-right":case"top-left":i=n-7;break;case"bottom-right":case"bottom-left":i=7-n;break;case"bottom":i=7-t;break;case"top":i=t-7}switch(e){case"top-right":case"bottom-right":r=-n;break;case"top-left":case"bottom-left":r=n;break;case"left":r=t;break;case"right":r=-t}}else{switch(t=Math.abs(t),n=Math.abs(n),e){case"top-right":case"top-left":case"top":i=n-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-n}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}}return[r,i]}function jf(e,t,n,r,i,o,a,s,l,u){e.createArrays(),e.tilePixelRatio=Vs/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const c=e.layers[0].layout,h=e.layers[0]._unevaluatedLayout._values,d={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:n}=e.textSizeData;d.compositeTextSizes=[h["text-size"].possiblyEvaluate(new ia(t),s),h["text-size"].possiblyEvaluate(new ia(n),s)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:n}=e.iconSizeData;d.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new ia(t),s),h["icon-size"].possiblyEvaluate(new ia(n),s)]}d.layoutTextSize=h["text-size"].possiblyEvaluate(new ia(l+1),s),d.layoutIconSize=h["icon-size"].possiblyEvaluate(new ia(l+1),s),d.textMaxSize=h["text-size"].possiblyEvaluate(new ia(18),s);const f="map"===c.get("text-rotation-alignment")&&"point"!==c.get("symbol-placement"),p=c.get("text-size");for(const o of e.features){const l=c.get("text-font").evaluate(o,{},s).join(","),h=p.evaluate(o,{},s),m=d.layoutTextSize.evaluate(o,{},s),g=(d.layoutIconSize.evaluate(o,{},s),{horizontal:{},vertical:void 0}),_=o.text;let y,v=[0,0];if(_){const r=_.toString(),a=24*c.get("text-letter-spacing").evaluate(o,{},s),u=24*c.get("text-line-height").evaluate(o,{},s),d=jo(r)?a:0,p=c.get("text-anchor").evaluate(o,{},s),y=c.get("text-variable-anchor");if(!y){const e=c.get("text-radial-offset").evaluate(o,{},s);v=e?Ff(p,[24*e,Rf]):c.get("text-offset").evaluate(o,{},s).map(e=>24*e)}let x=f?"center":c.get("text-justify").evaluate(o,{},s);const b="point"===c.get("symbol-placement"),w=b?24*c.get("text-max-width").evaluate(o,{},s):1/0,E=o=>{e.allowVerticalPlacement&&Fo(r)&&(g.vertical=ef(_,t,n,i,l,w,u,p,o,d,v,Kd.vertical,!0,m,h))};if(!f&&y){const e="auto"===x?y.map(e=>Uf(e)):[x];let r=!1;for(let o=0;o=0||!Fo(r)){const e=ef(_,t,n,i,l,w,u,p,x,d,v,Kd.horizontal,!1,m,h);e&&(g.horizontal[x]=e)}E(b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const t=r[o.icon.name];t&&(y=cf(i[o.icon.name],c.get("icon-offset").evaluate(o,{},s),c.get("icon-anchor").evaluate(o,{},s)),x=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&$("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==c.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const b=$f(g.horizontal)||g.vertical;e.iconsInText||(e.iconsInText=!!b&&b.iconsInText),(b||y)&&Nf(e,o,g,y,r,d,m,0,v,x,a,s,u)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Uf(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Nf(e,t,n,r,i,o,a,s,l,u,c,h,d){let f=o.textMaxSize.evaluate(t,{},h);void 0===f&&(f=a);const p=e.layers[0].layout,m=p.get("icon-offset").evaluate(t,{},h),g=$f(n.horizontal)||n.vertical,_="globe"===d.name,y=a/24,v=e.tilePixelRatio*f/24,x=(C=e.overscaling,e.zoom>18&&C>2&&(C>>=1),Math.max(Vs/(512*C),1)*p.get("symbol-spacing")),b=p.get("text-padding")*e.tilePixelRatio,E=p.get("icon-padding")*e.tilePixelRatio,T=w(p.get("text-max-angle")),S="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),A="map"===p.get("icon-rotation-alignment")&&"point"!==p.get("symbol-placement"),k=p.get("symbol-placement"),M=x/2;var C;const I=p.get("icon-text-fit");let P;r&&"none"!==I&&(e.allowVerticalPlacement&&n.vertical&&(P=hf(r,n.vertical,I,p.get("icon-text-fit-padding"),m,y)),g&&(r=hf(r,g,I,p.get("icon-text-fit-padding"),m,y)));const O=(a,s,f)=>{if(s.x<0||s.x>=Vs||s.y<0||s.y>=Vs)return;let p=null;if(_){const{x:e,y:t,z:n}=d.projectTilePoint(s.x,s.y,f);p={anchor:new df(e,t,n,0,void 0),up:d.upVector(f,s.x,s.y)}}!function(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_,y,v,x,b,w,E,T){const S=e.addToLineVertexArray(t,r);let A,k,M,C,I,P,O,z=0,L=0,D=0,R=0,B=-1,F=-1;const j={};let U=fs("");const N=n?n.anchor:t;let V=0,G=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[V,G]=l.layout.get("text-offset").evaluate(x,{},T).map(e=>24*e):(V=24*l.layout.get("text-radial-offset").evaluate(x,{},T),G=Rf),e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(p)P=Wf(e),s&&(O=Wf(s));else{const n=l.layout.get("text-rotate").evaluate(x,{},T)+90;M=Zf(u,N,t,c,h,d,e,f,n,m),s&&(C=Zf(u,N,t,c,h,d,s,_,n))}}if(o){const r=l.layout.get("icon-rotate").evaluate(x,{},T),i="none"!==l.layout.get("icon-text-fit"),a=Sf(o,r,w,i),f=s?Sf(s,r,w,i):void 0;k=Zf(u,N,t,c,h,d,o,_,r),z=4*a.length;const p=e.iconSizeData;let m=null;"source"===p.kind?(m=[fd*l.layout.get("icon-size").evaluate(x,{},T)],m[0]>Gf&&$(`${e.layerIds[0]}: Value for "icon-size" is >= ${Vf}. Reduce your "icon-size".`)):"composite"===p.kind&&(m=[fd*b.compositeIconSizes[0].evaluate(x,{},T),fd*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Gf||m[1]>Gf)&&$(`${e.layerIds[0]}: Value for "icon-size" is >= ${Vf}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,m,v,y,x,!1,n,t,S.lineStartIndex,S.lineLength,-1,E,T),B=e.icon.placedSymbolArray.length-1,f&&(L=4*f.length,e.addSymbols(e.icon,f,m,v,y,x,Kd.vertical,n,t,S.lineStartIndex,S.lineLength,-1,E,T),F=e.icon.placedSymbolArray.length-1)}for(const r in i.horizontal){const o=i.horizontal[r];A||(U=fs(o.text),p?I=Wf(o):A=Zf(u,N,t,c,h,d,o,f,l.layout.get("text-rotate").evaluate(x,{},T),m));const s=1===o.positionedLines.length;if(D+=qf(e,n,t,o,a,l,p,x,m,S,i.vertical?Kd.horizontal:Kd.horizontalOnly,s?Object.keys(i.horizontal):[r],j,B,b,E,T),s)break}i.vertical&&(R+=qf(e,n,t,i.vertical,a,l,p,x,m,S,Kd.vertical,["vertical"],j,F,b,E,T));let q=-1;const Z=(e,t)=>e?Math.max(e,t):t;q=Z(I,q),q=Z(P,q),q=Z(O,q);const W=q>-1?1:0;e.glyphOffsetArray.length>=Ap.MAX_GLYPHS&&$("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey),e.symbolInstances.emplaceBack(N.x,N.y,N.z,t.x,t.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,B,F,U,void 0!==A?A:e.collisionBoxArray.length,void 0!==A?A+1:e.collisionBoxArray.length,void 0!==M?M:e.collisionBoxArray.length,void 0!==M?M+1:e.collisionBoxArray.length,void 0!==k?k:e.collisionBoxArray.length,void 0!==k?k+1:e.collisionBoxArray.length,C||e.collisionBoxArray.length,C?C+1:e.collisionBoxArray.length,c,D,R,z,L,W,0,V,G,q)}(e,s,p,a,n,r,i,P,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,b,S,l,0,E,A,m,t,o,u,c,h)};if("line"===k)for(const i of vf(t.geometry,0,0,Vs,Vs)){const t=yf(i,x,T,n.vertical||g,r,24,v,e.overscaling,Vs);for(const n of t)g&&Xf(e,g.text,M,n)||O(i,n,h)}else if("line-center"===k){for(const e of t.geometry)if(e.length>1){const t=_f(e,T,n.vertical||g,r,24,v);t&&O(e,t,h)}}else if("Polygon"===t.type)for(const e of Jc(t.geometry,0)){const t=zf(e,16);O(e[0],new df(t.x,t.y,0,0,void 0),h)}else if("LineString"===t.type)for(const e of t.geometry)O(e,new df(e[0].x,e[0].y,0,0,void 0),h);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)O([t],new df(t.x,t.y,0,0,void 0),h)}const Vf=255,Gf=Vf*fd;function qf(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g){const _=function(e,t,n,r,i,o,a,s){const l=[];if(0===t.positionedLines.length)return l;const u=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=function(e){const t=e[0],n=e[1],r=t*n;return r>0?[t,-n]:r<0?[-t,n]:0===t?[n,t]:[n,-t]}(n);let h=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)h-=e.lineOffset;const d=t.positionedLines.length,f=h/d;let p=t.top-n[1];for(let e=0;eGf&&$(`${e.layerIds[0]}: Value for "text-size" is >= ${Vf}. Reduce your "text-size".`)):"composite"===y.kind&&(x=[fd*p.compositeTextSizes[0].evaluate(s,{},g),fd*p.compositeTextSizes[1].evaluate(s,{},g)],(x[0]>Gf||x[1]>Gf)&&$(`${e.layerIds[0]}: Value for "text-size" is >= ${Vf}. Reduce your "text-size".`)),e.addSymbols(e.text,_,x,l,a,s,c,t,n,u.lineStartIndex,u.lineLength,f,m,g);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*_.length}function $f(e){for(const t in e)return e[t];return null}function Zf(e,t,n,r,i,o,a,s,l,u){let c=a.top,h=a.bottom,d=a.left,f=a.right;const p=a.collisionPadding;if(p&&(d-=p[0],c-=p[1],f+=p[2],h+=p[3]),l){const e=new v(d,c),t=new v(f,c),n=new v(d,h),r=new v(f,h),i=w(l);let o=new v(0,0);u&&(o=new v(u[0],u[1])),e._rotateAround(i,o),t._rotateAround(i,o),n._rotateAround(i,o),r._rotateAround(i,o),d=Math.min(e.x,t.x,n.x,r.x),f=Math.max(e.x,t.x,n.x,r.x),c=Math.min(e.y,t.y,n.y,r.y),h=Math.max(e.y,t.y,n.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,n.x,n.y,d,c,f,h,s,r,i,o),e.length-1}function Wf(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Xf(e,t,n,r){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])v&&(x(e,u,r,i,s,l),x(u,n,s,l,o,a))}x(h,d,r,o,i,o),x(d,f,i,o,i,a),x(f,p,i,a,r,a),x(p,h,r,a,r,o),m-=v,g-=v,_+=v,y+=v;const b=1/Math.max(_-m,y-g);return{scale:b,x:m*b,y:g*b,x2:_*b,y2:y*b,projection:t}}const Kf=Xs(new Float32Array(16));class Jf{constructor(e){this.spec=e,this.name=e.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(e,t){return{x:0,y:0,z:0}}unproject(e,t){return new yu(0,0)}projectTilePoint(e,t,n){return{x:e,y:t,z:0}}locationPoint(e,t,n=!0){return e._coordinatePoint(e.locationCoordinate(t),n)}pixelsPerMeter(e,t){return wu(1,e)*t}pixelSpaceConversion(e,t,n){return 1}farthestPixelDistance(e){return Hf(e,e.pixelsPerMeter)}pointCoordinate(e,t,n,r){const i=e.horizonLineFromTop(!1),o=new v(t,Math.max(i,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,n){const r=new v(t,n);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const n=e.horizonLineFromTop();return t.y0?t<-sp+n&&(t=-sp+n):t>sp-n&&(t=sp-n);const o=i/Math.pow(lp(t),r);let a=o*Math.sin(r*e),s=i-o*Math.cos(r*e);return a=.5*(a/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:a,y:this.southernCenter?s:1-s,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:n,f:r}=this,i=r-t,o=Math.sign(i),a=Math.sign(n)*Math.sqrt(e*e+i*i);let s=Math.atan2(e,Math.abs(i))*o;i*n<0&&(s-=Math.PI*Math.sign(e)*o);const l=M(E(s/n)+this.center[0],-180,180),u=M(E(2*Math.atan(Math.pow(r/a,1/n))-sp),-Au,Au);return new yu(l,this.southernCenter?-u:u)}}class cp extends Jf{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,t){return{x:xu(e),y:bu(t),z:0}}unproject(e,t){const n=Eu(e),r=Tu(t);return new yu(n,r)}}const hp=w(Au);class dp extends Jf{project(e,t){const n=(t=w(t))*t,r=n*n;return{x:.5*((e=w(e))*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let n=t=(2*(1-t)-1)*Math.PI,r=25,i=0,o=n*n;do{o=n*n;const e=o*o;i=(n*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),n=M(n-i,-hp,hp)}while(Math.abs(i)>1e-6&&--r>0);o=n*n;const a=M(E(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=E(n);return new yu(a,s)}}const fp=w(Au);class pp extends Jf{project(e,t){t=w(t),e=w(e);const n=Math.cos(t),r=2/Math.PI,i=Math.acos(n*Math.cos(e/2)),o=Math.sin(i)/i,a=.5*(e*r+2*n*Math.sin(e/2)/o)||0,s=.5*(t+Math.sin(t)/o)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}unproject(e,t){let n=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,i=25;const o=1e-6;let a=0,s=0;do{const i=Math.cos(r),o=Math.sin(r),l=2*o*i,u=o*o,c=i*i,h=Math.cos(n/2),d=Math.sin(n/2),f=2*h*d,p=d*d,m=1-c*h*h,g=m?1/m:0,_=m?Math.acos(i*h)*Math.sqrt(1/m):0,y=.5*(2*_*i*d+2*n/Math.PI)-e,v=.5*(_*o+r)-t,x=.5*g*(c*p+_*i*h*u)+1/Math.PI,b=g*(f*l/4-_*o*d),w=.125*g*(l*d-_*o*c*f),E=.5*g*(u*h+_*p*i)+.5,T=b*w-E*x;a=(v*b-y*E)/T,s=(y*w-v*x)/T,n=M(n-a,-Math.PI,Math.PI),r=M(r-s,-fp,fp)}while((Math.abs(a)>o||Math.abs(s)>o)&&--i>0);return new yu(E(n),E(r))}}class mp extends Jf{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(w(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:n,cosPhi:r}=this;return{x:w(e)*r*n+.5,y:-Math.sin(w(t))/r*n+.5,z:0}}unproject(e,t){const{scale:n,cosPhi:r}=this,i=-(t-.5)/n,o=M(E((e-.5)/n)/r,-180,180),a=Math.asin(M(i*r,-1,1)),s=M(E(a),-Au,Au);return new yu(o,s)}}class gp extends cp{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,t,n){const r=ru(e,t,n);return yl(r,r,au(Hl(n))),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const n=nu(t.lat,t.lng),r=ml([],n),i=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;pl(n,n,r,wu(1,0)*Vs*i);const o=Xs(new Float64Array(16));return Ys(o,e.pixelMatrix,e.globeMatrix),yl(n,n,o),new v(n[0],n[1])}pixelsPerMeter(e,t){return wu(1,0)*t}pixelSpaceConversion(e,t,n){const r=wu(1,e)*t,i=On(wu(1,45)*t,r,n);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,n){const r=su(Hl(n.canonical));return Ys(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:n}=e,r=au(Hl(t));return el(r,r,w(n.lng)),Qs(r,r,w(n.lat)),Js(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,n,r){return Zl(e,t,n,!0)||new Mu(0,0)}pointCoordinate3D(e,t,n){const r=this.pointCoordinate(e,t,n,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!Zl(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const n=e.cameraToCenterDistance,r=e._centerAltitude*t,i=e._camera,o=e._camera.forward(),a=ll([],fl([],o,-n),[0,0,r]),s=e.worldSize/(2*Math.PI),l=[0,0,-s],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=fl([],i.up(),c),d=fl([],i.right(),c*u),f=ml([],ll([],ll([],o,h),d)),p=[];let m;if(new Rl(a,f).closestPointOnSphere(l,s,p)){const t=ll([],p,l),n=bl([],t,a);m=Math.cos(e.fovAboveCenter)*al(n)}else{const e=bl([],a,l),t=bl([],l,a);ml(t,t);const n=al(e)-s;m=Math.sqrt(n*(n+2*s));const r=Math.acos(m/(s+n))-Math.acos(gl(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=uu(e.zoom);if(n>0){const r=Hf(e,wu(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return On(t,r+i*(1-Math.cos(o)),Math.pow(n,10))}return t}upVector(e,t,n){return ru(t,n,e,1)}upVectorScale(e){return{metersToTile:$l(iu(Hl(e)))}}}function _p(e){const t=e.parallels,n=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new cp(e);case"equirectangular":return new ap(e);case"naturalEarth":return new dp(e);case"equalEarth":return new op(e);case"winkelTripel":return new pp(e);case"albers":return n?new mp(e):new Qf(e);case"lambertConformalConic":return n?new mp(e):new up(e);case"globe":return new gp(e)}throw new Error("Invalid projection name: "+e.name)}const yp=wh.types,vp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function xp(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=s?Math.min(Gf,Math.round(s[0])):0,p=s?Math.min(Gf,Math.round(s[1])):0;e.emplaceBack(t,n,Math.round(32*r),Math.round(32*i),o,a,(f<<1)+(l?1:0),p,16*u,16*c,256*h,256*d)}function bp(e,t,n,r,i,o,a){e.emplaceBack(t,n,r,i,o,a)}function wp(e,t,n,r,i){e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i)}function Ep(e){for(const t of e.sections)if($o(t.text))return!0;return!1}class Tp{constructor(e){this.layoutVertexArray=new Pa,this.indexArray=new ja,this.programConfigurations=e,this.segments=new Ns,this.dynamicLayoutVertexArray=new ka,this.opacityVertexArray=new za,this.placedSymbolArray=new Ka,this.globeExtVertexArray=new Oa}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ad.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,ld.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,vp,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,sd.members,!0)),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(e))}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())}}Fi(Tp,"SymbolBuffers");class Sp{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new Ns,this.collisionVertexArray=new Ba,this.collisionVertexArrayExt=new Fa}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,ud.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,cd.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Fi(Sp,"CollisionBuffers");class Ap{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Xs([]),this.placementViewportMatrix=Xs([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=pd(this.zoom,t["text-size"]),this.iconSizeData=pd(this.zoom,t["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),i=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(e=>Kd[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new Tp(new Ps(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Tp(new Ps(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new es,this.lineVertexArray=new ts,this.symbolInstances=new Qa}calculateGlyphDependencies(e,t,n,r,i){for(let n=0;n0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const f=t.iconDependencies,p=t.glyphDependencies,m=t.availableImages,g=new ia(this.zoom);for(const{feature:t,id:l,index:u,sourceLayerIndex:_}of e){const e=i._featureFilter.needGeometry,y=Bu(t,e);if(!i._featureFilter.filter(g,y,n))continue;if(e||(y.geometry=Ru(t,n,r)),a&&1!==t.type&&n.z<=5){const e=y.geometry,t=.98078528056,r=(e,r)=>gl(ru(e.x,e.y,n,1),ru(r.x,r.y,n,1))=0;for(const n of v.sections)if(n.image)f[n.image.name]=!0;else{const r=Fo(v.toString()),i=n.fontStack||e,o=p[i]=p[i]||{};this.calculateGlyphDependencies(n.text,o,t,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},n={},r=[];let i=0;function o(t){r.push(e[t]),i++}function a(e,t,i){const o=n[e];return delete n[e],n[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(i[0]),o}function s(e,n,i){const o=t[n];return delete t[n],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=i[0].concat(r[o].geometry[0]),o}function l(e,t,n){const r=n?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let u=0;ue.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,n,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,n,r),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,n,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=_p(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const n=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:n}of t)this.lineVertexArray.emplaceBack(e,n);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,t,n,r,i,o,a,s,l,u,c,h,d,f){const p=e.indexArray,m=e.layoutVertexArray,g=e.globeExtVertexArray,_=e.segments.prepareSegment(4*t.length,m,p,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,v=_.vertexLength,x=this.allowVerticalPlacement&&a===Kd.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let r=0;r=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=md(this.textSizeData,e,i)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,n){const r=this.icon.placedSymbolArray.get(n),i=md(this.iconSizeData,e,r);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,n){e.emplaceBack(t,-n,-n),e.emplaceBack(t,n,-n),e.emplaceBack(t,n,n),e.emplaceBack(t,-n,n)}_updateTextDebugCollisionBoxes(e,t,n,r,i,o){for(let a=r;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+4*n.numGlyphs;for(let t=n.vertexStartIndex;tr[e]-r[t]||i[t]-i[e]),o}addToSortKeyRanges(e,t){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===t?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:s}=t;n>=0&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&this.addIndicesForPlacedSymbol(this.text,r),i>=0&&i!==r&&i!==n&&this.addIndicesForPlacedSymbol(this.text,i),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Fi(Ap,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Ap.MAX_GLYPHS=65535,Ap.addDynamicAttributes=wp;const kp=new ga({"symbol-placement":new fa(tt.layout_symbol["symbol-placement"]),"symbol-spacing":new fa(tt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new fa(tt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new pa(tt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new fa(tt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new fa(tt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new fa(tt.layout_symbol["icon-ignore-placement"]),"icon-optional":new fa(tt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new fa(tt.layout_symbol["icon-rotation-alignment"]),"icon-size":new pa(tt.layout_symbol["icon-size"]),"icon-text-fit":new fa(tt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new fa(tt.layout_symbol["icon-text-fit-padding"]),"icon-image":new pa(tt.layout_symbol["icon-image"]),"icon-rotate":new pa(tt.layout_symbol["icon-rotate"]),"icon-padding":new fa(tt.layout_symbol["icon-padding"]),"icon-keep-upright":new fa(tt.layout_symbol["icon-keep-upright"]),"icon-offset":new pa(tt.layout_symbol["icon-offset"]),"icon-anchor":new pa(tt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new fa(tt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new fa(tt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new fa(tt.layout_symbol["text-rotation-alignment"]),"text-field":new pa(tt.layout_symbol["text-field"]),"text-font":new pa(tt.layout_symbol["text-font"]),"text-size":new pa(tt.layout_symbol["text-size"]),"text-max-width":new pa(tt.layout_symbol["text-max-width"]),"text-line-height":new pa(tt.layout_symbol["text-line-height"]),"text-letter-spacing":new pa(tt.layout_symbol["text-letter-spacing"]),"text-justify":new pa(tt.layout_symbol["text-justify"]),"text-radial-offset":new pa(tt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new fa(tt.layout_symbol["text-variable-anchor"]),"text-anchor":new pa(tt.layout_symbol["text-anchor"]),"text-max-angle":new fa(tt.layout_symbol["text-max-angle"]),"text-writing-mode":new fa(tt.layout_symbol["text-writing-mode"]),"text-rotate":new pa(tt.layout_symbol["text-rotate"]),"text-padding":new fa(tt.layout_symbol["text-padding"]),"text-keep-upright":new fa(tt.layout_symbol["text-keep-upright"]),"text-transform":new pa(tt.layout_symbol["text-transform"]),"text-offset":new pa(tt.layout_symbol["text-offset"]),"text-allow-overlap":new fa(tt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new fa(tt.layout_symbol["text-ignore-placement"]),"text-optional":new fa(tt.layout_symbol["text-optional"])});var Mp={paint:new ga({"icon-opacity":new pa(tt.paint_symbol["icon-opacity"]),"icon-color":new pa(tt.paint_symbol["icon-color"]),"icon-halo-color":new pa(tt.paint_symbol["icon-halo-color"]),"icon-halo-width":new pa(tt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new pa(tt.paint_symbol["icon-halo-blur"]),"icon-translate":new fa(tt.paint_symbol["icon-translate"]),"icon-translate-anchor":new fa(tt.paint_symbol["icon-translate-anchor"]),"text-opacity":new pa(tt.paint_symbol["text-opacity"]),"text-color":new pa(tt.paint_symbol["text-color"],{runtimeType:ft,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new pa(tt.paint_symbol["text-halo-color"]),"text-halo-width":new pa(tt.paint_symbol["text-halo-width"]),"text-halo-blur":new pa(tt.paint_symbol["text-halo-blur"]),"text-translate":new fa(tt.paint_symbol["text-translate"]),"text-translate-anchor":new fa(tt.paint_symbol["text-translate-anchor"])}),layout:kp};class Cp{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:ut,this.defaultValue=e}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Fi(Cp,"FormatSectionOverride",{omit:["defaultValue"]});class Ip extends Fs{constructor(e){super(e,Mp)}recalculate(e,t){super.recalculate(e,t),"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 n=this.layout.get("text-writing-mode");if(n){const e=[];for(const t of n)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,r){const i=this.layout.get(e).evaluate(t,{},n,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||qr(o.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,(t,n)=>n in e?String(e[n]):"")}(t.properties,i)}createBucket(e){return new Ap(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Mp.paint.overridableProperties){if(!Ip.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),n=new Cp(t),r=new Gr(n,t.property.specification);let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new Zr("source",r):new Wr("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new ha(t.property,i,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&Ip.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const n=e.get("text-field"),r=Mp.paint.properties[t];let i=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(i=!0)};if("constant"===n.value.kind&&n.value.value instanceof Dt)o(n.value.value.sections);else if("source"===n.value.kind){const e=t=>{i||(t instanceof Vt&&jt(t.value)===_t?o(t.value.sections):t instanceof Wt?o(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}getProgramConfiguration(e){return new Is(this,e)}}var Pp={paint:new ga({"background-color":new fa(tt.paint_background["background-color"]),"background-pattern":new fa(tt.paint_background["background-pattern"]),"background-opacity":new fa(tt.paint_background["background-opacity"])})},Op={paint:new ga({"raster-opacity":new fa(tt.paint_raster["raster-opacity"]),"raster-hue-rotate":new fa(tt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new fa(tt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new fa(tt.paint_raster["raster-brightness-max"]),"raster-saturation":new fa(tt.paint_raster["raster-saturation"]),"raster-contrast":new fa(tt.paint_raster["raster-contrast"]),"raster-resampling":new fa(tt.paint_raster["raster-resampling"]),"raster-fade-duration":new fa(tt.paint_raster["raster-fade-duration"])})};class zp extends Fs{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var Lp={paint:new ga({"sky-type":new fa(tt.paint_sky["sky-type"]),"sky-atmosphere-sun":new fa(tt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new fa(tt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new fa(tt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new fa(tt.paint_sky["sky-gradient-radius"]),"sky-gradient":new ma(tt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new fa(tt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new fa(tt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new fa(tt.paint_sky["sky-opacity"])})};function Dp(e,t,n){const r=[0,0,1],i=Ml([]);return Il(i,i,n?-w(e)+Math.PI:w(e)),Cl(i,i,-w(t)),vl(r,r,i),ml(r,r)}const Rp={circle:class extends Fs{constructor(e){super(e,ic)}createBucket(e){return new Uu(e)}queryRadius(e){const t=e;return Qu("circle-radius",this,t)+Qu("circle-stroke-width",this,t)+ec(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=nc(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(t,n)+this.paint.get("circle-stroke-width").evaluate(t,n);return oc(e,r,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new Is(this,e)}},heatmap:class extends Fs{createBucket(e){return new cc(e)}constructor(e){super(e,gc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=_c({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(e){return Qu("heatmap-radius",this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=this.paint.get("heatmap-radius").evaluate(t,n);return oc(e,r,o,a,s,!0,!0,new v(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new Is(this,e)}},hillshade:class extends Fs{constructor(e){super(e,yc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Fs{constructor(e){super(e,ih)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),n=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(e){return new Is(this,e)}recalculate(e,t){super.recalculate(e,t);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new nh(e)}queryRadius(){return ec(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,n,r,i,o){return!e.queryGeometry.isAboveHorizon&&Gu(tc(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends Fs{constructor(e){super(e,jh)}createBucket(e){return new Ch(e)}queryRadius(){return ec(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new Is(this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s,l){const u=nc(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(t,n),h=this.paint.get("fill-extrusion-base").evaluate(t,n),d=[0,0],f=s&&o.elevation,p=o.elevation?o.elevation.exaggeration():1,m=e.tile.getBucket(this);if(f&&m instanceof Ch){const e=m.centroidVertexArray,t=l+1;te.polygon).flat());const g=f?s:null,[_,y]=function(e,t,n,r,i,o,a,s,l,u,c){return"globe"===e.projection.name?function(e,t,n,r,i,o,a,s,l,u,c){const h=[],d=[],f=e.projection.upVectorScale(c,e.center.lat,e.worldSize).metersToTile,p=[0,0,0,1],m=[0,0,0,1],g=(e,t,n,r)=>{e[0]=t,e[1]=n,e[2]=r,e[3]=1},_=Rh();n>0&&(n+=_),r+=_;for(const _ of t){const t=[],y=[];for(const h of _){const d=h.x+i.x,_=h.y+i.y,v=e.projection.projectTilePoint(d,_,c),x=e.projection.upVector(c,h.x,h.y);let b=n,w=r;if(a){const e=Xh(d,_,n,r,a,s,l,u);b+=e.base,w+=e.top}0!==n?g(p,v.x+x[0]*f*b,v.y+x[1]*f*b,v.z+x[2]*f*b):g(p,v.x,v.y,v.z),g(m,v.x+x[0]*f*w,v.y+x[1]*f*w,v.z+x[2]*f*w),yl(p,p,o),yl(m,m,o),t.push(new $h(p[0],p[1],p[2])),y.push(new $h(m[0],m[1],m[2]))}h.push(t),d.push(y)}return[h,d]}(e,t,n,r,i,o,a,s,l,u,c):a?function(e,t,n,r,i,o,a,s,l){const u=[],c=[],h=[0,0,0,1];for(const d of e){const e=[],f=[];for(const u of d){const c=u.x+r.x,d=u.y+r.y,p=Xh(c,d,t,n,o,a,s,l);h[0]=c,h[1]=d,h[2]=p.base,h[3]=1,Al(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new $h(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=d,h[2]=p.top,h[3]=1,Al(h,h,i),h[3]=Math.max(h[3],1e-5);const g=new $h(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),f.push(g)}u.push(e),c.push(f)}return[u,c]}(t,n,r,i,o,a,s,l,u):function(e,t,n,r,i){const o=[],a=[],s=i[8]*t,l=i[9]*t,u=i[10]*t,c=i[11]*t,h=i[8]*n,d=i[9]*n,f=i[10]*n,p=i[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x+r.x,a=o.y+r.y,m=i[0]*t+i[4]*a+i[12],g=i[1]*t+i[5]*a+i[13],_=i[2]*t+i[6]*a+i[14],y=i[3]*t+i[7]*a+i[15],v=m+s,x=g+l,b=_+u,w=Math.max(y+c,1e-5),E=m+h,T=g+d,S=_+f,A=Math.max(y+p,1e-5);e.push(new $h(v/w,x/w,b/w)),n.push(new $h(E/A,T/A,S/A))}o.push(e),a.push(n)}return[o,a]}(t,n,r,i,o)}(o,r,h,c,u,a,g,d,p,o.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(e,t,n){let r=1/0;Gu(n,t)&&(r=Wh(n,t[0]));for(let i=0;i=3)for(let t=0;t{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 jp{constructor(){this.tasks={},this.taskQueue=[],j(["process"],this),this.invoker=new Fp(this.process),this.nextId=0}add(e,t){const n=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:n}){return n=n||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-n:"maybePrepare"===e&&t?400-n:500:200-n:100-n}(t);if(0===r){X();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:e,metadata:t,priority:r,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){X();try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let n=0;n>=1)>1;){const e=n+i>>1,l=r+o>>1;1&t?(i=n,o=r,n=a,r=s):(n=i,r=o,i=a,o=s),a=e,s=l}const l=4*e;Gp[l+0]=n,Gp[l+1]=r,Gp[l+2]=i,Gp[l+3]=o}const qp=new Uint16Array(2178),$p=new Uint8Array(1089),Zp=new Uint16Array(1089);function Wp(e){return 0===e?-.03125:32===e?.03125:0}var Xp=ba([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Hp={type:2,extent:Vs,loadGeometry:()=>[[new v(0,0),new v(8193,0),new v(8193,8193),new v(0,8193),new v(0,0)]]};class Yp{constructor(e,t,n,r,i){this.tileID=e,this.uid=D(),this.uses=0,this.tileSize=t,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)n[t.id]=r}}return n}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Ap){if(this.hasSymbolBuckets=!0,!n)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Ap&&t.hasRTLText){this.hasRTLText=!0,ra.isLoading()||ra.isLoaded()||"deferred"!==ta()||na();break}}this.queryPadding=0;for(const e in this.buckets){const n=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(n))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new Ha}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].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._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=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(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const n=this.buckets[t];n.uploadPending()&&n.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Bp(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Bp(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Bp(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,n,r,i,o,a,s){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:a,transform:o,params:i,tileTransform:this.tileTransform},e,t,n):{}}querySourceFeatures(e,t){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const r=n.loadVTLayers(),i=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[i];if(!o)return;const a=ii(t&&t.filter),{z:s,x:l,y:u}=this.tileID.canonical,c={z:s,x:l,y:u};for(let t=0;te)n=!1;else if(t)if(this.expirationTime=0;e--){const t=4*e,n=Gp[t+0],r=Gp[t+1],i=Gp[t+2],o=Gp[t+3],a=n+i>>1,s=r+o>>1,l=a+s-r,u=s+n-a,c=33*r+n,h=33*o+i,d=33*s+a,f=Math.hypot((qp[2*c+0]+qp[2*h+0])/2-qp[2*d+0],(qp[2*c+1]+qp[2*h+1])/2-qp[2*d+1])>=16;$p[d]=$p[d]||(f?1:0),e<1022&&($p[d]=$p[d]||$p[33*(r+u>>1)+(n+l>>1)]||$p[33*(o+u>>1)+(i+l>>1)])}const i=new Sa,o=new ja;let a=0;function s(e,t){const n=33*t+e;return 0===Zp[n]&&(i.emplaceBack(qp[2*n+0],qp[2*n+1],e*Vs/32,t*Vs/32),Zp[n]=++a),Zp[n]-1}function l(e,t,n,r,i,a){const u=e+n>>1,c=t+r>>1;if(Math.abs(e-i)+Math.abs(t-a)>1&&$p[33*c+u])l(i,a,e,t,u,c),l(n,r,i,a,u,c);else{const l=s(e,t),u=s(n,r),c=s(i,a);o.emplaceBack(l,u,c)}}return l(0,0,32,32,32,0),l(32,32,0,0,0,32),{vertices:i,indices:o}}(this.tileID.canonical,t);r=e.vertices,i=e.indices}else{r=new Sa,i=new ja;for(const{x:e,y:t}of n)r.emplaceBack(e,t,0,0);const e=Xc(r.int16,void 0,4);for(let t=0;t0&&(a=Hs(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,t,i,a,o),this._makeGlobeTileDebugTextBuffer(e,r,t,i,a,o)}_globePoint(e,t,n,r,i,o,a){let s=ru(e,t,n);if(o){const i=1<.5?h=-1:c<-.5&&(h=1);let d=(e/Vs+n.x)/i+h,f=(t/Vs+n.y)/i;d=(d-l)*r._pixelsPerMercatorPixel+l,f=(f-u)*r._pixelsPerMercatorPixel+u;const p=[d*r.worldSize,f*r.worldSize,0];yl(p,p,o),s=Yl(s,p,a)}return yl(s,s,i)}_makeGlobeTileDebugBorderBuffer(e,t,n,r,i,o){const a=new Ea,s=new Za,l=new Ta,u=(e,u,c,h,d)=>{const f=(c-e)/(d-1),p=(h-u)/(d-1),m=a.length;for(let c=0;cu*e+t;for(let e=0;et[a])return null}else{const s=1/r[a];let l=(e[a]-n[a])*s,u=(t[a]-n[a])*s;if(l>u){const e=l;l=u,u=e}if(l>i&&(i=l),uo)return null}return i}function em(e,t,n,r,i,o,a,s,l,u,c){const h=r-e,d=i-t,f=o-n,p=a-e,m=s-t,g=l-n,_=c[1]*g-c[2]*m,y=c[2]*p-c[0]*g,v=c[0]*m-c[1]*p,x=h*_+d*y+f*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=u[0]-e,E=u[1]-t,T=u[2]-n,S=(w*_+E*y+T*v)*b;if(S<0||S>1)return null;const A=E*f-T*d,k=T*h-w*f,M=w*d-E*h,C=(c[0]*A+c[1]*k+c[2]*M)*b;return C<0||S+C>1?null:(p*A+m*k+g*M)*b}function tm(e,t,n){return(e-t)/(n-t)}function nm(e,t,n,r,i,o,a,s,l){const u=1<{const o=r?1:0,a=(e+1)*n-o,s=t*n,l=(t+1)*n-o;i[0]=e*n,i[1]=s,i[2]=a,i[3]=l};let a=new Jp(r);const s=[];for(let t=0;t=1;r/=2){const e=n[n.length-1];a=new Jp(r);for(let t=0;t0;){const{idx:s,t:f,nodex:p,nodey:m,depth:g}=d.pop();if(this.leaves[s]){nm(p,m,g,e,t,n,r,c,h);const s=1<=e[2])return f}continue}let _=0;for(let d=0;d=l[u[n]]&&(u.splice(n,0,d),t=!0);t||(u[_]=d),_++}}for(let e=0;e<_;e++){const t=u[e];d.push({idx:this.childOffsets[s]+t,t:l[t],nodex:(p<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:g+1})}}return null}_addNode(e,t,n){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(n),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,n,r,i){if(1===e[r].isLeaf(t,n))return;this.childOffsets[i]||(this.childOffsets[i]=this.nodeCount);const o=r-1,a=e[o];let s=0,l=0;for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}static pack(e,t){const n=[0,0,0,0],r=um.getUnpackVector(t);let i=Math.floor((e+r[3])/r[2]);return n[2]=i%256,i=Math.floor(i/256),n[1]=i%256,i=Math.floor(i/256),n[0]=i,n}getPixels(){return new mc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,i=t*this.dim+this.dim,o=n*this.dim,a=n*this.dim+this.dim;switch(t){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:o=a-1;break;case 1:a=o+1}const s=-t*this.dim,l=-n*this.dim;for(let t=o;t{this.remove(e,i)},n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const n=e.wrapped().key,r=void 0===t?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const n in this.data)for(const r of this.data[n])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class hm{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}hm.ReadOnly=!1,hm.ReadWrite=!0,hm.disabled=new hm(519,hm.ReadOnly,[0,1]);class dm{constructor(e,t,n,r,i,o){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=o}}dm.disabled=new dm({func:519,mask:0},0,0,7680,7680,7680);class fm{constructor(e,t,n){this.blendFunction=e,this.blendColor=t,this.mask=n}}fm.Replace=[1,0],fm.disabled=new fm(fm.Replace,Ot.transparent,[!1,!1,!1,!1]),fm.unblended=new fm(fm.Replace,Ot.transparent,[!0,!0,!0,!0]),fm.alphaBlended=new fm([1,771],Ot.transparent,[!0,!0,!0,!0]);class pm{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}pm.disabled=new pm(!1,1029,2305),pm.backCCW=new pm(!0,1029,2305),pm.backCW=new pm(!0,1029,2304),pm.frontCW=new pm(!0,1028,2304),pm.frontCCW=new pm(!0,1028,2305);class mm extends et{constructor(e,t,n){super(),this.id=e,this._onlySymbols=n,t.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),t.on("error",()=>{this._sourceErrored=!0}),this._source=t,this._tiles={},this._cache=new cm(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Kp,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const n=this._tiles[t];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return O(this._tiles).map(e=>e.tileID).sort(gm).map(e=>e.key)}getRenderableIds(e){const t=[];for(const n in this._tiles)this._isIdRenderable(+n,e)&&t.push(this._tiles[n]);return e?t.sort((e,t)=>{const n=e.tileID,r=t.tileID,i=new v(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),o=new v(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-r.overscaledZ||o.y-i.y||o.x-i.x}).map(e=>e.tileID.key):t.map(e=>e.tileID).sort(gm).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const n=this._tiles[e];n&&("loading"!==n.state&&(n.state=t),this._loadTile(n,this._tileLoaded.bind(this,n,e,t)))}_tileLoaded(e,t,n,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new Qe(r,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=He.now(),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Je("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,n,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,n,r){for(const i in this._tiles){let o=this._tiles[i];if(r[i]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>n)continue;let a=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(a=e)}let s=a;for(;s.overscaledZ>t;)if(s=s.scaledTo(s.overscaledZ-1),e[s.key]){r[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=t?n:null}for(let n=e.overscaledZ-1;n>=t;n--){const t=e.scaledTo(n),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const n=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,i=Math.floor(n*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,i):i,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const n in this._tiles){const r=this._tiles[n];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(e,t,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;let r;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new Gh(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(r=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter(e=>this._source.hasTile(e)))):r=[];const i=this._updateRetainedTiles(r);if(_m(this._source.type)&&0!==r.length){const e={},t={},n=Object.keys(i);for(const r of n){const n=i[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=He.now())continue;const a=this.findLoadedParent(n,Math.max(n.overscaledZ-mm.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),t[r]=n}const o=r[r.length-1].overscaledZ;for(const e in this._tiles){const n=this._tiles[e];if(i[e]||!n.hasData())continue;let r=n.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&t[r.key]){i[e]=n.tileID;break}}}for(const t in e)i[t]||(this._coveredTiles[t]=!0,i[t]=e[t])}for(const e in i)this._tiles[e].clearFadeHold();const o=function(e,t){const n=[];for(const r in e)r in t||n.push(r);return n}(this._tiles,i);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const n={},r=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),i=e[0].overscaledZ,o=Math.max(i-mm.maxOverzooming,this._source.minzoom),a=Math.max(i+mm.maxUnderzooming,this._source.minzoom),s={};for(const n of e){const e=this._addTile(n);t[n.key]=n,e.hasData()||r=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],n=this.getTile(e);if(n&&n.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let i=e.wasRequested();for(let a=r.overscaledZ-1;a>=o;--a){const o=r.scaledTo(a);if(n[o.key])break;if(n[o.key]=!0,e=this.getTile(o),!e&&i&&(e=this._addTile(o)),e&&(t[o.key]=o,i=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let n,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){n=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(n=this._getLoadedTile(e),n)break;r=e}for(const e of t)this._loadedParentTiles[e]=n}}_addTile(e){let t=this._tiles[e.key];if(t)return t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const n=Boolean(t);if(!n){const n=this.map?this.map.painter:null;t=new Yp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,n,this._isRaster),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,n||this._source.fire(new Je("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const n=t.getExpiryTimeout();n&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},n))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);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(e,t,n){const r=[],i=this.transform;if(!i)return r;const o="globe"===i.projection.name,a=xu(i.center.lng);for(const s in this._tiles){const l=this._tiles[s];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;let u;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(M(a,...ym(e,-1))-a),Math.abs(M(a,...ym(e,1))-a)];u=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(M(a,...ym(e,-1))-a),Math.abs(M(a,...ym(e,0))-a),Math.abs(M(a,...ym(e,1))-a)];u=[t.indexOf(Math.min(...t))-1]}}else u=[0];for(const n of u){const o=e.containsTile(l,i,t,n);o&&r.push(o)}}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(_m(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=He.now())return!0}return!1}setFeatureState(e,t,n){this._state.updateState(e=e||"_geojsonTileLayer",t,n)}removeFeatureState(e,t,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,n)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,n){const r=this._tiles[e];r&&r.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(const n in this._tiles)this._tiles[n].hasDependency(e,t)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(e,t))}_preloadTiles(e,t){if(!this._sourceLoaded){const n=()=>{this._sourceLoaded&&(this._source.off("data",n),this._preloadTiles(e,t))};return void this._source.on("data",n)}const n=new Map,r=Array.isArray(e)?e:[e],i=this.map.painter.terrain,o=this.usedForTerrain&&i?i.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.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 e of t)n.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}P(Array.from(n.values()),(e,t)=>{const n=new Yp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(n,e=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),t(e,n)})},t)}}function gm(e,t){const n=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-n||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function _m(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function ym(e,t){const n=1<=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bh(new qd(this.rawTileData)).layers,this.sourceLayerCoder=new Up(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,n,r){this.loadVTLayers();const i=e.params||{},o=ii(i.filter),a=e.tileResult,s=e.transform,l=a.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,(e,t,n,r)=>Ku(a.bufferedTilespaceGeometry,e,t,n,r));u.sort(wm);let c=null;s.elevation&&u.length>0&&(c=vm.create(s.elevation,this.tileID));const h={};let d;for(let s=0;s(p||(p=Ru(t,this.tileID.canonical,e.tileTransform)),n.queryIntersectsFeature(a,t,r,p,this.z,e.transform,e.pixelPosMatrix,c,i)))}return h}loadMatchingFeature(e,t,n,r,i,o,a,s,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:d}=t,f=this.bucketLayerIDs[c];if(r&&!function(e,t){for(let n=0;n=0)return!0;return!1}(r,f))return;const p=this.sourceLayerCoder.decode(h),m=this.vtLayers[p].feature(u);if(n.needGeometry){const e=Bu(m,!0);if(!n.filter(new ia(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new ia(this.tileID.overscaledZ),m))return;const g=this.getId(m,p);for(let t=0;t{const a=t instanceof da?t.get(o):null;return a&&a.evaluate?a.evaluate(n,r,i):a})}function wm(e,t){return t-e}Fi(xm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Em{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new pc({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const n=this.getKey(e,t);return this.positions[n]}trim(){const e=this.width,t=this.height=B(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,n){const r=[];let i=e.length%2==1?-e[e.length-1]*n:0,o=e[0]*n,a=!0;r.push({left:i,right:o,isDash:a,zeroLength:0===e[0]});let s=e[0];for(let t=1;t1&&(a=e[++o]);const l=Math.abs(s-a.left),u=Math.abs(s-a.right),c=Math.min(l,u);let h;const d=t/n*(r+1);if(a.isDash){const e=r-Math.abs(d);h=Math.sqrt(c*c+e*e)}else h=r-Math.sqrt(c*c+d*d);this.image.data[i+s]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const n=e[t],r=e[t+1];n.zeroLength?e.splice(t,1):r&&r.isDash===n.isDash&&(r.left=n.left,e.splice(t,1))}const n=e[0],r=e[e.length-1];n.isDash===r.isDash&&(n.left=r.left-this.width,r.right=n.right+this.width);const i=this.width*this.nextRow;let o=0,a=e[o];for(let n=0;n1&&(a=e[++o]);const r=Math.abs(n-a.left),s=Math.abs(n-a.right),l=Math.min(r,s);this.image.data[i+n]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128))}}addDash(e,t){const n=this.getKey(e,t);if(this.positions[n])return this.positions[n];const r="round"===t,i=r?7:0,o=2*i+1;if(this.nextRow+o>this.height)return $("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t=t.maxzoom||"none"!==t.visibility&&(Am(e,this.zoom,n),(s[t.id]=t.createBucket({index:a.bucketLayerIDs.length,layers:e,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:n})).populate(d,u,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(e.map(e=>e.id)))}}let h,d,f,p;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},g=()=>{if(h)return i(h);if(d&&f&&p){const e=new Tm(d),t=new Yd(f,p);for(const r in s){const i=s[r];i instanceof Ap?(Am(i.layers,this.zoom,n),jf(i,d,e.positions,f,t.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):i.hasPattern&&(i instanceof td||i instanceof nh||i instanceof Ch)&&(Am(i.layers,this.zoom,n),i.addFeatures(u,this.tileID.canonical,t.patternPositions,n,this.tileTransform))}this.status="done",i(null,{buckets:O(s).filter(e=>!e.isEmpty()),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,glyphMap:this.returnDependencies?d:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?e.positions:null})}},_=N(u.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(_).length?r.send("getGlyphs",{uid:this.uid,stacks:_},(e,t)=>{h||(h=e,d=t,g())},void 0,!1,m):d={};const y=Object.keys(u.iconDependencies);y.length?r.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"icons"},(e,t)=>{h||(h=e,f=t,g())},void 0,!1,m):f={};const v=Object.keys(u.patternDependencies);v.length?r.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"patterns"},(e,t)=>{h||(h=e,p=t,g())},void 0,!1,m):p={},g()}}function Am(e,t,n){const r=new ia(t);for(const t of e)t.recalculate(r,n)}class km{constructor(e){this.entries={},this.scheduler=e}request(e,t,n,r){const i=this.entries[e]=this.entries[e]||{callbacks:[]};if(i.result){const[e,n]=i.result;return this.scheduler?this.scheduler.add(()=>{r(e,n)},t):r(e,n),()=>{}}return i.callbacks.push(r),i.cancel||(i.cancel=n((n,r)=>{i.result=[n,r];for(const e of i.callbacks)this.scheduler?this.scheduler.add(()=>{e(n,r)},t):e(n,r);setTimeout(()=>delete this.entries[e],3e3)})),()=>{i.result||(i.callbacks=i.callbacks.filter(e=>e!==r),i.callbacks.length||(i.cancel(),delete this.entries[e]))}}}function Mm(e,t,n){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},t=>{const r=fe(e.request,(e,r,i,o)=>{e?t(e):r&&t(null,{vectorTile:n?void 0:new bh(new qd(r)),rawData:r,cacheControl:i,expires:o})});return()=>{r.cancel(),t()}},t)}const Cm=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Im{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,n]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=n>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const i=Cm[15&n];if(!i)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new Im(a,o,i,e)}constructor(e,t=64,n=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const i=Cm.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,a=e*this.IndexArrayType.BYTES_PER_ELEMENT,s=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${n}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+a+s),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+a+s,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=t,n}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return function e(t,n,r,i,o,a){if(o-i<=r)return;const s=i+o>>1;(function e(t,n,r,i,o,a){for(;o>i;){if(o-i>600){const s=o-i+1,l=r-i+1,u=Math.log(s),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(s-c)/s)*(l-s/2<0?-1:1);e(t,n,r,Math.max(i,Math.floor(r-l*c/s+h)),Math.min(o,Math.floor(r+(s-l)*c/s+h)),a)}const s=n[2*r+a];let l=i,u=o;for(Pm(t,n,i,r),n[2*o+a]>s&&Pm(t,n,i,o);ls;)u--}n[2*i+a]===s?Pm(t,n,i,u):(u++,Pm(t,n,u,o)),u<=r&&(i=u+1),r<=u&&(o=u-1)}})(t,n,s,i,o,a),e(t,n,r,i,s-1,1-a),e(t,n,r,s+1,o,1-a)}(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,n,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:i,coords:o,nodeSize:a}=this,s=[0,i.length-1,0],l=[];for(;s.length;){const u=s.pop()||0,c=s.pop()||0,h=s.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const s=o[2*a],u=o[2*a+1];s>=e&&s<=n&&u>=t&&u<=r&&l.push(i[a])}continue}const d=h+c>>1,f=o[2*d],p=o[2*d+1];f>=e&&f<=n&&p>=t&&p<=r&&l.push(i[d]),(0===u?e<=f:t<=p)&&(s.push(h),s.push(d-1),s.push(1-u)),(0===u?n>=f:r>=p)&&(s.push(d+1),s.push(c),s.push(1-u))}return l}within(e,t,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:i,nodeSize:o}=this,a=[0,r.length-1,0],s=[],l=n*n;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=o){for(let n=h;n<=c;n++)zm(i[2*n],i[2*n+1],e,t)<=l&&s.push(r[n]);continue}const d=h+c>>1,f=i[2*d],p=i[2*d+1];zm(f,p,e,t)<=l&&s.push(r[d]),(0===u?e-n<=f:t-n<=p)&&(a.push(h),a.push(d-1),a.push(1-u)),(0===u?e+n>=f:t+n>=p)&&(a.push(d+1),a.push(c),a.push(1-u))}return s}}function Pm(e,t,n,r){Om(e,n,r),Om(t,2*n,2*r),Om(t,2*n+1,2*r+1)}function Om(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function zm(e,t,n,r){const i=e-n,o=t-r;return i*i+o*o}e.ARRAY_TYPE=$s,e.AUTH_ERR_MSG=ve,e.Aabb=jl,e.Actor=class{constructor(e,t,r){this.target=e,this.parent=t,this.mapId=r,this.callbacks={},this.cancelCallbacks={},j(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=X()?e:n,this.scheduler=new jp}send(e,t,n,r,i=!1,o){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=o,this.callbacks[a]=n);const s=K(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:e,hasCallback:!!n,targetMapId:r,mustQueue:i,sourceMapId:this.mapId,data:Ni(t,s)},s),{cancel:()=>{n&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,n=t.id;if(n&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[n];delete this.cancelCallbacks[n],e&&e.cancel()}else if(t.mustQueue||X()){const e=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,t),e&&e.metadata||{type:"message"})}else this.processTask(n,t)}processTask(e,t){if(""===t.type){const n=this.callbacks[e];delete this.callbacks[e],n&&(t.error?n(Vi(t.error)):n(null,Vi(t.data)))}else{const n=K(this.globalScope)?void 0:[],r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Ni(t):null,data:Ni(r,n)},n)}:e=>{},i=Vi(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,i,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],i.source)[e[1]](i,r)}else r(new Error("Could not find function "+t.type))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},e.CanonicalTileID=Nh,e.Color=Ot,e.ColorMode=fm,e.CullFaceMode=pm,e.DEMData=um,e.DataConstantProperty=fa,e.DedupedRequest=km,e.DepthMode=hm,e.EXTENT=Vs,e.Elevation=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const n=t.getSource().maxzoom,r=1<1)return t;const i=r.getSource().maxzoom,o=1<{const o=this.getAtTileOffset(e,i.x,i.y),a=r.upVector(e.canonical,i.x,i.y);return fl(a,a,o*r.upVectorScale(e.canonical,t,n).metersToTile),a}}getForTilePoints(e,t,n,r){if(this.isUsingMockSource())return!1;const i=vm.create(this,e,r);return!!i&&(t.forEach(e=>{e[2]=this.exaggeration()*i.getElevationAt(e[0],e[1],n)}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const n=t.dem.tree,r=t.tileID,i=1<{let r=e===o-1?e-2:0===e?e:e-1;return r+=n?24575:0,[r,t]};for(let e=0;ethis._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!xe(e))return e;const n=Ae(e);return n.path="/styles/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!xe(e))return e;const n=Ae(e);return n.path="/fonts/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeSourceURL(e,t,n,r){if(!xe(e))return e;const i=Ae(e);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),n&&i.params.push("language="+n),r&&i.params.push("worldview="+r),this._makeAPIURL(i,this._customAccessToken||t)}normalizeSpriteURL(e,t,n,r){const i=Ae(e);return xe(e)?(i.path=`/styles/v1${i.path}/sprite${t}${n}`,this._makeAPIURL(i,this._customAccessToken||r)):(i.path+=`${t}${n}`,ke(i))}normalizeTileURL(e,t,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!xe(e))return e;const r=Ae(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||n&&"raster"!==r.authority&&512===n?"@2x":""}${a.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${o.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${o.TILE_URL_VERSION}${r.path}`);const i=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||o.ACCESS_TOKEN;return o.REQUIRE_ACCESS_TOKEN&&i&&this._skuToken&&r.params.push("sku="+this._skuToken),this._makeAPIURL(r,i)}canonicalizeTileURL(e,t){const n=Ae(e);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return e;let r="mapbox://";n.path.match(/^\/raster\/v1\//)?r+="raster/"+n.path.replace(`/${o.RASTER_URL_PREFIX}/`,""):r+="tiles/"+n.path.replace(`/${o.TILE_URL_VERSION}/`,"");let i=n.params;return t&&(i=i.filter(e=>!e.match(/^access_token=/))),i.length&&(r+="?"+i.join("&")),r}canonicalizeTileset(e,t){const n=!!t&&xe(t),r=[];for(const t of e.tiles||[])be(t)?r.push(this.canonicalizeTileURL(t,n)):r.push(t);return r}_makeAPIURL(e,t){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=Ae(o.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!o.REQUIRE_ACCESS_TOKEN)return ke(e);if(t=t||o.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error("An API access token is required to use Mapbox GL. "+n);if("s"===t[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+n)}return e.params=e.params.filter(e=>-1===e.indexOf("access_token")),e.params.push("access_token="+(t||"")),ke(e)}},e.ResourceType=ue,e.SegmentVector=Ns,e.SourceCache=mm,e.StencilMode=dm,e.StructArrayLayout1ui2=Za,e.StructArrayLayout2f1f2i16=Ra,e.StructArrayLayout2i4=Ea,e.StructArrayLayout2ui4=$a,e.StructArrayLayout3f12=Fa,e.StructArrayLayout3ui6=ja,e.StructArrayLayout4i8=Sa,e.StructArrayLayout5f20=Ga,e.Texture=Bp,e.Tile=Yp,e.Transitionable=sa,e.Uniform1f=ys,e.Uniform1i=class extends _s{constructor(e){super(e),this.current=0}set(e,t,n){this.fetchUniformLocation(e,t)&&this.current!==n&&(this.current=n,this.gl.uniform1i(this.location,n))}},e.Uniform2f=class extends _s{constructor(e){super(e),this.current=[0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]||(this.current=n,this.gl.uniform2f(this.location,n[0],n[1])))}},e.Uniform3f=class extends _s{constructor(e){super(e),this.current=[0,0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]||(this.current=n,this.gl.uniform3f(this.location,n[0],n[1],n[2])))}},e.Uniform4f=vs,e.UniformColor=xs,e.UniformMatrix2f=class extends _s{constructor(e){super(e),this.current=Es}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix2fv(this.location,!1,n);break}}},e.UniformMatrix3f=class extends _s{constructor(e){super(e),this.current=ws}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix3fv(this.location,!1,n);break}}},e.UniformMatrix4f=class extends _s{constructor(e){super(e),this.current=bs}set(e,t,n){if(this.fetchUniformLocation(e,t)){if(n[12]!==this.current[12]||n[0]!==this.current[0])return this.current=n,void this.gl.uniformMatrix4fv(this.location,!1,n);for(let e=1;e<16;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix4fv(this.location,!1,n);break}}}},e.UnwrappedTileID=Vh,e.ValidationError=Yr,e.VectorTileFeature=wh,e.VectorTileWorkerSource=class extends et{constructor(e,t,n,r,i){super(),this.actor=e,this.layerIndex=t,this.availableImages=n,this.loadVectorData=i||Mm,this.loading={},this.loaded={},this.deduped=new km(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler}loadTile(e,t){const n=e.uid,r=e&&e.request,i=r&&r.collectResourceTiming,o=this.loading[n]=new Sm(e);o.abort=this.loadVectorData(e,(a,s)=>{const l=!this.loading[n];if(delete this.loading[n],l||a||!s)return o.status="done",l||(this.loaded[n]=o),t(a);const u=s.rawData,c={};s.expires&&(c.expires=s.expires),s.cacheControl&&(c.cacheControl=s.cacheControl),o.vectorTile=s.vectorTile||new bh(new qd(u));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,(e,n)=>{if(e||!n)return t(e);const o={};if(i){const e=qe(r);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)))}t(null,z({rawTileData:u.slice(0)},n,c,o))})};this.isSpriteLoaded?h():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):h()}),this.loaded=this.loaded||{},this.loaded[n]=o})}reloadTile(e,t){const n=this.loaded,r=e.uid,i=this;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.enableTerrain=!!e.enableTerrain,o.projection=e.projection,o.tileTransform=Yf(e.tileID.canonical,e.projection);const a=(e,n)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,i.layerIndex,this.availableImages,i.actor,r)),t(e,n)};"parsing"===o.status?o.reloadCallback=a:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}}abortTile(e,t){const n=e.uid,r=this.loading[n];r&&(r.abort&&r.abort(),delete this.loading[n]),t()}removeTile(e,t){const n=this.loaded,r=e.uid;n&&n[r]&&delete n[r],t()}},e.WritingMode=Kd,e.ZoomDependentExpression=Wr,e.add=ll,e.addDynamicAttributes=wp,e.adjoint=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-s*u,e[1]=i*u-r*c,e[2]=r*s-i*a,e[3]=s*l-o*c,e[4]=n*c-i*l,e[5]=i*o-n*s,e[6]=o*u-a*l,e[7]=r*l-n*u,e[8]=n*a-r*o,e},e.asyncAll=P,e.bezier=A,e.bindAll=j,e.boundsAttributes=Xp,e.bufferConvexPolygon=function(e,t){const n=[];for(let r=0;rie&&(e.getActor().send("enforceCacheSizeLimit",re),le=0)},e.calculateGlobeLabelMatrix=function(e,t){const{x:n,y:r}=e.point,i=lu(n,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return Ys(i,i,su(Hl(t)))},e.calculateGlobeMatrix=function(e){const{x:t,y:n}=e.point,{lng:r,lat:i}=e._center;return lu(t,n,e.worldSize,r,i)},e.calculateGlobeMercatorMatrix=function(e){const t=e.pixelsPerMeter,n=t/wu(1,e.center.lat),r=Xs(new Float64Array(16));return Ks(r,r,[e.point.x,e.point.y,0]),Js(r,r,[n,n,t]),Float32Array.from(r)},e.circumferenceAtLatitude=vu,e.clamp=M,e.clearTileCache=function(e){if(!oe())return;const t=n.caches.delete(ee);e&&t.catch(e).then(()=>e())},e.clipLine=vf,e.clone=function(e){var t=new $s(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.clone$1=G,e.collisionCircleLayout=dd,e.config=o,e.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.create=function(){var e=new $s(16);return $s!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.create$1=Zs,e.createExpression=$r,e.createLayout=ba,e.createStyleLayer=function(e){return"custom"===e.type?new zp(e):new Rp[e.type](e)},e.cross=_l,e.degToRad=w,e.distance=function(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])},e.div=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e},e.dot=gl,e.earthRadius=mu,e.ease=k,e.easeCubicInOut=S,e.ecefToLatLng=function([e,t,n]){const r=Math.hypot(e,t,n),i=Math.atan2(e,n),o=.5*Math.PI-Math.acos(-t/r);return new yu(E(i),E(o))},e.emitValidationErrors=zi,e.endsWith=U,e.enforceCacheSizeLimit=function(e){ae(),te&&te.then(t=>{t.keys().then(n=>{for(let r=0;ro&&(r+=(e[i]-o)*(e[i]-o)),t[i]0){const e=180/r;Ws(f,f,[e/u+1,0,0,0,e/c+1,0,-.5*e/h,.5*e/d,1])}return f[2]=l,f[5]=e.x,f[8]=e.y,f},e.getImage=ye,e.getJSON=function(e,t){return de(z(e,{type:"json"}),t)},e.getLatitudinalLod=function(e){const t=Au-5;e=M(e,-t,t)/t*90;const n=Math.pow(Math.abs(Math.sin(w(e))),3);return Math.round(n*(Nl.length-1))},e.getMapSessionAPI=Fe,e.getPerformanceMeasurement=qe,e.getProjection=_p,e.getRTLTextPluginStatus=ta,e.getReferrer=he,e.getTilePoint=function(e,{x:t,y:n},r=0){return new v(((t-r)*e.scale-e.x)*Vs,(n*e.scale-e.y)*Vs)},e.getTileVec3=function(e,t,n=0){return sl(((t.x-n)*e.scale-e.x)*Vs,(t.y*e.scale-e.y)*Vs,Su(t.z,t.y))},e.getVideo=function(e,t){const r=n.document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(let t=0;t{}}},e.globeCenterToScreenPoint=function(e){const t=[0,0,0],n=Xs(new Float64Array(16));return Ys(n,e.pixelMatrix,e.globeMatrix),yl(t,t,n),new v(t[0],t[1])},e.globeDenormalizeECEF=su,e.globeECEFOrigin=function(e,t){const n=[0,0,0];return yl(n,n,au(Hl(t.canonical))),yl(n,n,e),n},e.globeMetersToEcef=$l,e.globeNormalizeECEF=au,e.globePixelsToTileUnits=function(e,t){return Vs/(512*Math.pow(2,e))*iu(Hl(t))},e.globePoleMatrixForTile=function(e,t,n){const r=Xs(new Float64Array(16)),i=(t/(1<0;return 0===r&&!i&&!a&&o},e.identity=Xs,e.identity$1=Ml,e.invert=Hs,e.isFullscreen=function(){return!!n.document.fullscreenElement||!!n.document.webkitFullscreenElement},e.isLngLatBehindGlobe=hu,e.isMapAuthenticated=function(e){return je.has(e)},e.isMapboxURL=xe,e.isSafariWithAntialiasingBug=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!K(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.latFromMercatorY=Tu,e.latLngToECEF=nu,e.len=El,e.length=al,e.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},e.lngFromMercatorX=Eu,e.loadVectorTile=Mm,e.makeRequest=de,e.mapValue=function(e,t,n,r,i){return M((e-t)/(n-t)*(i-r)+r,r,i)},e.mercatorScale=ku,e.mercatorXfromLng=xu,e.mercatorYfromLat=bu,e.mercatorZfromAltitude=wu,e.mul=rl,e.mul$1=wl,e.multiply=Ys,e.multiply$1=Ws,e.multiply$2=cl,e.nextPowerOfTwo=B,e.normalize=ml,e.normalize$1=Pl,e.normalize$2=Sl,e.number=On,e.ortho=function(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=(a+o)*u,e[15]=1,e},e.pbf=wd,e.perspective=function(e,t,n,r,i){var o,a=1/Math.tan(t/2);return e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(e[10]=(i+r)*(o=1/(r-i)),e[14]=2*i*r*o):(e[10]=-1,e[14]=-2*r),e},e.pick=function(e,t){const n={};for(let r=0;r0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!hu(e,new yu(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!hu(e,new yu(e.center.lat,-90))]},e.polygonContainsPoint=Yu,e.polygonIntersectsBox=Ku,e.polygonIntersectsPolygon=Nu,e.polygonizeBounds=function(e,t,n=0,r=!0){const i=new v(n,n),o=e.sub(i),a=t.add(i),s=[o,new v(a.x,o.y),a,new v(o.x,a.y)];return r&&s.push(o.clone()),s},e.posAttributes=Dl,e.postMapLoadEvent=Le,e.postPerformanceEvent=Re,e.postTurnstileEvent=Oe,e.potpack=Xd,e.prevPowerOfTwo=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.radToDeg=E,e.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.registerForPluginStateChange=function(e){return e({pluginStatus:Yo,pluginURL:Ko}),ea.on("pluginStateChange",e),e},e.removeAuthState=function(e){je.delete(e)},e.renderColorRamp=_c,e.resample=Iu,e.rotateX=Qs,e.rotateX$1=Cl,e.rotateY=el,e.rotateY$1=Il,e.rotateZ=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(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[0]=o*i+u*r,e[1]=a*i+c*r,e[2]=s*i+h*r,e[3]=l*i+d*r,e[4]=u*i-o*r,e[5]=c*i-a*r,e[6]=h*i-s*r,e[7]=d*i-l*r,e},e.rotateZ$1=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+i*s,e[1]=i*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e},e.scale=Js,e.scale$1=Tl,e.scale$2=fl,e.scaleAndAdd=pl,e.set=function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},e.setCacheLimits=function(e,t){re=e,ie=t},e.setColumn=function(e,t,n){e[4*t+0]=n[0],e[4*t+1]=n[1],e[4*t+2]=n[2],e[4*t+3]=n[3]},e.setRTLTextPlugin=function(e,t,n=!1){if(Yo===Zo||Yo===Wo||Yo===Xo)throw new Error("setRTLTextPlugin cannot be called multiple times.");Ko=He.resolveURL(e),Yo=Zo,Ho=t,Qo(),n||na()},e.smoothstep=C,e.spec=tt,e.squaredLength=function(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},e.storeAuthState=function(e,t){t?je.add(e):je.delete(e)},e.sub=bl,e.subtract=ul,e.symbolSize=_d,e.tileAABB=function(e,t,n,r,i,o,a,s,l){if("globe"===l.name)return function(e,t,n){const r=t/e.worldSize,i=e.globeMatrix;if(n.z<=1){const e=Hl(n).getCorners();return Jl(e,i,r),jl.fromPoints(e)}const o=Ql(n),a=eu(o);Jl(a,i,r);const s=Number.MAX_VALUE,l=[-s,-s,-s],u=[s,s,s];if(o.contains(e.center)){for(const e of a)hl(u,u,e),dl(l,l,e);l[2]=0;const t=e.point,n=[t.x*r,t.y*r,0];return hl(u,u,n),dl(l,l,n),new jl(u,l)}const c=[i[12]*r,i[13]*r,i[14]*r],h=o.getCenter(),d=M(e.center.lat,-Au,Au),f=M(h.lat,-Au,Au),p=xu(e.center.lng),m=bu(d);let g=p-xu(h.lng);const _=m-bu(f);g>.5?g-=1:g<-.5&&(g+=1);let y=0;Math.abs(g)>Math.abs(_)?y=g>=0?1:3:(y=_>=0?0:2,pl(c,c,[i[4]*r,i[5]*r,i[6]*r],-Math.sin(w(_>=0?o.getSouth():o.getNorth()))*Ul));const v=a[y],x=a[(y+1)%4],b=new Wl(v,x,c),E=[Xl(b,0)||v[0],Xl(b,1)||v[1],Xl(b,2)||v[2]],T=uu(e.zoom);if(T>0){const r=function({x:e,y:t,z:n},r,i,o,a){const s=1/(1<.5?d=-1:f<-.5&&(d=1),l=((l+d)*r-(o*=r))*i+o,u=((u+d)*r-o)*i+o,c=(c*r-(a*=r))*i+a,h=(h*r-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(n,t,e._pixelsPerMercatorPixel,p,m);for(let e=0;eOi(pi(e)),e.validateFog=e=>Oi(Si(e)),e.validateLayer=e=>Oi(yi(e)),e.validateLight=e=>Oi(Ei(e)),e.validateSource=e=>Oi(bi(e)),e.validateStyle=Ci,e.validateTerrain=e=>Oi(Ti(e)),e.values=O,e.vectorTile=uh,e.version=r,e.warnOnce=$,e.window=n,e.wrap=I})),i(0,(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let n="[";for(const r of e)n+=t(r)+",";return n+"]"}let n="{";for(const r of Object.keys(e).sort())n+=`${r}:${t(e[r])},`;return n+"}"}function n(n){let r="";for(const i of e.refProperties)r+="/"+t(n[i]);return r}class r{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,r){for(const n of t)this._layerConfigs[n.id]=n,(this._layers[n.id]=e.createStyleLayer(n)).compileFilter(),this.keyCache[n.id]&&delete this.keyCache[n.id];for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=function(e,t){const r={};for(let i=0;ithis._layers[e.id]),n=t[0];if("none"===n.visibility)continue;const r=n.source||"";let i=this.familiesBySource[r];i||(i=this.familiesBySource[r]={});const o=n.sourceLayer||"_geojsonTileLayer";let a=i[o];a||(a=i[o]=[]),a.push(t)}}}class i{loadTile(t,n){const{uid:r,encoding:i,rawImageData:o,padding:a,buildQuadTree:s}=t,l=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap?this.getImageData(o,a):o;n(null,new e.DEMData(r,l,i,a<1,s))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const n=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),n}}function o(e,t){if(0!==e.length){a(e[0],t);for(var n=1;n=Math.abs(s)?n-l+s:s-l+n,n=l}n+r>=0!=!!t&&e.reverse()}var s=e.getDefaultExportFromCjs((function e(t,n){var r,i=t&&t.type;if("FeatureCollection"===i)for(r=0;r>31}function E(e,t){for(var n=e.loadGeometry(),r=e.type,i=0,o=0,a=n.length,s=0;se},k=Math.fround||(M=new Float32Array(1),e=>(M[0]=+e,M[0]));var M;class C{constructor(e){this.options=Object.assign(Object.create(A),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:n,maxZoom:r}=this.options;t&&console.time("total time");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;const o=[];for(let t=0;t=n;e--){const n=+Date.now();a=this.trees[e]=this._createTree(this._cluster(a,e)),t&&console.log("z%d: %d clusters in %dms",e,a.numItems,+Date.now()-n)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let n=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){const e=this.getClusters([n,r,180,o],t),a=this.getClusters([-180,r,i,o],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(O(n),z(o),O(i),z(r)),l=a.data,u=[];for(const e of s){const t=this.stride*e;u.push(l[t+5]>1?I(l,t,this.clusterProps):this.points[l[t+3]])}return u}getChildren(e){const t=this._getOriginId(e),n=this._getOriginZoom(e),r="No cluster with the specified id.",i=this.trees[n];if(!i)throw new Error(r);const o=i.data;if(t*this.stride>=o.length)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,n-1)),s=i.within(o[t*this.stride],o[t*this.stride+1],a),l=[];for(const t of s){const n=t*this.stride;o[n+4]===e&&l.push(o[n+5]>1?I(o,n,this.clusterProps):this.points[o[n+3]])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,n){const r=[];return this._appendLeaves(r,e,t=t||10,n=n||0,0),r}getTile(e,t,n){const r=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:o,radius:a}=this.options,s=a/o,l=(n-s)/i,u=(n+1+s)/i,c={features:[]};return this._addTileFeatures(r.range((t-s)/i,l,(t+1+s)/i,u),r.data,t,n,i,c),0===t&&this._addTileFeatures(r.range(1-s/i,l,1,u),r.data,i,n,i,c),t===i-1&&this._addTileFeatures(r.range(0,l,s/i,u),r.data,-1,n,i,c),c.features.length?c:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const n=this.getChildren(e);if(t++,1!==n.length)break;e=n[0].properties.cluster_id}return t}_appendLeaves(e,t,n,r,i){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?i+o.point_count<=r?i+=o.point_count:i=this._appendLeaves(e,o.cluster_id,n,r,i):i1;let l,u,c;if(s)l=P(t,e,this.clusterProps),u=t[e],c=t[e+1];else{const n=this.points[t[e+3]];l=n.properties;const[r,i]=n.geometry.coordinates;u=O(r),c=z(i)}const h={type:1,geometry:[[Math.round(this.options.extent*(u*i-n)),Math.round(this.options.extent*(c*i-r))]],tags:l};let d;d=s||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:n,extent:r,reduce:i,minPoints:o}=this.options,a=n/(r*Math.pow(2,t)),s=e.data,l=[],u=this.stride;for(let n=0;nt&&(f+=s[n+5])}if(f>d&&f>=o){let e,o=r*d,a=c*d,p=-1;const m=((n/u|0)<<5)+(t+1)+this.points.length;for(const r of h){const l=r*u;if(s[l+2]<=t)continue;s[l+2]=t;const c=s[l+5];o+=s[l]*c,a+=s[l+1]*c,s[l+4]=m,i&&(e||(e=this._map(s,n,!0),p=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(s,l)))}s[n+4]=m,l.push(o/f,a/f,1/0,m,-1,f),i&&l.push(p)}else{for(let e=0;e1)for(const e of h){const n=e*u;if(!(s[n+2]<=t)){s[n+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,n){if(e[t+5]>1){const r=this.clusterProps[e[t+6]];return n?Object.assign({},r):r}const r=this.points[e[t+3]].properties,i=this.options.map(r);return n&&i===r?Object.assign({},i):i}}function I(e,t,n){return{type:"Feature",id:e[t+3],properties:P(e,t,n),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),L(e[t+1])]}};var r}function P(e,t,n){const r=e[t+5],i=r>=1e4?Math.round(r/1e3)+"k":r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+6],a=-1===o?{}:Object.assign({},n[o]);return Object.assign(a,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:i})}function O(e){return e/360+.5}function z(e){const t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function L(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function D(e,t,n,r,i,o){var a=i-n,s=o-r;if(0!==a||0!==s){var l=((e-n)*a+(t-r)*s)/(a*a+s*s);l>1?(n=i,r=o):l>0&&(n+=a*l,r+=s*l)}return(a=e-n)*a+(s=t-r)*s}function R(e,t,n,r){var i={id:void 0===e?null:e,type:t,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,n=e.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)B(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r0&&(a+=r?(i*u-l*o)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-o,2))),i=l,o=u}var c=t.length-3;t[2]=1,function e(t,n,r,i){for(var o,a=i,s=r-n>>1,l=r-n,u=t[n],c=t[n+1],h=t[r],d=t[r+1],f=n+3;fa)o=f,a=p;else if(p===a){var m=Math.abs(f-s);mi&&(o-n>3&&e(t,n,o,i),t[o+2]=a,r-o>3&&e(t,o,r,i))}(t,0,c,n),t[c+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function N(e,t,n,r){for(var i=0;i1?1:n}function q(e,t,n,r,i,o,a,s){if(r/=t,o>=(n/=t)&&a=r)return null;for(var l=[],u=0;u=n&&p=r)){var m=[];if("Point"===d||"MultiPoint"===d)$(h,m,n,r,i);else if("LineString"===d)Z(h,m,n,r,i,!1,s.lineMetrics);else if("MultiLineString"===d)X(h,m,n,r,i,!1);else if("Polygon"===d)X(h,m,n,r,i,!0);else if("MultiPolygon"===d)for(var g=0;g=n&&a<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function Z(e,t,n,r,i,o,a){for(var s,l,u=W(e),c=0===i?Y:K,h=e.start,d=0;dn&&(l=c(u,f,p,g,_,n),a&&(u.start=h+s*l)):y>r?v=n&&(l=c(u,f,p,g,_,n),x=!0),v>r&&y<=r&&(l=c(u,f,p,g,_,r),x=!0),!o&&x&&(a&&(u.end=h+s*l),t.push(u),u=W(e)),a&&(h+=s)}var b=e.length-3;f=e[b],p=e[b+1],m=e[b+2],(y=0===i?f:p)>=n&&y<=r&&H(u,f,p,m),b=u.length-3,o&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&H(u,u[0],u[1],u[2]),u.length&&t.push(u)}function W(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function X(e,t,n,r,i,o){for(var a=0;aa.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function re(e,t,n,r){var i=t.geometry,o=t.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s0&&t.size<(i?a:r))n.numPoints+=t.length/3;else{for(var s=[],l=0;la)&&(n.numSimplified++,s.push(t[l]),s.push(t[l+1])),n.numPoints++;i&&function(e,t){for(var n=0,r=0,i=e.length,o=i-2;r0===t)for(r=0,i=e.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(e,t){var n=[];if("FeatureCollection"===e.type)for(var r=0;r1&&console.time("creation"),d=this.tiles[h]=ne(e,t,n,r,l),this.tileCoords.push({z:t,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,n,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(d.source=e,i){if(t===l.maxZoom||t===i)continue;var p=1<1&&console.time("clipping");var m,g,_,y,v,x,b=.5*l.buffer/l.extent,w=.5-b,E=.5+b,T=1+b;m=g=_=y=null,v=q(e,c,n-b,n+E,0,d.minX,d.maxX,l),x=q(e,c,n+w,n+T,0,d.minX,d.maxX,l),e=null,v&&(m=q(v,c,r-b,r+E,1,d.minY,d.maxY,l),g=q(v,c,r+w,r+T,1,d.minY,d.maxY,l),v=null),x&&(_=q(x,c,r-b,r+E,1,d.minY,d.maxY,l),y=q(x,c,r+w,r+T,1,d.minY,d.maxY,l),x=null),u>1&&console.timeEnd("clipping"),s.push(m||[],t+1,2*n,2*r),s.push(g||[],t+1,2*n,2*r+1),s.push(_||[],t+1,2*n+1,2*r),s.push(y||[],t+1,2*n+1,2*r+1)}}},oe.prototype.getTile=function(e,t,n){var r=this.options,i=r.extent,o=r.debug;if(e<0||e>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",e,t,n);for(var l,u=e,c=t,h=n;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[ae(u,c,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",u,c,h),o>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,e,t,n),o>1&&console.timeEnd("drilling down"),this.tiles[s]?ee(this.tiles[s],i):null):null};class le extends e.VectorTileWorkerSource{constructor(e,t,n,r,i){super(e,t,n,r,se),i&&(this.loadGeoJSON=i)}loadData(t,n){const r=t&&t.request,i=r&&r.collectResourceTiming;this.loadGeoJSON(t,(o,a)=>{if(o||!a)return n(o);if("object"!=typeof a)return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{s(a,!0);try{if(t.filter){const n=e.createExpression(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));const r=a.features.filter(e=>n.value.evaluate({zoom:0},e));a={type:"FeatureCollection",features:r}}this._geoJSONIndex=t.cluster?new C(function({superclusterOptions:t,clusterProperties:n}){if(!n||!t)return t;const r={},i={},o={accumulated:null,zoom:0},a={properties:null},s=Object.keys(n);for(const t of s){const[o,a]=n[t],s=e.createExpression(a),l=e.createExpression("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=s.value,i[t]=l.value}return t.map=e=>{a.properties=e;const t={};for(const e of s)t[e]=r[e].evaluate(o,a);return t},t.reduce=(e,t)=>{a.properties=t;for(const t of s)o.accumulated=e[t],e[t]=i[t].evaluate(o,a)},t}(t)).load(a.features):function(e,t){return new oe(e,t)}(a,t.geojsonVtOptions)}catch(o){return n(o)}this.loaded={};const l={};if(i){const n=e.getPerformanceMeasurement(r);n&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(n)))}n(null,l)}})}reloadTile(e,t){const n=this.loaded;return n&&n[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,n){if(t.request)e.getJSON(t.request,n);else{if("string"!=typeof t.data)return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(t.data))}catch(e){return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class ue{constructor(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:"mercator"}),this.workerSourceTypes={vector:e.VectorTileWorkerSource,geojson:le},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.plugin.isParsed())throw new Error("RTL text plugin already registered.");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,n){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],n()}checkIfReady(e,t,n){n()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,n){this.isSpriteLoaded[t]=n;for(const r in this.workerSources[t]){const i=this.workerSources[t][r];for(const t in i)i[t]instanceof e.VectorTileWorkerSource&&(i[t].isSpriteLoaded=n,i[t].fire(new e.Event("isSpriteLoaded")))}}setImages(e,t,n){this.availableImages[e]=t;for(const n in this.workerSources[e]){const r=this.workerSources[e][n];for(const e in r)r[e].availableImages=t}n()}enableTerrain(e,t,n){this.terrain=t,n()}setProjection(t,n){this.projections[t]=e.getProjection(n)}setLayers(e,t,n){this.getLayerIndex(e).replace(t),n()}updateLayers(e,t,n){this.getLayerIndex(e).update(t.layers,t.removedIds),n()}loadTile(t,n,r){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).loadTile(i,r)}loadDEMTile(t,n,r){const i=this.enableTerrain?e.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(t,n.source).loadTile(i,r)}reloadTile(t,n,r){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).reloadTile(i,r)}abortTile(e,t,n){this.getWorkerSource(e,t.type,t.source).abortTile(t,n)}removeTile(e,t,n){this.getWorkerSource(e,t.type,t.source).removeTile(t,n)}removeSource(e,t,n){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const r=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,n):n()}loadWorkerSource(e,t,n){try{this.self.importScripts(t.url),n()}catch(e){n(e.toString())}}syncRTLPluginState(t,n,r){try{e.plugin.setState(n);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const n=e.plugin.isParsed();r(n?void 0:new Error("RTL Text Plugin failed to import scripts from "+t),n)}}catch(e){r(e.toString())}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new r),t}getWorkerSource(e,t,n){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][n]){const r={send:(t,n,r,i,o,a)=>{this.actor.send(t,n,r,e,o,a)},scheduler:this.actor.scheduler};this.workerSources[e][t][n]=new this.workerSourceTypes[t](r,this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])}return this.workerSources[e][t][n]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new i),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,n){e.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(e,t,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new ue(self)),ue})),i(0,(function(e){function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let r=0;r{e.window.removeEventListener("click",d,!0)},0)}function p(e,t){const n=e.getBoundingClientRect();return _(e,n,t)}function m(e,t){const n=e.getBoundingClientRect(),r=[];for(let i=0;i=0?0:t.button}function _(t,n,r){const i=t.offsetWidth===n.width?1:t.offsetWidth/n.width;return new e.Point((r.clientX-n.left)*i,(r.clientY-n.top)*i)}function y(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*o-i*r;return a?(e[0]=o*(a=1/a),e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e):null}function v(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class x extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(t,n){let r=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(n.content,n)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let n=0;for(const r of e){if(r[0]{this.ready=!0})}broadcast(t,n,r){e.asyncAll(this.actors,(e,r)=>{e.send(t,n,r)},r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}function I(t,n,r){return n*(e.EXTENT/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}C.Actor=e.Actor;class P{constructor(e,t,n,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=n,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(t,n){let r,i;if(t instanceof e.Point||"number"==typeof t[0]){const o=e.Point.convert(t);r=[o],i=n.isPointAboveHorizon(o)}else{const o=e.Point.convert(t[0]),a=e.Point.convert(t[1]);r=[o,a],i=e.polygonizeBounds(o,a).every(e=>n.isPointAboveHorizon(e))}return new P(r,n.getCameraPoint(),i,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.Point(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=r.x?i[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(i[3]=this.cameraPoint)),e.bufferConvexPolygon(i,t)}bufferedCameraGeometryGlobe(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.Point(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,r,t),o=this.cameraPoint.clone();switch(3*((o.y>n.y)+(o.y>r.y))+((o.x>n.x)+(o.x>r.x))){case 0:i[0]=o,i[4]=o.clone();break;case 1:i.splice(1,0,o);break;case 2:i[1]=o;break;case 3:i.splice(4,0,o);break;case 5:i.splice(2,0,o);break;case 6:i[3]=o;break;case 7:i.splice(3,0,o);break;case 8:i[2]=o}return i}containsTile(t,n,r,i=0){const o=t.queryPadding/n._pixelsPerMercatorPixel+1,a=r?this._bufferedCameraMercator(o,n):this._bufferedScreenMercator(o,n);let s=t.tileID.wrap+(a.unwrapped?i:0);const l=a.polygon.map(n=>e.getTilePoint(t.tileTransform,n,s));if(!e.polygonIntersectsBox(l,0,0,e.EXTENT,e.EXTENT))return;s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?i:0);const u=this.screenGeometryMercator.polygon.map(n=>e.getTileVec3(t.tileTransform,n,s)),c=u.map(t=>new e.Point(t[0],t[1])),h=n.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),d=e.getTileVec3(t.tileTransform,h,s),f=u.map(t=>{const n=e.sub(t,t,d);return e.normalize(n,n),new e.Ray(d,n)}),p=I(t,1,n.zoom)*n._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:c,tilespaceRays:f,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.getBounds(l),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var m}_bufferedScreenMercator(e,t){const n=L(e);if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[n]=r,r}}_bufferedCameraMercator(e,t){const n=L(e);if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[n]=r,r}}_projectAndResample(t,n){const r=function(t,n){const r=e.multiply([],n.pixelMatrix,n.globeMatrix),i=[0,-e.GLOBE_RADIUS,0,1],o=[0,e.GLOBE_RADIUS,0,1],a=[0,0,0,1];e.transformMat4$1(i,i,r),e.transformMat4$1(o,o,r),e.transformMat4$1(a,a,r);const s=new e.Point(i[0]/i[3],i[1]/i[3]),l=new e.Point(o[0]/o[3],o[1]/o[3]),u=e.polygonContainsPoint(t,s)&&i[3]1?O(t.slice(0,d),n):[],m=dnew e.Point(z(t.x),t.y)),m=m.map(t=>new e.Point(z(t.x),t.y));const g=[...p];0===g.length&&g.push(m[m.length-1]);const _=e.number(g[g.length-1].y,(0===m.length?p[0]:m[0]).y,f);let y;return y=u?[new e.Point(0,_),new e.Point(0,0),new e.Point(1,0),new e.Point(1,_)]:[new e.Point(1,_),new e.Point(1,1),new e.Point(0,1),new e.Point(0,_)],g.push(...y),0===m.length?g.push(p[0]):g.push(...m),{polygon:g.map(t=>new e.MercatorCoordinate(t.x,t.y)),unwrapped:!1}}(t,n);if(r)return r;const i=function(t,n){let r=!1,i=-1/0,o=0;for(let e=0;ei&&(i=t[e].x,o=e);for(let e=0;e.5&&(i.x{e.x-=1}),{polygon:t,unwrapped:r}}(O(t,n).map(t=>new e.Point(z(t.x),t.y)),n);return{polygon:i.polygon.map(t=>new e.MercatorCoordinate(t.x,t.y)),unwrapped:i.unwrapped}}}function O(t,n){return e.resample(t,e=>{const t=n.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function z(e){return e<0?1+e%1:e%1}function L(e){return 100*e|0}function D(t,n,r,i,o){const a=function(r,i){if(r)return o(r);if(i){t.url&&i.tiles&&t.tiles&&delete t.tiles;const r=e.pick(e.extend(i,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);i.vector_layers&&(r.vectorLayers=i.vector_layers,r.vectorLayerIds=r.vectorLayers.map(e=>e.id)),r.tiles=n.canonicalizeTileset(r,t.url),o(null,r)}};return t.url?e.getJSON(n.transformRequest(n.normalizeSourceURL(t.url,null,r,i),e.ResourceType.Source),a):e.exported.frame(()=>a(null,t))}class R{constructor(t,n,r){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=r||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),r=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*n),i=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*n),o=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*n),a=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*n);return t.x>=r&&t.x=i&&t.y{this._tileJSONRequest=null,this._loaded=!0,i?(n&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: "+n),r&&2!==r.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: "+r),this.fire(new e.ErrorEvent(i))):o&&(e.extend(this,o),o.bounds&&(this.tileBounds=new R(o.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.extend({},this._options)}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(r,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(i.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=n:t.request=t.actor.send("reloadTile",i,o.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",i,o.bind(this),void 0,!0);else{const n=e.loadVectorTile.call({deduped:this._deduped},i,(e,n)=>{e||!n?o.call(this,e):(i.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},t.actor&&t.actor.send("loadTile",i,o.bind(this),void 0,!0))},!0);t.request={cancel:n}}function o(r,i){return delete t.request,t.aborted?n(null):r&&404!==r.status?n(r):(i&&i.resourceTiming&&(t.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&i&&t.setExpiryData(i),t.loadVectorData(i,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Ae extends e.Evented{constructor(t,n,r,i){super(),this.id=t,this.dispatcher=r,this.setEventedParent(i),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.extend({type:"raster"},n),e.extend(this,e.pick(n,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=D(this._options,this.map._requestManager,null,null,(n,r)=>{this._tileJSONRequest=null,this._loaded=!0,n?this.fire(new e.ErrorEvent(n)):r&&(e.extend(this,r),r.bounds&&(this.tileBounds=new R(r.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(r.tiles),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const r=e.exported.devicePixelRatio>=2,i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(i,e.ResourceType.Tile),(r,i,o,a)=>(delete t.request,t.aborted?(t.state="unloaded",n(null)):r?(t.state="errored",n(r)):i?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:a}),t.setTexture(i,this.map.painter),t.state="loaded",e.cacheEntryPossiblyAdded(this.dispatcher),void n(null)):n(null)))}static loadTileData(e,t,n){e.setTexture(t,n)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function ke(t,n,r,i,o,a,s,l){const u=[t,r,o,n,i,a,1,1,1],c=[s,l,1],h=e.adjoint([],u),[d,f,p]=e.transformMat3(c,c,e.transpose(h,h));return e.multiply$1(u,[d,0,0,0,f,0,0,0,p],u)}class Me extends e.Evented{constructor(e,t,n,r){super(),this.id=e,this.dispatcher=n,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(t,n){this._loaded=n||!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),(n,r)=>{if(this._imageRequest=null,this._loaded=!0,n)this.fire(new e.ErrorEvent(n));else if(r){const{HTMLImageElement:n}=e.window;this.image=r instanceof n?e.exported.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}})}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const n=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let n=1/0,r=1/0,i=-1/0,o=-1/0;for(const e of t)n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x),o=Math.max(o,e.y);const a=Math.max(i-n,o-r),s=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),l=Math.pow(2,s);return new e.CanonicalTileID(s,Math.floor((n+i)/2*l),Math.floor((r+o)/2*l))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const n=e.tileTransform(this.tileID,this.map.transform.projection),[r,i,o,a]=this.coordinates.map(t=>{const r=n.projection.project(t[0],t[1]);return e.getTilePoint(n,r)._round()});this.perspectiveTransform=function(t,n,r,i,o,a,s,l,u,c){const h=ke(0,0,t,0,0,n,t,n),d=ke(r,i,o,a,s,l,u,c);return e.multiply$1(d,e.adjoint(h,h),d),[d[6]/d[8]*t/e.EXTENT,d[7]/d[8]*n/e.EXTENT]}(this.width,this.height,r.x,r.y,i.x,i.y,a.x,a.y,o.x,o.y);const s=this._boundsArray=new e.StructArrayLayout4i8;s.emplaceBack(r.x,r.y,0,0),s.emplaceBack(i.x,i.y,e.EXTENT,0),s.emplaceBack(a.x,a.y,0,e.EXTENT),s.emplaceBack(o.x,o.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(s,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,n=t.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Ce={vector:Se,raster:Ae,"raster-dem":class extends Ae{constructor(t,n,r,i){super(t,n,r,i),this.type="raster-dem",this.maxzoom=22,this._options=e.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(e,r){e&&(t.state="errored",n(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",n(null))}t.request=e.getImage(this.map._requestManager.transformRequest(r,e.ResourceType.Tile),function(r,o,a,s){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(r)t.state="errored",n(r);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:s});const n=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap&&(null==ae&&(ae=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.window.createImageBitmap),ae),r=1-(o.width-e.prevPowerOfTwo(o.width))/2;r<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=n?o:e.exported.getImageData(o,r),u={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:r};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",u,i.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const n=t.canonical,r=Math.pow(2,n.z),i=(n.x-1+r)%r,o=0===n.x?t.wrap-1:t.wrap,a=(n.x+1+r)%r,s=n.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,o,n.z,i,n.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,n.z,a,n.y).key]={backfilled:!1},n.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,o,n.z,i,n.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,n.z,a,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(t.resourceTiming=n.resourceTiming[this.id]),this.fire(new e.Event("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(t,n){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(r,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(e,i)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):e?n(e):(t.loadVectorData(i,this.map.painter,"reloadTile"===r),n(null))),void 0,"loadTile"===r)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Me{constructor(e,t,n,r){super(e,t,n,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,e.ResourceType.Source).url);e.getVideo(this.urls,(t,n)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):n&&(this.video=n,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(t){if(this.video){const n=this.video.seekable;tn.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError("sources."+this.id,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Me,canvas:class extends Me{constructor(t,n,r,i){super(t,n,r,i),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.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(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const n=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(n,this.canvas,n.gl.RGBA,{premultiply:!0}),this._prepareData(n)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.Evented{constructor(t,n,r,i){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=n,this.setEventedParent(i),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new R(this._implementation.bounds,this.minzoom,this.maxzoom)),n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(n,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:n,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:n,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const{x:r,y:i,z:o}=t.tileID.canonical,a=new e.window.AbortController;t.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:o},{signal:a.signal})).then(function(r){return delete t.request,t.aborted?(t.state="unloaded",n(null)):void 0===r?(t.state="errored",n(null)):null===r?(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",n(null)):function(t){return t instanceof e.window.ImageData||t instanceof e.window.HTMLCanvasElement||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLImageElement}(r)?(this.loadTileData(t,r),t.state="loaded",void n(null)):(t.state="errored",n(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(e=>{20!==e.code&&(t.state="errored",n(e))}),t.request.cancel=()=>a.abort()}loadTileData(e,t){Ae.loadTileData(e,t,this._map.painter)}unloadTileData(e){Ae.unloadTileData(e,this._map.painter)}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:n,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:n,z:r})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Ie=function(t,n,r,i){const o=new Ce[n.type](t,n,r,i);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.bindAll(["load","abort","unload","serialize","prepare"],o),o};function Pe(t,n){const r=e.identity([]);return e.scale(r,r,[.5*t.width,.5*-t.height,1]),e.translate(r,r,[1,-1,0]),e.multiply(r,r,t.calculateProjMatrix(n.toUnwrapped())),Float32Array.from(r)}function Oe(e,t,n,r,i,o,a,s=!1){const l=e.tilesIn(r,a,s);l.sort(Le);const u=[];for(const r of l)u.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,n,e._state,r,i,o,Pe(e.transform,r.tile.tileID),s)});const c=function(e){const t={},n={};for(const r of e){const e=r.queryResults,i=r.wrappedTileID,o=n[i]=n[i]||{};for(const n in e){const r=e[n],i=o[n]=o[n]||{},a=t[n]=t[n]||[];for(const e of r)i[e.featureIndex]||(i[e.featureIndex]=!0,a.push(e))}}return t}(u);for(const t in c)c[t].forEach(t=>{const n=t.feature,r=n.layer;r&&"background"!==r.type&&"sky"!==r.type&&(n.source=r.source,r["source-layer"]&&(n.sourceLayer=r["source-layer"]),n.state=void 0!==n.id?e.getFeatureState(r["source-layer"],n.id):{})});return c}function ze(e,t){const n=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],i={};for(let e=0;e{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Re]}numActive(){return Object.keys(this.active).length}}let Fe;function je(){return Fe||(Fe=new Be),Fe}function Ue(t,n){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return e.refProperties.forEach(e=>{e in n&&(r[e]=n[e])}),r}function Ne(e){e=e.slice();const t=Object.create(null);for(let n=0;n0?(i-a)/s:0;return this.points[o].mult(1-l).add(this.points[n].mult(l))}}class Ke{constructor(e,t,n){const r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let e=0;ethis.width||r<0||t>this.height)return!i&&[];const a=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(let e=0;e0:a}_queryCircle(e,t,n,r,i){const o=e-n,a=e+n,s=t-n,l=t+n;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];const u=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,u,{hitTest:r,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}},i),r?u.length>0:u}query(e,t,n,r,i){return this._query(e,t,n,r,!1,i)}hitTest(e,t,n,r,i){return this._query(e,t,n,r,!0,i)}hitTestCircle(e,t,n,r){return this._queryCircle(e,t,n,!0,r)}_queryCell(e,t,n,r,i,o,a,s){const l=a.seenUids,u=this.boxCells[i];if(null!==u){const i=this.bboxes;for(const c of u)if(!l.box[c]){l.box[c]=!0;const u=4*c;if(e<=i[u+2]&&t<=i[u+3]&&n>=i[u+0]&&r>=i[u+1]&&(!s||s(this.boxKeys[c]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[c],x1:i[u],y1:i[u+1],x2:i[u+2],y2:i[u+3]})}}}const c=this.circleCells[i];if(null!==c){const i=this.circles;for(const u of c)if(!l.circle[u]){l.circle[u]=!0;const c=3*u;if(this._circleAndRectCollide(i[c],i[c+1],i[c+2],e,t,n,r)&&(!s||s(this.circleKeys[u]))){if(a.hitTest)return o.push(!0),!0;{const e=i[c],t=i[c+1],n=i[c+2];o.push({key:this.circleKeys[u],x1:e-n,y1:t-n,x2:e+n,y2:t+n})}}}}}_queryCellCircle(e,t,n,r,i,o,a,s){const l=a.circle,u=a.seenUids,c=this.boxCells[i];if(null!==c){const e=this.bboxes;for(const t of c)if(!u.box[t]){u.box[t]=!0;const n=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!s||s(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[i];if(null!==h){const e=this.circles;for(const t of h)if(!u.circle[t]){u.circle[t]=!0;const n=3*t;if(this._circlesCollide(e[n],e[n+1],e[n+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,n,r,i,o,a,s){const l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),c=this._convertToXCellCoord(n),h=this._convertToYCellCoord(r);for(let d=l;d<=c;d++)for(let l=u;l<=h;l++)if(i.call(this,e,t,n,r,this.xCellCount*l+d,o,a,s))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,n,r,i,o){const a=r-e,s=i-t,l=n+o;return l*l>a*a+s*s}_circleAndRectCollide(e,t,n,r,i,o,a){const s=(o-r)/2,l=Math.abs(e-(r+s));if(l>s+n)return!1;const u=(a-i)/2,c=Math.abs(t-(i+u));if(c>u+n)return!1;if(l<=s||c<=u)return!0;const h=l-s,d=c-u;return h*h+d*d<=n*n}}const Je=0,Qe=1,et=2,tt=Math.tan(85*Math.PI/180);function nt(t,n,r,i,o,a,s){const l=e.create();if(r)if("globe"===a.name){const t=e.calculateGlobeLabelMatrix(o,n);e.multiply(l,l,t)}else{const t=y([],s);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],i||e.rotateZ(l,l,o.angle)}else e.multiply(l,o.labelPlaneMatrix,t);return l}function rt(e,t,n,r,i,o,a){const s=nt(e,t,n,r,i,o,a);return"globe"===o.name&&n||(s[2]=s[6]=s[10]=s[14]=0),s}function it(t,n,r,i,o,a,s){if(r){if("globe"===a.name){const l=nt(t,n,r,i,o,a,s);return e.invert(l,l),e.multiply(l,t,l),l}{const n=e.clone(t),r=e.identity([]);return r[0]=s[0],r[1]=s[1],r[4]=s[2],r[5]=s[3],e.multiply(n,n,r),i||e.rotateZ(n,n,-o.angle),n}}return o.glCoordMatrix}function ot(t,n,r,i){const o=[t,n,r,1];r?e.transformMat4$1(o,o,i):gt(o,o,i);const a=o[3];return o[0]/=a,o[1]/=a,o[2]/=a,o}function at(e,t){return Math.min(.5+e/t*.5,1.5)}function st(e,t){const n=e[0]/e[3],r=e[1]/e[3];return n>=-t[0]&&n<=t[0]&&r>=-t[1]&&r<=t[1]}function lt(t,n,r,i,o,a,s,l,u,c){const h=r.transform,d=i?t.textSizeData:t.iconSizeData,f=e.evaluateSizeForZoom(d,r.transform.zoom),p="globe"===h.projection.name,m=[256/r.width*2+1,256/r.height*2+1],g=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let _=null;p&&(_=i?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=r.transform.width/r.transform.height;let b,w=!1;for(let i=0;iMath.abs(r)?{useVertical:!0}:t===e.WritingMode.vertical?i>0?{needsFlipping:!0}:null:n!==Je&&function(e,t){return 0===e||Math.abs(t/e)>tt}(r,i)?n===Qe?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function ht(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_,y,v){const x=n/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x,{lineStartIndex:E,glyphStartIndex:T,numGlyphs:S,segment:A,writingMode:k,flipState:M}=t,C=E+t.lineLength,I=t=>{if(h){const[n,r,i]=t.up,o=c.length;e.updateGlobeVertexNormal(h,o+0,n,r,i),e.updateGlobeVertexNormal(h,o+1,n,r,i),e.updateGlobeVertexNormal(h,o+2,n,r,i),e.updateGlobeVertexNormal(h,o+3,n,r,i)}const[n,r,i]=t.point;e.addDynamicAttributes(c,n,r,i,t.angle)};if(S>1){const e=ut(x,l,b,w,r,d,f,t,u,a,p,g,!1,_,y,v);if(!e)return{notEnoughRoom:!0};if(i&&!r){let[n,r,i]=e.first.point,[o,a,l]=e.last.point;[n,r]=ot(n,r,i,s),[o,a]=ot(o,a,l,s);const u=ct(k,M,(o-n)*m,a-r);if(t.flipState=u&&u.needsFlipping?Qe:et,u)return u}I(e.first);for(let e=T+1;e0?a:ft(f,i,n,1,o,void 0,_,y.canonical),l=ct(k,M,(s[0]-n[0])*m,s[1]-n[1]);if(t.flipState=l&&l.needsFlipping?Qe:et,l)return l}const n=pt(x*l.getoffsetX(T),b,w,r,d,f,A,E,C,u,a,p,g,!1,!1,_,y,v);if(!n)return{notEnoughRoom:!0};I(n)}return{}}function dt(e,t,n,r,i){const{x:o,y:a,z:s}=r.projectTilePoint(e.x,e.y,t);if(!i)return ot(o,a,s,n);const[l,u,c]=i(e);return ot(o+l,a+u,s+c,n)}function ft(t,n,r,i,o,a,s,l){const u=dt(t.sub(n)._unit()._add(t),l,o,s,a);return e.sub(u,r,u),e.normalize(u,u),e.scaleAndAdd(u,r,u,i)}function pt(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_,y){const v=i?t-n:t+n;let x=v>0?1:-1,b=0;i&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=l+s+(x>0?0:1)|0,E=o,T=o,S=0,A=0;const k=Math.abs(v),M=[],C=[];let I=a,P=I;const O=()=>ft(P,I,T,k-S+1,h,f,g,_.canonical);for(;S+A<=k;){if(w+=x,w=u)return null;if(T=E,P=I,M.push(T),p&&C.push(P),I=new e.Point(c.getx(w),c.gety(w)),E=d[w],!E){const e=dt(I,_.canonical,h,g,f);E=e[3]>0?d[w]=e:O()}S+=A,A=e.distance(T,E)}m&&f&&(d[w]&&(E=O(),A=e.distance(T,E)),d[w]=E);const z=(k-S)/A,L=I.sub(P)._mult(z)._add(P),D=e.sub([],E,T),R=e.scaleAndAdd([],T,D,z);let B=[0,0,1],F=D[0],j=D[1];if(y&&(B=g.upVector(_.canonical,L.x,L.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],n=e.cross([],B,t);e.normalize(t,t),e.normalize(n,n),F=e.dot(D,t),j=e.dot(D,n)}if(r){const t=e.cross([],B,D);e.normalize(t,t),e.scaleAndAdd(R,R,t,r*x)}const U=b+Math.atan2(j,F);return M.push(R),p&&C.push(L),{point:R,angle:U,path:M,tilePath:C,up:B}}function mt(e,t){const n=t.length,r=n+4*e;t.resize(r),t.float32.fill(-1/0,4*n,4*r)}function gt(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e[3]=n[3]*r+n[7]*i+n[15],e}const _t=100;class yt{constructor(e,t,n=new Ke(e.width+200,e.height+200,25),r=new Ke(e.width+200,e.height+200,25)){this.transform=e,this.grid=n,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+_t,this.screenBottomBoundary=e.height+_t,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,n,r,i,o,a,s){let l=n.projectedAnchorX,u=n.projectedAnchorY,c=n.projectedAnchorZ;const h=n.elevation,d=n.tileID,f=e.getProjection();if(h&&d){const[e,t,r]=f.upVector(d.canonical,n.tileAnchorX,n.tileAnchorY),i=f.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*h*i,u+=t*h*i,c+=r*h*i}const p=this.projectAndGetPerspectiveRatio(a,l,u,c,n.tileID,"globe"===f.name||!!h||this.transform.pitch>0,f),m=o*p.perspectiveRatio,g=(n.x1*t+r.x-n.padding)*m+p.point.x,_=(n.y1*t+r.y-n.padding)*m+p.point.y,y=(n.x2*t+r.x+n.padding)*m+p.point.x,v=(n.y2*t+r.y+n.padding)*m+p.point.y,x=p.perspectiveRatio<=.55||p.occluded;return!this.isInsideGrid(g,_,y,v)||!i&&this.grid.hitTest(g,_,y,v,s)||x?{box:[],offscreen:!1,occluded:p.occluded}:{box:[g,_,y,v],offscreen:this.isOffscreen(g,_,y,v),occluded:!1}}placeCollisionCircles(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m){const g=[],_=this.transform.elevation,y=t.getProjection(),v=_?_.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,x=new e.Point(r.tileAnchorX,r.tileAnchorY);let{x:b,y:w,z:E}=y.projectTilePoint(x.x,x.y,m.canonical);if(v){const[e,t,n]=v(x);b+=e,w+=t,E+=n}const T="globe"===y.name,S=this.projectAndGetPerspectiveRatio(s,b,w,E,m,T||!!_||this.transform.pitch>0,y),{perspectiveRatio:A}=S,k=(h?a/A:a*A)/e.ONE_EM,M=ot(b,w,E,l),C=S.signedDistanceFromCamera>0?ut(k,o,r.lineOffsetX*k,r.lineOffsetY*k,!1,M,x,r,i,l,{},_&&!h?v:null,h&&!!_,y,m,h):null;let I=!1,P=!1,O=!0;if(C&&!S.occluded){const t=.5*f*A+p,r=new e.Point(-100,-100),i=new e.Point(this.screenRightBoundary,this.screenBottomBoundary),o=new Ye,{first:a,last:s}=C,l=a.path.length;let h=[];for(let e=l-1;e>=1;e--)h.push(a.path[e]);for(let e=1;e(v&&!T&&(n=v(re[3]<=0)&&(h=[]));let _=[];if(h.length>0){let t=1/0,n=-1/0,o=1/0,a=-1/0;for(const e of h)t=Math.min(t,e[0]),o=Math.min(o,e[1]),n=Math.max(n,e[0]),a=Math.max(a,e[1]);n>=r.x&&t<=i.x&&a>=r.y&&o<=i.y&&(_=[h.map(t=>new e.Point(t[0],t[1]))],(ti.x||oi.y)&&(_=e.clipLine(_,r.x,r.y,i.x,i.y)))}for(const e of _){o.reset(e,.25*t);let r=0;r=o.length<=.5*t?1:Math.ceil(o.paddedLength/m)+1;for(let e=0;e0?(e.transformMat4$1(l,l,t),this.fogState&&o&&"globe"!==s.name&&(u=function(t,n,r,i,o,a){const s=a.calculateFogTileMatrix(o),l=[n,r,i];return e.transformMat4(l,l,s),S(t,l,a.pitch,a._fov)}(this.fogState,n,r,i,o.toUnwrapped(),this.transform)>.9)):gt(l,l,t);const c=l[3];return{point:new e.Point((l[0]/c+1)/2*this.transform.width+_t,(-l[1]/c+1)/2*this.transform.height+_t),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/c*.5,1.5),signedDistanceFromCamera:c,occluded:a&&l[2]>c||u}}isOffscreen(e,t,n,r){return n<_t||e>=this.screenRightBoundary||r<_t||t>this.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function Mt(t,n,r,i,o){const{horizontalAlign:a,verticalAlign:s}=e.getAnchorAlignment(t),l=-(a-.5)*n,u=-(s-.5)*r,c=e.evaluateVariableOffset(t,i);return new e.Point(l+c[0]*o,u+c[1]*o)}function Ct(t,n,r,i,o){const a=new e.Point(t,n);return r&&a._rotate(i?o:-o),a}class It{constructor(e,t,n,r,i){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new yt(this.transform,i),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new kt(n),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,r,i){const o=r.getBucket(n),a=r.latestFeatureIndex;if(!o||!a||n.id!==o.layerIds[0])return;const s=o.layers[0].layout,l=r.collisionBoxArray,u=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),c=r.tileSize/e.EXTENT,h=r.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(f=r.tileID,p=o.getProjection(),m=this.transform,p.name===this.projection?m.calculateProjMatrix(f.toUnwrapped()):vt(m,p,f));var f,p,m;const g="map"===s.get("text-pitch-alignment"),_="map"===s.get("text-rotation-alignment");n.compileFilter();const y=n.dynamicFilter(),v=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(r),b=rt(d,r.tileID.canonical,g,_,this.transform,o.getProjection(),x);let w=null;if(g){const t=it(d,r.tileID.canonical,g,_,this.transform,o.getProjection(),x);w=e.multiply([],this.transform.labelPlaneMatrix,t)}let E=null;y&&r.latestFeatureIndex&&(E={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new At(o.bucketInstanceId,a,o.sourceLayerIndex,o.index,r.tileID);const T={bucket:o,layout:s,posMatrix:d,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:E,scale:u,textPixelRatio:c,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(i)for(const e of o.sortKeyRanges){const{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=e;t.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:T})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:T})}attemptAnchorPlacement(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g,_){const{textOffset0:y,textOffset1:v,crossTileID:x}=h,b=[y,v],w=Mt(e,n,r,b,i),E=this.collisionIndex.placeCollisionBox(f,i,t,Ct(w.x,w.y,o,a,this.transform.angle),c,s,l,u.predicate);if(m){const e=f.getSymbolInstanceIconSize(_,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(f,e,m,Ct(w.x,w.y,o,a,this.transform.angle),c,s,l,u.predicate).box.length)return}if(E.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(t=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:b,width:n,height:r,anchor:e,textScale:i,prevAnchor:t},this.markUsedJustification(f,e,h,p),f.allowVerticalPlacement&&(this.markUsedOrientation(f,p,h),this.placedOrientations[x]=p),{shift:w,placedGlyphBoxes:E}}}placeLayerBucketPart(t,n,r,i){const{bucket:o,layout:a,posMatrix:s,textLabelPlaneMatrix:l,labelToScreenMatrix:u,clippingData:c,textPixelRatio:h,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:m,collisionGroup:g}=t.parameters,_=a.get("text-optional"),y=a.get("icon-optional"),v=a.get("text-allow-overlap"),x=a.get("icon-allow-overlap"),b="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),E="none"!==a.get("icon-text-fit"),T="viewport-y"===a.get("symbol-z-order");this.transform.setProjection(o.projection);let S=v&&(x||!o.hasIconData()||y),A=x&&(v||!o.hasTextData()||_);!o.collisionArrays&&f&&o.deserializeCollisionBoxes(f),r&&i&&o.updateCollisionDebugBuffers(this.transform.zoom,f);const k=(t,i,f)=>{const{crossTileID:T,numVerticalGlyphVertices:k}=t;if(c){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let i=null;if(c.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];i=c.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,c.dynamicFilter)(r,i,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.Point(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(c.unwrappedTileID)))return this.placements[T]=new Tt(!1,!1,!1,!0),void n.add(T)}if(n.has(T))return;if(d)return void(this.placements[T]=new Tt(!1,!1,!1));let M=!1,C=!1,I=!0,P=!1,O=!1,z=null,L={box:null,offscreen:null,occluded:null},D={box:null,offscreen:null,occluded:null},R=null,B=null,F=null,j=0,U=0,N=0;f.textFeatureIndex?j=f.textFeatureIndex:t.useRuntimeCollisionCircles&&(j=t.featureIndex),f.verticalTextFeatureIndex&&(U=f.verticalTextFeatureIndex);const V=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const t=this.transform.elevation;(t||e.elevation)&&(e.elevation=t?t.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0)},G=f.textBox;if(G){V(G);const n=n=>{let r=e.WritingMode.horizontal;if(o.allowVerticalPlacement&&!n&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[T];e&&(this.placedOrientations[T]=e,r=e,this.markUsedOrientation(o,r,t))}return r},r=(t,n)=>{if(o.allowVerticalPlacement&&k>0&&f.verticalTextBox){for(const r of o.writingModes)if(r===e.WritingMode.vertical?(L=n(),D=L):L=t(),L&&L.box&&L.box.length)break}else L=t()};if(a.get("text-variable-anchor")){let l=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];l.indexOf(e.anchor)>0&&(l=l.filter(t=>t!==e.anchor),l.unshift(e.anchor))}const u=(e,n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),u=(e.x2-e.x1)*a+2*e.padding,c=(e.y2-e.y1)*a+2*e.padding,d=E&&!x?n:null;d&&V(d);let f={box:[],offscreen:!1,occluded:!1};const _=v?2*l.length:l.length;for(let n=0;n<_;++n){const _=this.attemptAnchorPlacement(l[n%l.length],e,u,c,a,b,w,h,s,g,n>=l.length,t,i,o,r,d,p,m);if(_&&(f=_.placedGlyphBoxes,f&&f.box&&f.box.length)){M=!0,z=_.shift;break}}return f};r(()=>u(G,f.iconBox,e.WritingMode.horizontal),()=>{const t=f.verticalTextBox;return t&&V(t),o.allowVerticalPlacement&&!(L&&L.box&&L.box.length)&&k>0&&t?u(t,f.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),L&&(M=L.box,I=L.offscreen,P=L.occluded);const c=n(!(!L||!L.box));if(!M&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[T];e&&(this.variableOffsets[T]=e,this.markUsedJustification(o,e.anchor,t,c))}}else{const a=(n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),l=this.collisionIndex.placeCollisionBox(o,a,n,new e.Point(0,0),v,h,s,g.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,r,t),this.placedOrientations[T]=r),l};r(()=>a(G,e.WritingMode.horizontal),()=>{const t=f.verticalTextBox;return o.allowVerticalPlacement&&k>0&&t?(V(t),a(t,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),n(!!(L&&L.box&&L.box.length))}}if(R=L,M=R&&R.box&&R.box.length>0,I=R&&R.offscreen,P=R&&R.occluded,t.useRuntimeCollisionCircles){const n=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),i=e.evaluateSizeForFeature(o.textSizeData,p,n),c=a.get("text-padding");B=this.collisionIndex.placeCollisionCircles(o,v,n,o.lineVertexArray,o.glyphOffsetArray,i,s,l,u,r,w,g.predicate,t.collisionCircleDiameter*i/e.ONE_EM,c,this.retainedQueryData[o.bucketInstanceId].tileID),M=v||B.circles.length>0&&!B.collisionDetected,I=I&&B.offscreen,P=B.occluded}if(f.iconFeatureIndex&&(N=f.iconFeatureIndex),f.iconBox){const n=n=>{V(n);const r=E&&z?Ct(z.x,z.y,b,w,this.transform.angle):new e.Point(0,0),i=o.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,i,n,r,x,h,s,g.predicate)};D&&D.box&&D.box.length&&f.verticalIconBox?(F=n(f.verticalIconBox),C=F.box.length>0):(F=n(f.iconBox),C=F.box.length>0),I=I&&F.offscreen,O=F.occluded}const q=_||0===t.numHorizontalGlyphVertices&&0===k,$=y||0===t.numIconVertices;if(q||$?$?q||(C=C&&M):M=C&&M:C=M=C&&M,M&&R&&R.box&&this.collisionIndex.insertCollisionBox(R.box,a.get("text-ignore-placement"),o.bucketInstanceId,D&&D.box&&U?U:j,g.ID),C&&F&&this.collisionIndex.insertCollisionBox(F.box,a.get("icon-ignore-placement"),o.bucketInstanceId,N,g.ID),B&&(M&&this.collisionIndex.insertCollisionCircles(B.circles,a.get("text-ignore-placement"),o.bucketInstanceId,j,g.ID),r)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new St);for(let e=0;e=0;--t){const n=e[t];k(o.symbolInstances.get(n),n,o.collisionArrays[n])}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:u),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:u),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:u),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:u)}markUsedOrientation(t,n,r){const i=n===e.WritingMode.horizontal||n===e.WritingMode.horizontalOnly?n:0,o=n===e.WritingMode.vertical?n:0,{leftJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:u}=r,c=t.text.placedSymbolArray;a>=0&&(c.get(a).placedOrientation=i),s>=0&&(c.get(s).placedOrientation=i),l>=0&&(c.get(l).placedOrientation=i),u>=0&&(c.get(u).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},o=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=i[e];o?(this.opacities[e]=new Et(o,r,t.text,t.icon,null,t.clipped),n=n||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Et(null,r,t.text,t.icon,t.skipFade,t.clipped),n=n||t.text||t.icon)}for(const e in i){const t=i[e];if(!this.opacities[e]){const i=new Et(t,r,!1,!1);i.isHidden()||(this.opacities[e]=i,n=n||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);n?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const n=new Set;for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n,r.collisionBoxArray)}}updateBucketOpacities(t,n,r){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const i=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),a=new Et(null,0,!1,!1,!0),s=i.get("text-allow-overlap"),l=i.get("icon-allow-overlap"),u=i.get("text-variable-anchor"),c="map"===i.get("text-rotation-alignment"),h="map"===i.get("text-pitch-alignment"),d="none"!==i.get("icon-text-fit"),f=new Et(null,0,s&&(l||!t.hasIconData()||i.get("icon-optional")),l&&(s||!t.hasTextData()||i.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const p=(e,t,n)=>{for(let r=0;r0||l>0,b=_>0,w=this.placedOrientations[g],E=w===e.WritingMode.vertical,T=w===e.WritingMode.horizontal||w===e.WritingMode.horizontalOnly;if(!x&&!b||v.isHidden()||m++,x){const e=jt(v.text);p(t.text,s,E?Ut:e),p(t.text,l,T?Ut:e);const n=v.text.isHidden(),{leftJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:u}=i,c=t.text.placedSymbolArray,h=n||E?1:0;r>=0&&(c.get(r).hidden=h),o>=0&&(c.get(o).hidden=h),a>=0&&(c.get(a).hidden=h),u>=0&&(c.get(u).hidden=n||T?1:0);const d=this.variableOffsets[g];d&&this.markUsedJustification(t,d.anchor,i,w);const f=this.placedOrientations[g];f&&(this.markUsedJustification(t,"left",i,f),this.markUsedOrientation(t,f,i))}if(b){const e=jt(v.icon),{placedIconSymbolIndex:n,verticalPlacedIconSymbolIndex:r}=i,o=t.icon.placedSymbolArray,a=v.icon.isHidden()?1:0;n>=0&&(p(t.icon,_,E?Ut:e),o.get(n).hidden=a),r>=0&&(p(t.icon,i.numVerticalIconVertices,T?Ut:e),o.get(r).hidden=a)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const n=t.collisionArrays[r];if(n){let r=new e.Point(0,0),i=!0;if(n.textBox||n.verticalTextBox){if(u){const e=this.variableOffsets[g];e?(r=Mt(e.anchor,e.width,e.height,e.textOffset,e.textScale),c&&r._rotate(h?this.transform.angle:-this.transform.angle)):i=!1}o&&(i=!v.clipped),n.textBox&&Pt(t.textCollisionBox.collisionVertexArray,v.text.placed,!i||E,r.x,r.y),n.verticalTextBox&&Pt(t.textCollisionBox.collisionVertexArray,v.text.placed,!i||T,r.x,r.y)}const a=i&&Boolean(!T&&n.verticalIconBox);n.iconBox&&Pt(t.iconCollisionBox.collisionVertexArray,v.icon.placed,a,d?r.x:0,d?r.y:0),n.verticalIconBox&&Pt(t.iconCollisionBox.collisionVertexArray,v.icon.placed,!a,d?r.x:0,d?r.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Pt(e,t,n,r,i){e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0)}const Ot=Math.pow(2,25),zt=Math.pow(2,24),Lt=Math.pow(2,17),Dt=Math.pow(2,16),Rt=Math.pow(2,9),Bt=Math.pow(2,8),Ft=Math.pow(2,1);function jt(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,n=Math.floor(127*e.opacity);return n*Ot+t*zt+n*Lt+t*Dt+n*Rt+t*Bt+n*Ft+t}const Ut=0;class Nt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(e,t,n,r,i){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex{const t=e.exported.now()-i;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const e=n[t[this._currentPlacementIndex]],i=this.placement.collisionIndex.transform.zoom;if("symbol"===e.type&&(!e.minzoom||e.minzoom<=i)&&(!e.maxzoom||e.maxzoom>i)){if(this._inProgressLayer||(this._inProgressLayer=new Nt(e)),this._inProgressLayer.continuePlacement(r[e.source],this.placement,this._showCollisionBoxes,e,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Gt=512/e.EXTENT/2;class qt{constructor(t,n,r){this.tileID=t,this.bucketInstanceId=r,this.index=new e.KDBush(n.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const i=t.canonical.x*e.EXTENT,o=t.canonical.y*e.EXTENT;for(let e=0;ee.overscaledZ)for(const n in i){const o=i[n];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=i[e.scaledTo(Number(n)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Xt=(t,n)=>e.emitValidationErrors(t,n&&n.filter(e=>"source.canvas"!==e.identifier)),Ht=e.pick(Ve,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Yt=e.pick(Ve,["setCenter","setZoom","setBearing","setPitch"]),Kt={version:8,layers:[],sources:{}},Jt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Qt extends e.Evented{constructor(t,n={}){super(),this.map=t,this.dispatcher=new C(je(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new e.GlyphManager(t._requestManager,n.localFontFamily?e.LocalGlyphMode.all:n.localIdeographFontFamily?e.LocalGlyphMode.ideographs:e.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.crossTileSymbolIndex=new Wt,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",e.getReferrer());const r=this;this._rtlTextPluginCallback=Qt.registerForPluginStateChange(t=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,n)=>{if(e.triggerPluginCompletionEvent(t),n&&n.every(e=>e))for(const e in r._sourceCaches){const t=r._sourceCaches[e],n=t.getSource().type;"vector"!==n&&"geojson"!==n||t.reload()}})}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const n=this._layers[e];n.source===t.id&&this._validateLayer(n)}})}loadURL(t,n={}){this.fire(new e.Event("dataloading",{dataType:"style"}));const r="boolean"==typeof n.validate?n.validate:!e.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,n.accessToken);const i=this.map._requestManager.transformRequest(t,e.ResourceType.Style);this._request=e.getJSON(i,(t,n)=>{this._request=null,t?this.fire(new e.ErrorEvent(t)):n&&this._load(n,r)})}loadJSON(t,n={}){this.fire(new e.Event("dataloading",{dataType:"style"})),this._request=e.exported.frame(()=>{this._request=null,this._load(t,!1!==n.validate)})}loadEmpty(){this.fire(new e.Event("dataloading",{dataType:"style"})),this._load(Kt,!1)}_updateLayerCount(e,t){const n=t?1:-1;e.is3D()&&(this._num3DLayers+=n),"circle"===e.type&&(this._numCircleLayers+=n),"symbol"===e.type&&(this._numSymbolLayers+=n)}_load(t,n){if(n&&Xt(this,e.validateStyle(t)))return;this._loaded=!0,this.stylesheet=e.clone$1(t),this._updateMapProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const r=Ne(this.stylesheet.layers);this._order=r.map(e=>e.id),this._layers={},this._serializedLayers={};for(const t of r){const n=e.createStyleLayer(t);n.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=n,this._serializedLayers[n.id]=n.serialize(),this._updateLayerCount(n,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new w(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 e.Event("data",{dataType:"style"})),this.fire(new e.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this._updateMapProjection()}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))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(t){this._spriteRequest=function(t,n,r){let i,o,a;const s=e.exported.devicePixelRatio>1?"@2x":"";let l=e.getJSON(n.transformRequest(n.normalizeSpriteURL(t,s,".json"),e.ResourceType.SpriteJSON),(e,t)=>{l=null,a||(a=e,i=t,c())}),u=e.getImage(n.transformRequest(n.normalizeSpriteURL(t,s,".png"),e.ResourceType.SpriteImage),(e,t)=>{u=null,a||(a=e,o=t,c())});function c(){if(a)r(a);else if(i&&o){const t=e.exported.getImageData(o),n={};for(const r in i){const{width:o,height:a,x:s,y:l,sdf:u,pixelRatio:c,stretchX:h,stretchY:d,content:f}=i[r],p=new e.RGBAImage({width:o,height:a});e.RGBAImage.copy(t,p,{x:s,y:l},{x:0,y:0},{width:o,height:a}),n[r]={data:p,pixelRatio:c,sdf:u,stretchX:h,stretchY:d,content:f}}r(null,n)}}return{cancel(){l&&(l.cancel(),l=null),u&&(u.cancel(),u=null)}}}(t,this.map._requestManager,(t,n)=>{if(this._spriteRequest=null,t)this.fire(new e.ErrorEvent(t));else if(n)for(const e in n)this.imageManager.addImage(e,n[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new e.Event("data",{dataType:"style"}))})}_validateLayer(t){const n=this.getSource(t.source);if(!n)return;const r=t.sourceLayer;r&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new e.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const n of e){const e=this._layers[n];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&("function"==typeof e.isLayerDraped?e.isLayerDraped():Jt[e.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(e.length||n.length)&&this._updateWorkerLayers(e,n);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const r={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];r[e]=t.used,t.used=!1}for(const e of this._order){const n=this._layers[e];if(n.recalculate(t,this._availableImages),!n.isHidden(t.zoom)){const e=this._getLayerSourceCache(n);e&&(e.used=!0)}const r=this.map.painter;if(r){const e=n.getProgramIds();if(!e)continue;const i=n.getProgramConfiguration(t.zoom);for(const t of e)r.useProgram(t,i)}}for(const t in r){const n=this._sourceCaches[t];r[t]!==n.used&&n.getSource().fire(new e.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:n.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new e.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(n){if(this._checkLoaded(),Xt(this,e.validateStyle(n)))return!1;(n=e.clone$1(n)).layers=Ne(n.layers);const r=function(e,n){if(!e)return[{command:Ve.setStyle,args:[n]}];let r=[];try{if(!t(e.version,n.version))return[{command:Ve.setStyle,args:[n]}];t(e.center,n.center)||r.push({command:Ve.setCenter,args:[n.center]}),t(e.zoom,n.zoom)||r.push({command:Ve.setZoom,args:[n.zoom]}),t(e.bearing,n.bearing)||r.push({command:Ve.setBearing,args:[n.bearing]}),t(e.pitch,n.pitch)||r.push({command:Ve.setPitch,args:[n.pitch]}),t(e.sprite,n.sprite)||r.push({command:Ve.setSprite,args:[n.sprite]}),t(e.glyphs,n.glyphs)||r.push({command:Ve.setGlyphs,args:[n.glyphs]}),t(e.transition,n.transition)||r.push({command:Ve.setTransition,args:[n.transition]}),t(e.light,n.light)||r.push({command:Ve.setLight,args:[n.light]}),t(e.fog,n.fog)||r.push({command:Ve.setFog,args:[n.fog]}),t(e.projection,n.projection)||r.push({command:Ve.setProjection,args:[n.projection]});const i={},o=[];!function(e,n,r,i){let o;for(o in n=n||{},e=e||{})e.hasOwnProperty(o)&&(n.hasOwnProperty(o)||qe(o,r,i));for(o in n){if(!n.hasOwnProperty(o))continue;const a=n[o];e.hasOwnProperty(o)?t(e[o],a)||("geojson"===e[o].type&&"geojson"===a.type&&Ze(e,n,o)?r.push({command:Ve.setGeoJSONSourceData,args:[o,a.data]}):$e(o,n,r,i)):Ge(o,n,r)}}(e.sources,n.sources,o,i);const a=[];e.layers&&e.layers.forEach(e=>{e.source&&i[e.source]?r.push({command:Ve.removeLayer,args:[e.id]}):a.push(e)});let s=e.terrain;s&&i[s.source]&&(r.push({command:Ve.setTerrain,args:[void 0]}),s=void 0),r=r.concat(o),t(s,n.terrain)||r.push({command:Ve.setTerrain,args:[n.terrain]}),function(e,n,r){n=n||[];const i=(e=e||[]).map(Xe),o=n.map(Xe),a=e.reduce(He,{}),s=n.reduce(He,{}),l=i.slice(),u=Object.create(null);let c,h,d,f,p,m,g;for(c=0,h=0;c!(e.command in Yt));if(0===r.length)return!1;const i=r.filter(e=>!(e.command in Ht));if(i.length>0)throw new Error(`Unimplemented: ${i.map(e=>e.command).join(", ")}.`);return r.forEach(e=>{"setTransition"!==e.command&&"setProjection"!==e.command&&this[e.command].apply(this,e.args)}),this.stylesheet=n,this._updateMapProjection(),!0}addImage(t,n){return this.getImage(t)?this.fire(new e.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,n),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t),this):this.fire(new e.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new e.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,n,r={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(e.validateSource,"sources."+t,n,null,r))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const i=Ie(t,n,this.dispatcher,this);i.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:i.serialize(),sourceId:t}));const o=n=>{const r=(n?"symbol:":"other:")+t,o=this._sourceCaches[r]=new e.SourceCache(r,i,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[t]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==n.type&&"geojson"!==n.type||o(!0),i.onAdd&&i.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const n=this.getSource(t);if(!n)throw new Error("There is no source with this ID");for(const n in this._layers)if(this._layers[n].source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${n}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const r=this._getSourceCaches(t);for(const t of r)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new e.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}_getSources(){const e=[];for(const t in this._otherSourceCaches){const n=this._getSourceCache(t);n&&e.push(n.getSource())}return e}addLayer(t,n,r={}){this._checkLoaded();const i=t.id;if(this.getLayer(i))return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" already exists on this map`)));let o;if("custom"===t.type){if(Xt(this,e.validateCustomStyleLayer(t)))return;o=e.createStyleLayer(t)}else{if("object"==typeof t.source&&(this.addSource(i,t.source),t=e.clone$1(t),t=e.extend(t,{source:i})),this._validate(e.validateLayer,"layers."+i,t,{arrayIndex:-1},r))return;o=e.createStyleLayer(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const a=n?this._order.indexOf(n):this._order.length;if(n&&-1===a)return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(a,0,i),this._layerOrderChanged=!0,this._layers[i]=o;const s=this._getLayerSourceCache(o);if(this._removedLayers[i]&&o.source&&s&&"custom"!==o.type){const e=this._removedLayers[i];delete this._removedLayers[i],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",s.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const r=this._order.indexOf(t);this._order.splice(r,1);const i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(i,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(t,n,r){this._checkLoaded();const i=this.getLayer(t);i?i.minzoom===n&&i.maxzoom===r||(null!=n&&(i.minzoom=n),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(n,r,i={}){this._checkLoaded();const o=this.getLayer(n);if(o){if(!t(o.filter,r))return null==r?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(e.validateFilter,`layers.${o.id}.filter`,r,{layerType:o.type},i)||(o.filter=e.clone$1(r),this._updateLayer(o)))}else this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){const n=this.getLayer(t);return n&&e.clone$1(n.filter)}setLayoutProperty(n,r,i,o={}){this._checkLoaded();const a=this.getLayer(n);a?t(a.getLayoutProperty(r),i)||(a.setLayoutProperty(r,i,o),this._updateLayer(a)):this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,n){const r=this.getLayer(t);if(r)return r.getLayoutProperty(n);this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(n,r,i,o={}){this._checkLoaded();const a=this.getLayer(n);a?t(a.getPaintProperty(r),i)||(a.setPaintProperty(r,i,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[n]=!0):this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){const n=this.getLayer(e);return n&&n.getPaintProperty(t)}setFeatureState(t,n){this._checkLoaded();const r=t.source,i=t.sourceLayer,o=this.getSource(r);if(!o)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.type;if("geojson"===a&&i)return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===a&&!i)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));const s=this._getSourceCaches(r);for(const e of s)e.setFeatureState(i,t.id,n)}removeFeatureState(t,n){this._checkLoaded();const r=t.source,i=this.getSource(r);if(!i)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const o=i.type,a="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!a)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const s=this._getSourceCaches(r);for(const e of s)e.removeFeatureState(a,t.id,n)}getFeatureState(t){this._checkLoaded();const n=t.source,r=t.sourceLayer,i=this.getSource(n);if(i){if("vector"!==i.type||r)return void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(r,t.id);this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new e.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return e.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const n=this._sourceCaches[e].getSource();t[n.id]||(t[n.id]=n.serialize())}return e.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,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:t,layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,n={},r=[];for(let i=this._order.length-1;i>=0;i--){const o=this._order[i];if(t(o)){n[o]=i;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const i=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(n[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()}):this.has3DLayers(),s=P.createFromScreenPoints(t,r);for(const e in this._sourceCaches){const t=this._sourceCaches[e].getSource().id;n.layers&&!i[t]||o.push(Oe(this._sourceCaches[e],this._layers,this._serializedLayers,s,n,r,a,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,n,r,i,o,a){const s={},l=o.queryRenderedSymbols(r),u=[];for(const e of Object.keys(l).map(Number))u.push(a[e]);u.sort(Le);for(const n of u){const r=n.featureIndex.lookupSymbolFeatures(l[n.bucketInstanceId],t,n.bucketIndex,n.sourceLayerIndex,i.filter,i.layers,i.availableImages,e);for(const e in r){const t=s[e]=s[e]||[],i=r[e];i.sort((e,t)=>{const r=n.featureSortOrder;if(r){const n=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-n}return t.featureIndex-e.featureIndex});for(const e of i)t.push(e)}}for(const t in s)s[t].forEach(r=>{const i=r.feature,o=n(e[t]);if(!o)return;const a=o.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=a});return s}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),s.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,n){n&&n.filter&&this._validate(e.validateFilter,"querySourceFeatures.filter",n.filter,null,n);const r=this._getSourceCaches(t);let i=[];for(const e of r)i=i.concat(ze(e,n));return i}addSourceType(e,t,n){return Qt.getSourceType(e)?n(new Error(`A source type called "${e}" already exists.`)):(Qt.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},n):n(null,null))}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();const r=this.light.getLight();let i=!1;for(const n in e)if(!t(e[n],r[n])){i=!0;break}if(!i)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,n),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(n,r=1){if(this._checkLoaded(),!n)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let i=n;if(1===r){if("object"==typeof i.source){const t="terrain-dem-src";this.addSource(t,i.source),i=e.clone$1(i),i=e.extend(i,{source:t})}if(this._validate(e.validateTerrain,"terrain",i))return}if(!this.terrain||this.terrain&&r!==this.terrain.drapeRenderMode){if(!i)return;this._createTerrain(i,r)}else{const n=this.terrain,r=n.get();for(const t of Object.keys(e.spec.terrain))!i.hasOwnProperty(t)&&e.spec.terrain[t].default&&(i[t]=e.spec.terrain[t].default);for(const e in i)if(!t(i[e],r[e])){n.set(i),this.stylesheet.terrain=i;const e=this._setTransitionParameters({duration:0});n.updateTransitions(e);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new M(e,this.map.transform);this.stylesheet.fog=e;const n=this._setTransitionParameters({duration:0});t.updateTransitions(n)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,r=n.get();0===Object.keys(e).length&&n.set(e);for(const i in e)if(!t(e[i],r[i])){n.set(e),this.stylesheet.fog=e;const t=this._setTransitionParameters({duration:0});n.updateTransitions(t);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(t){return{now:e.exported.now(),transition:e.extend(t,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter(e=>this.isLayerDraped(this._layers[e])),t=this._order.filter(e=>!this.isLayerDraped(this._layers[e]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const n=this.terrain=new T(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});n.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,n,r,i,o={}){return(!o||!1!==o.validate)&&Xt(this,t.call(e.validateStyle,e.extend({key:n,style:this.serialize(),value:r,styleSpec:e.spec},i)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),e.reload()}_reloadSources(){for(const e of this._getSources())e.reload&&e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,n,r,i,o=!1){let a=!1,s=!1;const l={};for(const e of this._order){const n=this._layers[e];if("symbol"!==n.type)continue;if(!l[n.source]){const e=this._getLayerSourceCache(n);if(!e)continue;l[n.source]=e.getRenderableIds(!0).map(t=>e.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const r=this.crossTileSymbolIndex.addLayer(n,l[n.source],t.center.lng,t.projection);a=a||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.exported.now(),t.zoom))&&(this.pauseablePlacement=new Vt(t,this._order,o,n,r,i,this.placement,this.fog&&t.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(e.exported.now()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.exported.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,n){this.imageManager.getImages(t.icons,n),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,n){this.glyphManager.getGlyphs(t.stacks,n)}getResource(t,n,r){return e.makeRequest(n,r)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const n=this._getSourceCaches(t);return 0===n.length?(this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t}'`))),!1):n.every(e=>e.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)}}Qt.getSourceType=function(e){return Ce[e]},Qt.setSourceType=function(e,t){Ce[e]=t},Qt.registerForPluginStateChange=e.registerForPluginStateChange;var en="\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",tn="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;}",nn="\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\nconst float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\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) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.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;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",rn="#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",on="#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";let an={},sn={};const ln=[];fn(en,ln),fn(nn,ln),fn(rn,ln),fn(on,ln),an=pn("",nn),sn=pn(on,rn);const un=pn("\n#if __VERSION__ >=300\n#define varying in\n#define gl_FragColor glFragColor\n#define texture2D texture\n#define textureCube texture\nout vec4 glFragColor;\n#endif\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;}highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}","\n#if __VERSION__ >=300\n#define attribute in\n#define varying out\n#define texture2D texture\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."),cn=en,hn="\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 dn={background:pn("uniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nvarying vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\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;\n#ifdef LIGHTING_3D_MODE\nuniform vec4 u_color;varying vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(u_color);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:pn("uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:pn("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 LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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;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);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;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);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);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();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;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:pn("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:pn("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);vec3 pos;\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;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=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:pn("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:pn("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:pn("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:pn("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:pn("#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 LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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:pn("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 LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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:pn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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 float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(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:pn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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 float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:pn("varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\nvoid main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvec3 normal=v_normal;\n#endif\nfloat z;vec4 color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);\n#else\ncolor=v_color;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef ZERO_ROOF_RADIUS\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#endif\ncolor.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\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;uniform float u_edge_radius;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#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\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\nvec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;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));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nv_normal=normal;\n#endif\nbase=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : 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\nfloat ele=0.0;float h=0.0;float c_ele;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=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*h);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);\n#ifdef RENDER_SHADOWS\nv_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(color,NdotL);\n#else\nv_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_color*=u_opacity;\n#ifdef ZERO_ROOF_RADIUS\nv_roof_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef LIGHTING_3D_MODE\nv_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));\n#else\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:pn("uniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,v_NdotL)*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\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 float u_tile_units_to_pixels;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;varying vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;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=(pattern_br-pattern_tl)/pixel_ratio;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\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=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=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_NdotL=NdotL;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:pn("#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+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=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+e+e+h)-(a+d+d+f),(f+g+g+h)-(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:pn("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 LIGHTING_3D_MODE\ngl_FragColor=apply_lighting(gl_FragColor);\n#endif\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:pn("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;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nuniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\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=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\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);trimmed=0.0;}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\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\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);\n#ifdef RENDER_LINE_BORDER_AUTO\nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}\n#else\nout_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha);\n#endif\n}\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 float u_tile_units_to_pixels;varying vec2 v_tex;\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\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\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 scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.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:pn("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;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\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.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=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting(color);\n#endif\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\n#pragma mapbox: define lowp float pixel_ratio\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\n#pragma mapbox: initialize lowp float pixel_ratio\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:pn("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 LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\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:pn("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);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);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;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_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);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_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 TERRAIN\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\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:pn("#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);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);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;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_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);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_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 TERRAIN\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\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:pn("#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);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);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;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;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);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_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 TERRAIN\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\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:pn("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\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;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nconst float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=wireframeOffset;\n#endif\nv_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}"),terrainDepth:pn("#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;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:pn("\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}",tn),skyboxGradient:pn("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}",tn),skyboxCapture:pn("\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:pn("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() {vec4 color;\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);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\ncolor=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;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_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 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:pn("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);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_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);float horizon_angle;\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));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\nhorizon_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 fn(e,t){const n=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of n)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const n=e.split(" ");for(const e of n)t.includes(e)||t.push(e)}}function pn(e,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),i={},o=[...ln];return fn(e,o),fn(t,o),{fragmentSource:e=e.replace(n,(e,t,n,r,o)=>(i[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = u_${o};\n#endif\n`)),vertexSource:t=t.replace(n,(e,t,n,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return i[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${a} a_${o};\nvarying ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${a} a_${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = a_${o};\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`}),staticAttributes:r,usedDefines:o}}class mn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,n,r,i,o,a){this.context=e;let s=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!s&&e{const i=n.paint.get("hillshade-shadow-color"),o=n.paint.get("hillshade-highlight-color"),a=n.paint.get("hillshade-accent-color");let s=n.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===n.paint.get("hillshade-illumination-anchor")&&(s-=e.transform.angle);const l=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:gn(0,t.tileID),u_light:[n.paint.get("hillshade-exaggeration"),s],u_shadow:i,u_highlight:o,u_accent:a}})(t,r,i,t.terrain?n.projMatrix:null);t.prepareDrawProgram(l,h,n.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:p,tileBoundsSegments:m}=t.getTileBoundsBuffers(r);h.draw(l,u.TRIANGLES,o,a,s,e.CullFaceMode.disabled,d,i.id,f,p,m)}function yn(t,n,r){if(!n.needsDEMTextureUpload)return;const i=t.context,o=i.gl;i.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||t.getTileTexture(r.stride);const a=r.getPixels();n.demTexture?n.demTexture.update(a,{premultiply:!1}):n.demTexture=new e.Texture(i,a,o.RGBA,{premultiply:!1}),n.needsDEMTextureUpload=!1}function vn(t,n,r,i,o,a){const s=t.context,l=s.gl;if(!n.dem)return;const u=n.dem;if(s.activeTexture.set(l.TEXTURE1),yn(t,n,u),!n.demTexture)return;n.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const c=u.dim;s.activeTexture.set(l.TEXTURE0);let h=n.fbo;if(!h){const t=new e.Texture(s,{width:c,height:c,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=n.fbo=s.createFramebuffer(c,c,!0),h.colorAttachment.set(t.texture)}s.bindFramebuffer.set(h.framebuffer),s.viewport.set([0,0,c,c]);const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:p}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(s,l.TRIANGLES,i,o,a,e.CullFaceMode.disabled,((t,n)=>{const r=n.stride,i=e.create();return e.ortho(i,0,e.EXTENT,-e.EXTENT,0,0,1),e.translate(i,i,[0,-e.EXTENT,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:n.unpackVector}})(n.tileID,u),r.id,d,f,p),n.needsHillshadePrepare=!1}const xn=t=>({u_matrix:new e.UniformMatrix4f(t),u_image0:new e.Uniform1i(t),u_skirt_height:new e.Uniform1f(t)}),bn=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),wn=(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:n,u_zoom_transition:i,u_merc_center:o,u_image0:0,u_frustum_tl:a,u_frustum_tr:s,u_frustum_br:l,u_frustum_bl:u,u_globe_pos:c,u_globe_radius:h,u_viewport:d,u_grid_matrix:p?Float32Array.from(p):new Float32Array(9),u_skirt_height:f});function En(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Tn=new class{constructor(){this.operations={}}newMorphing(e,t,n,r,i){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==n.tileID.key&&(t.queued=n)}else this.operations[e]={startTime:r,phase:0,duration:i,from:t,to:n,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const n=this.operations[t];for(n.phase=(e-n.startTime)/n.duration;n.phase>=1||!this._validOp(n);)if(!this._nextOp(n,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},Sn={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function An(e){return 6*Math.pow(1.5,22-e)}function kn(e,t){const n=1<({u_matrix:e});function Cn(t,n,r,i,o){if(o>0){const a=e.exported.now(),s=(a-t.timeAdded)/o,l=n?(a-n.timeAdded)/o:-1,u=r.getSource(),c=i.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),h=!n||Math.abs(n.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),d=h&&t.refreshedUponExpiration?1:e.clamp(h?s:1-l,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),n?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class In extends e.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},n=new C(je(),null),r=Ie("mock-dem",t,n,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Pn extends e.SourceCache{constructor(e){const t=Ie("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new C(je(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,n,r){if(t.freezeTileCoverage)return;this.transform=t;const i=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((n,r)=>{if(n[r.key]="",!this._tiles[r.key]){const n=new e.Tile(r,this._source.tileSize*r.overscaleFactor(),t.tileZoom);n.state="loaded",this._tiles[r.key]=n}return n},{});for(const e in this._tiles)e in i||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const n=Object.values(t);this.renderCachePool.push(...n),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class On extends e.OverscaledTileID{constructor(e,t,n){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=n}}class zn extends e.Elevation{constructor(t,n){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,i,o]=function(t){const n=new e.StructArrayLayout2i4,r=new e.StructArrayLayout3ui6,i=131;n.reserve(17161),r.reserve(33800);const o=e.EXTENT/128,a=e.EXTENT+o/2,s=a+o;for(let t=-o;ta||t<0||t>a?24575:0,o=e.clamp(Math.round(r),0,e.EXTENT),s=e.clamp(Math.round(t),0,e.EXTENT);n.emplaceBack(o+i,s)}const l=(e,t)=>{const n=t*i+e;r.emplaceBack(n+1,n,n+i),r.emplaceBack(n+i,n+i+1,n+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach(e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)}),[n,r,32768]}(),a=t.context;this.gridBuffer=a.createVertexBuffer(r,e.posAttributes.members),this.gridIndexBuffer=a.createIndexBuffer(i),this.gridSegments=e.SegmentVector.simpleSegment(0,0,r.length,i.length),this.gridNoSkirtSegments=e.SegmentVector.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Pn(n.map),this.orthoMatrix=e.create(),e.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.EXTENT,0,e.EXTENT,0,1);const s=a.gl;this._overlapStencilMode=new e.StencilMode({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=n,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new In(n.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,n,r){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const i=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(i.get("source")),this._exaggeration=i.get("exaggeration");const o=()=>{this.sourceCache.used&&e.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 t=this.getScaledDemTileSize();this.sourceCache.update(n,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),n.updateElevation(!0,r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(n),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&e.warnOnce(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${t.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const n=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const i=this.proxyCoords=n.getIds().map(e=>{const t=n.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t});!function(t,n){const r=n.transform.pointCoordinate(n.transform.getCameraPoint()),i=new e.Point(r.x,r.y);t.sort((t,n)=>{if(n.overscaledZ-t.overscaledZ)return n.overscaledZ-t.overscaledZ;const r=new e.Point(t.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const a=this._style._sourceCaches;for(const e in a){const n=a[e];if(!n.used)continue;if(n!==this.sourceCache&&this.resetTileLookupCache(n.id),this._setupProxiedCoordsForOrtho(n,t[e],o),n.usedForTerrain)continue;const r=t[e];n.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[n.id]=i.map(e=>new On(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(i),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=e.exported.now();const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const n=t.tileID.key;n in s||(this._visibleDemTiles.push(t),s[n]=n)}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)})}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const n in this.terrainTileForTile){const r=this.terrainTileForTile[n],i=r.dem;!i||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),yn(this.painter,r,i))}}_prepareDemTileUniforms(e,t,n,r){if(!t||null==t.demTexture)return!1;const i=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-i.z),a=r||"";return n["u_dem_tl"+a]=[i.x*o%1,i.y*o%1],n["u_dem_scale"+a]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,n=t.gl;if(!this._emptyDepthBufferTexture){const r=new e.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.Texture(t,r,n.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce((t,n)=>{if(!n.dem)return t;const r=n.dem.tree.minimums[0];return r>0&&e++,t+r},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,n=t.gl;t.activeTexture.set(n.TEXTURE2);const r=this._getLoadedAreaMinimum(),i=new e.RGBAImage({width:1,height:1},new Uint8Array(e.DEMData.pack(r,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(i,{premultiply:!1}):o=this._emptyDEMTexture=new e.Texture(t,i,n.RGBA,{premultiply:!1}),o}setupElevationDraw(t,n,r){const i=this.painter.context,o=i.gl,a=(s=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:e.DEMData.getUnpackVector(s),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});var s;a.u_dem_size=this.sourceCache.getSource().tileSize,a.u_exaggeration=this.exaggeration();let l=null,u=null,c=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,n=r.morphing.dstDemTile;c=r.morphing.phase,e&&n&&(this._prepareDemTileUniforms(t,e,a,"_prev")&&(u=e),this._prepareDemTileUniforms(t,n,a)&&(l=n))}if(u&&l?(i.activeTexture.set(o.TEXTURE2),l.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),i.activeTexture.set(o.TEXTURE4),u.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),a.u_dem_lerp=c):(l=this.terrainTileForTile[t.tileID.key],i.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(t,l,a)?l.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),i.activeTexture.set(o.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(a.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),a.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&l){const t=(1<{if(u===e)return;const r=[Sn[e],"PROJECTION_GLOBE_VIEW"];d&&r.push("CUSTOM_ANTIALIASING"),n&&r.push(Sn[c]),l=t.useProgram("globeRaster",null,r),u=e},p=t.colorModeForRenderPass(),m=new e.DepthMode(s.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);Tn.update(o);const g=e.calculateGlobeMercatorMatrix(h),_=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],y=c?[!1,!0]:[!1],v=t.globeSharedBuffers,x=[h.width*e.exported.devicePixelRatio,h.height*e.exported.devicePixelRatio],b=Float32Array.from(h.globeMatrix),w={useDenormalizedUpVectorScale:!0};if(y.forEach(c=>{const h=t.transform,d=An(h.zoom)*n.exaggeration();u=-1;const y=c?s.LINES:s.TRIANGLES;for(const u of i){const i=r.getTile(u),E=e.StencilMode.disabled,T=n.prevTerrainTileForTile[u.key],S=n.terrainTileForTile[u.key];En(T,S)&&Tn.newMorphing(u.key,T,S,o,250),a.activeTexture.set(s.TEXTURE0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const A=Tn.getMorphValuesForProxy(u.key),k=A?1:0;A&&e.extend$1(w,{morphing:{srcDemTile:A.from,dstDemTile:A.to,phase:e.easeCubicInOut(A.phase)}});const M=e.tileCornersToBounds(u.canonical),C=e.getLatitudinalLod(M.getCenter().lat),I=e.getGridMatrix(u.canonical,M,C,h.worldSize/h._pixelsPerMercatorPixel),P=e.globeNormalizeECEF(e.globeTileBounds(u.canonical)),O=wn(h.projMatrix,b,g,P,e.globeToMercatorTransition(h.zoom),_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,d,I);if(f(k,c),n.setupElevationDraw(i,l,w),t.prepareDrawProgram(a,l,u.toUnwrapped()),v){const[n,r,i]=c?v.getWirefameBuffers(t.context,C):v.getGridBuffers(C,0!==d);l.draw(a,y,m,E,p,e.CullFaceMode.backCCW,O,"globe_raster",n,r,i)}}}),v){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&o.push("CUSTOM_ANTIALIASING"),l=t.useProgram("globeRaster",null,o);for(const o of i){const{x:i,y:u,z:c}=o.canonical,d=0===u,f=u===(1<t.draw(a,s.TRIANGLES,m,e.StencilMode.disabled,p,e.CullFaceMode.disabled,wn(h.projMatrix,v,v,T,0,_,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,0),"globe_pole_raster",n,b,E);n.setupElevationDraw(u,l,w),t.prepareDrawProgram(a,l,o.toUnwrapped()),d&&S(l,g),f&&(v=e.scale(e.create(),v,[1,-1,1]),S(l,y))}}}}(t,n,r,i,o);else{const a=t.context,s=a.gl;let l,u;const c=t.options.showTerrainWireframe?2:0,h=(e,n)=>{if(u===e)return;const r=[Sn[e]];n&&r.push(Sn[c]),l=t.useProgram("terrainRaster",null,r),u=e},d=t.colorModeForRenderPass(),f=new e.DepthMode(s.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);Tn.update(o);const p=t.transform,m=An(p.zoom)*n.exaggeration();(c?[!1,!0]:[!1]).forEach(c=>{u=-1;const g=c?s.LINES:s.TRIANGLES,[_,y]=c?n.getWirefameBuffer():[n.gridIndexBuffer,n.gridSegments];for(const u of i){const i=r.getTile(u),v=e.StencilMode.disabled,x=n.prevTerrainTileForTile[u.key],b=n.terrainTileForTile[u.key];En(x,b)&&Tn.newMorphing(u.key,x,b,o,250),a.activeTexture.set(s.TEXTURE0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST);const w=Tn.getMorphValuesForProxy(u.key),E=w?1:0;let T;w&&(T={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:e.easeCubicInOut(w.phase)}});const S=bn(u.projMatrix,kn(u.canonical,p.renderWorldCopies)?m/10:m);h(E,c),n.setupElevationDraw(i,l,T),t.prepareDrawProgram(a,l,u.toUnwrapped()),l.draw(a,g,f,v,d,e.CullFaceMode.backCCW,S,"terrain_raster",n.gridBuffer,_,y)}})}}(n,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,n.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const n=this.painter,r=this.painter.context,i=this.proxySourceCache,o=this.proxiedCoords[i.id],a=this._drapedRenderBatches.shift(),s=[],l=n.style.order;let u=0;for(const c of o){const o=i.getTileByID(c.proxyTileKey),h=i.proxyCachedFBO[c.key]?i.proxyCachedFBO[c.key][t]:void 0,d=void 0!==h?i.renderCache[h]:this.pool[u++],f=void 0!==h;if(o.texture=d.tex,f&&!d.dirty){s.push(o.tileID);continue}let p;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.Color.transparent,stencil:0}),d.dirty=!1);for(let e=a.start;e<=a.end;++e){const t=n.style._layers[l[e]];if(t.isHidden(n.transform.zoom))continue;const i=n.style._getLayerSourceCache(t),o=i?this.proxyToSource[c.key][i.id]:[c];if(!o)continue;const a=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(i?i.id:null)&&(this._setupStencil(d,o,t,i),p=i?i.id:null),n.renderLayer(n,i,t,a)}this.renderedToTile?(d.dirty=!0,s.push(o.tileID)):f||--u,5===u&&(u=0,this.renderToBackBuffer(s))}return this.renderToBackBuffer(s),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,n.width,n.height]),a.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let n,r=0,i=0,o=!1;for(let a=0;ae.dem).forEach(t=>{e=Math.min(e,t.dem.tree.minimums[0])}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,n){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter(e=>e.dem).map(r=>{const i=r.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const i of r){if(null==i.t)return null;const r=i.tile.dem.tree.raycast(i.minx,i.miny,i.maxx,i.maxy,e,t,n);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,n=t.gl,r=this.drapeBufferSize;t.activeTexture.set(n.TEXTURE0);const i=new e.Texture(t,{width:r[0],height:r[1],data:null},n.RGBA);i.bind(n.LINEAR,n.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!1);return o.colorAttachment.set(i.texture),o.depthAttachment=new we(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&n.texParameterf(n.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:i,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._layers[e],n=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!n&&t.shouldRedrape():!n&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style._getSources())if(e instanceof Se){t=!0;break}if(!t)return;const n={};for(let t=0;tt.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let n=0;n=0;i--){const o=n[i];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const n=e[o.key],i=this.proxyToSource[o.key];let a=0;for(const e in i){const t=i[e],o=n[e];if(!o||o.length!==t.length||t.some((t,n)=>t!==o[n]||r[e]&&r[e].hasOwnProperty(t.key))){a=-1;break}++a}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=a<0||a!==Object.values(n).length}}const i=[...this._drapedRenderBatches];i.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of i)for(const r of n){if(t.proxyCachedFBO[r.key])continue;let n=t.renderCachePool.pop();void 0===n&&t.renderCache.length<50&&(n=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==n&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=n,t.renderCache[n].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,n,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const i=this.painter.context,o=i.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let a;if(n.isTileClipped())a=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);a=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+a>255&&(i.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,this._overlapStencilMode.ref=this._stencilRef,n.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.StencilMode.disabled}_renderTileClippingMasks(t,n){const r=this.painter,i=this.painter.context,o=i.gl;r._tileClippingMaskIDs={},i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=r.useProgram("clippingMask");for(const s of t){const t=r._tileClippingMaskIDs[s.key]=--n;a.draw(i,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Mn(s.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(t){const n=this.painter.transform;if(t.x<0||t.x>n.width||t.y<0||t.y>n.height)return null;const r=[t.x,t.y,1,1];e.transformMat4$1(r,r,n.pixelMatrixInverse),e.scale$1(r,r,1/r[3]),r[0]/=n.worldSize,r[1]/=n.worldSize;const i=n._camera.position,o=e.mercatorZfromAltitude(1,n.center.lat),a=[i[0],i[1],i[2]/o,0],s=e.subtract([],r.slice(0,3),a);e.normalize(s,s);const l=this.raycast(a,s,this._exaggeration);return null!==l&&l?(e.scaleAndAdd(a,a,s,l),a[3]=a[2],a[2]*=o,a):null}drawDepth(){const t=this.painter,n=t.context,r=this.proxySourceCache,i=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===i&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=n.gl,r=n.createFramebuffer(i,o,!0);n.activeTexture.set(t.TEXTURE0);const a=new e.Texture(n,{width:i,height:o,data:null},t.RGBA);a.bind(t.NEAREST,t.CLAMP_TO_EDGE),r.colorAttachment.set(a.texture);const s=n.createRenderbuffer(n.gl.DEPTH_COMPONENT16,i,o);r.depthAttachment.set(s),this._depthFBO=r,this._depthTexture=a}n.bindFramebuffer.set(this._depthFBO.framebuffer),n.viewport.set([0,0,i,o]),function(t,n,r,i){if("globe"===t.transform.projection.name)return;const o=t.context,a=o.gl;o.clear({depth:1});const s=t.useProgram("terrainDepth"),l=new e.DepthMode(a.LESS,e.DepthMode.ReadWrite,t.depthRangeFor3D);for(const t of i){const i=r.getTile(t),u=bn(t.projMatrix,0);n.setupElevationDraw(i,s),s.draw(o,a.TRIANGLES,l,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.backCCW,u,"terrain_depth",n.gridBuffer,n.gridIndexBuffer,n.gridNoSkirtSegments)}}(t,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,n){if(e.getSource()instanceof Me)return this._setupProxiedCoordsForImageSource(e,t,n);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],i=this.proxyCoords;for(let t=0;t(e.min.x=Math.min(e.min.x,t.x-s.x),e.min.y=Math.min(e.min.y,t.y-s.y),e.max.x=Math.max(e.max.x,t.x-s.x),e.max.y=Math.max(e.max.y,t.y-s.y),e),{min:new e.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,n)=>{const r=t.wrap+t.canonical.x/(1<a+l.max.x||i+os+l.max.y};for(let e=0;ee.key===n.tileID.key);if(e)return e}if(n.tileID.key!==t.key){const r=t.canonical.z-n.tileID.canonical.z;let o,a,s;i=e.create();const l=n.tileID.wrap-t.wrap<0?(o=e.EXTENT>>r,a=o*((n.tileID.canonical.x<=i){const r=t.canonical.z-i;n.getSource().reparseOverscaled?(s=Math.max(t.canonical.z+2,n.transform.tileZoom),a=new e.OverscaledTileID(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(s=i,a=new e.OverscaledTileID(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r))}a.key!==t.key&&(u.push(a.key),r=n.getTile(a))}const c=e=>{u.forEach(t=>{i[t]=e}),u.length=0};for(s-=1;s>=l&&(!r||!r.hasData());s--){r&&c(r.tileID.key);const e=a.calculateScaledKey(s);if(r=n.getTileByID(e),r&&r.hasData())break;const t=i[e];if(null===t)break;void 0===t?u.push(e):r=n.getTileByID(t)}return c(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let n=this._tilesDirty[e];n||(n=this._tilesDirty[e]={}),n[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let n=0;const r=new e.StructArrayLayout2ui4,i=131;for(let e=1;e<129;e++){for(let t=1;t<129;t++)n=e*i+t,r.emplaceBack(n,n+1),r.emplaceBack(n,n+i),r.emplaceBack(n+1,n+i),128===e&&r.emplaceBack(n+i,n+i+1);r.emplaceBack(n+1,n+1+i)}return r}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=e.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Ln{static cacheKey(e,t,n,r){let i=`${t}${r?r.cacheKey:""}`;for(const t of n)e.usedDefines.includes(t)&&(i+="/"+t);return i}constructor(t,n,r,i,o,a){const s=t.gl;this.program=s.createProgram();const l=function(e){const t=[];for(let n=0;n"#define "+e));const d=t.isWebGL2?"#version 300 es\n":"",f=d+h.concat(t.extStandardDerivatives&&0===d.length?"#extension GL_OES_standard_derivatives : enable\n".concat(hn):hn,hn,cn,un.fragmentSource,sn.fragmentSource,r.fragmentSource).join("\n"),p=d+h.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",cn,un.vertexSource,sn.vertexSource,an.vertexSource,r.vertexSource).join("\n"),m=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(m,f),s.compileShader(m),s.attachShader(this.program,m);const g=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())this.failedToCreate=!0;else{s.shaderSource(g,p),s.compileShader(g),s.attachShader(this.program,g),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.Uniform1i(t),u_dem_prev:new e.Uniform1i(t),u_dem_unpack:new e.Uniform4f(t),u_dem_tl:new e.Uniform2f(t),u_dem_scale:new e.Uniform1f(t),u_dem_tl_prev:new e.Uniform2f(t),u_dem_scale_prev:new e.Uniform1f(t),u_dem_size:new e.Uniform1f(t),u_dem_lerp:new e.Uniform1f(t),u_exaggeration:new e.Uniform1f(t),u_depth:new e.Uniform1i(t),u_depth_size_inv:new e.Uniform2f(t),u_meter_to_dem:new e.Uniform1f(t),u_label_plane_matrix_inv:new e.UniformMatrix4f(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.Uniform3f(t),u_tile_tr_up:new e.Uniform3f(t),u_tile_br_up:new e.Uniform3f(t),u_tile_bl_up:new e.Uniform3f(t),u_tile_up_scale:new e.Uniform1f(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.UniformMatrix4f(t),u_fog_range:new e.Uniform2f(t),u_fog_color:new e.Uniform4f(t),u_fog_horizon_blend:new e.Uniform1f(t),u_fog_temporal_offset:new e.Uniform1f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_globe_transition:new e.Uniform1f(t),u_is_globe:new e.Uniform1i(t),u_viewport:new e.Uniform2f(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const n=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const n=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const n=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}draw(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(n),e.setStencilMode(r),e.setColorMode(i),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);f&&f.setUniforms(this.program,e,this.binderUniforms,h,{zoom:d});const g={[m.LINES]:2,[m.TRIANGLES]:3,[m.LINE_STRIP]:1}[t];for(const n of c.get()){const r=n.vaos||(n.vaos={});(r[s]||(r[s]=new mn)).bind(e,this,l,f?f.getPaintVertexBuffers():[],u,n.vertexOffset,p||[]),m.drawElements(t,n.primitiveLength*g,m.UNSIGNED_SHORT,n.primitiveOffset*g*2)}}}function Dn(e,t){const n=Math.pow(2,t.tileID.overscaledZ),r=t.tileSize*Math.pow(2,e.transform.tileZoom)/n,i=r*(t.tileID.canonical.x+t.tileID.wrap*n),o=r*t.tileID.canonical.y;return{u_image:0,u_texsize:t.imageAtlasTexture.size,u_tile_units_to_pixels:1/I(t,1,e.transform.tileZoom),u_pixel_coord_upper:[i>>16,o>>16],u_pixel_coord_lower:[65535&i,65535&o]}}const Rn=e.create(),Bn=(t,n,r,i,o,a,s,l,u,c,h)=>{const d=n.style.light,f=d.properties.get("position"),p=[f.x,f.y,f.z],m=e.create$1();"viewport"===d.properties.get("anchor")&&(e.fromRotation(m,-n.transform.angle),e.transformMat3(p,p,m));const g=d.properties.get("color"),_=n.transform,y={u_matrix:t,u_lightpos:p,u_lightintensity:d.properties.get("intensity"),u_lightcolor:[g.r,g.g,g.b],u_vertical_gradient:+r,u_opacity:i,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Rn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:a};return"globe"===_.projection.name&&(y.u_tile_id=[s.canonical.x,s.canonical.y,1<{const f=Bn(t,n,r,i,o,a,s,u,c,h,d),p={u_height_factor:-Math.pow(2,s.overscaledZ)/l.tileSize/8};return e.extend(f,Dn(n,l),p)},jn=e=>({u_matrix:e}),Un=(t,n,r)=>e.extend(jn(t),Dn(n,r)),Nn=(e,t)=>({u_matrix:e,u_world:t}),Vn=(t,n,r,i)=>e.extend(Un(t,n,r),{u_world:i}),Gn=e.create(),qn=(t,n,r,i,o,a)=>{const s=t.transform,l="globe"===s.projection.name;let u;if("map"===a.paint.get("circle-pitch-alignment"))if(l){const t=e.globePixelsToTileUnits(s.zoom,n.canonical)*s._pixelsPerMercatorPixel;u=Float32Array.from([t,0,0,t])}else u=s.calculatePixelsToTileUnitsMatrix(r);else u=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:s.cameraToCenterDistance,u_matrix:t.translatePosMatrix(n.projMatrix,r,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_device_pixel_ratio:e.exported.devicePixelRatio,u_extrude_scale:u,u_inv_rot_matrix:Gn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){c.u_inv_rot_matrix=i,c.u_merc_center=o,c.u_tile_id=[n.canonical.x,n.canonical.y,1<{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},Zn=(t,n,r,i)=>{const o=e.EXTENT/r.tileSize;return{u_matrix:t,u_camera_to_center_distance:n.getCameraToCenterDistance(i),u_extrude_scale:[n.pixelsToGLUnits[0]/o,n.pixelsToGLUnits[1]/o]}},Wn=(e,t,n=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:n}),Xn=e.create(),Hn=(t,n,r,i,o,a,s)=>{const l=t.transform,u="globe"===l.projection.name,c=u?e.globePixelsToTileUnits(l.zoom,n.canonical)*l._pixelsPerMercatorPixel:I(r,1,a),h={u_matrix:n.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:Xn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(u){h.u_inv_rot_matrix=i,h.u_merc_center=o,h.u_tile_id=[n.canonical.x,n.canonical.y,1<{const s=e.transform,l=s.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Qn(e,t,n,r),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:er(n)?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Jn(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:a}},Kn=(e,t,n,r,i)=>{const o=e.transform;return{u_matrix:Qn(e,t,n,r),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:Jn(t,o),u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Jn(e,t){return 1/I(e,1,t.tileZoom)}function Qn(e,t,n,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}function er(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const tr=(e,t,n,r,i,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:n,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:(s=i.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=i.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:nr(i.paint.get("raster-hue-rotate")),u_perspective_transform:o};var a,s};function nr(e){e*=Math.PI/180;const t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const rr=e.create(),ir=(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g)=>{const _=o.transform,y={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:_.cameraToCenterDistance,u_rotate_symbol:+r,u_aspect_ratio:_.width/_.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:s,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+i,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:rr,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:rr,u_up_vector:[0,-1,0]};return"globe"===g.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<e.extend(ir(t,n,r,i,o,a,s,l,u,c,d,f,p,m,g,_),{u_gamma_scale:i?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.exported.devicePixelRatio,u_is_halo:+h}),ar=(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,g)=>e.extend(or(t,n,r,i,o,a,s,l,!0,u,!0,h,d,f,p,m,g),{u_texsize_icon:c,u_texture_icon:1}),sr=(e,t,n)=>({u_matrix:e,u_opacity:t,u_color:n}),lr=(t,n,r,i,o)=>e.extend(function(e,t,n){const r=t.imageManager.getPattern(e.toString()),{width:i,height:o}=t.imageManager.getPixelSize(),a=Math.pow(2,n.tileID.overscaledZ),s=n.tileSize*Math.pow(2,t.transform.tileZoom)/a,l=s*(n.tileID.canonical.x+n.tileID.wrap*a),u=s*n.tileID.canonical.y;return{u_image:0,u_pattern_tl:r.tl,u_pattern_br:r.br,u_texsize:[i,o],u_pattern_size:r.displaySize,u_tile_units_to_pixels:1/I(n,1,t.transform.tileZoom),u_pixel_coord_upper:[l>>16,u>>16],u_pixel_coord_lower:[65535&l,65535&u]}}(i,r,o),{u_matrix:t,u_opacity:n}),ur={fillExtrusion:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t)}),fillExtrusionPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_height_factor:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t)}),fill:t=>({u_matrix:new e.UniformMatrix4f(t)}),fillPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),fillOutline:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t)}),fillOutlinePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),circle:t=>({u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),collisionBox:t=>({u_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.Uniform2f(t)}),collisionCircle:t=>({u_matrix:new e.UniformMatrix4f(t),u_inv_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_viewport_size:new e.Uniform2f(t)}),debug:t=>({u_color:new e.UniformColor(t),u_matrix:new e.UniformMatrix4f(t),u_overlay:new e.Uniform1i(t),u_overlay_scale:new e.Uniform1f(t)}),clippingMask:t=>({u_matrix:new e.UniformMatrix4f(t)}),heatmap:t=>({u_extrude_scale:new e.Uniform1f(t),u_intensity:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),heatmapTexture:t=>({u_image:new e.Uniform1i(t),u_color_ramp:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t)}),hillshade:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_latrange:new e.Uniform2f(t),u_light:new e.Uniform2f(t),u_shadow:new e.UniformColor(t),u_highlight:new e.UniformColor(t),u_accent:new e.UniformColor(t)}),hillshadePrepare:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_dimension:new e.Uniform2f(t),u_zoom:new e.Uniform1f(t),u_unpack:new e.Uniform4f(t)}),line:t=>({u_matrix:new e.UniformMatrix4f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_units_to_pixels:new e.Uniform2f(t),u_dash_image:new e.Uniform1i(t),u_gradient_image:new e.Uniform1i(t),u_image_height:new e.Uniform1f(t),u_texsize:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t),u_trim_offset:new e.Uniform2f(t)}),linePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_texsize:new e.Uniform2f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_units_to_pixels:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t)}),raster:t=>({u_matrix:new e.UniformMatrix4f(t),u_tl_parent:new e.Uniform2f(t),u_scale_parent:new e.Uniform1f(t),u_fade_t:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_image0:new e.Uniform1i(t),u_image1:new e.Uniform1i(t),u_brightness_low:new e.Uniform1f(t),u_brightness_high:new e.Uniform1f(t),u_saturation_factor:new e.Uniform1f(t),u_contrast_factor:new e.Uniform1f(t),u_spin_weights:new e.Uniform3f(t),u_perspective_transform:new e.Uniform2f(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_texture:new e.Uniform1i(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_is_halo:new e.Uniform1i(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texsize_icon:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_texture_icon:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_is_halo:new e.Uniform1i(t)}),background:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_color:new e.UniformColor(t)}),backgroundPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_pattern_tl:new e.Uniform2f(t),u_pattern_br:new e.Uniform2f(t),u_texsize:new e.Uniform2f(t),u_pattern_size:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),terrainRaster:xn,terrainDepth:xn,skybox:t=>({u_matrix:new e.UniformMatrix4f(t),u_sun_direction:new e.Uniform3f(t),u_cubemap:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxGradient:t=>({u_matrix:new e.UniformMatrix4f(t),u_color_ramp:new e.Uniform1i(t),u_center_direction:new e.Uniform3f(t),u_radius:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxCapture:t=>({u_matrix_3f:new e.UniformMatrix3f(t),u_sun_direction:new e.Uniform3f(t),u_sun_intensity:new e.Uniform1f(t),u_color_tint_r:new e.Uniform4f(t),u_color_tint_m:new e.Uniform4f(t),u_luminance:new e.Uniform1f(t)}),globeRaster:t=>({u_proj_matrix:new e.UniformMatrix4f(t),u_globe_matrix:new e.UniformMatrix4f(t),u_normalize_matrix:new e.UniformMatrix4f(t),u_merc_matrix:new e.UniformMatrix4f(t),u_zoom_transition:new e.Uniform1f(t),u_merc_center:new e.Uniform2f(t),u_image0:new e.Uniform1i(t),u_grid_matrix:new e.UniformMatrix3f(t),u_skirt_height:new e.Uniform1f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_viewport:new e.Uniform2f(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_horizon:new e.Uniform1f(t),u_transition:new e.Uniform1f(t),u_fadeout_range:new e.Uniform1f(t),u_color:new e.Uniform4f(t),u_high_color:new e.Uniform4f(t),u_space_color:new e.Uniform4f(t),u_star_intensity:new e.Uniform1f(t),u_star_density:new e.Uniform1f(t),u_star_size:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t),u_horizon_angle:new e.Uniform1f(t),u_rotation_matrix:new e.UniformMatrix4f(t)})};let cr;function hr(t,n,r,i,o,a,s){const l=t.context,u=l.gl,c=t.transform,h=t.useProgram("collisionBox"),d=[];let f=0,p=0;for(let m=0;m0){const t=e.create(),n=x;e.mul(t,y.placementInvProjMatrix,c.glCoordMatrix),e.mul(t,t,y.placementViewportMatrix),d.push({circleArray:w,circleOffset:p,transform:n,invTransform:t,projection:y.getProjection()}),f+=w.length/4,p=f}b&&(t.terrain&&t.terrain.setupElevationDraw(_,h),h.draw(l,u.LINES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,Zn(x,c,_,y.getProjection()),r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,c.zoom,null,[b.collisionVertexBuffer,b.collisionVertexBufferExt]))}if(!s||!d.length)return;const m=t.useProgram("collisionCircle"),g=new e.StructArrayLayout2f1f2i16;g.resize(4*f),g._trim();let _=0;for(const e of d)for(let t=0;t=0&&(m[x.associatedIconIndex]={x:S,y:A,z:k,angle:O})}else mt(E,f)}if(h){p.clear();const n=t.icon.placedSymbolArray;for(let t=0;te.sortKey-t.sortKey);for(const e of A){const n=e.state;if(t.terrain&&t.terrain.setupElevationDraw(n.tile,n.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:n.labelPlaneMatrixInv}),f.activeTexture.set(p.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,p.CLAMP_TO_EDGE),n.atlasTextureIcon&&(f.activeTexture.set(p.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),n.isSDF){const i=n.uniformValues;n.hasHalo&&(i.u_is_halo=1,_r(n.buffers,e.segments,r,t,n.program,w,h,d,i)),i.u_is_halo=0}_r(n.buffers,e.segments,r,t,n.program,w,h,d,n.uniformValues)}}function _r(t,n,r,i,o,a,s,l,u){const c=i.context,h=[t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.globeExtVertexBuffer];o.draw(c,c.gl.TRIANGLES,a,s,l,e.CullFaceMode.disabled,u,r.id,t.layoutVertexBuffer,t.indexBuffer,n,r.paint,i.transform.zoom,t.programConfigurations.get(r.id),h)}function yr(t,n,r,i,o,a,s){const l=t.context.gl,u=r.paint.get("fill-pattern"),c=u&&u.constantOr(1);let h,d,f,p,m;s?(d=c&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=l.LINES):(d=c?"fillPattern":"fill",h=l.TRIANGLES);for(const g of i){const i=n.getTile(g);if(c&&!i.patternsLoaded())continue;const _=i.getBucket(r);if(!_)continue;t.prepareDrawTile();const y=_.programConfigurations.get(r.id),v=t.useProgram(d,y);c&&(t.context.activeTexture.set(l.TEXTURE0),i.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),y.updatePaintBuffers());const x=u.constantOr(null);if(x&&i.imageAtlas){const e=i.imageAtlas.patternPositions[x.toString()];e&&y.setConstantPatternPositions(e)}const b=t.translatePosMatrix(g.projMatrix,i,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if(s){p=_.indexBuffer2,m=_.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===d&&c?Vn(b,t,i,e):Nn(b,e)}else p=_.indexBuffer,m=_.segments,f=c?Un(b,t,i):jn(b);t.prepareDrawProgram(t.context,v,g.toUnwrapped()),v.draw(t.context,h,o,t.stencilModeForClipping(g),a,e.CullFaceMode.disabled,f,r.id,_.layoutVertexBuffer,p,m,r.paint,t.transform.zoom,y)}}function vr(t,n,r,i,o,a,s){const l=t.context,u=l.gl,c=t.transform,h=r.paint.get("fill-extrusion-pattern"),d=h.constantOr(1),f=r.paint.get("fill-extrusion-opacity"),p=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),r.paint.get("fill-extrusion-ambient-occlusion-radius")],m=r.layout.get("fill-extrusion-edge-radius"),g=m>0&&!r.paint.get("fill-extrusion-rounded-roof"),_=g?0:m,y="globe"===c.projection.name?e.fillExtrusionHeightLift():0,v="globe"===c.projection.name,x=v?e.globeToMercatorTransition(c.zoom):0,b=[e.mercatorXfromLng(c.center.lng),e.mercatorYfromLat(c.center.lat)],w=[];v&&w.push("PROJECTION_GLOBE_VIEW"),p[0]>0&&w.push("FAUX_AO"),g&&w.push("ZERO_ROOF_RADIUS");for(const m of i){const i=n.getTile(m),g=i.getBucket(r);if(!g||g.projection.name!==c.projection.name)continue;const E=g.programConfigurations.get(r.id),T=t.useProgram(d?"fillExtrusionPattern":"fillExtrusion",E,w);if(t.terrain){const e=t.terrain;if(t.style.terrainSetForDrapingOnly())e.setupElevationDraw(i,T,{useMeterToDem:!0});else{if(!g.enableTerrain)continue;if(e.setupElevationDraw(i,T,{useMeterToDem:!0}),xr(l,n,m,g,r,e),!g.centroidVertexBuffer){const e=T.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}}}d&&(t.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),E.updatePaintBuffers());const S=h.constantOr(null);if(S&&i.imageAtlas){const e=i.imageAtlas.patternPositions[S.toString()];e&&E.setConstantPatternPositions(e)}const A=t.translatePosMatrix(m.projMatrix,i,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),k=c.projection.createInversionMatrix(c,m.canonical),M=r.paint.get("fill-extrusion-vertical-gradient"),C=d?Fn(A,t,M,f,p,_,m,i,y,x,b,k):Bn(A,t,M,f,p,_,m,y,x,b,k);t.prepareDrawProgram(l,T,m.toUnwrapped());const I=[];t.terrain&&I.push(g.centroidVertexBuffer),v&&I.push(g.layoutVertexExtBuffer),T.draw(l,l.gl.TRIANGLES,o,a,s,e.CullFaceMode.backCCW,C,r.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,r.paint,t.transform.zoom,E,I)}}function xr(t,n,r,i,o,a){const s=[t=>{let n=t.canonical.x-1,r=t.wrap;return n<0&&(n=(1<{let n=t.canonical.x+1,r=t.wrap;return n===1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<{const t=n.getSource().minzoom,r=e=>{const t=n.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},i=[0,-1,1];for(const n of i){if(e.overscaledZ+n(u[0]=Math.min(t.min.y,n.min.y),u[1]=Math.max(t.max.y,n.max.y),u[2]=e.EXTENT-n.min.x>t.max.x?n.min.x-e.EXTENT:t.max.x,u),h=(t,n)=>(u[0]=Math.min(t.min.x,n.min.x),u[1]=Math.max(t.max.x,n.max.x),u[2]=e.EXTENT-n.min.y>t.max.y?n.min.y-e.EXTENT:t.max.y,u),d=[(e,t)=>c(e,t),(e,t)=>c(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],f=new e.Point(0,0);let p,m,g;const _=(t,n,i,o,s)=>{const l=[[o?i:t,o?t:i,0],[o?i:n,o?n:i,0]],u=s<0?e.EXTENT+s:s,c=[o?u:(t+n)/2,o?(t+n)/2:u,0];return 0===i&&s<0||0!==i&&s>0?a.getForTilePoints(g,[c],!0,m):l.push(c),a.getForTilePoints(r,l,!0,p),Math.max(l[0][2],l[1][2],c[2])/a.exaggeration()};for(let t=0;t<4;t++){const n=(t<2?1:5)-t,o=i.borders[t];if(0===o.length)continue;const u=g=s[t](r),c=l(u);if(!(c&&c instanceof e.FillExtrusionBucket&&c.enableTerrain))continue;if(i.borderDoneWithNeighborZ[t]===c.canonical.z&&c.borderDoneWithNeighborZ[n]===i.canonical.z)continue;if(m=a.findDEMTileFor(u),!m||!m.dem)continue;if(!p){const e=a.findDEMTileFor(r);if(!e||!e.dem)return;p=e}const h=c.borders[n];let y=0;const v=c.borderDoneWithNeighborZ[n]!==i.canonical.z;if(i.canonical.z===c.canonical.z){for(let r=0;rs[0]+3));)v&&c.encodeCentroid(void 0,l,!1),y++;if(l&&ys[1]-3)&&(o++,++y!==h.length);)l=c.featuresOnBorder[h[y]];if(l=c.featuresOnBorder[h[r]],a.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(y=r),i.encodeCentroid(void 0,a,!1),v&&c.encodeCentroid(void 0,l,!1);continue}const u=d[t](a,l),p=t%2?e.EXTENT-1:0;f.x=_(u[0],Math.min(e.EXTENT-1,u[1]),p,t<2,u[2]),f.y=0,i.encodeCentroid(f,a,!1),v&&c.encodeCentroid(f,l,!1)}else i.encodeCentroid(void 0,a,!1)}i.borderDoneWithNeighborZ[t]=c.canonical.z,i.needsCentroidUpdate=!0,v&&(c.borderDoneWithNeighborZ[n]=i.canonical.z,c.needsCentroidUpdate=!0)}else{for(const e of o)i.encodeCentroid(void 0,i.featuresOnBorder[e],!1);if(v){for(const e of h)c.encodeCentroid(void 0,c.featuresOnBorder[e],!1);c.borderDoneWithNeighborZ[n]=i.canonical.z,c.needsCentroidUpdate=!0}i.borderDoneWithNeighborZ[t]=c.canonical.z,i.needsCentroidUpdate=!0}}(i.needsCentroidUpdate||!i.centroidVertexBuffer&&0!==i.centroidVertexArray.length)&&i.uploadCentroid(t)}const br=new e.Color(1,0,0,1),wr=new e.Color(0,1,0,1),Er=new e.Color(0,0,1,1),Tr=new e.Color(1,0,1,1),Sr=new e.Color(0,1,1,1);function Ar(t,n,r){const i=t.context,o=t.transform,a=i.gl,s="globe"===o.projection.name,l=s?["PROJECTION_GLOBE_VIEW"]:null;let u=r.projMatrix;if(s&&e.globeToMercatorTransition(o.zoom)>0){const t=e.transitionTileAABBinECEF(r.canonical,o),n=e.globeDenormalizeECEF(t);u=e.multiply(new Float32Array(16),o.globeMatrix,n),e.multiply(u,o.projMatrix,u)}const c=t.useProgram("debug",null,l),h=n.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(h,c);const d=e.DepthMode.disabled,f=e.StencilMode.disabled,p=t.colorModeForRenderPass(),m="$debug";i.activeTexture.set(a.TEXTURE0),t.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),s?h._makeGlobeTileDebugBuffers(t.context,o):h._makeDebugTileBoundsBuffers(t.context,o.projection);const g=h._tileDebugBuffer||t.debugBuffer,_=h._tileDebugIndexBuffer||t.debugIndexBuffer,y=h._tileDebugSegments||t.debugSegments;c.draw(i,a.LINE_STRIP,d,f,p,e.CullFaceMode.disabled,Wn(u,e.Color.red),m,g,_,y,null,null,null,[h._globeTileDebugBorderBuffer]);const v=h.latestRawTileData,x=Math.floor((v&&v.byteLength||0)/1024),b=n.getTile(r).tileSize,w=512/Math.min(b,512)*(r.overscaledZ/o.zoom)*.5;let E=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(E+=" => "+r.overscaledZ),E+=` ${x}kb`,function(e,t){e.initDebugOverlayCanvas();const n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,n.width,n.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,E);const T=h._tileDebugTextBuffer||t.debugBuffer,S=h._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,A=h._tileDebugTextSegments||t.debugSegments;c.draw(i,a.TRIANGLES,d,f,e.ColorMode.alphaBlended,e.CullFaceMode.disabled,Wn(u,e.Color.transparent,w),m,T,S,A,null,null,null,[h._globeTileDebugTextBuffer])}function kr(e,t,n,r){Cr(e,0,t+n/2,e.transform.width,n,r)}function Mr(e,t,n,r){Cr(e,t-n/2,0,n,e.transform.height,r)}function Cr(t,n,r,i,o,a){const s=t.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(n*e.exported.devicePixelRatio,r*e.exported.devicePixelRatio,i*e.exported.devicePixelRatio,o*e.exported.devicePixelRatio),s.clear({color:a}),l.disable(l.SCISSOR_TEST)}const Ir=e.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Pr}=Ir;function Or(e,t,n,r){e.emplaceBack(t,n,r)}class zr{constructor(t){this.vertexArray=new e.StructArrayLayout3f12,this.indices=new e.StructArrayLayout3ui6,Or(this.vertexArray,-1,-1,1),Or(this.vertexArray,1,-1,1),Or(this.vertexArray,-1,1,1),Or(this.vertexArray,1,1,1),Or(this.vertexArray,-1,-1,-1),Or(this.vertexArray,1,-1,-1),Or(this.vertexArray,-1,1,-1),Or(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=t.createVertexBuffer(this.vertexArray,Pr),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.SegmentVector.simpleSegment(0,0,36,12)}}function Lr(t,n,r,i,o,a){const s=t.gl,l=n.paint.get("sky-atmosphere-color"),u=n.paint.get("sky-atmosphere-halo-color"),c=n.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,n,r,i)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:n,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[i.r,i.g,i.b,i.a],u_luminance:5e-5}))(e.fromMat4(e.create$1(),i),o,c,l,u);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+a,n.skyboxTexture,0),r.draw(t,s.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.frontCW,h,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const Dr=e.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Rr{constructor(t){const n=new e.StructArrayLayout5f20;n.emplaceBack(-1,1,1,0,0),n.emplaceBack(1,1,1,1,0),n.emplaceBack(1,-1,1,1,1),n.emplaceBack(-1,-1,1,0,1);const r=new e.StructArrayLayout3ui6;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(n,Dr.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=e.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Br={symbol:function(t,n,r,i,o){if("translucent"!==t.renderPass)return;const a=e.StencilMode.disabled,s=t.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(t,n,r,i,o,a,s){const l=n.transform,u="map"===o,c="map"===a;for(const n of t){const t=i.getTile(n),o=t.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const a=e.evaluateSizeForZoom(o.textSizeData,l.zoom),h=bt(n,o.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),f=nt(h,t.tileID.canonical,c,u,l,o.getProjection(),d),p="none"!==r.layout.get("icon-text-fit")&&o.hasIconData();if(a){const r=Math.pow(2,l.zoom-t.tileID.overscaledZ);pr(o,u,c,s,e.symbolSize,l,f,n,r,a,p)}}}(i,t,r,n,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&gr(t,n,r,i,!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"),a,s),0!==r.paint.get("text-opacity").constantOr(1)&&gr(t,n,r,i,!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"),a,s),n.map.showCollisionBoxes&&(hr(t,n,r,i,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),hr(t,n,r,i,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===a.constantOr(1)||0===s.constantOr(1)))return;const u=t.context,c=u.gl,h=t.transform,d=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),f=e.StencilMode.disabled,p=t.colorModeForRenderPass(),m="globe"===h.projection.name,g=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],_=[];for(let o=0;oe.sortKey-t.sortKey);const y={useDepthForOcclusion:!m};for(const n of _){const{programConfiguration:i,program:o,layoutVertexBuffer:a,globeExtVertexBuffer:s,indexBuffer:l,uniformValues:m,tile:g}=n.state,_=n.segments;t.terrain&&t.terrain.setupElevationDraw(g,o,y),t.prepareDrawProgram(u,o,g.tileID.toUnwrapped()),o.draw(u,c.TRIANGLES,d,f,p,e.CullFaceMode.disabled,m,r.id,a,l,_,r.paint,h.zoom,i,[s])}},heatmap:function(t,n,r,i){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,a=o.gl,s=e.StencilMode.disabled,l=new e.ColorMode([a.ONE,a.ONE],e.Color.transparent,[!0,!0,!0,!0]);!function(e,t,n,r){const i=e.gl,o=t.width*r,a=t.height*r;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,o,a]);let s=n.heatmapFbo;if(!s||s&&(s.width!==o||s.height!==a)){s&&s.destroy();const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),s=n.heatmapFbo=e.createFramebuffer(o,a,!1),function(e,t,n,r,i,o){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,e.isWebGL2&&e.extRenderToTextureHalfFloat?a.RGBA16F:a.RGBA,i,o,0,a.RGBA,e.extRenderToTextureHalfFloat?e.isWebGL2?a.HALF_FLOAT:e.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),r.colorAttachment.set(n)}(e,0,t,s,o,a)}else i.bindTexture(i.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)}(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.Color.transparent});const u=t.transform,c="globe"===u.projection.name,h=c?["PROJECTION_GLOBE_VIEW"]:null,d=c?e.CullFaceMode.frontCCW:e.CullFaceMode.disabled,f=[e.mercatorXfromLng(u.center.lng),e.mercatorYfromLat(u.center.lat)];for(let p=0;p({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,n),n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,n.paint,t.transform.zoom)}(t,r))},line:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),a=r.paint.get("line-width");if(0===o.constantOr(1)||0===a.constantOr(1))return;const s=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),l=t.colorModeForRenderPass(),u=t.terrain&&t.terrain.renderingToTexture?1:e.exported.devicePixelRatio,c=r.paint.get("line-dasharray"),h=c.constantOr(1),d=r.layout.get("line-cap"),f=r.paint.get("line-pattern"),p=f.constantOr(1),m=r.paint.get("line-gradient"),g=p?"linePattern":"line",_=t.context,y=_.gl,v=(e=>{const t=[];er(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const n=e.paint.get("line-trim-offset");0===n[0]&&0===n[1]||t.push("RENDER_LINE_TRIM_OFFSET");const r=e.paint.get("line-pattern").constantOr(1),i=1!==e.paint.get("line-opacity").constantOr(1);return!r&&i&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(r);let x=v.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(x=!1);for(const o of i){const i=n.getTile(o);if(p&&!i.patternsLoaded())continue;const a=i.getBucket(r);if(!a)continue;t.prepareDrawTile();const b=a.programConfigurations.get(r.id),w=t.useProgram(g,b,v),E=f.constantOr(null);if(E&&i.imageAtlas){const e=i.imageAtlas.patternPositions[E.toString()];e&&b.setConstantPatternPositions(e)}const T=c.constantOr(null),S=d.constantOr(null);if(!p&&T&&S&&i.lineAtlas){const e=i.lineAtlas.getDash(T,S);e&&b.setConstantPatternPositions(e)}let[A,k]=r.paint.get("line-trim-offset");if("round"===S||"square"===S){const e=1;A!==k&&(0===A&&(A-=e),1===k&&(k+=e))}const M=t.terrain?o.projMatrix:null,C=p?Kn(t,i,r,M,u):Yn(t,i,r,M,a.lineClipsArray.length,u,[A,k]);if(m){const i=a.gradients[r.id];let s=i.texture;if(r.gradientVersion!==i.version){let l=256;if(r.stepInterpolant){const r=n.getSource().maxzoom,i=o.canonical.z===r?Math.ceil(1<{w.draw(_,y.TRIANGLES,s,n,l,e.CullFaceMode.disabled,C,r.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,r.paint,t.transform.zoom,b,[a.layoutVertexBuffer2])};if(x){const n=t.stencilModeForClipping(o).ref;0===n&&t.terrain&&_.clear({stencil:0});const r={func:y.EQUAL,mask:255};C.u_alpha_discard_threshold=.8,I(new e.StencilMode(r,n,255,y.KEEP,y.KEEP,y.INVERT)),C.u_alpha_discard_threshold=0,I(new e.StencilMode(r,n,255,y.KEEP,y.KEEP,y.KEEP))}else I(t.stencilModeForClipping(o))}x&&(t.resetStencilClippingMasks(),t.terrain&&_.clear({stencil:0}))},fill:function(t,n,r,i){const o=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const s=t.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(e.Color.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const o=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly);yr(t,n,r,i,o,s,!1)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const o=t.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,e.DepthMode.ReadOnly);yr(t,n,r,i,o,s,!0)}},"fill-extrusion":function(t,n,r,i){const o=r.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===t.renderPass){const a=new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);if(1!==o||r.paint.get("fill-extrusion-pattern").constantOr(1))vr(t,n,r,i,a,e.StencilMode.disabled,e.ColorMode.disabled),vr(t,n,r,i,a,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const o=t.colorModeForRenderPass();vr(t,n,r,i,a,e.StencilMode.disabled,o)}}},hillshade:function(t,n,r,i){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const o=t.context,a=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),s=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture,[u,c]="translucent"!==t.renderPass||l?[{},i]:t.stencilConfigForOverlap(i);for(const i of c){const o=n.getTile(i);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)vn(t,o,r,a,e.StencilMode.disabled,s);else if("translucent"===t.renderPass){const e=l&&t.terrain?t.terrain.stencilModeForRTTOverlap(i):u[i.overscaledZ];_n(t,i,o,r,a,e,s)}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,n,r,i,o,a){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;if(!i.length)return;const s=t.context,l=s.gl,u=n.getSource(),c=t.useProgram("raster"),h=t.colorModeForRenderPass(),d=t.terrain&&t.terrain.renderingToTexture,[f,p]=u instanceof Me||d?[{},i]:t.stencilConfigForOverlap(i),m=p[p.length-1].overscaledZ,g=!t.options.moving;for(const i of p){const o=d?e.DepthMode.disabled:t.depthModeForSublayer(i.overscaledZ-m,1===r.paint.get("raster-opacity")?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly,l.LESS),p=i.toUnwrapped(),_=n.getTile(i);if(d&&(!_||!_.hasData()))continue;const y=d?i.projMatrix:t.transform.calculateProjMatrix(p,g),v=t.terrain&&d?t.terrain.stencilModeForRTTOverlap(i):f[i.overscaledZ],x=a?0:r.paint.get("raster-fade-duration");_.registerFadeDuration(x);const b=n.findLoadedParent(i,0),w=Cn(_,b,n,t.transform,x);let E,T;t.terrain&&t.terrain.prepareDrawTile();const S="nearest"===r.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;s.activeTexture.set(l.TEXTURE0),_.texture.bind(S,l.CLAMP_TO_EDGE),s.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),E=Math.pow(2,b.tileID.overscaledZ-_.tileID.overscaledZ),T=[_.tileID.canonical.x*E%1,_.tileID.canonical.y*E%1]):_.texture.bind(S,l.CLAMP_TO_EDGE),_.texture.useMipmap&&s.extTextureFilterAnisotropic&&t.transform.pitch>20&&l.texParameterf(l.TEXTURE_2D,s.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,s.extTextureFilterAnisotropicMax);const A=tr(y,T||[0,0],E||1,w,r,u instanceof Me?u.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(s,c,p),u instanceof Me)u.boundsBuffer&&u.boundsSegments&&c.draw(s,l.TRIANGLES,o,e.StencilMode.disabled,h,e.CullFaceMode.disabled,A,r.id,u.boundsBuffer,t.quadTriangleIndexBuffer,u.boundsSegments);else{const{tileBoundsBuffer:n,tileBoundsIndexBuffer:i,tileBoundsSegments:a}=t.getTileBoundsBuffers(_);c.draw(s,l.TRIANGLES,o,v,h,e.CullFaceMode.disabled,A,r.id,n,i,a)}}t.resetStencilClippingMasks()},background:function(t,n,r,i){const o=r.paint.get("background-color"),a=r.paint.get("background-opacity");if(0===a)return;const s=t.context,l=s.gl,u=t.transform,c=u.tileSize,h=r.paint.get("background-pattern");if(t.isPatternMissing(h))return;const d=!h&&1===o.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==d)return;const f=e.StencilMode.disabled,p=t.depthModeForSublayer(0,"opaque"===d?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly),m=t.colorModeForRenderPass(),g=t.useProgram(h?"backgroundPattern":"background");let _,y=i;y||(_=t.getBackgroundTiles(),y=Object.values(_).map(e=>e.tileID)),h&&(s.activeTexture.set(l.TEXTURE0),t.imageManager.bind(t.context));for(const d of y){const y=d.toUnwrapped(),v=i?d.projMatrix:t.transform.calculateProjMatrix(y);t.prepareDrawTile();const x=n?n.getTile(d):_?_[d.key]:new e.Tile(d,c,u.zoom,t),b=h?lr(v,a,t,h,{tileID:d,tileSize:c}):sr(v,a,o);t.prepareDrawProgram(s,g,y);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:E,tileBoundsSegments:T}=t.getTileBoundsBuffers(x);g.draw(s,l.TRIANGLES,p,f,m,e.CullFaceMode.disabled,b,r.id,w,E,T)}},sky:function(t,n,r){const i=t.transform,o="mercator"===i.projection.name||"globe"===i.projection.name?1:e.smoothstep(7,8,i.zoom),a=r.paint.get("sky-opacity")*o;if(0===a)return;const s=t.context,l=r.paint.get("sky-type"),u=new e.DepthMode(s.gl.LEQUAL,e.DepthMode.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&(function(t,n,r,i){const o=t.context,a=o.gl;let s=n.skyboxFbo;if(!s){s=n.skyboxFbo=o.createFramebuffer(32,32,!1),n.skyboxGeometry=new zr(o),n.skyboxTexture=o.gl.createTexture(),a.bindTexture(a.TEXTURE_CUBE_MAP,n.skyboxTexture),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR);for(let e=0;e<6;++e)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,a.RGBA,32,32,0,a.RGBA,a.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(s.framebuffer),o.viewport.set([0,0,32,32]);const l=n.getCenter(t,!0),u=t.useProgram("skyboxCapture"),c=new Float64Array(16);e.identity(c),e.rotateY(c,c,.5*-Math.PI),Lr(o,n,u,c,l,0),e.identity(c),e.rotateY(c,c,.5*Math.PI),Lr(o,n,u,c,l,1),e.identity(c),e.rotateX(c,c,.5*-Math.PI),Lr(o,n,u,c,l,2),e.identity(c),e.rotateX(c,c,.5*Math.PI),Lr(o,n,u,c,l,3),e.identity(c),Lr(o,n,u,c,l,4),e.identity(c),e.rotateY(c,c,Math.PI),Lr(o,n,u,c,l,5),o.viewport.set([0,0,t.width,t.height])}(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,n,r,i,o){const a=t.context,s=a.gl,l=t.transform,u=t.useProgram("skybox");a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,n.skyboxTexture);const c=((e,t,n,r,i)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:i}))(l.skyboxMatrix,n.getCenter(t,!1),0,i,o);t.prepareDrawProgram(a,u),u.draw(a,s.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,c,"skybox",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,r,u,a,c):"gradient"===l&&"sky"===t.renderPass&&function(t,n,r,i,o){const a=t.context,s=a.gl,l=t.transform,u=t.useProgram("skyboxGradient");n.skyboxGeometry||(n.skyboxGeometry=new zr(a)),a.activeTexture.set(s.TEXTURE0);let c=n.colorRampTexture;c||(c=n.colorRampTexture=new e.Texture(a,n.colorRamp,s.RGBA)),c.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=((t,n,r,i,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:n,u_radius:e.degToRad(r),u_opacity:i,u_temporal_offset:o}))(l.skyboxMatrix,n.getCenter(t,!1),n.paint.get("sky-gradient-radius"),i,o);t.prepareDrawProgram(a,u),u.draw(a,s.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,h,"skyboxGradient",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,r,u,a,c)},debug:function(e,t,n){for(let r=0;rr)return void(this.transform.fogCullDistSq=null);const i=n+.78*(r-n);this.transform.fogCullDistSq=i*i}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,n){if(this.width=t*e.exported.devicePixelRatio,this.height=n*e.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,n=new e.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(e.EXTENT,0),n.emplaceBack(0,e.EXTENT),n.emplaceBack(e.EXTENT,e.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(n,e.posAttributes.members),this.tileExtentSegments=e.SegmentVector.simpleSegment(0,0,4,2);const r=new e.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(e.EXTENT,0),r.emplaceBack(0,e.EXTENT),r.emplaceBack(e.EXTENT,e.EXTENT),this.debugBuffer=t.createVertexBuffer(r,e.posAttributes.members),this.debugSegments=e.SegmentVector.simpleSegment(0,0,4,5);const i=new e.StructArrayLayout2i4;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(-1,1),i.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(i,e.posAttributes.members),this.viewportSegments=e.SegmentVector.simpleSegment(0,0,4,2);const o=new e.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(e.EXTENT,0,e.EXTENT,0),o.emplaceBack(0,e.EXTENT,0,e.EXTENT),o.emplaceBack(e.EXTENT,e.EXTENT,e.EXTENT,e.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.boundsAttributes.members),this.mercatorBoundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);const a=new e.StructArrayLayout3ui6;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const s=new e.StructArrayLayout1ui2;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(s),this.emptyTexture=new e.Texture(t,new e.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.create();const l=this.context.gl;this.stencilClearMode=new e.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.window.performance.now()),this.atmosphereBuffer=new Rr(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(t,n.TRIANGLES,e.DepthMode.disabled,this.stencilClearMode,e.ColorMode.disabled,e.CullFaceMode.disabled,Mn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,n,r){if(!n||this.currentStencilSource===n.id||!t.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of r)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=n.id;const i=this.context,o=i.gl;this.nextStencilID+r.length>256&&this.clearStencil(),i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of r){const r=n.getTile(t),s=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:u,tileBoundsSegments:c}=this.getTileBoundsBuffers(r);a.draw(i,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},s,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Mn(t.projMatrix),"$clipping",l,u,c)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new e.StencilMode({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const n=this.context.gl;return new e.StencilMode({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,r=t.sort((e,t)=>t.overscaledZ-e.overscaledZ),i=r[r.length-1].overscaledZ,o=r[0].overscaledZ-i+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let r=0;r=0;this.currentLayer--){const e=this.style._layers[r[this.currentLayer]],n=t._getLayerSourceCache(e);if(e.isSky())continue;const i=n?a[n.id]:void 0;this._renderTileClippingMasks(e,n,i),this.renderLayer(this,n,e,i)}if(this.style.fog&&this.transform.projection.supportsFog&&function(t,n){const r=t.context,i=r.gl,o=t.transform,a=new e.DepthMode(i.LEQUAL,e.DepthMode.ReadOnly,[0,1]),s=t.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=e.globeToMercatorTransition(o.zoom),u=n.properties.get("color").toArray01(),c=n.properties.get("high-color").toArray01(),h=n.properties.get("space-color").toArray01PremultipliedAlpha(),d=e.identity$1([]);e.rotateY$1(d,d,-e.degToRad(o._center.lng)),e.rotateX$1(d,d,e.degToRad(o._center.lat)),e.rotateZ$1(d,d,o.angle),e.rotateX$1(d,d,-o._pitch);const f=e.fromQuat(new Float32Array(16),d),p=e.mapValue(n.properties.get("star-intensity"),0,1,0,.25),m=5e-4,g=e.mapValue(n.properties.get("horizon-blend"),0,1,m,.25),_=e.globeUseCustomAntiAliasing(t,r,o)&&g===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=t.frameCounter/1e3%1,v=e.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(_,2)),b=Math.acos(x/v),w=((t,n,r,i,o,a,s,l,u,c,h,d,f,p)=>({u_frustum_tl:t,u_frustum_tr:n,u_frustum_br:r,u_frustum_bl:i,u_horizon:o,u_transition:a,u_fadeout_range:s,u_color:l,u_high_color:u,u_space_color:c,u_star_intensity:h,u_star_size:5*e.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:d,u_horizon_angle:f,u_rotation_matrix:p}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,l,g,u,c,h,p,y,b,f);t.prepareDrawProgram(r,s);const E=t.atmosphereBuffer;E&&s.draw(r,i.TRIANGLES,a,e.StencilMode.disabled,e.ColorMode.alphaBlended,e.CullFaceMode.backCW,w,"skybox",E.vertexBuffer,E.indexBuffer,E.segments)}(this,this.style.fog),this.renderPass="sky",(e.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const r=t._getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&(!n||n.getSource().maxzoom0?t.pop():null}isPatternMissing(e){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.terrain&&0===this.terrain.exaggeration(),n=this.style&&this.style.fog,r=[];return this.terrainRenderModeElevated()&&r.push("TERRAIN"),"globe"===this.transform.projection.name&&r.push("GLOBE"),t&&r.push("ZERO_EXAGGERATION"),n&&!e&&0!==n.getOpacity(this.transform.pitch)&&r.push("FOG"),e&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}useProgram(e,t,n){this.cache=this.cache||{};const r=n||[],i=this.currentGlobalDefines().concat(r),o=Ln.cacheKey(dn[e],e,i,t);return this.cache[o]||(this.cache[o]=new Ln(this.context,e,dn[e],t,ur[e],i)),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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=e.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.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(t,n,r){if(this.terrain&&this.terrain.renderingToTexture)return;const i=this.style.fog;if(i){const o=i.getOpacity(this.transform.pitch),a=((t,n,r,i,o,a,s,l,u,c,h)=>{const d=t.transform,f=n.properties.get("color").toArray01();f[3]=i;const p=t.frameCounter/1e3%1;return{u_fog_matrix:r?d.calculateFogTileMatrix(r):t.identityMat,u_fog_range:n.getFovAdjustedRange(d._fov),u_fog_color:f,u_fog_horizon_blend:n.properties.get("horizon-blend"),u_fog_temporal_offset:p,u_frustum_tl:o,u_frustum_tr:a,u_frustum_br:s,u_frustum_bl:l,u_globe_pos:u,u_globe_radius:c,u_viewport:h,u_globe_transition:e.globeToMercatorTransition(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,i,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*e.exported.devicePixelRatio,this.transform.height*e.exported.devicePixelRatio]);n.setFogUniformValues(t,a)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1)}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,n=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const i of r)n[i.key]=t[i.key]||new e.Tile(i,512,this.transform.tileZoom,this);return n}clearBackgroundTiles(){this._backgroundTiles={}}}class jr{constructor(e=0,t=0,n=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(t,n,r){return null!=n.top&&null!=t.top&&(this.top=e.number(t.top,n.top,r)),null!=n.bottom&&null!=t.bottom&&(this.bottom=e.number(t.bottom,n.bottom,r)),null!=n.left&&null!=t.left&&(this.left=e.number(t.left,n.left,r)),null!=n.right&&null!=t.right&&(this.right=e.number(t.right,n.right,r)),this}getCenter(t,n){const r=e.clamp((this.left+t-this.right)/2,0,t),i=e.clamp((this.top+n-this.bottom)/2,0,n);return new e.Point(r,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new jr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ur(t,n){const r=e.getColumn(t,3);e.fromQuat(t,n),e.setColumn(t,3,r)}function Nr(t,n){const r=e.identity$1([]);return e.rotateZ$1(r,r,-n),e.rotateX$1(r,r,-t),r}function Vr(t,n){const r=[t[0],t[1],0],i=[n[0],n[1],0];if(e.length(r)>=1e-15){const t=e.normalize([],r);e.scale$2(i,t,e.dot(i,t)),n[0]=i[0],n[1]=i[1]}const o=e.cross([],n,t);if(e.len(o)<1e-15)return null;const a=Math.atan2(-o[1],o[0]);return Nr(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),a)}class Gr{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const n=t instanceof e.MercatorCoordinate?t:new e.MercatorCoordinate(t[0],t[1],t[2]);this._renderWorldCopies&&(n.x=e.wrap(n.x,0,1)),this._position=n}else this._position=null}lookAtPoint(t,n){if(this.orientation=null,!this.position)return;const r=this.position,i=this._elevation?this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t)):0,o=e.MercatorCoordinate.fromLngLat(t,i),a=[o.x-r.x,o.y-r.y,o.z-r.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=Vr(a,n)}setPitchBearing(t,n){this.orientation=Nr(e.degToRad(t),e.degToRad(-n))}}class qr{constructor(t,n){this._transform=e.identity([]),this.orientation=n,this.position=t}get mercatorPosition(){const t=this.position;return new e.MercatorCoordinate(t[0],t[1],t[2])}get position(){const t=e.getColumn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var n;t&&e.setColumn(this._transform,3,[(n=t)[0],n[1],n[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.identity$1([]),t&&Ur(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Nr(e,t),Ur(this._transform,this._orientation)}forward(){const t=e.getColumn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.getColumn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.getColumn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,n){const r=new Float64Array(16);return e.invert(r,this.getWorldToCamera(t,n)),r}getWorldToCameraPosition(t,n,r){const i=this.position;e.scale$2(i,i,-t);const o=new Float64Array(16);return e.fromScaling(o,[r,r,r]),e.translate(o,o,i),o[10]*=n,o}getWorldToCamera(t,n){const r=new Float64Array(16),i=new Float64Array(4),o=this.position;return e.conjugate(i,this._orientation),e.scale$2(o,o,-t),e.fromQuat(r,i),e.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=n,r[9]*=n,r[10]*=n,r[11]*=n,r}getCameraToClipPerspective(t,n,r,i){const o=new Float64Array(16);return e.perspective(o,t,n,r,i),o}getDistanceToElevation(t,n=!1){const r=0===t?0:e.mercatorZfromAltitude(t,n?e.latFromMercatorY(this.position[1]):this.position[1]),i=this.forward();return(r-this.position[2])/i[2]}clone(){return new qr([...this.position],[...this.orientation])}}function $r(t,n){const r=Wr(t.projection,t.zoom,t.width,t.height),i=function(t,n,r,i,o){const a=new e.LngLat(r.lng-180*Xr,r.lat),s=new e.LngLat(r.lng+180*Xr,r.lat),l=t.project(a.lng,a.lat),u=t.project(s.lng,s.lat),c=-Math.atan2(u.y-l.y,u.x-l.x),h=e.MercatorCoordinate.fromLngLat(r);h.y=e.clamp(h.y,-1+Xr,1-Xr);const d=h.toLngLat(),f=t.project(d.lng,d.lat),p=e.MercatorCoordinate.fromLngLat(d);p.x+=Xr;const m=p.toLngLat(),g=t.project(m.lng,m.lat),_=Yr(g.x-f.x,g.y-f.y,c),y=e.MercatorCoordinate.fromLngLat(d);y.y+=Xr;const v=y.toLngLat(),x=t.project(v.lng,v.lat),b=Yr(x.x-f.x,x.y-f.y,c),w=Math.abs(_.x)/Math.abs(b.y),E=e.identity([]);e.rotateZ(E,E,-c*(1-(o?0:i)));const T=e.identity([]);return e.scale(T,T,[1,1-(1-w)*i,1]),T[4]=-b.x/b.y*i,e.rotateZ(T,T,c),e.multiply(T,E,T),T}(t.projection,0,t.center,r,n),o=Zr(t);return e.scale(i,i,[o,o,1]),i}function Zr(t){const n=t.projection,r=Wr(t.projection,t.zoom,t.width,t.height),i=Hr(n,t.center),o=Hr(n,e.LngLat.convert(n.center));return Math.pow(2,i*r+(1-r)*o)}function Wr(t,n,r,i,o=1/0){const a=t.range;if(!a)return 0;const s=Math.min(o,Math.max(r,i)),l=Math.log(s/1024)/Math.LN2;return e.smoothstep(a[0]+l,a[1]+l,n)}const Xr=1/4e4;function Hr(t,n){const r=e.clamp(n.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),i=new e.LngLat(n.lng-180*Xr,r),o=new e.LngLat(n.lng+180*Xr,r),a=t.project(i.lng,r),s=t.project(o.lng,r),l=e.MercatorCoordinate.fromLngLat(i),u=e.MercatorCoordinate.fromLngLat(o),c=s.x-a.x,h=s.y-a.y,d=u.x-l.x,f=u.y-l.y,p=Math.sqrt((d*d+f*f)/(c*c+h*h));return Math.log(p)/Math.LN2}function Yr(e,t,n){const r=Math.cos(n),i=Math.sin(n);return{x:e*r-t*i,y:e*i+t*r}}class Kr{constructor(t,n,r,i,o,a,s){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==i?60:i,this.setProjection(a),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new e.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 jr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new qr,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new Kr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e,t=!1){const n=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||n)&&this._updateCameraOnTerrain(),(e||n)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.pick(this.projection,["name","center","parallels"])}setProjection(n){this.projectionOptions=n||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=e.getProjection(this.projectionOptions);const i=!t(r,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.getProjection({name:"mercator"});const n=t!==this.projection.name;return n&&this._calcMatrices(),n}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.Point(this.width,this.height)}get bearing(){return e.wrap(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const n=-t*Math.PI/180;var r;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(r=new e.ARRAY_TYPE(4),e.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=e.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.degToRad(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-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 e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.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 t=this._elevation,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let i=0,o=0;for(let a=0;at.maxzoom&&(n=t.maxzoom);const a=this.locationCoordinate(this.center),s=this.center.lat,l=1<{const n=1/4e4,r=new e.MercatorCoordinate(t.x+n,t.y,t.z),i=new e.MercatorCoordinate(t.x,t.y+n,t.z),o=t.toLngLat(),a=r.toLngLat(),s=i.toLngLat(),l=this.locationCoordinate(o),u=this.locationCoordinate(a),c=this.locationCoordinate(s),h=Math.hypot(u.x-l.x,u.y-l.y),d=Math.hypot(c.x-l.x,c.y-l.y);return Math.sqrt(h*d)*b/n},E=t=>{const n=v,r=x;return{aabb:e.tileAABB(this,l,0,0,0,t,r,n,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:n,wrap:t,fullyVisible:!1}},T=[];let S=[];const A=n,k=t.reparseOverscaled?r:n,M=e=>e*e,C=M((m-this._centerAltitude)*p),I=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),n=e.aabb;t?(n.min[2]=t.min,n.max[2]=t.max,n.center[2]=(n.min[2]+n.max[2])/2):(e.shouldSplit=P(e),e.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},P=t=>{if(t.zoom=.9)return!0}else if(i&&(a=M(t.aabb.distanceZ(g)*p)),this.projection.isReprojectedInTileSpace&&r<=5){const n=Math.pow(2,t.zoom),r=w(new e.MercatorCoordinate((t.x+.5)/n,(t.y+.5)/n));l=r>.85?1:r}const u=n*n+o*o+a;return u{if(t*M(.707)0;){const r=T.pop(),a=r.x,s=r.y;let h=r.fullyVisible;if(!h){const e=r.aabb.intersects(d);if(0===e)continue;h=2===e}if(r.zoom!==A&&P(r))for(let t=0;t<4;t++){const n=(a<<1)+t%2,u=(s<<1)+(t>>1),d={aabb:o?r.aabb.quadrant(t):e.tileAABB(this,l,r.zoom+1,n,u,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:n,y:u,wrap:r.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};i&&!c&&(d.tileID=new e.OverscaledTileID(r.zoom+1===A?k:r.zoom+1,r.wrap,r.zoom+1,n,u),I(d)),T.push(d)}else{const i=r.zoom===A?k:r.zoom;if(t.minzoom&&t.minzoom>i)continue;const o=u[0]-(.5+a+(r.wrap<{const o=[0,0,0,1],a=[e.EXTENT,e.EXTENT,0,1],s=this.calculateFogTileMatrix(i.tileID.toUnwrapped());e.transformMat4$1(o,o,s),e.transformMat4$1(a,a,s);const l=e.getAABBPointSquareDist(o,a);if(0===l)return!0;let u=!1;const c=this._elevation;if(c&&l>n&&0!==r){const n=this.calculateProjMatrix(i.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=c.getMinMaxForTile(i.tileID)),o||(o={min:x,max:v});const a=e.furthestTileCorner(this.rotation),s=[a[0]*e.EXTENT,a[1]*e.EXTENT,o.max];e.transformMat4(s,s,n),u=(1-s[1])*this.height*.5e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const n=e.clamp(t.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),r=this.projection.project(t.lng,n);return new e.Point(r.x*this.worldSize,r.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/e.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,n){let r,i;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;r=(n.x-o.x)/e,i=(n.y-o.y)/e}else{const e=this.pointCoordinate(n),t=this.pointCoordinate(o);r=e.x-t.x,i=e.y-t.y}const a=this.locationCoordinate(t);this.setLocation(new e.MercatorCoordinate(a.x-r,a.y-i))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,n){const r=n?e.mercatorZfromAltitude(n,t.lat):void 0,i=this.projection.project(t.lng,t.lat);return new e.MercatorCoordinate(i.x,i.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,n){const r=null!=n?n:this._centerAltitude,i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.transformMat4$1(i,i,this.pixelMatrixInverse),e.transformMat4$1(o,o,this.pixelMatrixInverse);const a=o[3];e.scale$1(i,i,1/i[3]),e.scale$1(o,o,1/a);const s=i[2],l=o[2];return{p0:i,p1:o,t:s===l?0:(r-s)/(l-s)}}screenPointToMercatorRay(t){const n=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.transformMat4$1(n,n,this.pixelMatrixInverse),e.transformMat4$1(r,r,this.pixelMatrixInverse),e.scale$1(n,n,1/n[3]),e.scale$1(r,r,1/r[3]),n[2]=e.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,r[2]=e.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,e.scale$1(n,n,1/this.worldSize),e.scale$1(r,r,1/this.worldSize),new e.Ray([n[0],n[1],n[2]],e.normalize([],e.sub([],r,n)))}rayIntersectionCoordinate(t){const{p0:n,p1:r,t:i}=t,o=e.mercatorZfromAltitude(n[2],this._center.lat),a=e.mercatorZfromAltitude(r[2],this._center.lat);return new e.MercatorCoordinate(e.number(n[0],r[0],i)/this.worldSize,e.number(n[1],r[1],i)/this.worldSize,e.number(o,a,i))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.MercatorCoordinate(n[0],n[1],n[2]);let r=0,i=this.horizonLineFromTop();if(t.y>i)return this.pointCoordinate(t);const o=.02*i,a=t.clone();for(let t=0;t<10&&i-r>o;t++){a.y=e.number(r,i,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(i=a.y,n=t):r=a.y}return n?new e.MercatorCoordinate(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(t);const n=this.pointCoordinate(t);return n.y>=0&&n.y<=1}_coordinatePoint(t,n){const r=n&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,i=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.transformMat4$1(i,i,this.pixelMatrix),i[3]>0?new e.Point(i[0]/i[3],i[1]/i[3]):new e.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:n}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,i=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.Point(n,t)),a=this.pointLocation3D(new e.Point(i,t)),s=this.pointLocation3D(new e.Point(i,r)),l=this.pointLocation3D(new e.Point(n,r));let u=Math.min(o.lng,a.lng,s.lng,l.lng),c=Math.max(o.lng,a.lng,s.lng,l.lng),h=Math.min(o.lat,a.lat,s.lat,l.lat),d=Math.max(o.lat,a.lat,s.lat,l.lat);const f=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,m=(t,n,r,i,o)=>{const a=(t+r)/2,s=(n+i)/2,l=new e.Point(a,s),{lng:g,lat:_}=this.pointLocation3D(l),y=Math.max(0,u-g,h-_,g-c,_-d);u=Math.min(u,g),c=Math.max(c,g),h=Math.min(h,_),d=Math.max(d,_),(of)&&(m(t,n,a,s,o+1),m(a,s,r,i,o+1))};if(m(n,t,i,t,1),m(i,t,i,r,1),m(i,r,n,r,1),m(n,r,n,t,1),"globe"===this.projection.name){const[t,n]=e.polesInViewport(this);t?(d=90,c=180,u=-180):n&&(h=-90,c=180,u=-180)}return new e.LngLatBounds(new e.LngLat(u,h),new e.LngLat(c,d))}_getBoundsRectangular(t,n){const{top:r,left:i}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,a=this.width-this._edgeInsets.right,s=new e.Point(i,r),l=new e.Point(a,r),u=new e.Point(a,o),c=new e.Point(i,o);let h=this.pointCoordinate(s,t),d=this.pointCoordinate(l,t);const f=this.pointCoordinate(u,n),p=this.pointCoordinate(c,n),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.MercatorCoordinate((1-p.y)/m(p,h)+p.x,1):h.y<0&&d.y<=1&&(h=new e.MercatorCoordinate(-p.y/m(p,h)+p.x,0)),d.y>1&&h.y>=0?d=new e.MercatorCoordinate((1-f.y)/m(f,d)+f.x,1):d.y<0&&h.y<=1&&(d=new e.MercatorCoordinate(-f.y/m(f,d)+f.x,0)),(new e.LngLatBounds).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(f))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const n=t.dem.tree;e.min=Math.min(e.min,n.minimums[0]),e.max=Math.max(e.max,n.maximums[0])}return e},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,n=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.MAX_MERCATOR_LATITUDE,this.maxLat=e.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngh&&(s=h-u),h-ct&&(a=t-l),t-e.5?x-1:x,b>.5?b-1:b,0]),this.alignedProjMatrix=w,s=e.create(),e.scale(s,s,[this.width/2,-this.height/2,1]),e.translate(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=e.create(),e.scale(s,s,[1,-1,1]),e.translate(s,s,[-1,-1,0]),e.scale(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s,this.pixelMatrix=e.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},s=e.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=e.calculateGlobeMatrix(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.transformMat4(t,t,o),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=s;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,n=this.cameraPixelsPerMeter,r=this._camera.position,i=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,n];e.scale$2(o,o,i),e.scale$2(r,r,-1),e.multiply$2(r,r,o);const a=e.create();e.translate(a,a,r),e.scale(a,a,o),this.mercatorFogMatrix=a,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,n,i)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),r=this.point,i=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-n[0]*i,r.y/this.worldSize-n[1]*i,e/this.worldSize*this._centerAltitude-n[2]*i]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],i=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),i>0&&(o=Math.min((n-r)/i,1)),this._camera.position=e.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,n=this._camera.forward(),{pitch:r,bearing:i}=this._camera.getPitchBearing(),o=e.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,a=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.degToRad(this._maxPitch)),s=Math.max((t[2]-o)/Math.cos(r),a),l=this._zoomFromMercatorZ(s);e.scaleAndAdd(t,t,n,s),this._pitch=e.clamp(r,e.degToRad(this.minPitch),e.degToRad(this.maxPitch)),this.angle=e.wrap(i,-Math.PI,Math.PI),this._setZoom(e.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.MercatorCoordinate(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let n=0,r=e.GLOBE_ZOOM_THRESHOLD_MAX,i=0,o=1/0;for(;r-n>1e-6&&r>n;){const e=n+.5*(r-n),a=this.tileSize*Math.pow(2,e),s=this.getCameraToCenterDistance(this.projection,e,a),l=this.scaleZoom(s/(t*this.tileSize)),u=Math.abs(e-l);uu||n.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.Point(0,0),new e.Point(this.width,this.height))}zoomDeltaToMovement(t,n){const r=e.length(e.sub([],this._camera.position,t)),i=this._zoomFromMercatorZ(r)+n;return r-this._mercatorZfromZoom(i)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,n,r],i){const o=[t,n,r,1];e.transformMat4$1(o,o,i);const a=o[3]=Math.max(o[3],1e-6);return o[0]/=a,o[1]/=a,o[2]/=a,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.Point(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.Point(0,t))}}getCameraToCenterDistance(e,t=this.zoom,n=this.worldSize){const r=Wr(e,t,this.width,this.height,1024),i=e.pixelSpaceConversion(this.center.lat,n,r);return.5/Math.tan(.5*this._fov)*this.height*i}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.multiply(t,t,this.globeMatrix),t}}function Jr(e,t){let n=!1,r=null;const i=()=>{r=null,n&&(e(),r=setTimeout(i,t),n=!1)};return()=>(n=!0,r||i(),r)}class Qr{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Jr(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const t=this._map;if(!t)return"";const n=ei(t);if(this._hashName){const t=this._hashName;let r=!1;const i=e.window.location.hash.slice(1).split("&").map(e=>{const i=e.split("=")[0];return i===t?(r=!0,`${i}=${n}`):e}).filter(e=>e);return r||i.push(`${t}=${n}`),"#"+i.join("&")}return"#"+n}_getCurrentHash(){const t=e.window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map(e=>e.split("=")).forEach(t=>{t[0]===this._hashName&&(e=t)}),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(e))){const n=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:n,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=e.window.location.href.replace(/(#.+)?$/,this.getHashString());e.window.history.replaceState(e.window.history.state,null,t)}}function ei(e,t){const n=e.getCenter(),r=Math.round(100*e.getZoom())/100,i=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,i),a=Math.round(n.lng*o)/o,s=Math.round(n.lat*o)/o,l=e.getBearing(),u=e.getPitch();let c=t?`/${a}/${s}/${r}`:`${r}/${s}/${a}`;return(l||u)&&(c+="/"+Math.round(10*l)/10),u&&(c+="/"+Math.round(u)),c}const ti={linearity:.3,easing:e.bezier(0,0,.3,1)},ni=e.extend({deceleration:2500,maxSpeed:1400},ti),ri=e.extend({deceleration:20,maxSpeed:1400},ti),ii=e.extend({deceleration:1e3,maxSpeed:360},ti),oi=e.extend({deceleration:1e3,maxSpeed:90},ti);class ai{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=e.exported.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new e.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){const o=li(n.pan.mag(),r,e.extend({},ni,t||{}));i.offset=n.pan.mult(o.amount/n.pan.mag()),i.center=this._map.transform.center,si(i,o)}if(n.zoom){const e=li(n.zoom,r,ri);i.zoom=this._map.transform.zoom+e.amount,si(i,e)}if(n.bearing){const t=li(n.bearing,r,ii);i.bearing=this._map.transform.bearing+e.clamp(t.amount,-179,179),si(i,t)}if(n.pitch){const e=li(n.pitch,r,oi);i.pitch=this._map.transform.pitch+e.amount,si(i,e)}if(i.zoom||i.bearing){const e=void 0===n.pinchAround?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),i.noMoveStart=!0,i}}function si(e,t){(!e.duration||e.durationn.unproject(e)),s=o.reduce((e,t,n,r)=>e.add(t.div(r.length)),new e.Point(0,0));super(t,{points:o,point:s,lngLats:a,lngLat:n.unproject(s),originalEvent:r}),this._defaultPrevented=!1}}class hi extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class di{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new hi(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ui(e.type,this._map,e))}mouseup(e){this._map.fire(new ui(e.type,this._map,e))}preclick(t){const n=e.extend({},t);n.type="preclick",this._map.fire(new ui(n.type,this._map,n))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new ui(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new ui(e.type,this._map,e))}mouseover(e){this._map.fire(new ui(e.type,this._map,e))}mouseout(e){this._map.fire(new ui(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ci(e.type,this._map,e))}touchmove(e){this._map.fire(new ci(e.type,this._map,e))}touchend(e){this._map.fire(new ci(e.type,this._map,e))}touchcancel(e){this._map.fire(new ci(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class fi{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new ui(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ui("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new ui(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pi{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(c(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const n=t,r=this._startPos,i=this._lastPos;if(!r||!i||i.equals(n)||!this._box&&n.dist(r){this._box&&(this._box.style.transform=`translate(${a}px,${l}px)`,this._box.style.width=s-a+"px",this._box.style.height=u-l+"px")})}mouseupWindow(t,n){if(!this._active)return;const r=this._startPos,i=n;if(r&&0===t.button){if(this.reset(),f(),r.x!==i.x||r.y!==i.y)return this._map.fire(new e.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,i,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}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(t,n){return this._map.fire(new e.Event(t,{originalEvent:n}))}}function mi(e,t){const n={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const n=new e.Point(0,0);for(const e of t)n._add(e);return n.div(t.length)}(n),this.touches=mi(r,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;const r=mi(n,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class _i{constructor(e){this.singleTap=new gi(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){const r=this.singleTap.touchend(e,t,n);if(r){const t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class yi{constructor(){this._zoomIn=new _i({numTouches:1,numTaps:2}),this._zoomOut=new _i({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,t,n){const r=this._zoomIn.touchend(e,t,n),i=this._zoomOut.touchend(e,t,n);return r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):i?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(i)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const vi={0:1,2:2};class xi{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const n=g(e);this._correctButton(e,n)&&(this._lastPoint=t,this._eventButton=n)}mousemoveWindow(e,t){const n=this._lastPoint;if(n)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const n=vi[t];return void 0===e.buttons||(e.buttons&n)!==n}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(n)0&&(this._active=!0);const i=mi(r,n),o=new e.Point(0,0),a=new e.Point(0,0);let s=0;for(const e in i){const t=i[e],n=this._touches[e];n&&(o._add(t),a._add(t.sub(n)),s++,i[e]=t)}if(this._touches=i,s{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class Si{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,n){return{}}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[i,o]=r,a=Ai(n,t,i),s=Ai(n,t,o);if(!a||!s)return;const l=this._aroundCenter?null:a.add(s).div(2);return this._move([a,s],l,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;const[r,i]=this._firstTwoTouches,o=Ai(n,t,r),a=Ai(n,t,i);o&&a||(this._active&&f(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ai(e,t,n){for(let r=0;rMath.abs(e.x)}class Oi extends Si{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,Pi(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,n,r){const i=this._lastPoints;if(!i)return;const o=t[0].sub(i[0]),a=t[1].sub(i[1]);return this._map._cooperativeGestures&&!e.isFullscreen()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(o,a,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+a.y)/2*-.5})}gestureBeginsVertically(e,t,n){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return null==this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Pi(e)&&Pi(t)&&o}}const zi={panStep:100,bearingStep:15,pitchStep:10};class Li{constructor(){const e=zi;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,n=0,r=0,i=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?n=-1:(e.preventDefault(),i=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),i=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(n=0,r=0),{cameraAnimation:a=>{const s=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Di,zoom:t?Math.round(s)+t*(e.shiftKey?2:1):s,bearing:a.getBearing()+n*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-i*this._panStep,-o*this._panStep],center:a.getCenter()},{originalEvent:e})}}}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 Di(e){return e*(2-e)}const Ri=4.000244140625;class Bi{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=t.deltaMode===e.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=e.exported.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%Ri==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){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 t=p(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,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 t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const n=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Ri?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const i=n(),o=Math.pow(2,i),a="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(a*r))),"wheel"===this._type&&(this._startZoom=i,this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:n(),i=this._startZoom,o=this._easing;let a,s=!1;if("wheel"===this._type&&i&&o){const t=Math.min((e.exported.now()-this._lastWheelEventTime)/200,1),n=o(t);a=e.number(i,r,n),t<1?this._frameId||(this._frameId=!0):s=!0}else a=r,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!s,zoomDelta:a-n(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=e.ease;if(this._prevEase){const t=this._prevEase,r=(e.exported.now()-t.start)/t.duration,i=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(i*i+1e-4)*.01,a=Math.sqrt(.0729-o*o);n=e.bezier(o,a,.25,1)}return this._prevEase={start:e.exported.now(),duration:t,easing:n},n}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(e.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")}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class Fi{constructor(e,t){this._clickZoom=e,this._tapZoom=t}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 ji{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:n.getZoom()+(e.shiftKey?-1:1),around:n.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ui{constructor(){this._tap=new _i({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,n){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=t[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(e,t,n))}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(e,t,n)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ni{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},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 Vi{constructor(e,t,n){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=n}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 Gi{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),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 qi=e=>e.zoom||e.drag||e.pitch||e.rotate;class $i extends e.Event{}class Zi{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,n){const r=e.sub([],n,t);this.radius=e.length(r[2]<0?e.div([],r,this.constants):[r[0],r[1],0])}projectRay(t){e.div(t,t,this.constants),e.normalize(t,t),e.mul$1(t,t,this.constants);const n=e.scale$2([],t,this.radius);if(n[2]>0){const t=e.scale$2([],[0,0,1],e.dot(n,[0,0,1])),r=e.scale$2([],e.normalize([],[n[0],n[1],0]),this.radius),i=e.add([],n,e.scale$2([],e.sub([],e.add([],r,t),n),2));n[0]=i[0],n[1]=i[1]}return n}}function Wi(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Xi{constructor(t,n){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ai(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Zi,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),e.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],[e.window.document,"mousemove",{capture:!0}],[e.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],[e.window,"blur",void 0]];for(const[t,n,r]of this._listeners)t.addEventListener(n,t===e.window.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[t,n,r]of this._listeners)t.removeEventListener(n,t===e.window.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){const t=this._map,n=t.getCanvasContainer();this._add("mapEvent",new di(t,e));const r=t.boxZoom=new pi(t,e);this._add("boxZoom",r);const i=new yi,o=new ji;t.doubleClickZoom=new Fi(o,i),this._add("tapZoom",i),this._add("clickZoom",o);const a=new Ui;this._add("tapDragZoom",a);const s=t.touchPitch=new Oi(t);this._add("touchPitch",s);const l=new wi(e),u=new Ei(e);t.dragRotate=new Vi(e,l,u),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);const c=new bi(e),h=new Ti(t,e);t.dragPan=new Ni(n,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new Ii,f=new Mi;t.touchZoomRotate=new Gi(n,f,d,a),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),this._add("blockableMapEvent",new fi(t));const p=t.scrollZoom=new Bi(t,this);this._add("scrollZoom",p,["mousePan"]);const m=t.keyboard=new Li;this._add("keyboard",m);for(const n of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[n]&&t[n].enable(e[n])}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!qi(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,n){for(const r in e)if(r!==n&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,e.type+"Window")}_getMapTouches(e){const t=[];for(const n of e)this._el.contains(n.target)&&t.push(n);return t}handleEvent(e,t){this._updatingCamera=!0;const n="renderFrame"===e.type,r=n?void 0:e,i={needsRenderFrame:!1},o={},a={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?m(this._el,s):n?void 0:p(this._el,e);for(const{handlerName:n,handler:u,allowed:c}of this._handlers){if(!u.isEnabled())continue;let h;this._blockedByActive(a,c,n)?u.reset():u[t||e.type]&&(h=u[t||e.type](e,l,s),this.mergeHandlerResult(i,o,h,n,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||u.isActive())&&(a[n]=u)}const u={};for(const e in this._previousActiveHandlers)a[e]||(u[e]=r);this._previousActiveHandlers=a,(Object.keys(u).length||Wi(i))&&(this._changes.push([i,o,u]),this._triggerRenderFrame()),(Object.keys(a).length||Wi(i))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=i;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))}mergeHandlerResult(t,n,r,i,o){if(!r)return;e.extend(t,r);const a={handlerName:i,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(n.zoom=a),void 0!==r.panDelta&&(n.drag=a),void 0!==r.pitchDelta&&(n.pitch=a),void 0!==r.bearingDelta&&(n.rotate=a)}_applyChanges(){const t={},n={},r={};for(const[i,o,a]of this._changes)i.panDelta&&(t.panDelta=(t.panDelta||new e.Point(0,0))._add(i.panDelta)),i.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+i.pitchDelta),void 0!==i.around&&(t.around=i.around),void 0!==i.aroundCoord&&(t.aroundCoord=i.aroundCoord),void 0!==i.pinchAround&&(t.pinchAround=i.pinchAround),i.noInertia&&(t.noInertia=i.noInertia),e.extend(n,o),e.extend(r,a);this._updateMapTransform(t,n,r),this._changes=[]}_updateMapTransform(t,n,r){const i=this._map,o=i.transform,a=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Wi(t)){const e=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&i._stop(!0),!Wi(t))return void this._fireEvents(n,r,!0);let{panDelta:s,zoomDelta:l,bearingDelta:u,pitchDelta:c,around:h,aroundCoord:d,pinchAround:f}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==f&&(h=f),(l||(e=>n[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=a(o.pointCoordinate3D(h)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",i._stop(!0),h=h||i.transform.centerPoint,u&&(o.bearing+=u),c&&(o.pitch+=c),o._updateCameraState();const p=[0,0,0];if(s)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(s)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){s=s.rotate(-o.angle);const n=o._pixelsPerMercatorPixel/o.worldSize;p[0]=-s.x*e.mercatorScale(e.latFromMercatorY(t.y))*n,p[1]=-s.y*e.mercatorScale(o.center.lat)*n}else{const e=o.pointCoordinate(h.sub(s));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y)}}const m=o.zoom,g=[0,0,0];if(l){const t=a(d||o.pointCoordinate3D(h)),n={dir:e.normalize([],e.sub([],t,o._camera.position))};if(n.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e.scale$2(g,n.dir,r)}}const _=e.add(p,p,g);o._translateCameraConstrained(_),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,r,!0)}_fireEvents(t,n,r){const i=qi(this._eventsInProgress),o=qi(t),a={};for(const e in t){const{originalEvent:n}=t[e];this._eventsInProgress[e]||(a[e+"start"]=n),this._eventsInProgress[e]=t[e]}!i&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in a)this._fireEvent(e,a[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:n}=t[e];this._fireEvent(e,n)}const s={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=n[t]||r,s[e+"end"]=l)}for(const e in s)this._fireEvent(e,s[e]);const u=qi(this._eventsInProgress);if(r&&(i||o)&&!u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new $i("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Hi="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Yi extends e.Evented{constructor(t,n){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this._respectPrefersReducedMotion=!1!==n.respectPrefersReducedMotion,e.bindAll(["_renderFrameCallback"],this)}getCenter(){return new e.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,n,r){return t=e.Point.convert(t).mult(-1),this.panTo(this.transform.center,e.extend({offset:t},n),r)}panTo(t,n,r){return this.easeTo(e.extend({center:t},n),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,n,r){return this.easeTo(e.extend({zoom:t},n),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,n,r){return this.easeTo(e.extend({bearing:t},n),r)}resetNorth(t,n){return this.rotateTo(0,e.extend({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(e.extend({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?n/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,n,r,i,o,a){const s=t.clone(),l=this._extendCameraOptions(a);s.bearing=i,s.pitch=o;const u=e.LngLat.convert(n),c=e.LngLat.convert(r),h=.5*(u.lat+c.lat),d=.5*(u.lng+c.lng),f=e.latLngToECEF(h,d),p=e.normalize([],f),m=e.normalize([],e.cross([],p,[0,1,0])),g=e.cross([],m,p),_=[m[0],m[1],m[2],0,g[0],g[1],g[2],0,p[0],p[1],p[2],0,0,0,0,1],y=[f,e.latLngToECEF(u.lat,u.lng),e.latLngToECEF(c.lat,u.lng),e.latLngToECEF(c.lat,c.lng),e.latLngToECEF(u.lat,c.lng),e.latLngToECEF(h,u.lng),e.latLngToECEF(h,c.lng),e.latLngToECEF(u.lat,d),e.latLngToECEF(c.lat,d)];let v=e.Aabb.fromPoints(y.map(t=>[e.dot(m,t),e.dot(g,t),e.dot(p,t)]));const x=e.transformMat4([],v.center,_);0===e.squaredLength(x)&&e.set(x,0,0,1),e.normalize(x,x),e.scale$2(x,x,e.GLOBE_RADIUS),s.center=e.ecefToLatLng(x);const b=s.getWorldToCameraMatrix(),w=e.invert(new Float64Array(16),b);v=e.Aabb.applyTransform(v,e.multiply([],b,_)),e.transformMat4(x,x,b);const E=.5*(v.max[2]-v.min[2]),T=this._minimumAABBFrustumDistance(s,v),S=e.scale$2([],[0,0,1],E),A=e.add(S,x,S),k=T+(0===s.pitch?0:e.distance(x,A)),M=s.globeCenterInViewSpace,C=e.sub([],x,[M[0],M[1],M[2]]);e.normalize(C,C),e.scale$2(C,C,k);const I=e.add([],x,C);e.transformMat4(I,I,w);const P=e.earthRadius/e.GLOBE_RADIUS,O=e.length(I),z=e.mercatorZfromAltitude(Math.max(O*P-e.earthRadius,Number.EPSILON),0),L=Math.min(s.zoomFromMercatorZAdjusted(z),l.maxZoom);return L>.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(s.setProjection({name:"mercator"}),s.zoom=L,this._cameraForBounds(s,n,r,i,o,a)):{center:s.center,zoom:L,bearing:i,pitch:o}}queryTerrainElevation(t,n){const r=this.transform.elevation;return r?(n=e.extend({},{exaggerated:!0},n),r.getAtPoint(e.MercatorCoordinate.fromLngLat(t),null,n.exaggerated)):null}_cameraForBounds(t,n,r,i,o,a){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,n,r,i,o,a);const s=t.clone(),l=this._extendCameraOptions(a),u=s.padding;s.bearing=i,s.pitch=o;const c=e.LngLat.convert(n),h=e.LngLat.convert(r),d=new e.LngLat(c.lng,h.lat),f=new e.LngLat(h.lng,c.lat),p=s.project(c),m=s.project(h),g=this.queryTerrainElevation(c),_=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),v=this.queryTerrainElevation(f),x=[[p.x,p.y,Math.min(g||0,_||0,y||0,v||0)],[m.x,m.y,Math.max(g||0,_||0,y||0,v||0)]];let b=e.Aabb.fromPoints(x);const w=s.getWorldToCameraMatrix(),E=e.invert(new Float64Array(16),w);b=e.Aabb.applyTransform(b,w);const T=e.sub([],b.max,b.min),S=u.left||0,A=u.right||0,k=u.bottom||0,M=u.top||0,{left:C,right:I,top:P,bottom:O}=l.padding,z=.5*(S+A),L=.5*(M+k),D=Math.min(s.scaleZoom(s.scale*Math.min((s.width-(S+A+C+I))/T[0],(s.height-(k+M+O+P))/T[1])),l.maxZoom),R=s.scale/s.zoomScale(D);b=new e.Aabb([b.min[0]-(C+z)*R,b.min[1]-(O+L)*R,b.min[2]],[b.max[0]+(I+z)*R,b.max[1]+(P+L)*R,b.max[2]]);const B=.5*T[2],F=this._minimumAABBFrustumDistance(s,b),j=[0,0,1,0];e.transformMat4$1(j,j,w),e.normalize$2(j,j);const U=e.scale$2([],j,F+B),N=e.add([],b.center,U),V=("number"==typeof l.offset.x&&"number"==typeof l.offset.y?new e.Point(l.offset.x,l.offset.y):e.Point.convert(l.offset)).rotate(-e.degToRad(i));b.center[0]-=V.x*R,b.center[1]+=V.y*R,e.transformMat4(b.center,b.center,E),e.transformMat4(N,N,E);const G=[b.center[0],b.center[1],N[2]*s.pixelsPerMeter];e.scale$2(G,G,1/s.worldSize);const q=e.lngFromMercatorX(G[0]),$=e.latFromMercatorY(G[1]),Z=Math.min(s._zoomFromMercatorZ(G[2]),l.maxZoom),W=new e.LngLat(q,$);return s.mercatorFromTransition&&Z<.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(s.setProjection({name:"globe"}),s.zoom=Z,this._cameraForBounds(s,n,r,i,o,a)):{center:W,zoom:Z,bearing:i,pitch:o}}fitBounds(e,t,n){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,n)}fitScreenCoordinates(t,n,r,i,o){const a=e.Point.convert(t),s=e.Point.convert(n),l=new e.Point(Math.min(a.x,s.x),Math.min(a.y,s.y)),u=new e.Point(Math.max(a.x,s.x),Math.max(a.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(a,s))return this;const c=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(u),d=this.transform.pointLocation3D(new e.Point(l.x,u.y)),f=this.transform.pointLocation3D(new e.Point(u.x,l.y)),p=[Math.min(c.lng,h.lng,d.lng,f.lng),Math.min(c.lat,h.lat,d.lat,f.lat)],m=[Math.max(c.lng,h.lng,d.lng,f.lng),Math.max(c.lat,h.lat,d.lat,f.lat)],g=i&&i.pitch?i.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,p,m,r,g,i);return this._fitInternal(_,i,o)}_fitInternal(t,n,r){return t?(delete(n=e.extend(t,n)).padding,n.linear?this.easeTo(n,r):this.flyTo(n,r)):this}jumpTo(t,n){this.stop();const r=t.preloadOnly?this.transform.clone():this.transform;let i=!1,o=!1,a=!1;return"zoom"in t&&r.zoom!==+t.zoom&&(i=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.LngLat.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(a=!0,r.pitch=+t.pitch),null==t.padding||r.isPaddingEqual(t.padding)||(r.padding=t.padding),t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),i&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),o&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),a&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.warnOnce(Hi),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,n){const r=this.transform;if(!r.projection.supportsFreeCamera)return e.warnOnce(Hi),this;this.stop();const i=r.zoom,o=r.pitch,a=r.bearing;r.setFreeCameraOptions(t);const s=i!==r.zoom,l=o!==r.pitch,u=a!==r.bearing;return this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),s&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),u&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),l&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)),this}easeTo(t,n){this._stop(!1,t.easeId),(!1===(t=e.extend({offset:[0,0],duration:500,easing:e.ease},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?+t.zoom:i,u="bearing"in t?this._normalizeBearing(t.bearing,o):o,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:r.padding,d=e.Point.convert(t.offset);let f,p,m;if("globe"===r.projection.name){const n=e.MercatorCoordinate.fromLngLat(r.center),i=d.rotate(-r.angle);n.x+=i.x/r.worldSize,n.y+=i.y/r.worldSize;const o=n.toLngLat(),a=e.LngLat.convert(t.center||o);this._normalizeCenter(a),f=r.centerPoint.add(i),p=new e.Point(n.x,n.y).mult(r.worldSize),m=new e.Point(e.mercatorXfromLng(a.lng),e.mercatorYfromLat(a.lat)).mult(r.worldSize).sub(p)}else{f=r.centerPoint.add(d);const n=r.pointLocation(f),i=e.LngLat.convert(t.center||n);this._normalizeCenter(i),p=r.project(n),m=r.project(i).sub(p)}const g=r.zoomScale(l-i);let _,y;t.around&&(_=e.LngLat.convert(t.around),y=r.locationPoint(_));const v=this._zooming||l!==i,x=this._rotating||o!==u,b=this._pitching||c!==a,w=!r.isPaddingEqual(h),E=r=>E=>{if(v&&(r.zoom=e.number(i,l,E)),x&&(r.bearing=e.number(o,u,E)),b&&(r.pitch=e.number(a,c,E)),w&&(r.interpolatePadding(s,h,E),f=r.centerPoint.add(d)),_)r.setLocationAtPoint(_,y);else{const e=r.zoomScale(r.zoom-i),t=l>i?Math.min(2,g):Math.max(.5,g),n=Math.pow(t,1-E),o=r.unproject(p.add(m.mult(E*n)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,f)}return t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(E,t.duration,r);return this._preloadTiles(e),this}const T={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=t.easeId,this._prepareEase(n,t.noMoveStart,T),this._ease(E(r),e=>{r.recenterOnTerrain(),this._afterEase(n,e)},t),this}_prepareEase(t,n,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",n||r.moving||this.fire(new e.Event("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.Event("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.Event("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.Event("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.Event("move",t)),this._zooming&&this.fire(new e.Event("zoom",t)),this._rotating&&this.fire(new e.Event("rotate",t)),this._pitching&&this.fire(new e.Event("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,i=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.Event("zoomend",t)),i&&this.fire(new e.Event("rotateend",t)),o&&this.fire(new e.Event("pitchend",t)),this.fire(new e.Event("moveend",t))}flyTo(t,n){if(this._prefersReducedMotion(t)){const r=e.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,n)}this.stop(),t=e.extend({offset:[0,0],speed:1.2,curve:1.42,easing:e.ease},t);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?e.clamp(+t.zoom,r.minZoom,r.maxZoom):i,u="bearing"in t?this._normalizeBearing(t.bearing,o):o,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:r.padding,d=r.zoomScale(l-i),f=e.Point.convert(t.offset);let p=r.centerPoint.add(f);const m=r.pointLocation(p),g=e.LngLat.convert(t.center||m);this._normalizeCenter(g);const _=r.project(m),y=r.project(g).sub(_);let v=t.curve;const x=Math.max(r.width,r.height),b=x/d,w=y.mag();if("minZoom"in t){const n=e.clamp(Math.min(t.minZoom,i,l),r.minZoom,r.maxZoom),o=x/r.zoomScale(n-i);v=Math.sqrt(o/w*2)}const E=v*v;function T(e){const t=(b*b-x*x+(e?-1:1)*E*E*w*w)/(2*(e?b:x)*E*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function A(e){return(Math.exp(e)+Math.exp(-e))/2}const k=T(0);let M=function(e){return A(k)/A(k+v*e)},C=function(e){return x*((A(k)*(S(t=k+v*e)/A(t))-S(k))/E)/w;var t},I=(T(1)-k)/v;if(Math.abs(w)<1e-6||!isFinite(I)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,n);const e=bt.maxDuration&&(t.duration=0);const P=o!==u,O=c!==a,z=!r.isPaddingEqual(h),L=r=>d=>{const m=d*I,v=1/M(m);r.zoom=1===d?l:i+r.scaleZoom(v),P&&(r.bearing=e.number(o,u,d)),O&&(r.pitch=e.number(a,c,d)),z&&(r.interpolatePadding(s,h,d),p=r.centerPoint.add(f));const x=1===d?g:r.unproject(_.add(y.mult(C(m))).mult(v));return r.setLocationAtPoint(r.renderWorldCopies?x.wrap():x,p),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(L,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=O,this._padding=z,this._prepareEase(n,!1),this._ease(L(r),()=>this._afterEase(n),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,n,r){!1===r.animate||0===r.duration?(t(1),n()):(this._easeStart=e.exported.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.exported.now()-this._easeStart)/this._easeOptions.duration,1),n=this._onEaseFrame;n&&n(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,n){t=e.wrap(t,-180,180);const r=Math.abs(t-n);return Math.abs(t-360-n)180?-360:n<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.exported.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,n){const r=Math.ceil(15*t/1e3),i=[],o=e(n.clone());for(let e=0;e<=r;e++){const t=o(e/r);i.push(t.clone())}return i}}class Ki{constructor(t={}){this.options=t,e.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,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"),t&&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===t&&(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(e,t){const n=this._map._getUIString("AttributionControl."+t);e.setAttribute("aria-label",n),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}_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 t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.config.ACCESS_TOKEN}];if(t){const r=n.reduce((e,t,r)=>(t.value&&(e+=`${t.key}=${t.value}${re.length-t.length),e=e.filter((t,n)=>{for(let r=n+1;r=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const n=e.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,e.length?(this._innerContainer.innerHTML=n,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 Ji{constructor(){e.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),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(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const n=e[t].getSource();if(n.hasOwnProperty("mapbox_logo")&&!n.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class Qi{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(const t of n)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function eo(t,n,r){if(t=new e.LngLat(t.lng,t.lat),n){const i=new e.LngLat(t.lng-360,t.lat),o=new e.LngLat(t.lng+360,t.lat),a=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),s=r.locationPoint(t).distSqr(n),l=n.x<0||n.y<0||n.x>r.width||n.y>r.height;r.locationPoint(i).distSqr(n)180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const to={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 no extends e.Evented{constructor(t,n){if(super(),(t instanceof e.window.HTMLElement||n)&&(t=e.extend({element:t},n)),e.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.Point.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const n=41,r=27,i=a("svg",{display:"block",height:n*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${n}`},this._element),s=a("radialGradient",{id:"shadowGradient"},a("defs",{},i));a("stop",{offset:"10%","stop-opacity":.4},s),a("stop",{offset:"100%","stop-opacity":.05},s),a("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},i),a("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"},i),a("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"},i),a("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},i),this._offset=e.Point.convert(t&&t.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",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()});const r=this._element.classList;for(const e in to)r.remove("mapboxgl-marker-anchor-"+e);r.add("mapboxgl-marker-anchor-"+this._anchor),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){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")),e){if(!("offset"in e.options)){const t=38.1,n=13.5,r=Math.sqrt(Math.pow(n,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-n+r)],"bottom-right":[-r,-1*(t-n+r)],left:[n,-1*(t-n)],right:[-n,-1*(t-n)]}:this._offset}this._popup=e,e._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(e){const t=e.code,n=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==n&&13!==n||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const n=e.unproject(t),r=e.getFreeCameraOptions();if(!r.position)return!1;const i=r.position.toLngLat();return i.distanceTo(n)<.9*i.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const n=this._pos;if(!n||n.x<0||n.x>t.transform.width||n.y<0||n.y>t.transform.height)return void this._clearFadeTimer();const r=t.unproject(n);let i;t._showingGlobe()&&e.isLngLatBehindGlobe(t.transform,this._lngLat)?i=0:(i=1-t._queryFogOpacity(r),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(i*=this._occludedOpacity)),this._element.style.opacity=""+i,this._element.style.pointerEvents=i>0?"auto":"none",this._popup&&this._popup._setOpacity(i),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${to[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,n=this._map,r=this.getPitchAlignment();if(!n||!t||"map"!==r)return"";if(!n._showingGlobe()){const e=n.getPitch();return e?`rotateX(${e}deg)`:""}const i=e.radToDeg(e.globeTiltAtLngLat(n.transform,this._lngLat)),o=t.sub(e.globeCenterToScreenPoint(n.transform)),a=Math.abs(o.x)+Math.abs(o.y);if(0===a)return"";const s=i/a;return`rotateX(${-o.y*s}deg) rotateY(${o.x*s}deg)`}_calculateZTransform(){const t=this._pos,n=this._map;if(!n||!t)return"";let r=0;const i=this.getRotationAlignment();if("map"===i)if(n._showingGlobe()){const t=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),i=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);r=e.radToDeg(Math.atan2(i.y,i.x))-90}else r=-n.getBearing();else if("horizon"===i){const i=e.smoothstep(4,6,n.getZoom()),o=e.globeCenterToScreenPoint(n.transform);o.y+=i*n.transform.height;const a=t.sub(o),s=e.radToDeg(Math.atan2(a.y,a.x));r=(s>90?s-270:s+90)*(1-i)}return r+=this._rotation,r?`rotateZ(${r}deg)`:""}_update(t){e.window.cancelAnimationFrame(this._updateFrameId);const n=this._map;n&&(n.transform.renderWorldCopies&&(this._lngLat=eo(this._lngLat,this._pos,n.transform)),this._pos=n.project(this._lngLat),!0===t?this._updateFrameId=e.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),n._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(n._showingGlobe()||n.getTerrain()||n.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=e.Point.convert(t),this._update(),this}_onMove(t){const n=this._map;if(!n)return;const r=this._pointerdownPos,i=this._positionDelta;if(r&&i){if(!this._isDragging){const e=this._clickTolerance||n._clickTolerance;if(t.point.dist(r)=this._endTime)return this._end;const n=e.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,n){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+n}}const so={"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"},lo={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,performanceMetricsCollection:!0,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,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},uo={showCompass:!0,showZoom:!0,visualizePitch:!1};class co{constructor(t,n,r=!1){this._clickTolerance=10,this.element=n,this.mouseRotate=new wi({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new Ei({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),c()}move(e,t){const n=this.map,r=this.mouseRotate.mousemoveWindow(e,t),i=r&&r.bearingDelta;if(i&&n.setBearing(n.getBearing()+i),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),i=r&&r.pitchDelta;i&&n.setPitch(n.getPitch()+i)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),e.window.removeEventListener("mousemove",this.mousemove),e.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),p(this.element,t)),e.window.addEventListener("mousemove",this.mousemove),e.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,p(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=m(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.isSafariWithAntialiasingBug(e.window)&&(t.antialias=!1,e.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Kr(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._useWebGL2=t.useWebGL2,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Qi,this._domRenderTaskQueue=new Qi,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.uniqueId(),this._locale=e.extend({},so,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ao(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.window.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof e.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_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!==e.window&&(e.window.addEventListener("online",this._onWindowOnline,!1),e.window.addEventListener("resize",this._onWindowResize,!1),e.window.addEventListener("orientationchange",this._onWindowResize,!1),e.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Xi(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Qr("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.extend({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new Ki({customAttribution:t.customAttribution})),this._logoControl=new Ji,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.Event(t.dataType+"data",t))}),this.on("dataloading",t=>{this.fire(new e.Event(t.dataType+"dataloading",t))})}_getMapId(){return this._mapId}addControl(t,n){if(void 0===n&&(n=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const i=this._controlPositions[n];return-1!==n.indexOf("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(t);return n>-1&&this._controls.splice(n,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 n=!this._moving;return n&&this.fire(new e.Event("movestart",t)).fire(new e.Event("move",t)),this.fire(new e.Event("resize",t)),n&&this.fire(new e.Event("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.LngLatBounds.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.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(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(t){return"auto"===t?e.window.navigator.language:Array.isArray(t)?0===t.length?void 0:t.map(t=>"auto"===t?e.window.navigator.language:t):t}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style._reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,n=t.projection.name;let r;"globe"===n&&t.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?(t.setMercatorFromTransition(),r=!0):"mercator"===n&&t.zoom=e.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),n){this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(t){return this.transform.locationPoint3D(e.LngLat.convert(t))}unproject(t){return this.transform.pointLocation3D(e.Point.convert(t))}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}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,n){if("mouseenter"===e||"mouseover"===e){let r=!1;const i=i=>{const o=t.filter(e=>this.getLayer(e)),a=o.length?this.queryRenderedFeatures(i.point,{layers:o}):[];a.length?r||(r=!0,n.call(this,new ui(e,this,i.originalEvent,{features:a}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const i=i=>{const o=t.filter(e=>this.getLayer(e));(o.length?this.queryRenderedFeatures(i.point,{layers:o}):[]).length?r=!0:r&&(r=!1,n.call(this,new ui(e,this,i.originalEvent)))},o=t=>{r&&(r=!1,n.call(this,new ui(e,this,t.originalEvent)))};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}{const r=e=>{const r=t.filter(e=>this.getLayer(e)),i=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:new Set(t),listener:n,delegates:{[e]:r}}}}on(e,t,n){if(void 0===n)return super.on(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,n){if(void 0===n)return super.once(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,n);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,n){if(void 0===n)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const r=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0},i=this._delegatedListeners?this._delegatedListeners[e]:void 0;return i&&(e=>{for(let i=0;i{t?this.fire(new e.ErrorEvent(t)):r&&this._updateDiff(r,n)})}else"object"==typeof t&&this._updateDiff(t,n)}_updateDiff(t,n){try{this.style.setState(t)&&this._update(!0)}catch(r){e.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(t,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.warnOnce("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const n=e[t]._tiles;for(const e in n){const t=n[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,n){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,n)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,n,{pixelRatio:r=1,sdf:i=!1,stretchX:o,stretchY:a,content:s}={}){if(this._lazyInitEmptyStyle(),n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap){const{width:l,height:u,data:c}=e.exported.getImageData(n);this.style.addImage(t,{data:new e.RGBAImage({width:l,height:u},c),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0})}else if(void 0===n.width||void 0===n.height)this.fire(new e.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:u}=n,c=n;this.style.addImage(t,{data:new e.RGBAImage({width:l,height:u},new Uint8Array(c.data)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0,userImage:c}),c.onAdd&&c.onAdd(this,t)}}updateImage(t,n){const r=this.style.getImage(t);if(!r)return void this.fire(new e.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap?e.exported.getImageData(n):n,{width:o,height:a}=i;void 0!==o&&void 0!==a?o===r.data.width&&a===r.data.height?(r.data.replace(i.data,!(n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap)),this.style.updateImage(t,r)):this.fire(new e.ErrorEvent(new Error(`The width and height of the updated image (${o}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new e.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(t){return t?!!this.style.getImage(t):(this.fire(new e.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,n){e.getImage(this._requestManager.transformRequest(t,e.ResourceType.Image),(t,r)=>{n(t,r instanceof e.window.HTMLImageElement?e.exported.getImageData(r):r)})}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t,n={}){return this.style.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n,r={}){return this.style.setPaintProperty(e,t,n,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n,r={}){return this.style.setLayoutProperty(e,t,n,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300;let r,i,o,a=this._container;for(;a&&(!i||!o);){const t=e.window.getComputedStyle(a).transform;t&&"none"!==t&&(r=t.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(i=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(o=r[3])),a=a.parentElement}this._containerWidth=i?Math.abs(t/i):t,this._containerHeight=o?Math.abs(n/o):n}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.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 e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=o("canvas","mapboxgl-canvas",t),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 n=this._controlContainer=o("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{r[e]=o("div","mapboxgl-ctrl-"+e,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,n){const r=e.exported.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(n),this._canvas.style.width=t+"px",this._canvas.style.height=n+"px"}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.extend({},n.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._useWebGL2&&this._canvas.getContext("webgl2",t),i=r||this._canvas.getContext("webgl",t)||this._canvas.getContext("experimental-webgl",t);i?(this._useWebGL2&&!r&&e.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),e.storeAuthState(i,!0),this.painter=new Fr(i,this.transform,!!r),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.exported$1.testSupport(i)):this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.Event("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.Event("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.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(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let n;const r=this.painter.context.extTimerQuery,i=e.exported.now();if(this.listens("gpu-timing-frame")&&(n=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,n)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],e.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],e.window.performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,n=this.transform.pitch,r=e.exported.now(),i=new e.EvaluationParameters(t,{now:r,fadeDuration:o,pitch:n,transition:this.style.getTransition()});this.style.update(i)}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(i),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(i),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,o,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:o,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 e.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const t=e.exported.now()-i;r.endQueryEXT(r.TIME_ELAPSED_EXT,n),setTimeout(()=>{const o=r.getQueryObjectEXT(n,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(n),this.fire(new e.Event("gpu-timing-frame",{cpuTime:t,gpuTime:o})),e.window.performance.mark("frame-gpu",{startTime:i,detail:{gpuTime:o}})},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const n=this.painter.queryGpuTimers(t);this.fire(new e.Event("gpu-timing-layer",{layerTimes:n}))},50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const n=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.Event("gpu-timing-deferred-render",{gpuTime:n}))},50)}const s=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(s||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(i,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.Event("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0,e.LivePerformanceUtils.mark(e.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&e.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const n=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation(),i=!1;this.transform.elevation&&(i=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-r);if(o>1){if(this._isInitialLoad||i)return this._averageElevation.jumpTo(r),n(r);this._averageElevation.easeTo(r,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(r),n(r)}return!!this._averageElevation.isEasing(e)&&n(this._averageElevation.getValue(e))}_authenticate(){e.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{if(t&&(t.message===e.AUTH_ERR_MSG||401===t.status)){const t=this.painter.context.gl;e.storeAuthState(t,!1),this._logoControl instanceof Ji&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.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/")))}}),e.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const n=this.painter.context.gl,r=n.createFramebuffer();function i(e){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0);const t=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,t),t}return n.bindFramebuffer(n.FRAMEBUFFER,r),this._canvasPixelComparison(i(e),t.canvasCopies.map(i),t.timeStamps)}_canvasPixelComparison(e,t,n){let r=n[1]-n[0];const i=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)}))}_preloadTiles(t){const n=this.style?Object.values(this.style._sourceCaches):[];return e.asyncAll(n,(e,n)=>e._preloadTiles(t,n),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===e.window.document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update())}_setCacheLimits(t,n){e.setCacheLimits(t,n)}get version(){return e.version}},NavigationControl:class{constructor(t){this.options=e.extend({},uo,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e})}),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))}),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),n=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new co(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const n=o("button",e,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(e,t){if(!this._map)return;const n=this._map._getUIString("NavigationControl."+t);e.setAttribute("aria-label",n),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends e.Evented{constructor(t){super(),this.options=e.extend({geolocation:e.window.navigator.geolocation},ho,t),e.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Jr(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,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(t){const n=(e=!!this.options.geolocation)=>{this._supportsGeolocation=e,t(e)};void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==e.window.navigator.permissions?e.window.navigator.permissions.query({name:"geolocation"}).then(e=>n("denied"!==e.state)).catch(()=>n()):n()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),n=e.coords;return!!t&&(n.longitudet.getEast()||n.latitudet.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(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.Event("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("geolocate",t)),this._finish()}}_updateCamera(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,i=this._map.getBearing(),o=e.extend({bearing:i},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,n=e.mercatorZfromAltitude(1,t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*n);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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.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 e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.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===t){e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}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 no({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new no({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.Event("trackuserlocationend")))})}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.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 e.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 e.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 e.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 e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),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 t=()=>{e.window.addEventListener("ondeviceorientationabsolute"in e.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.window.DeviceMotionEvent&&"function"==typeof e.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(e=>{"granted"===e&&t()}).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.window.removeEventListener("deviceorientation",this._onDeviceOrientation),e.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:Ki,ScaleControl:class{constructor(t){this.options=e.extend({},fo,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,n=t._containerHeight/2,r=t._containerWidth/2-e/2,i=t.unproject([r,n]),o=t.unproject([r+e,n]),a=i.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"meter")}_setScale(e,t,n){this._map._requestDomTask(()=>{const r=function(e){const t=Math.pow(10,(""+Math.floor(e)).length-1);let n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(n),t*n}(t),i=r/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==n?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:n}).format(r):`${r} ${po[n]}`,this._container.style.width=e*i+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.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(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.window.HTMLElement?this._container=t.container:e.warnOnce("Full screen control 'container' must be a DOM element.")),e.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,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",e.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.window.document.fullscreenEnabled&&!e.window.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(e.window.document.fullscreenElement||e.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()?e.window.document.exitFullscreen?e.window.document.exitFullscreen():e.window.document.webkitCancelFullScreen&&e.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.Evented{constructor(t){super(),this.options=e.extend(Object.create(ro),t),e.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.LngLat.convert(t),this._pos=null,this._trackPointer=!1,this._update();const n=this._map;return n&&(n.on("move",this._update),n.off("mousemove",this._onMouseEvent),n._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.window.document.createTextNode(t))}setHTML(t){const n=e.window.document.createDocumentFragment(),r=e.window.document.createElement("body");let i;for(r.innerHTML=t;i=r.firstChild,i;)n.appendChild(i);return this.setDOMContent(n)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,n=this._container,r=this._pos;if(!t||!n||!r)return"bottom";const i=n.offsetWidth,o=n.offsetHeight,a=r.xt.transform.width-i/2;if(r.y+et.transform.height-o){if(a)return"bottom-left";if(s)return"bottom-right"}return a?"left":s?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push("mapboxgl-popup-anchor-"+this._anchor),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const n=this._map,r=this._content;if(!n||!this._lngLat&&!this._trackPointer||!r)return;let i=this._container;if(i||(i=this._container=o("div","mapboxgl-popup",n.getContainer()),this._tip=o("div","mapboxgl-popup-tip",i),i.appendChild(r)),this.options.maxWidth&&i.style.maxWidth!==this.options.maxWidth&&(i.style.maxWidth=this.options.maxWidth),n.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=eo(this._lngLat,this._pos,n.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:n.project(this._lngLat),r=oo(this.options.offset),i=this._anchor=this._getAnchor(r.y),o=oo(this.options.offset,i),a=e.add(o).round();n._requestDomTask(()=>{this._container&&i&&(this._container.style.transform=`${to[i]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&n._showingGlobe()){const t=e.isLngLatBehindGlobe(n.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(io);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=""+e),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:no,Style:Qt,LngLat:e.LngLat,LngLatBounds:e.LngLatBounds,Point:e.Point,MercatorCoordinate:e.MercatorCoordinate,FreeCameraOptions:Gr,Evented:e.Evented,config:e.config,prewarm:function(){je().acquire(Re)},clearPrewarmedResources:function(){const e=Fe;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Re),Fe=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 e.config.ACCESS_TOKEN},set accessToken(t){e.config.ACCESS_TOKEN=t},get baseApiUrl(){return e.config.API_URL},set baseApiUrl(t){e.config.API_URL=t},get workerCount(){return Be.workerCount},set workerCount(e){Be.workerCount=e},get maxParallelImageRequests(){return e.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.clearTileCache(t)},workerUrl:"",workerClass:null,setNow:e.exported.setNow,restoreNow:e.exported.restoreNow};return mo})),r}()}).call(this,n(32))},function(e,t,n){"use strict";function r(e,t,n,r,i,o,a){try{var s=e[o](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,i)}function i(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,l,"next",e)}function l(e){r(a,i,o,s,l,"throw",e)}s(void 0)}))}}n.d(t,"a",(function(){return i}))},function(e,t,n){"use strict";(function(e){var r=n(2),i=n(5),o=n(28);function a(e){return r.a.isPlainObject(e)||r.a.isArray(e)}function s(e){return r.a.endsWith(e,"[]")?e.slice(0,-2):e}function l(e,t,n){return e?e.concat(t).map((function(e,t){return e=s(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}const u=r.a.toFlatObject(r.a,{},null,(function(e){return/^is[A-Z]/.test(e)}));t.a=function(t,n,c){if(!r.a.isObject(t))throw new TypeError("target must be an object");n=n||new(o.a||FormData);const h=(c=r.a.toFlatObject(c,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!r.a.isUndefined(t[e])}))).metaTokens,d=c.visitor||_,f=c.dots,p=c.indexes,m=(c.Blob||"undefined"!=typeof Blob&&Blob)&&r.a.isSpecCompliantForm(n);if(!r.a.isFunction(d))throw new TypeError("visitor must be a function");function g(t){if(null===t)return"";if(r.a.isDate(t))return t.toISOString();if(!m&&r.a.isBlob(t))throw new i.a("Blob is not supported. Use a Buffer instead.");return r.a.isArrayBuffer(t)||r.a.isTypedArray(t)?m&&"function"==typeof Blob?new Blob([t]):e.from(t):t}function _(e,t,i){let o=e;if(e&&!i&&"object"==typeof e)if(r.a.endsWith(t,"{}"))t=h?t:t.slice(0,-2),e=JSON.stringify(e);else if(r.a.isArray(e)&&function(e){return r.a.isArray(e)&&!e.some(a)}(e)||(r.a.isFileList(e)||r.a.endsWith(t,"[]"))&&(o=r.a.toArray(e)))return t=s(t),o.forEach((function(e,i){!r.a.isUndefined(e)&&null!==e&&n.append(!0===p?l([t],i,f):null===p?t:t+"[]",g(e))})),!1;return!!a(e)||(n.append(l(i,t,f),g(e)),!1)}const y=[],v=Object.assign(u,{defaultVisitor:_,convertValue:g,isVisitable:a});if(!r.a.isObject(t))throw new TypeError("data must be an object");return function e(t,i){if(!r.a.isUndefined(t)){if(-1!==y.indexOf(t))throw Error("Circular reference detected in "+i.join("."));y.push(t),r.a.forEach(t,(function(t,o){!0===(!(r.a.isUndefined(t)||null===t)&&d.call(n,t,r.a.isString(o)?o.trim():o,i,v))&&e(t,i?i.concat(o):[o])})),y.pop()}}(t),n}}).call(this,n(85).Buffer)},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE){0;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}}(),e.exports=n(51)},function(e,t,n){"use strict";function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t96?d:f},m=function(e,t,n){var r;if(t){var i=t.shouldForwardProp;r=e.__emotion_forwardProp&&i?function(t){return e.__emotion_forwardProp(t)&&i(t)}:i}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},g=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;return Object(u.c)(t,n,r),Object(h.a)((function(){return Object(u.b)(t,n,r)})),null},_=(n(60),function e(t,n){var o,a,s=t.__emotion_real===t,h=s&&t.__emotion_base||t;void 0!==n&&(o=n.label,a=n.target);var d=m(t,n,s),f=d||p(h),_=!f("as");return function(){var y=arguments,v=s&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==o&&v.push("label:"+o+";"),null==y[0]||void 0===y[0].raw)v.push.apply(v,y);else{0,v.push(y[0][0]);for(var x=y.length,b=1;b2||B(C)>3?"":" "}function V(e,t){for(;--t&&z()&&!(C<48||C>102||C>57&&C<65||C>70&&C<97););return R(e,D()+(t<6&&32==L()&&32==z()))}function G(e,t){for(;z()&&e+C!==57&&(e+C!==84||47!==L()););return"/*"+R(t,M-1)+"*"+d(47===e?e:z())}function q(e){for(;!B(L());)z();return R(e,M)}function $(e){return j(function e(t,n,r,i,o,a,s,l,u){var c=0,h=0,f=s,p=0,m=0,g=0,x=1,w=1,T=1,k=0,P="",O=o,R=a,B=i,F=P;for(;w;)switch(g=k,k=z()){case 40:if(108!=g&&58==v(F,f-1)){-1!=y(F+=_(U(k),"&","&\f"),"&\f")&&(T=-1);break}case 34:case 39:case 91:F+=U(k);break;case 9:case 10:case 13:case 32:F+=N(g);break;case 92:F+=V(D()-1,7);continue;case 47:switch(L()){case 42:case 47:E(W(G(z(),D()),n,r),u);break;default:F+="/"}break;case 123*x:l[c++]=b(F)*T;case 125*x:case 59:case 0:switch(k){case 0:case 125:w=0;case 59+h:-1==T&&(F=_(F,/\f/g,"")),m>0&&b(F)-f&&E(m>32?X(F+";",i,r,f-1):X(_(F," ","")+";",i,r,f-2),u);break;case 59:F+=";";default:if(E(B=Z(F,n,r,c,h,o,l,P,O=[],R=[],f),a),123===k)if(0===h)e(F,n,B,B,O,a,f,l,R);else switch(99===p&&110===v(F,3)?100:p){case 100:case 108:case 109:case 115:e(t,B,B,i&&E(Z(t,B,B,0,0,o,l,P,o,O=[],f),R),o,R,f,l,i?O:R);break;default:e(F,B,B,B,[""],R,0,l,R)}}c=h=m=0,x=T=1,P=F="",f=s;break;case 58:f=1+b(F),m=g;default:if(x<1)if(123==k)--x;else if(125==k&&0==x++&&125==(C=M>0?v(I,--M):0,A--,10===C&&(A=1,S--),C))continue;switch(F+=d(k),k*x){case 38:T=h>0?1:(F+="\f",-1);break;case 44:l[c++]=(b(F)-1)*T,T=1;break;case 64:45===L()&&(F+=U(z())),p=L(),h=f=b(P=F+=q(D())),k++;break;case 45:45===g&&2==b(F)&&(x=0)}}return a}("",null,null,null,[""],e=F(e),0,[0],e))}function Z(e,t,n,r,i,o,a,s,u,c,d){for(var f=i-1,p=0===i?o:[""],g=w(p),y=0,v=0,b=0;y0?p[E]+" "+T:_(T,/&\f/g,p[E])))&&(u[b++]=S);return P(e,t,n,0===i?l:s,u,c,d)}function W(e,t,n){return P(e,t,n,s,d(C),x(e,2,-2),0)}function X(e,t,n,r){return P(e,t,n,u,x(e,0,r),x(e,r+1,-1),r)}function H(e,t){for(var n="",r=w(e),i=0;i-1&&!e.return)switch(e.type){case u:e.return=function e(t,n){switch(p(t,n)){case 5103:return a+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return a+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return a+t+o+t+i+t+t;case 6828:case 4268:return a+t+i+t+t;case 6165:return a+t+i+"flex-"+t+t;case 5187:return a+t+_(t,/(\w+).+(:[^]+)/,a+"box-$1$2"+i+"flex-$1$2")+t;case 5443:return a+t+i+"flex-item-"+_(t,/flex-|-self/,"")+t;case 4675:return a+t+i+"flex-line-pack"+_(t,/align-content|flex-|-self/,"")+t;case 5548:return a+t+i+_(t,"shrink","negative")+t;case 5292:return a+t+i+_(t,"basis","preferred-size")+t;case 6060:return a+"box-"+_(t,"-grow","")+a+t+i+_(t,"grow","positive")+t;case 4554:return a+_(t,/([^-])(transform)/g,"$1"+a+"$2")+t;case 6187:return _(_(_(t,/(zoom-|grab)/,a+"$1"),/(image-set)/,a+"$1"),t,"")+t;case 5495:case 3959:return _(t,/(image-set\([^]*)/,a+"$1$`$1");case 4968:return _(_(t,/(.+:)(flex-)?(.*)/,a+"box-pack:$3"+i+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+a+t+t;case 4095:case 3583:case 4068:case 2532:return _(t,/(.+)-inline(.+)/,a+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(b(t)-1-n>6)switch(v(t,n+1)){case 109:if(45!==v(t,n+4))break;case 102:return _(t,/(.+:)(.+)-([^]+)/,"$1"+a+"$2-$3$1"+o+(108==v(t,n+3)?"$3":"$2-$3"))+t;case 115:return~y(t,"stretch")?e(_(t,"stretch","fill-available"),n)+t:t}break;case 4949:if(115!==v(t,n+1))break;case 6444:switch(v(t,b(t)-3-(~y(t,"!important")&&10))){case 107:return _(t,":",":"+a)+t;case 101:return _(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+a+(45===v(t,14)?"inline-":"")+"box$3$1"+a+"$2$3$1"+i+"$2box$3")+t}break;case 5936:switch(v(t,n+11)){case 114:return a+t+i+_(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return a+t+i+_(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return a+t+i+_(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return a+t+i+t+t}return t}(e.value,e.length);break;case c:return H([O(e,{value:_(e.value,"@","@"+a)})],r);case l:if(e.length)return T(e.props,(function(t){switch(g(t,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return H([O(e,{props:[_(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return H([O(e,{props:[_(t,/:(plac\w+)/,":"+a+"input-$1")]}),O(e,{props:[_(t,/:(plac\w+)/,":-moz-$1")]}),O(e,{props:[_(t,/:(plac\w+)/,i+"input-$1")]})],r)}return""}))}}],ie=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var i=e.stylisPlugins||re;var o,a,s={},l=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n1?t-1:0),r=1;re.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var U=Symbol("mobx-stored-annotations");function N(e){return Object.assign((function(t,n){V(t,n,e)}),e)}function V(e,t,n){I(e,U)||w(e,U,L({},e[U])),function(e){return"override"===e.annotationType_}(n)||(e[U][t]=n)}var G=Symbol("mobx administration"),q=function(){function e(e){void 0===e&&(e="Atom"),this.name_=void 0,this.isPendingUnobservation_=!1,this.isBeingObserved_=!1,this.observers_=new Set,this.batchId_=void 0,this.diffValue_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Ue.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e,this.batchId_=ot.inBatch?ot.batchId:NaN}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},t.reportObserved=function(){return ht(this)},t.reportChanged=function(){ot.inBatch&&this.batchId_===ot.batchId||(ot.stateVersion=ot.stateVersionr&&(r=s.dependenciesState_)}n.length=i,e.newObserving_=null,o=t.length;for(;o--;){var l=t[o];0===l.diffValue_&&st(l,e),l.diffValue_=0}for(;i--;){var u=n[i];1===u.diffValue_&&(u.diffValue_=0,at(u,e))}r!==Ue.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}(e),et(r),i}function He(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)st(t[n],e);e.dependenciesState_=Ue.NOT_TRACKING_}function Ye(e){var t=Ke();try{return e()}finally{Je(t)}}function Ke(){var e=ot.trackingDerivation;return ot.trackingDerivation=null,e}function Je(e){ot.trackingDerivation=e}function Qe(e){var t=ot.allowStateReads;return ot.allowStateReads=e,t}function et(e){ot.allowStateReads=e}function tt(e){if(e.dependenciesState_!==Ue.UP_TO_DATE_){e.dependenciesState_=Ue.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=Ue.UP_TO_DATE_}}var nt=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.batchId=Number.MIN_SAFE_INTEGER,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0,this.stateVersion=Number.MIN_SAFE_INTEGER},rt=!0,it=!1,ot=function(){var e=o();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(rt=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==(new nt).version&&(rt=!1),rt?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new nt):(setTimeout((function(){it||r(35)}),1),new nt)}();function at(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function st(e,t){e.observers_.delete(t),0===e.observers_.size&<(e)}function lt(e){!1===e.isPendingUnobservation_&&(e.isPendingUnobservation_=!0,ot.pendingUnobservations.push(e))}function ut(){0===ot.inBatch&&(ot.batchId=ot.batchId0&<(e),!1)}function dt(e){e.lowestObserverState_!==Ue.STALE_&&(e.lowestObserverState_=Ue.STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ue.UP_TO_DATE_&&e.onBecomeStale_(),e.dependenciesState_=Ue.STALE_})))}var ft=function(){function e(e,t,n,r){void 0===e&&(e="Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=Ue.NOT_TRACKING_,this.diffValue_=0,this.runId_=0,this.unboundDepsCount_=0,this.isDisposed_=!1,this.isScheduled_=!1,this.isTrackPending_=!1,this.isRunning_=!1,this.isTracing_=Ne.NONE,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}var t=e.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled_||(this.isScheduled_=!0,ot.pendingReactions.push(this),mt())},t.isScheduled=function(){return this.isScheduled_},t.runReaction_=function(){if(!this.isDisposed_){ut(),this.isScheduled_=!1;var e=ot.trackingContext;if(ot.trackingContext=this,Ze(this)){this.isTrackPending_=!0;try{this.onInvalidate_()}catch(e){this.reportExceptionInDerivation_(e)}}ot.trackingContext=e,ct()}},t.track=function(e){if(!this.isDisposed_){ut();0,this.isRunning_=!0;var t=ot.trackingContext;ot.trackingContext=this;var n=Xe(this,e,void 0);ot.trackingContext=t,this.isRunning_=!1,this.isTrackPending_=!1,this.isDisposed_&&He(this),$e(n)&&this.reportExceptionInDerivation_(n.cause),ct()}},t.reportExceptionInDerivation_=function(e){var t=this;if(this.errorHandler_)this.errorHandler_(e,this);else{if(ot.disableErrorBoundaries)throw e;var n="[mobx] uncaught error in '"+this+"'";ot.suppressReactionErrors||console.error(n,e),ot.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed_||(this.isDisposed_=!0,this.isRunning_||(ut(),He(this),ct()))},t.getDisposer_=function(e){var t=this,n=function n(){t.dispose(),null==e||null==e.removeEventListener||e.removeEventListener("abort",n)};return null==e||null==e.addEventListener||e.addEventListener("abort",n),n[G]=this,n},t.toString=function(){return"Reaction["+this.name_+"]"},t.trace=function(e){void 0===e&&(e=!1)},e}();var pt=function(e){return e()};function mt(){ot.inBatch>0||ot.isRunningReactions||pt(gt)}function gt(){ot.isRunningReactions=!0;for(var e=ot.pendingReactions,t=0;e.length>0;){100==++t&&(console.error("[mobx] cycle in reaction: "+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r",t,e):_(n)?Le(t,n,e):y(n)?V(t,n,e?xt:yt):y(t)?N(Y(e?"autoAction":"action",{name:t,autoAction:e})):void 0}}var Et=wt(!1);Object.assign(Et,yt);var Tt=wt(!0);function St(e){return _(e)&&!0===e.isMobxAction}function At(e,t){var n,r,i,o,a;void 0===t&&(t=h);var s,l=null!=(n=null==(r=t)?void 0:r.name)?n:"Autorun";if(!t.scheduler&&!t.delay)s=new ft(l,(function(){this.track(d)}),t.onError,t.requiresObservable);else{var u=Mt(t),c=!1;s=new ft(l,(function(){c||(c=!0,u((function(){c=!1,s.isDisposed_||s.track(d)})))}),t.onError,t.requiresObservable)}function d(){e(s)}return null!=(i=t)&&null!=(o=i.signal)&&o.aborted||s.schedule_(),s.getDisposer_(null==(a=t)?void 0:a.signal)}Object.assign(Tt,xt),Et.bound=N(vt),Tt.bound=N(bt);var kt=function(e){return e()};function Mt(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:kt}function Ct(e,t,n){return It("onBUO",e,t,n)}function It(e,t,n,r){var i="function"==typeof r?jn(t,n):jn(t),o=_(r)?r:n,a=e+"L";return i[a]?i[a].add(o):i[a]=new Set([o]),function(){var e=i[a];e&&(e.delete(o),0===e.size&&delete i[a])}}function Pt(e,t,n,r){var i=P(t);return Vn((function(){var t=wn(e,r)[G];M(i).forEach((function(e){t.extend_(e,i[e],!n||(!(e in n)||n[e]))}))})),e}var Ot=0;function zt(){this.message="FLOW_CANCELLED"}zt.prototype=Object.create(Error.prototype);var Lt=ee("flow"),Dt=ee("flow.bound",{bound:!0}),Rt=Object.assign((function(e,t){if(y(t))return V(e,t,Lt);var n=e,r=n.name||"",i=function(){var e,t=this,i=arguments,o=++Ot,a=Et(r+" - runid: "+o+" - init",n).apply(t,i),s=void 0,l=new Promise((function(t,n){var i=0;function l(e){var t;s=void 0;try{t=Et(r+" - runid: "+o+" - yield "+i++,a.next).call(a,e)}catch(e){return n(e)}c(t)}function u(e){var t;s=void 0;try{t=Et(r+" - runid: "+o+" - yield "+i++,a.throw).call(a,e)}catch(e){return n(e)}c(t)}function c(e){if(!_(null==e?void 0:e.then))return e.done?t(e.value):(s=Promise.resolve(e.value)).then(l,u);e.then(c,n)}e=n,l(void 0)}));return l.cancel=Et(r+" - runid: "+o+" - cancel",(function(){try{s&&Bt(s);var t=a.return(void 0),n=Promise.resolve(t.value);n.then(g,g),Bt(n),e(new zt)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),Lt);function Bt(e){_(e.cancel)&&e.cancel()}function Ft(e){return!0===(null==e?void 0:e.isMobXFlow)}function jt(e,t){return!!e&&(void 0!==t?!!Sn(e)&&e[G].values_.has(t):Sn(e)||!!e[G]||$(e)||_t(e)||Ge(e))}function Ut(e){return jt(e)}function Nt(e,t){void 0===t&&(t=void 0),ut();try{return e.apply(t)}finally{ct()}}function Vt(e){return e[G]}Rt.bound=N(Dt);var Gt={has:function(e,t){return Vt(e).has_(t)},get:function(e,t){return Vt(e).get_(t)},set:function(e,t,n){var r;return!!y(t)&&(null==(r=Vt(e).set_(t,n,!0))||r)},deleteProperty:function(e,t){var n;return!!y(t)&&(null==(n=Vt(e).delete_(t,!0))||n)},defineProperty:function(e,t,n){var r;return null==(r=Vt(e).defineProperty_(t,n))||r},ownKeys:function(e){return Vt(e).ownKeys_()},preventExtensions:function(e){r(13)}};function qt(e){return void 0!==e.interceptors_&&e.interceptors_.length>0}function $t(e,t){var n=e.interceptors_||(e.interceptors_=[]);return n.push(t),m((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Zt(e,t){var n=Ke();try{for(var i=[].concat(e.interceptors_||[]),o=0,a=i.length;o0}function Xt(e,t){var n=e.changeListeners_||(e.changeListeners_=[]);return n.push(t),m((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Ht(e,t){var n=Ke(),r=e.changeListeners_;if(r){for(var i=0,o=(r=r.slice()).length;i0?e.map(this.dehancer):e},t.intercept_=function(e){return $t(this,e)},t.observe_=function(e,t){return void 0===t&&(t=!1),t&&e({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),Xt(this,e)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(e){("number"!=typeof e||isNaN(e)||e<0)&&r("Out of range: "+e);var t=this.values_.length;if(e!==t)if(e>t){for(var n=new Array(e-t),i=0;i0&&Bn(e+t+1)},t.spliceWithArray_=function(e,t,n){var r=this;this.atom_;var i=this.values_.length;if(void 0===e?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=1===arguments.length?i-e:null==t?0:Math.max(0,Math.min(t,i-e)),void 0===n&&(n=c),qt(this)){var o=Zt(this,{object:this.proxy_,type:"splice",index:e,removedCount:t,added:n});if(!o)return c;t=o.removedCount,n=o.added}if(n=0===n.length?n:n.map((function(e){return r.enhancer_(e,void 0)})),this.legacyMode_){var a=n.length-t;this.updateArrayLength_(i,a)}var s=this.spliceItemsIntoValues_(e,t,n);return 0===t&&0===n.length||this.notifyArraySplice_(e,n,s),this.dehanceValues_(s)},t.spliceItemsIntoValues_=function(e,t,n){var r;if(n.length<1e4)return(r=this.values_).splice.apply(r,[e,t].concat(n));var i=this.values_.slice(e,e+t),o=this.values_.slice(e+t);this.values_.length+=n.length-t;for(var a=0;a=this.values_.length))return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e]);console.warn("[mobx] Out of bounds read: "+e)},t.set_=function(e,t){var n=this.values_;if(this.legacyMode_&&e>n.length&&r(17,e,n.length),e2?n-2:0),i=2;i-1&&(this.splice(n,1),!0)}};function nn(e,t){"function"==typeof Array.prototype[e]&&(tn[e]=t(e))}function rn(e){return function(){var t=this[G];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function on(e){return function(t,n){var r=this,i=this[G];return i.atom_.reportObserved(),i.dehanceValues_(i.values_)[e]((function(e,i){return t.call(n,e,i,r)}))}}function an(e){return function(){var t=this,n=this[G];n.atom_.reportObserved();var r=n.dehanceValues_(n.values_),i=arguments[0];return arguments[0]=function(e,n,r){return i(e,n,r,t)},r[e].apply(r,arguments)}}nn("concat",rn),nn("flat",rn),nn("includes",rn),nn("indexOf",rn),nn("join",rn),nn("lastIndexOf",rn),nn("slice",rn),nn("toString",rn),nn("toLocaleString",rn),nn("every",on),nn("filter",on),nn("find",on),nn("findIndex",on),nn("flatMap",on),nn("forEach",on),nn("map",on),nn("some",on),nn("reduce",an),nn("reduceRight",an);var sn,ln,un=T("ObservableArrayAdministration",Qt);function cn(e){return v(e)&&un(e[G])}var hn={},dn="add";sn=Symbol.iterator,ln=Symbol.toStringTag;var fn,pn,mn=function(){function e(e,t,n){var i=this;void 0===t&&(t=X),void 0===n&&(n="ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[G]=hn,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,_(Map)||r(18),Vn((function(){i.keysAtom_=Z("ObservableMap.keys()"),i.data_=new Map,i.hasMap_=new Map,e&&i.merge(e)}))}var t=e.prototype;return t.has_=function(e){return this.data_.has(e)},t.has=function(e){var t=this;if(!ot.trackingDerivation)return this.has_(e);var n=this.hasMap_.get(e);if(!n){var r=n=new je(this.has_(e),H,"ObservableMap.key?",!1);this.hasMap_.set(e,r),Ct(r,(function(){return t.hasMap_.delete(e)}))}return n.get()},t.set=function(e,t){var n=this.has_(e);if(qt(this)){var r=Zt(this,{type:n?Kt:dn,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this},t.delete=function(e){var t=this;if((this.keysAtom_,qt(this))&&!Zt(this,{type:"delete",object:this,name:e}))return!1;if(this.has_(e)){var n=Wt(this),r=n?{observableKind:"map",debugObjectName:this.name_,type:"delete",object:this,oldValue:this.data_.get(e).value_,name:e}:null;return Nt((function(){var n;t.keysAtom_.reportChanged(),null==(n=t.hasMap_.get(e))||n.setNewValue_(!1),t.data_.get(e).setNewValue_(void 0),t.data_.delete(e)})),n&&Ht(this,r),!0}return!1},t.updateValue_=function(e,t){var n=this.data_.get(e);if((t=n.prepareNewValue_(t))!==ot.UNCHANGED){var r=Wt(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:Kt,object:this,oldValue:n.value_,name:e,newValue:t}:null;0,n.setNewValue_(t),r&&Ht(this,i)}},t.addValue_=function(e,t){var n=this;this.keysAtom_,Nt((function(){var r,i=new je(t,n.enhancer_,"ObservableMap.key",!1);n.data_.set(e,i),t=i.value_,null==(r=n.hasMap_.get(e))||r.setNewValue_(!0),n.keysAtom_.reportChanged()}));var r=Wt(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:dn,object:this,name:e,newValue:t}:null;r&&Ht(this,i)},t.get=function(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)},t.dehanceValue_=function(e){return void 0!==this.dehancer?this.dehancer(e):e},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var e=this,t=this.keys();return Zn({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:e.get(i)}}})},t.entries=function(){var e=this,t=this.keys();return Zn({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},t[sn]=function(){return this.entries()},t.forEach=function(e,t){for(var n,r=j(this);!(n=r()).done;){var i=n.value,o=i[0],a=i[1];e.call(t,a,o,this)}},t.merge=function(e){var t=this;return gn(e)&&(e=new Map(e)),Nt((function(){x(e)?function(e){var t=Object.keys(e);if(!k)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter((function(t){return u.propertyIsEnumerable.call(e,t)}))):t}(e).forEach((function(n){return t.set(n,e[n])})):Array.isArray(e)?e.forEach((function(e){var n=e[0],r=e[1];return t.set(n,r)})):S(e)?(e.constructor!==Map&&r(19,e),e.forEach((function(e,n){return t.set(n,e)}))):null!=e&&r(20,e)})),this},t.clear=function(){var e=this;Nt((function(){Ye((function(){for(var t,n=j(e.keys());!(t=n()).done;){var r=t.value;e.delete(r)}}))}))},t.replace=function(e){var t=this;return Nt((function(){for(var n,i=function(e){if(S(e)||gn(e))return e;if(Array.isArray(e))return new Map(e);if(x(e)){var t=new Map;for(var n in e)t.set(n,e[n]);return t}return r(21,e)}(e),o=new Map,a=!1,s=j(t.data_.keys());!(n=s()).done;){var l=n.value;if(!i.has(l))if(t.delete(l))a=!0;else{var u=t.data_.get(l);o.set(l,u)}}for(var c,h=j(i.entries());!(c=h()).done;){var d=c.value,f=d[0],p=d[1],m=t.data_.has(f);if(t.set(f,p),t.data_.has(f)){var g=t.data_.get(f);o.set(f,g),m||(a=!0)}}if(!a)if(t.data_.size!==o.size)t.keysAtom_.reportChanged();else for(var _=t.data_.keys(),y=o.keys(),v=_.next(),b=y.next();!v.done;){if(v.value!==b.value){t.keysAtom_.reportChanged();break}v=_.next(),b=y.next()}t.data_=o})),this},t.toString=function(){return"[object ObservableMap]"},t.toJSON=function(){return Array.from(this)},t.observe_=function(e,t){return Xt(this,e)},t.intercept_=function(e){return $t(this,e)},z(e,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:ln,get:function(){return"Map"}}]),e}(),gn=T("ObservableMap",mn);var _n={};fn=Symbol.iterator,pn=Symbol.toStringTag;var yn=function(){function e(e,t,n){var i=this;void 0===t&&(t=X),void 0===n&&(n="ObservableSet"),this.name_=void 0,this[G]=_n,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,_(Set)||r(22),this.enhancer_=function(e,r){return t(e,r,n)},Vn((function(){i.atom_=Z(i.name_),e&&i.replace(e)}))}var t=e.prototype;return t.dehanceValue_=function(e){return void 0!==this.dehancer?this.dehancer(e):e},t.clear=function(){var e=this;Nt((function(){Ye((function(){for(var t,n=j(e.data_.values());!(t=n()).done;){var r=t.value;e.delete(r)}}))}))},t.forEach=function(e,t){for(var n,r=j(this);!(n=r()).done;){var i=n.value;e.call(t,i,i,this)}},t.add=function(e){var t=this;if((this.atom_,qt(this))&&!Zt(this,{type:dn,object:this,newValue:e}))return this;if(!this.has(e)){Nt((function(){t.data_.add(t.enhancer_(e,void 0)),t.atom_.reportChanged()}));var n=Wt(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:dn,object:this,newValue:e}:null;0,n&&Ht(this,r)}return this},t.delete=function(e){var t=this;if(qt(this)&&!Zt(this,{type:"delete",object:this,oldValue:e}))return!1;if(this.has(e)){var n=Wt(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:"delete",object:this,oldValue:e}:null;return Nt((function(){t.atom_.reportChanged(),t.data_.delete(e)})),n&&Ht(this,r),!0}return!1},t.has=function(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))},t.entries=function(){var e=0,t=Array.from(this.keys()),n=Array.from(this.values());return Zn({next:function(){var r=e;return e+=1,rOn){for(var t=On;t=0&&r++}t=$n(t),n=$n(n);var l="[object Array]"===s;if(!l){if("object"!=typeof t||"object"!=typeof n)return!1;var u=t.constructor,c=n.constructor;if(u!==c&&!(_(u)&&u instanceof u&&_(c)&&c instanceof c)&&"constructor"in t&&"constructor"in n)return!1}if(0===r)return!1;r<0&&(r=-1);o=o||[];var h=(i=i||[]).length;for(;h--;)if(i[h]===t)return o[h]===n;if(i.push(t),o.push(n),l){if((h=t.length)!==n.length)return!1;for(;h--;)if(!e(t[h],n[h],r-1,i,o))return!1}else{var d,f=Object.keys(t);if(h=f.length,Object.keys(n).length!==h)return!1;for(;h--;)if(d=f[h],!I(n,d)||!e(t[d],n[d],r-1,i,o))return!1}return i.pop(),o.pop(),!0}(e,t,n)}function $n(e){return cn(e)?e.slice():S(e)||gn(e)||A(e)||vn(e)?Array.from(e.entries()):e}function Zn(e){return e[Symbol.iterator]=Wn,e}function Wn(){return this}["Symbol","Map","Set"].forEach((function(e){void 0===o()[e]&&r("MobX requires global '"+e+"' to be available or polyfilled")})),"object"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:function(e){return console.warn("[mobx.spy] Is a no-op in production builds"),function(){}},extras:{getDebugName:Nn},$mobx:G})}).call(this,n(17))},function(e,t,n){"use strict";function r(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var r=function(e){var t=new WeakMap;return function(n){if(t.has(n))return t.get(n);var r=e(n);return t.set(n,r),r}}},function(e,t,n){"use strict";var r=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===i}(e)}(e)};var i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?c((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function a(e,t,n){return e.concat(t).map((function(e){return o(e,n)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function l(e,t){try{return t in e}catch(e){return!1}}function u(e,t,n){var r={};return n.isMergeableObject(e)&&s(e).forEach((function(t){r[t]=o(e[t],n)})),s(t).forEach((function(i){(function(e,t){return l(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(l(e,i)&&n.isMergeableObject(t[i])?r[i]=function(e,t){if(!t.customMerge)return c;var n=t.customMerge(e);return"function"==typeof n?n:c}(i,n)(e[i],t[i],n):r[i]=o(t[i],n))})),r}function c(e,t,n){(n=n||{}).arrayMerge=n.arrayMerge||a,n.isMergeableObject=n.isMergeableObject||r,n.cloneUnlessOtherwiseSpecified=o;var i=Array.isArray(t);return i===Array.isArray(e)?i?n.arrayMerge(e,t,n):u(e,t,n):o(t,n)}c.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,n){return c(e,n,t)}),{})};var h=c;e.exports=h},function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t=0||(i[n]=e[n]);return i}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";function r(e,t){return function(){return e.apply(t,arguments)}}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";t.a=null},function(e,t,n){"use strict";var r=n(6);function i(e,t,n){if(null!==e)for(var r,o,a,s,l,u,c,h,d=0,f=0,p=e.type,m="FeatureCollection"===p,g="Feature"===p,_=m?e.features.length:1,y=0;y<_;y++){l=(h=!!(c=m?e.features[y].geometry:g?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}(t),n.properties);case"Polygon":var o=[];i(t,(function(e){o.push(e)}));var l,u,c,h,d,f,p,m,g=s(t,{properties:n.properties}),_=g.geometry.coordinates,y=0,v=0,x=0,b=o.map((function(e){return[e[0]-_[0],e[1]-_[1]]}));for(l=0;l3?Object(r.f)([o]):null}(t);return E?e(E,{properties:n.properties}):s(t,{properties:n.properties})}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(31),i=n.n(r),o=function(e,t){return i()(e,t)}},function(e,t,n){"use strict";var r=n(58),i={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function l(e){return r.isMemo(e)?a:s[e.$$typeof]||i}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=a;var u=Object.defineProperty,c=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,p=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(p){var i=f(n);i&&i!==p&&e(t,i,r)}var a=c(n);h&&(a=a.concat(h(n)));for(var s=l(t),m=l(n),g=0;g1)for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n1&&(i-=1)),[360*i,100*o,100*u]},o.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const i=o.rgb.hsl(e)[0],a=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[i,100*a,100*r]},o.rgb.cmyk=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.min(1-t,1-n,1-r);return[100*((1-t-i)/(1-i)||0),100*((1-n-i)/(1-i)||0),100*((1-r-i)/(1-i)||0),100*i]},o.rgb.keyword=function(e){const t=i[e];if(t)return t;let n,o=1/0;for(const t of Object.keys(r)){const i=r[t],l=(s=i,((a=e)[0]-s[0])**2+(a[1]-s[1])**2+(a[2]-s[2])**2);l.04045?((t+.055)/1.055)**2.4:t/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;return[100*(.4124*t+.3576*n+.1805*r),100*(.2126*t+.7152*n+.0722*r),100*(.0193*t+.1192*n+.9505*r)]},o.rgb.lab=function(e){const t=o.rgb.xyz(e);let n=t[0],r=t[1],i=t[2];n/=95.047,r/=100,i/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;return[116*r-16,500*(n-r),200*(r-i)]},o.hsl.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;let i,o,a;if(0===n)return a=255*r,[a,a,a];i=r<.5?r*(1+n):r+n-r*n;const s=2*r-i,l=[0,0,0];for(let e=0;e<3;e++)o=t+1/3*-(e-1),o<0&&o++,o>1&&o--,a=6*o<1?s+6*(i-s)*o:2*o<1?i:3*o<2?s+(i-s)*(2/3-o)*6:s,l[e]=255*a;return l},o.hsl.hsv=function(e){const t=e[0];let n=e[1]/100,r=e[2]/100,i=n;const o=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,i*=o<=1?o:2-o;return[t,100*(0===r?2*i/(o+i):2*n/(r+n)),100*((r+n)/2)]},o.hsv.rgb=function(e){const t=e[0]/60,n=e[1]/100;let r=e[2]/100;const i=Math.floor(t)%6,o=t-Math.floor(t),a=255*r*(1-n),s=255*r*(1-n*o),l=255*r*(1-n*(1-o));switch(r*=255,i){case 0:return[r,l,a];case 1:return[s,r,a];case 2:return[a,r,l];case 3:return[a,s,r];case 4:return[l,a,r];case 5:return[r,a,s]}},o.hsv.hsl=function(e){const t=e[0],n=e[1]/100,r=e[2]/100,i=Math.max(r,.01);let o,a;a=(2-n)*r;const s=(2-n)*i;return o=n*i,o/=s<=1?s:2-s,o=o||0,a/=2,[t,100*o,100*a]},o.hwb.rgb=function(e){const t=e[0]/360;let n=e[1]/100,r=e[2]/100;const i=n+r;let o;i>1&&(n/=i,r/=i);const a=Math.floor(6*t),s=1-r;o=6*t-a,0!=(1&a)&&(o=1-o);const l=n+o*(s-n);let u,c,h;switch(a){default:case 6:case 0:u=s,c=l,h=n;break;case 1:u=l,c=s,h=n;break;case 2:u=n,c=s,h=l;break;case 3:u=n,c=l,h=s;break;case 4:u=l,c=n,h=s;break;case 5:u=s,c=n,h=l}return[255*u,255*c,255*h]},o.cmyk.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100,i=e[3]/100;return[255*(1-Math.min(1,t*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},o.xyz.rgb=function(e){const t=e[0]/100,n=e[1]/100,r=e[2]/100;let i,o,a;return i=3.2406*t+-1.5372*n+-.4986*r,o=-.9689*t+1.8758*n+.0415*r,a=.0557*t+-.204*n+1.057*r,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[255*i,255*o,255*a]},o.xyz.lab=function(e){let t=e[0],n=e[1],r=e[2];t/=95.047,n/=100,r/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;return[116*n-16,500*(t-n),200*(n-r)]},o.lab.xyz=function(e){let t,n,r;n=(e[0]+16)/116,t=e[1]/500+n,r=n-e[2]/200;const i=n**3,o=t**3,a=r**3;return n=i>.008856?i:(n-16/116)/7.787,t=o>.008856?o:(t-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,t*=95.047,n*=100,r*=108.883,[t,n,r]},o.lab.lch=function(e){const t=e[0],n=e[1],r=e[2];let i;i=360*Math.atan2(r,n)/2/Math.PI,i<0&&(i+=360);return[t,Math.sqrt(n*n+r*r),i]},o.lch.lab=function(e){const t=e[0],n=e[1],r=e[2]/360*2*Math.PI;return[t,n*Math.cos(r),n*Math.sin(r)]},o.rgb.ansi16=function(e,t=null){const[n,r,i]=e;let a=null===t?o.rgb.hsv(e)[2]:t;if(a=Math.round(a/50),0===a)return 30;let s=30+(Math.round(i/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===a&&(s+=60),s},o.hsv.ansi16=function(e){return o.rgb.ansi16(o.hsv.rgb(e),e[2])},o.rgb.ansi256=function(e){const t=e[0],n=e[1],r=e[2];if(t===n&&n===r)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},o.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const n=.5*(1+~~(e>50));return[(1&t)*n*255,(t>>1&1)*n*255,(t>>2&1)*n*255]},o.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},o.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},o.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let n=t[0];3===t[0].length&&(n=n.split("").map(e=>e+e).join(""));const r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},o.rgb.hcg=function(e){const t=e[0]/255,n=e[1]/255,r=e[2]/255,i=Math.max(Math.max(t,n),r),o=Math.min(Math.min(t,n),r),a=i-o;let s,l;return s=a<1?o/(1-a):0,l=a<=0?0:i===t?(n-r)/a%6:i===n?2+(r-t)/a:4+(t-n)/a,l/=6,l%=1,[360*l,100*a,100*s]},o.hsl.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=n<.5?2*t*n:2*t*(1-n);let i=0;return r<1&&(i=(n-.5*r)/(1-r)),[e[0],100*r,100*i]},o.hsv.hcg=function(e){const t=e[1]/100,n=e[2]/100,r=t*n;let i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],100*r,100*i]},o.hcg.rgb=function(e){const t=e[0]/360,n=e[1]/100,r=e[2]/100;if(0===n)return[255*r,255*r,255*r];const i=[0,0,0],o=t%1*6,a=o%1,s=1-a;let l=0;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=s,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=s,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=s}return l=(1-n)*r,[255*(n*i[0]+l),255*(n*i[1]+l),255*(n*i[2]+l)]},o.hcg.hsv=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);let r=0;return n>0&&(r=t/n),[e[0],100*r,100*n]},o.hcg.hsl=function(e){const t=e[1]/100,n=e[2]/100*(1-t)+.5*t;let r=0;return n>0&&n<.5?r=t/(2*n):n>=.5&&n<1&&(r=t/(2*(1-n))),[e[0],100*r,100*n]},o.hcg.hwb=function(e){const t=e[1]/100,n=t+e[2]/100*(1-t);return[e[0],100*(n-t),100*(1-n)]},o.hwb.hcg=function(e){const t=e[1]/100,n=1-e[2]/100,r=n-t;let i=0;return r<1&&(i=(n-r)/(1-r)),[e[0],100*r,100*i]},o.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},o.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},o.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},o.gray.hsl=function(e){return[0,0,e[0]]},o.gray.hsv=o.gray.hsl,o.gray.hwb=function(e){return[0,100,e[0]]},o.gray.cmyk=function(e){return[0,0,0,e[0]]},o.gray.lab=function(e){return[e[0],0,0]},o.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),n=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(n.length)+n},o.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]}},function(e,t,n){var r,i,o; /* @license Papa Parse v5.4.1 https://github.com/mholt/PapaParse License: MIT -*/i=[],void 0===(o="function"==typeof(r=function e(){"use strict";var t="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:{},n=!t.document&&!!t.postMessage,r=t.IS_PAPA_WORKER||!1,i={},o=0,a={parse:function(n,r){var s=(r=r||{}).dynamicTyping||!1;if(b(s)&&(r.dynamicTypingFunction=s,s={}),r.dynamicTyping=s,r.transform=!!b(r.transform)&&r.transform,r.worker&&a.WORKERS_SUPPORTED){var l=function(){if(!a.WORKERS_SUPPORTED)return!1;var n,r,s=(n=t.URL||t.webkitURL||null,r=e.toString(),a.BLOB_URL||(a.BLOB_URL=n.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",r,")();"],{type:"text/javascript"})))),l=new t.Worker(s);return l.onmessage=_,l.id=o++,i[l.id]=l}();return l.userStep=r.step,l.userChunk=r.chunk,l.userComplete=r.complete,l.userError=r.error,r.step=b(r.step),r.chunk=b(r.chunk),r.complete=b(r.complete),r.error=b(r.error),delete r.worker,void l.postMessage({input:n,config:r,workerId:l.id})}var f=null;return a.NODE_STREAM_INPUT,"string"==typeof n?(n=function(e){return 65279===e.charCodeAt(0)?e.slice(1):e}(n),f=r.download?new u(r):new h(r)):!0===n.readable&&b(n.read)&&b(n.on)?f=new d(r):(t.File&&n instanceof File||n instanceof Object)&&(f=new c(r)),f.stream(n)},unparse:function(e,t){var n=!1,r=!0,i=",",o="\r\n",s='"',l=s+s,u=!1,c=null,h=!1;!function(){if("object"==typeof t){if("string"!=typeof t.delimiter||a.BAD_DELIMITERS.filter((function(e){return-1!==t.delimiter.indexOf(e)})).length||(i=t.delimiter),("boolean"==typeof t.quotes||"function"==typeof t.quotes||Array.isArray(t.quotes))&&(n=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(u=t.skipEmptyLines),"string"==typeof t.newline&&(o=t.newline),"string"==typeof t.quoteChar&&(s=t.quoteChar),"boolean"==typeof t.header&&(r=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");c=t.columns}void 0!==t.escapeChar&&(l=t.escapeChar+s),("boolean"==typeof t.escapeFormulae||t.escapeFormulae instanceof RegExp)&&(h=t.escapeFormulae instanceof RegExp?t.escapeFormulae:/^[=+\-@\t\r].*$/)}}();var d=new RegExp(p(s),"g");if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return f(null,e,u);if("object"==typeof e[0])return f(c||Object.keys(e[0]),e,u)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||c),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),f(e.fields||[],e.data||[],u);throw new Error("Unable to serialize unrecognized input");function f(e,t,n){var a="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var s=Array.isArray(e)&&0=this._config.preview;if(r)t.postMessage({results:s,workerId:a.WORKER_ID,finished:u});else if(b(this._config.chunk)&&!n){if(this._config.chunk(s,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);s=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(s.data),this._completeResults.errors=this._completeResults.errors.concat(s.errors),this._completeResults.meta=s.meta),this._completed||!u||!b(this._config.complete)||s&&s.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),u||s&&s.meta.paused||this._nextChunk(),s}this._halted=!0},this._sendError=function(e){b(this._config.error)?this._config.error(e):r&&this._config.error&&t.postMessage({workerId:a.WORKER_ID,error:e,finished:!1})}}function u(e){var t;(e=e||{}).chunkSize||(e.chunkSize=a.RemoteChunkSize),l.call(this,e),this._nextChunk=n?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),n||(t.onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var r in e)t.setRequestHeader(r,e[r])}if(this._config.chunkSize){var i=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+i)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}n&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=function(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substring(t.lastIndexOf("/")+1))}(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){var n=t.statusText||e;this._sendError(new Error(n))}}function c(e){var t,n;(e=e||{}).chunkSize||(e.chunkSize=a.LocalChunkSize),l.call(this,e);var r="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,n=e.slice||e.webkitSlice||e.mozSlice,r?((t=new FileReader).onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function h(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,n=this._config.chunkSize;return n?(e=t.substring(0,n),t=t.substring(n)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function d(e){l.call(this,e=e||{});var t=[],n=!0,r=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){r&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):n=!0},this._streamData=x((function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),n&&(n=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}}),this),this._streamError=x((function(e){this._streamCleanUp(),this._sendError(e)}),this),this._streamEnd=x((function(){this._streamCleanUp(),r=!0,this._streamData("")}),this),this._streamCleanUp=x((function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)}),this)}function f(e){var t,n,r,i=Math.pow(2,53),o=-i,s=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,l=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,u=this,c=0,h=0,d=!1,f=!1,_=[],g={data:[],errors:[],meta:{}};if(b(e.step)){var y=e.step;e.step=function(t){if(g=t,E())w();else{if(w(),0===g.data.length)return;c+=t.data.length,e.preview&&c>e.preview?n.abort():(g.data=g.data[0],y(g,u))}}}function x(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function w(){return g&&r&&(S("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),r=!1),e.skipEmptyLines&&(g.data=g.data.filter((function(e){return!x(e)}))),E()&&function(){if(g)if(Array.isArray(g.data[0])){for(var t=0;E()&&t=_.length?"__parsed_extra":_[r]),e.transform&&(a=e.transform(a,o)),a=T(o,a),"__parsed_extra"===o?(i[o]=i[o]||[],i[o].push(a)):i[o]=a}return e.header&&(r>_.length?S("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+r,h+n):r<_.length&&S("FieldMismatch","TooFewFields","Too few fields: expected "+_.length+" fields but parsed "+r,h+n)),i}var n=1;return!g.data.length||Array.isArray(g.data[0])?(g.data=g.data.map(t),n=g.data.length):g.data=t(g.data,0),e.header&&g.meta&&(g.meta.fields=_),h+=n,g}()}function E(){return e.header&&0===_.length}function T(t,n){return r=t,e.dynamicTypingFunction&&void 0===e.dynamicTyping[r]&&(e.dynamicTyping[r]=e.dynamicTypingFunction(r)),!0===(e.dynamicTyping[r]||e.dynamicTyping)?"true"===n||"TRUE"===n||"false"!==n&&"FALSE"!==n&&(function(e){if(s.test(e)){var t=parseFloat(e);if(o=r.length/2?"\r\n":"\r"}(i,l)),r=!1,e.delimiter)b(e.delimiter)&&(e.delimiter=e.delimiter(i),g.meta.delimiter=e.delimiter);else{var u=function(t,n,r,i,o){var s,l,u,c;o=o||[",","\t","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var h=0;h=s)return Z(!0)}else for(j=c,c++;;){if(-1===(j=a.indexOf(t,j+1)))return f||w.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:x.length,index:c}),q();if(j===m-1)return q(a.substring(c,j).replace(F,t));if(t!==u||a[j+1]!==u){if(t===u||0===j||a[j-1]!==u){-1!==R&&R=s)return Z(!0);break}w.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:x.length,index:c}),j++}}else j++}return q();function V(e){x.push(e),T=c}function G(e){var t=0;if(-1!==e){var n=a.substring(j+1,e);n&&""===n.trim()&&(t=n.length)}return t}function q(e){return f||(void 0===e&&(e=a.substring(c)),E.push(e),c=m,V(E),v&&W()),Z()}function $(e){c=e,V(E),E=[],B=a.indexOf(r,c)}function Z(e){return{data:x,errors:w,meta:{delimiter:n,linebreak:r,aborted:h,truncated:!!e,cursor:T+(d||0)}}}function W(){o(Z()),x=[],w=[]}},this.abort=function(){h=!0},this.getCharIndex=function(){return c}}function _(e){var t=e.data,n=i[t.workerId],r=!1;if(t.error)n.userError(t.error,t.file);else if(t.results&&t.results.data){var o={abort:function(){r=!0,g(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:y,resume:y};if(b(n.userStep)){for(var a=0;ar[0]&&(r=s),s[1]i[1]&&(i=s)}var l=[t,n,r,i],u=l.slice();for(a=0;a=2&&f(t[t.length-2],t[t.length-1],e[n])<=0;)t.pop();t.push(e[n])}for(var r=[],i=e.length-1;i>=0;i--){for(;r.length>=2&&f(r[r.length-2],r[r.length-1],e[i])<=0;)r.pop();r.push(e[i])}return r.pop(),t.pop(),t.concat(r)}(u)}(e),a=new r(16);a.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},a.compareMinX=function(e,t){return e[0]-t[0]},a.compareMinY=function(e,t){return e[1]-t[1]},a.load(e);for(var s,u=[],c=0;ca||l.push({node:p,dist:m})}for(;l.length&&!l.peek().node.children;){var _=l.pop(),y=_.node,v=g(y,t,n),x=g(y,r,o);if(_.dist=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function d(e,t,n){for(var r,i,o,a,s=Math.min(e[0],t[0]),l=Math.min(e[1],t[1]),u=Math.max(e[0],t[0]),c=Math.max(e[1],t[1]),h=n.search({minX:s,minY:l,maxX:u,maxY:c}),d=0;d0!=f(r,i,a)>0&&f(o,a,r)>0!=f(o,a,i)>0)return!1;return!0}function f(e,t,n){return a(e[0],e[1],t[0],t[1],n[0],n[1])}function p(e){var t=e.p,n=e.next.p;return e.minX=Math.min(t[0],n[0]),e.minY=Math.min(t[1],n[1]),e.maxX=Math.max(t[0],n[0]),e.maxY=Math.max(t[1],n[1]),e}function m(e,t){var n={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(n.next=t.next,n.prev=t,t.next.prev=n,t.next=n):(n.prev=n,n.next=n),n}function _(e,t){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function g(e,t,n){var r=t[0],i=t[1],o=n[0]-r,a=n[1]-i;if(0!==o||0!==a){var s=((e[0]-r)*o+(e[1]-i)*a)/(o*o+a*a);s>1?(r=n[0],i=n[1]):s>0&&(r+=o*s,i+=a*s)}return(o=e[0]-r)*o+(a=e[1]-i)*a}function y(e,t,n,r,i,o,a,s){var l,u,c,h,d=n-e,f=r-t,p=a-i,m=s-o,_=e-i,g=t-o,y=d*d+f*f,v=d*p+f*m,x=p*p+m*m,b=d*_+f*g,w=p*_+m*g,E=y*x-v*v,T=E,S=E;0===E?(u=0,T=1,h=w,S=x):(h=y*w-v*b,(u=v*w-x*b)<0?(u=0,h=w,S=x):u>T&&(u=T,h=w+v,S=x)),h<0?(h=0,-b<0?u=0:-b>y?u=T:(u=-b,T=y)):h>S&&(h=S,-b+v<0?u=0:-b+v>y?u=T:(u=-b+v,T=y));var k=(1-(c=0===h?0:h/S))*i+c*a-((1-(l=0===u?0:u/T))*e+l*n),M=(1-c)*o+c*s-((1-l)*t+l*r);return k*k+M*M}function v(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}i.default&&(i=i.default),e.exports=s,e.exports.default=s},function(e,t,n){"use strict";function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}n.d(t,"a",(function(){return r}))},function(e,t,n){const r=n(87),i=n(90),o=["keyword","gray","hex"],a={};for(const e of Object.keys(i))a[[...i[e].labels].sort().join("")]=e;const s={};function l(e,t){if(!(this instanceof l))return new l(e,t);if(t&&t in o&&(t=null),t&&!(t in i))throw new Error("Unknown model: "+t);let n,u;if(null==e)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof l)this.model=e.model,this.color=[...e.color],this.valpha=e.valpha;else if("string"==typeof e){const t=r.get(e);if(null===t)throw new Error("Unable to parse color from string: "+e);this.model=t.model,u=i[this.model].channels,this.color=t.value.slice(0,u),this.valpha="number"==typeof t.value[u]?t.value[u]:1}else if(e.length>0){this.model=t||"rgb",u=i[this.model].channels;const n=Array.prototype.slice.call(e,0,u);this.color=d(n,u),this.valpha="number"==typeof e[u]?e[u]:1}else if("number"==typeof e)this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;const t=Object.keys(e);"alpha"in e&&(t.splice(t.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);const r=t.sort().join("");if(!(r in a))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=a[r];const{labels:o}=i[this.model],s=[];for(n=0;n(e%360+360)%360),saturationl:c("hsl",1,h(100)),lightness:c("hsl",2,h(100)),saturationv:c("hsv",1,h(100)),value:c("hsv",2,h(100)),chroma:c("hcg",1,h(100)),gray:c("hcg",2,h(100)),white:c("hwb",1,h(100)),wblack:c("hwb",2,h(100)),cyan:c("cmyk",0,h(100)),magenta:c("cmyk",1,h(100)),yellow:c("cmyk",2,h(100)),black:c("cmyk",3,h(100)),x:c("xyz",0,h(95.047)),y:c("xyz",1,h(100)),z:c("xyz",2,h(108.833)),l:c("lab",0,h(100)),a:c("lab",1),b:c("lab",2),keyword(e){return void 0!==e?new l(e):i[this.model].keyword(this.color)},hex(e){return void 0!==e?new l(e):r.to.hex(this.rgb().round().color)},hexa(e){if(void 0!==e)return new l(e);const t=this.rgb().round().color;let n=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===n.length&&(n="0"+n),r.to.hex(t)+n},rgbNumber(){const e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity(){const e=this.rgb().color,t=[];for(const[n,r]of e.entries()){const e=r/255;t[n]=e<=.04045?e/12.92:((e+.055)/1.055)**2.4}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),n=e.luminosity();return t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(2126*e[0]+7152*e[1]+722*e[2])/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return l.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let n=t.color[0];return n=(n+e)%360,n=n<0?360+n:n,t.color[0]=n,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const n=e.rgb(),r=this.rgb(),i=void 0===t?.5:t,o=2*i-1,a=n.alpha()-r.alpha(),s=((o*a==-1?o:(o+a)/(1+o*a))+1)/2,u=1-s;return l.rgb(s*n.red()+u*r.red(),s*n.green()+u*r.green(),s*n.blue()+u*r.blue(),n.alpha()*i+r.alpha()*(1-i))}};for(const e of Object.keys(i)){if(o.includes(e))continue;const{channels:t}=i[e];l.prototype[e]=function(...t){return this.model===e?new l(this):t.length>0?new l(t,e):new l([...(n=i[this.model][e].raw(this.color),Array.isArray(n)?n:[n]),this.valpha],e);var n},l[e]=function(...n){let r=n[0];return"number"==typeof r&&(r=d(n,t)),new l(r,e)}}function u(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}function c(e,t,n){e=Array.isArray(e)?e:[e];for(const r of e)(s[r]||(s[r]=[]))[t]=n;return e=e[0],function(r){let i;return void 0!==r?(n&&(r=n(r)),i=this[e](),i.color[t]=r,i):(i=this[e]().color[t],n&&(i=n(i)),i)}}function h(e){return function(t){return Math.max(0,Math.min(e,t))}}function d(e,t){for(let n=0;n=this._config.preview;if(r)t.postMessage({results:s,workerId:a.WORKER_ID,finished:u});else if(b(this._config.chunk)&&!n){if(this._config.chunk(s,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);s=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(s.data),this._completeResults.errors=this._completeResults.errors.concat(s.errors),this._completeResults.meta=s.meta),this._completed||!u||!b(this._config.complete)||s&&s.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),u||s&&s.meta.paused||this._nextChunk(),s}this._halted=!0},this._sendError=function(e){b(this._config.error)?this._config.error(e):r&&this._config.error&&t.postMessage({workerId:a.WORKER_ID,error:e,finished:!1})}}function u(e){var t;(e=e||{}).chunkSize||(e.chunkSize=a.RemoteChunkSize),l.call(this,e),this._nextChunk=n?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),n||(t.onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var r in e)t.setRequestHeader(r,e[r])}if(this._config.chunkSize){var i=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+i)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}n&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=function(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substring(t.lastIndexOf("/")+1))}(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){var n=t.statusText||e;this._sendError(new Error(n))}}function c(e){var t,n;(e=e||{}).chunkSize||(e.chunkSize=a.LocalChunkSize),l.call(this,e);var r="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,n=e.slice||e.webkitSlice||e.mozSlice,r?((t=new FileReader).onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function h(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,n=this._config.chunkSize;return n?(e=t.substring(0,n),t=t.substring(n)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function d(e){l.call(this,e=e||{});var t=[],n=!0,r=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){r&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):n=!0},this._streamData=x((function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),n&&(n=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}}),this),this._streamError=x((function(e){this._streamCleanUp(),this._sendError(e)}),this),this._streamEnd=x((function(){this._streamCleanUp(),r=!0,this._streamData("")}),this),this._streamCleanUp=x((function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)}),this)}function f(e){var t,n,r,i=Math.pow(2,53),o=-i,s=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,l=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,u=this,c=0,h=0,d=!1,f=!1,g=[],_={data:[],errors:[],meta:{}};if(b(e.step)){var y=e.step;e.step=function(t){if(_=t,E())w();else{if(w(),0===_.data.length)return;c+=t.data.length,e.preview&&c>e.preview?n.abort():(_.data=_.data[0],y(_,u))}}}function x(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function w(){return _&&r&&(S("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),r=!1),e.skipEmptyLines&&(_.data=_.data.filter((function(e){return!x(e)}))),E()&&function(){if(_)if(Array.isArray(_.data[0])){for(var t=0;E()&&t<_.data.length;t++)_.data[t].forEach(n);_.data.splice(0,1)}else _.data.forEach(n);function n(t,n){b(e.transformHeader)&&(t=e.transformHeader(t,n)),g.push(t)}}(),function(){if(!_||!e.header&&!e.dynamicTyping&&!e.transform)return _;function t(t,n){var r,i=e.header?{}:[];for(r=0;r=g.length?"__parsed_extra":g[r]),e.transform&&(a=e.transform(a,o)),a=T(o,a),"__parsed_extra"===o?(i[o]=i[o]||[],i[o].push(a)):i[o]=a}return e.header&&(r>g.length?S("FieldMismatch","TooManyFields","Too many fields: expected "+g.length+" fields but parsed "+r,h+n):r=r.length/2?"\r\n":"\r"}(i,l)),r=!1,e.delimiter)b(e.delimiter)&&(e.delimiter=e.delimiter(i),_.meta.delimiter=e.delimiter);else{var u=function(t,n,r,i,o){var s,l,u,c;o=o||[",","\t","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var h=0;h=s)return Z(!0)}else for(j=c,c++;;){if(-1===(j=a.indexOf(t,j+1)))return f||w.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:x.length,index:c}),q();if(j===m-1)return q(a.substring(c,j).replace(F,t));if(t!==u||a[j+1]!==u){if(t===u||0===j||a[j-1]!==u){-1!==R&&R=s)return Z(!0);break}w.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:x.length,index:c}),j++}}else j++}return q();function V(e){x.push(e),T=c}function G(e){var t=0;if(-1!==e){var n=a.substring(j+1,e);n&&""===n.trim()&&(t=n.length)}return t}function q(e){return f||(void 0===e&&(e=a.substring(c)),E.push(e),c=m,V(E),v&&W()),Z()}function $(e){c=e,V(E),E=[],B=a.indexOf(r,c)}function Z(e){return{data:x,errors:w,meta:{delimiter:n,linebreak:r,aborted:h,truncated:!!e,cursor:T+(d||0)}}}function W(){o(Z()),x=[],w=[]}},this.abort=function(){h=!0},this.getCharIndex=function(){return c}}function g(e){var t=e.data,n=i[t.workerId],r=!1;if(t.error)n.userError(t.error,t.file);else if(t.results&&t.results.data){var o={abort:function(){r=!0,_(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:y,resume:y};if(b(n.userStep)){for(var a=0;ar[0]&&(r=s),s[1]i[1]&&(i=s)}var l=[t,n,r,i],u=l.slice();for(a=0;a=2&&f(t[t.length-2],t[t.length-1],e[n])<=0;)t.pop();t.push(e[n])}for(var r=[],i=e.length-1;i>=0;i--){for(;r.length>=2&&f(r[r.length-2],r[r.length-1],e[i])<=0;)r.pop();r.push(e[i])}return r.pop(),t.pop(),t.concat(r)}(u)}(e),a=new r(16);a.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},a.compareMinX=function(e,t){return e[0]-t[0]},a.compareMinY=function(e,t){return e[1]-t[1]},a.load(e);for(var s,u=[],c=0;ca||l.push({node:p,dist:m})}for(;l.length&&!l.peek().node.children;){var g=l.pop(),y=g.node,v=_(y,t,n),x=_(y,r,o);if(g.dist=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function d(e,t,n){for(var r,i,o,a,s=Math.min(e[0],t[0]),l=Math.min(e[1],t[1]),u=Math.max(e[0],t[0]),c=Math.max(e[1],t[1]),h=n.search({minX:s,minY:l,maxX:u,maxY:c}),d=0;d0!=f(r,i,a)>0&&f(o,a,r)>0!=f(o,a,i)>0)return!1;return!0}function f(e,t,n){return a(e[0],e[1],t[0],t[1],n[0],n[1])}function p(e){var t=e.p,n=e.next.p;return e.minX=Math.min(t[0],n[0]),e.minY=Math.min(t[1],n[1]),e.maxX=Math.max(t[0],n[0]),e.maxY=Math.max(t[1],n[1]),e}function m(e,t){var n={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(n.next=t.next,n.prev=t,t.next.prev=n,t.next=n):(n.prev=n,n.next=n),n}function g(e,t){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function _(e,t,n){var r=t[0],i=t[1],o=n[0]-r,a=n[1]-i;if(0!==o||0!==a){var s=((e[0]-r)*o+(e[1]-i)*a)/(o*o+a*a);s>1?(r=n[0],i=n[1]):s>0&&(r+=o*s,i+=a*s)}return(o=e[0]-r)*o+(a=e[1]-i)*a}function y(e,t,n,r,i,o,a,s){var l,u,c,h,d=n-e,f=r-t,p=a-i,m=s-o,g=e-i,_=t-o,y=d*d+f*f,v=d*p+f*m,x=p*p+m*m,b=d*g+f*_,w=p*g+m*_,E=y*x-v*v,T=E,S=E;0===E?(u=0,T=1,h=w,S=x):(h=y*w-v*b,(u=v*w-x*b)<0?(u=0,h=w,S=x):u>T&&(u=T,h=w+v,S=x)),h<0?(h=0,-b<0?u=0:-b>y?u=T:(u=-b,T=y)):h>S&&(h=S,-b+v<0?u=0:-b+v>y?u=T:(u=-b+v,T=y));var A=(1-(c=0===h?0:h/S))*i+c*a-((1-(l=0===u?0:u/T))*e+l*n),k=(1-c)*o+c*s-((1-l)*t+l*r);return A*A+k*k}function v(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}i.default&&(i=i.default),e.exports=s,e.exports.default=s},function(e,t,n){"use strict";function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}n.d(t,"a",(function(){return r}))},function(e,t,n){const r=n(97),i=n(100),o=["keyword","gray","hex"],a={};for(const e of Object.keys(i))a[[...i[e].labels].sort().join("")]=e;const s={};function l(e,t){if(!(this instanceof l))return new l(e,t);if(t&&t in o&&(t=null),t&&!(t in i))throw new Error("Unknown model: "+t);let n,u;if(null==e)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof l)this.model=e.model,this.color=[...e.color],this.valpha=e.valpha;else if("string"==typeof e){const t=r.get(e);if(null===t)throw new Error("Unable to parse color from string: "+e);this.model=t.model,u=i[this.model].channels,this.color=t.value.slice(0,u),this.valpha="number"==typeof t.value[u]?t.value[u]:1}else if(e.length>0){this.model=t||"rgb",u=i[this.model].channels;const n=Array.prototype.slice.call(e,0,u);this.color=d(n,u),this.valpha="number"==typeof e[u]?e[u]:1}else if("number"==typeof e)this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;const t=Object.keys(e);"alpha"in e&&(t.splice(t.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);const r=t.sort().join("");if(!(r in a))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=a[r];const{labels:o}=i[this.model],s=[];for(n=0;n(e%360+360)%360),saturationl:c("hsl",1,h(100)),lightness:c("hsl",2,h(100)),saturationv:c("hsv",1,h(100)),value:c("hsv",2,h(100)),chroma:c("hcg",1,h(100)),gray:c("hcg",2,h(100)),white:c("hwb",1,h(100)),wblack:c("hwb",2,h(100)),cyan:c("cmyk",0,h(100)),magenta:c("cmyk",1,h(100)),yellow:c("cmyk",2,h(100)),black:c("cmyk",3,h(100)),x:c("xyz",0,h(95.047)),y:c("xyz",1,h(100)),z:c("xyz",2,h(108.833)),l:c("lab",0,h(100)),a:c("lab",1),b:c("lab",2),keyword(e){return void 0!==e?new l(e):i[this.model].keyword(this.color)},hex(e){return void 0!==e?new l(e):r.to.hex(this.rgb().round().color)},hexa(e){if(void 0!==e)return new l(e);const t=this.rgb().round().color;let n=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===n.length&&(n="0"+n),r.to.hex(t)+n},rgbNumber(){const e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity(){const e=this.rgb().color,t=[];for(const[n,r]of e.entries()){const e=r/255;t[n]=e<=.04045?e/12.92:((e+.055)/1.055)**2.4}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),n=e.luminosity();return t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(2126*e[0]+7152*e[1]+722*e[2])/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return l.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let n=t.color[0];return n=(n+e)%360,n=n<0?360+n:n,t.color[0]=n,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const n=e.rgb(),r=this.rgb(),i=void 0===t?.5:t,o=2*i-1,a=n.alpha()-r.alpha(),s=((o*a==-1?o:(o+a)/(1+o*a))+1)/2,u=1-s;return l.rgb(s*n.red()+u*r.red(),s*n.green()+u*r.green(),s*n.blue()+u*r.blue(),n.alpha()*i+r.alpha()*(1-i))}};for(const e of Object.keys(i)){if(o.includes(e))continue;const{channels:t}=i[e];l.prototype[e]=function(...t){return this.model===e?new l(this):t.length>0?new l(t,e):new l([...(n=i[this.model][e].raw(this.color),Array.isArray(n)?n:[n]),this.valpha],e);var n},l[e]=function(...n){let r=n[0];return"number"==typeof r&&(r=d(n,t)),new l(r,e)}}function u(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}function c(e,t,n){e=Array.isArray(e)?e:[e];for(const r of e)(s[r]||(s[r]=[]))[t]=n;return e=e[0],function(r){let i;return void 0!==r?(n&&(r=n(r)),i=this[e](),i.color[t]=r,i):(i=this[e]().color[t],n&&(i=n(i)),i)}}function h(e){return function(t){return Math.max(0,Math.min(e,t))}}function d(e,t){for(let n=0;n @@ -18,7 +18,7 @@ License: MIT * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */(function(){var o="Expected a function",a="__lodash_placeholder__",s=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],l="[object Arguments]",u="[object Array]",c="[object Boolean]",h="[object Date]",d="[object Error]",f="[object Function]",p="[object GeneratorFunction]",m="[object Map]",_="[object Number]",g="[object Object]",y="[object RegExp]",v="[object Set]",x="[object String]",b="[object Symbol]",w="[object WeakMap]",E="[object ArrayBuffer]",T="[object DataView]",S="[object Float32Array]",k="[object Float64Array]",M="[object Int8Array]",C="[object Int16Array]",A="[object Int32Array]",I="[object Uint8Array]",P="[object Uint16Array]",O="[object Uint32Array]",z=/\b__p \+= '';/g,L=/\b(__p \+=) '' \+/g,D=/(__e\(.*?\)|\b__t\)) \+\n'';/g,R=/&(?:amp|lt|gt|quot|#39);/g,B=/[&<>"']/g,F=RegExp(R.source),j=RegExp(B.source),N=/<%-([\s\S]+?)%>/g,U=/<%([\s\S]+?)%>/g,V=/<%=([\s\S]+?)%>/g,G=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,q=/^\w*$/,$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Z=/[\\^$.*+?()[\]{}|]/g,W=RegExp(Z.source),X=/^\s+/,H=/\s/,Y=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,K=/\{\n\/\* \[wrapped with (.+)\] \*/,J=/,? & /,Q=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ee=/[()=,{}\[\]\/\s]/,te=/\\(\\)?/g,ne=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,re=/\w*$/,ie=/^[-+]0x[0-9a-f]+$/i,oe=/^0b[01]+$/i,ae=/^\[object .+?Constructor\]$/,se=/^0o[0-7]+$/i,le=/^(?:0|[1-9]\d*)$/,ue=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ce=/($^)/,he=/['\n\r\u2028\u2029\\]/g,de="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",fe="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",pe="[\\ud800-\\udfff]",me="["+fe+"]",_e="["+de+"]",ge="\\d+",ye="[\\u2700-\\u27bf]",ve="[a-z\\xdf-\\xf6\\xf8-\\xff]",xe="[^\\ud800-\\udfff"+fe+ge+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",be="\\ud83c[\\udffb-\\udfff]",we="[^\\ud800-\\udfff]",Ee="(?:\\ud83c[\\udde6-\\uddff]){2}",Te="[\\ud800-\\udbff][\\udc00-\\udfff]",Se="[A-Z\\xc0-\\xd6\\xd8-\\xde]",ke="(?:"+ve+"|"+xe+")",Me="(?:"+Se+"|"+xe+")",Ce="(?:"+_e+"|"+be+")"+"?",Ae="[\\ufe0e\\ufe0f]?"+Ce+("(?:\\u200d(?:"+[we,Ee,Te].join("|")+")[\\ufe0e\\ufe0f]?"+Ce+")*"),Ie="(?:"+[ye,Ee,Te].join("|")+")"+Ae,Pe="(?:"+[we+_e+"?",_e,Ee,Te,pe].join("|")+")",Oe=RegExp("['’]","g"),ze=RegExp(_e,"g"),Le=RegExp(be+"(?="+be+")|"+Pe+Ae,"g"),De=RegExp([Se+"?"+ve+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[me,Se,"$"].join("|")+")",Me+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[me,Se+ke,"$"].join("|")+")",Se+"?"+ke+"+(?:['’](?:d|ll|m|re|s|t|ve))?",Se+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ge,Ie].join("|"),"g"),Re=RegExp("[\\u200d\\ud800-\\udfff"+de+"\\ufe0e\\ufe0f]"),Be=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Fe=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],je=-1,Ne={};Ne[S]=Ne[k]=Ne[M]=Ne[C]=Ne[A]=Ne[I]=Ne["[object Uint8ClampedArray]"]=Ne[P]=Ne[O]=!0,Ne[l]=Ne[u]=Ne[E]=Ne[c]=Ne[T]=Ne[h]=Ne[d]=Ne[f]=Ne[m]=Ne[_]=Ne[g]=Ne[y]=Ne[v]=Ne[x]=Ne[w]=!1;var Ue={};Ue[l]=Ue[u]=Ue[E]=Ue[T]=Ue[c]=Ue[h]=Ue[S]=Ue[k]=Ue[M]=Ue[C]=Ue[A]=Ue[m]=Ue[_]=Ue[g]=Ue[y]=Ue[v]=Ue[x]=Ue[b]=Ue[I]=Ue["[object Uint8ClampedArray]"]=Ue[P]=Ue[O]=!0,Ue[d]=Ue[f]=Ue[w]=!1;var Ve={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ge=parseFloat,qe=parseInt,$e="object"==typeof e&&e&&e.Object===Object&&e,Ze="object"==typeof self&&self&&self.Object===Object&&self,We=$e||Ze||Function("return this")(),Xe=t&&!t.nodeType&&t,He=Xe&&"object"==typeof r&&r&&!r.nodeType&&r,Ye=He&&He.exports===Xe,Ke=Ye&&$e.process,Je=function(){try{var e=He&&He.require&&He.require("util").types;return e||Ke&&Ke.binding&&Ke.binding("util")}catch(e){}}(),Qe=Je&&Je.isArrayBuffer,et=Je&&Je.isDate,tt=Je&&Je.isMap,nt=Je&&Je.isRegExp,rt=Je&&Je.isSet,it=Je&&Je.isTypedArray;function ot(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function at(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i-1}function dt(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function Dt(e,t){for(var n=e.length;n--&&bt(t,e[n],0)>-1;);return n}function Rt(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Bt=kt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Ft=kt({"&":"&","<":"<",">":">",'"':""","'":"'"});function jt(e){return"\\"+Ve[e]}function Nt(e){return Re.test(e)}function Ut(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function Vt(e,t){return function(n){return e(t(n))}}function Gt(e,t){for(var n=-1,r=e.length,i=0,o=[];++n",""":'"',"'":"'"});var Yt=function e(t){var n,r=(t=null==t?We:Yt.defaults(We.Object(),t,Yt.pick(We,Fe))).Array,i=t.Date,H=t.Error,de=t.Function,fe=t.Math,pe=t.Object,me=t.RegExp,_e=t.String,ge=t.TypeError,ye=r.prototype,ve=de.prototype,xe=pe.prototype,be=t["__core-js_shared__"],we=ve.toString,Ee=xe.hasOwnProperty,Te=0,Se=(n=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",ke=xe.toString,Me=we.call(pe),Ce=We._,Ae=me("^"+we.call(Ee).replace(Z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ie=Ye?t.Buffer:void 0,Pe=t.Symbol,Le=t.Uint8Array,Re=Ie?Ie.allocUnsafe:void 0,Ve=Vt(pe.getPrototypeOf,pe),$e=pe.create,Ze=xe.propertyIsEnumerable,Xe=ye.splice,He=Pe?Pe.isConcatSpreadable:void 0,Ke=Pe?Pe.iterator:void 0,Je=Pe?Pe.toStringTag:void 0,yt=function(){try{var e=eo(pe,"defineProperty");return e({},"",{}),e}catch(e){}}(),kt=t.clearTimeout!==We.clearTimeout&&t.clearTimeout,Kt=i&&i.now!==We.Date.now&&i.now,Jt=t.setTimeout!==We.setTimeout&&t.setTimeout,Qt=fe.ceil,en=fe.floor,tn=pe.getOwnPropertySymbols,nn=Ie?Ie.isBuffer:void 0,rn=t.isFinite,on=ye.join,an=Vt(pe.keys,pe),sn=fe.max,ln=fe.min,un=i.now,cn=t.parseInt,hn=fe.random,dn=ye.reverse,fn=eo(t,"DataView"),pn=eo(t,"Map"),mn=eo(t,"Promise"),_n=eo(t,"Set"),gn=eo(t,"WeakMap"),yn=eo(pe,"create"),vn=gn&&new gn,xn={},bn=Co(fn),wn=Co(pn),En=Co(mn),Tn=Co(_n),Sn=Co(gn),kn=Pe?Pe.prototype:void 0,Mn=kn?kn.valueOf:void 0,Cn=kn?kn.toString:void 0;function An(e){if($a(e)&&!La(e)&&!(e instanceof zn)){if(e instanceof On)return e;if(Ee.call(e,"__wrapped__"))return Ao(e)}return new On(e)}var In=function(){function e(){}return function(t){if(!qa(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Pn(){}function On(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function zn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Ln(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Kn(e,t,n,r,i,o){var a,s=1&t,u=2&t,d=4&t;if(n&&(a=i?n(e,r,i,o):n(e)),void 0!==a)return a;if(!qa(e))return e;var w=La(e);if(w){if(a=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&Ee.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!s)return yi(e,a)}else{var z=ro(e),L=z==f||z==p;if(Fa(e))return di(e,s);if(z==g||z==l||L&&!i){if(a=u||L?{}:oo(e),!s)return u?function(e,t){return vi(e,no(e),t)}(e,function(e,t){return e&&vi(t,ws(t),e)}(a,e)):function(e,t){return vi(e,to(e),t)}(e,Wn(a,e))}else{if(!Ue[z])return i?e:{};a=function(e,t,n){var r=e.constructor;switch(t){case E:return fi(e);case c:case h:return new r(+e);case T:return function(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case S:case k:case M:case C:case A:case I:case"[object Uint8ClampedArray]":case P:case O:return pi(e,n);case m:return new r;case _:case x:return new r(e);case y:return function(e){var t=new e.constructor(e.source,re.exec(e));return t.lastIndex=e.lastIndex,t}(e);case v:return new r;case b:return i=e,Mn?pe(Mn.call(i)):{}}var i}(e,z,s)}}o||(o=new Fn);var D=o.get(e);if(D)return D;o.set(e,a),Ya(e)?e.forEach((function(r){a.add(Kn(r,t,n,r,e,o))})):Za(e)&&e.forEach((function(r,i){a.set(i,Kn(r,t,n,i,e,o))}));var R=w?void 0:(d?u?Wi:Zi:u?ws:bs)(e);return st(R||e,(function(r,i){R&&(r=e[i=r]),qn(a,i,Kn(r,t,n,i,e,o))})),a}function Jn(e,t,n){var r=n.length;if(null==e)return!r;for(e=pe(e);r--;){var i=n[r],o=t[i],a=e[i];if(void 0===a&&!(i in e)||!o(a))return!1}return!0}function Qn(e,t,n){if("function"!=typeof e)throw new ge(o);return bo((function(){e.apply(void 0,n)}),t)}function er(e,t,n,r){var i=-1,o=ht,a=!0,s=e.length,l=[],u=t.length;if(!s)return l;n&&(t=ft(t,Pt(n))),r?(o=dt,a=!1):t.length>=200&&(o=zt,a=!1,t=new Bn(t));e:for(;++i-1},Dn.prototype.set=function(e,t){var n=this.__data__,r=$n(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Rn.prototype.clear=function(){this.size=0,this.__data__={hash:new Ln,map:new(pn||Dn),string:new Ln}},Rn.prototype.delete=function(e){var t=Ji(this,e).delete(e);return this.size-=t?1:0,t},Rn.prototype.get=function(e){return Ji(this,e).get(e)},Rn.prototype.has=function(e){return Ji(this,e).has(e)},Rn.prototype.set=function(e,t){var n=Ji(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Bn.prototype.add=Bn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Bn.prototype.has=function(e){return this.__data__.has(e)},Fn.prototype.clear=function(){this.__data__=new Dn,this.size=0},Fn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Fn.prototype.get=function(e){return this.__data__.get(e)},Fn.prototype.has=function(e){return this.__data__.has(e)},Fn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Dn){var r=n.__data__;if(!pn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Rn(r)}return n.set(e,t),this.size=n.size,this};var tr=wi(ur),nr=wi(cr,!0);function rr(e,t){var n=!0;return tr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function ir(e,t,n){for(var r=-1,i=e.length;++r0&&n(s)?t>1?ar(s,t-1,n,r,i):pt(i,s):r||(i[i.length]=s)}return i}var sr=Ei(),lr=Ei(!0);function ur(e,t){return e&&sr(e,t,bs)}function cr(e,t){return e&&lr(e,t,bs)}function hr(e,t){return ct(t,(function(t){return Ua(e[t])}))}function dr(e,t){for(var n=0,r=(t=li(t,e)).length;null!=e&&nt}function _r(e,t){return null!=e&&Ee.call(e,t)}function gr(e,t){return null!=e&&t in pe(e)}function yr(e,t,n){for(var i=n?dt:ht,o=e[0].length,a=e.length,s=a,l=r(a),u=1/0,c=[];s--;){var h=e[s];s&&t&&(h=ft(h,Pt(t))),u=ln(h.length,u),l[s]=!n&&(t||o>=120&&h.length>=120)?new Bn(s&&h):void 0}h=e[0];var d=-1,f=l[0];e:for(;++d=s)return l;var u=n[r];return l*("desc"==u?-1:1)}}return e.index-t.index}(e,t,n)}))}function Lr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)s!==e&&Xe.call(s,l,1),Xe.call(e,l,1);return e}function Rr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;so(i)?Xe.call(e,i,1):ei(e,i)}}return e}function Br(e,t){return e+en(hn()*(t-e+1))}function Fr(e,t){var n="";if(!e||t<1||t>9007199254740991)return n;do{t%2&&(n+=e),(t=en(t/2))&&(e+=e)}while(t);return n}function jr(e,t){return wo(_o(e,t,Ws),e+"")}function Nr(e){return Nn(Is(e))}function Ur(e,t){var n=Is(e);return So(n,Yn(t,0,n.length))}function Vr(e,t,n,r){if(!qa(e))return e;for(var i=-1,o=(t=li(t,e)).length,a=o-1,s=e;null!=s&&++io?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var a=r(o);++i>>1,a=e[o];null!==a&&!Ja(a)&&(n?a<=t:a=200){var u=t?null:Fi(e);if(u)return qt(u);a=!1,i=zt,l=new Bn}else l=t?[]:s;e:for(;++r=r?e:Zr(e,t,n)}var hi=kt||function(e){return We.clearTimeout(e)};function di(e,t){if(t)return e.slice();var n=e.length,r=Re?Re(n):new e.constructor(n);return e.copy(r),r}function fi(e){var t=new e.constructor(e.byteLength);return new Le(t).set(new Le(e)),t}function pi(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function mi(e,t){if(e!==t){var n=void 0!==e,r=null===e,i=e==e,o=Ja(e),a=void 0!==t,s=null===t,l=t==t,u=Ja(t);if(!s&&!u&&!o&&e>t||o&&a&&l&&!s&&!u||r&&a&&l||!n&&l||!i)return 1;if(!r&&!o&&!u&&e1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,a&&lo(n[0],n[1],a)&&(o=i<3?void 0:o,i=1),t=pe(t);++r-1?i[o?t[a]:a]:void 0}}function Ci(e){return $i((function(t){var n=t.length,r=n,i=On.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new ge(o);if(i&&!s&&"wrapper"==Hi(a))var s=new On([],!0)}for(r=s?r:n;++r1&&v.reverse(),h&&us))return!1;var u=o.get(e),c=o.get(t);if(u&&c)return u==t&&c==e;var h=-1,d=!0,f=2&n?new Bn:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(Y,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return st(s,(function(n){var r="_."+n[0];t&n[1]&&!ht(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(K);return t?t[1].split(J):[]}(r),n)))}function To(e){var t=0,n=0;return function(){var r=un(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function So(e,t){var n=-1,r=e.length,i=r-1;for(t=void 0===t?r:t;++n1?e[t-1]:void 0;return n="function"==typeof n?(e.pop(),n):void 0,Ho(e,n)}));function na(e){var t=An(e);return t.__chain__=!0,t}function ra(e,t){return t(e)}var ia=$i((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,i=function(t){return Hn(t,e)};return!(t>1||this.__actions__.length)&&r instanceof zn&&so(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ra,args:[i],thisArg:void 0}),new On(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(void 0),e}))):this.thru(i)}));var oa=xi((function(e,t,n){Ee.call(e,n)?++e[n]:Xn(e,n,1)}));var aa=Mi(zo),sa=Mi(Lo);function la(e,t){return(La(e)?st:tr)(e,Ki(t,3))}function ua(e,t){return(La(e)?lt:nr)(e,Ki(t,3))}var ca=xi((function(e,t,n){Ee.call(e,n)?e[n].push(t):Xn(e,n,[t])}));var ha=jr((function(e,t,n){var i=-1,o="function"==typeof t,a=Ra(e)?r(e.length):[];return tr(e,(function(e){a[++i]=o?ot(t,e,n):vr(e,t,n)})),a})),da=xi((function(e,t,n){Xn(e,n,t)}));function fa(e,t){return(La(e)?ft:Cr)(e,Ki(t,3))}var pa=xi((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var ma=jr((function(e,t){if(null==e)return[];var n=t.length;return n>1&&lo(e,t[0],t[1])?t=[]:n>2&&lo(t[0],t[1],t[2])&&(t=[t[0]]),zr(e,ar(t,1),[])})),_a=Kt||function(){return We.Date.now()};function ga(e,t,n){return t=n?void 0:t,Ni(e,128,void 0,void 0,void 0,void 0,t=e&&null==t?e.length:t)}function ya(e,t){var n;if("function"!=typeof t)throw new ge(o);return e=is(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=void 0),n}}var va=jr((function(e,t,n){var r=1;if(n.length){var i=Gt(n,Yi(va));r|=32}return Ni(e,r,t,n,i)})),xa=jr((function(e,t,n){var r=3;if(n.length){var i=Gt(n,Yi(xa));r|=32}return Ni(t,r,e,n,i)}));function ba(e,t,n){var r,i,a,s,l,u,c=0,h=!1,d=!1,f=!0;if("function"!=typeof e)throw new ge(o);function p(t){var n=r,o=i;return r=i=void 0,c=t,s=e.apply(o,n)}function m(e){return c=e,l=bo(g,t),h?p(e):s}function _(e){var n=e-u;return void 0===u||n>=t||n<0||d&&e-c>=a}function g(){var e=_a();if(_(e))return y(e);l=bo(g,function(e){var n=t-(e-u);return d?ln(n,a-(e-c)):n}(e))}function y(e){return l=void 0,f&&r?p(e):(r=i=void 0,s)}function v(){var e=_a(),n=_(e);if(r=arguments,i=this,u=e,n){if(void 0===l)return m(u);if(d)return hi(l),l=bo(g,t),p(u)}return void 0===l&&(l=bo(g,t)),s}return t=as(t)||0,qa(n)&&(h=!!n.leading,a=(d="maxWait"in n)?sn(as(n.maxWait)||0,t):a,f="trailing"in n?!!n.trailing:f),v.cancel=function(){void 0!==l&&hi(l),c=0,r=u=i=l=void 0},v.flush=function(){return void 0===l?s:y(_a())},v}var wa=jr((function(e,t){return Qn(e,1,t)})),Ea=jr((function(e,t,n){return Qn(e,as(t)||0,n)}));function Ta(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new ge(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Ta.Cache||Rn),n}function Sa(e){if("function"!=typeof e)throw new ge(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Ta.Cache=Rn;var ka=ui((function(e,t){var n=(t=1==t.length&&La(t[0])?ft(t[0],Pt(Ki())):ft(ar(t,1),Pt(Ki()))).length;return jr((function(r){for(var i=-1,o=ln(r.length,n);++i=t})),za=xr(function(){return arguments}())?xr:function(e){return $a(e)&&Ee.call(e,"callee")&&!Ze.call(e,"callee")},La=r.isArray,Da=Qe?Pt(Qe):function(e){return $a(e)&&pr(e)==E};function Ra(e){return null!=e&&Ga(e.length)&&!Ua(e)}function Ba(e){return $a(e)&&Ra(e)}var Fa=nn||al,ja=et?Pt(et):function(e){return $a(e)&&pr(e)==h};function Na(e){if(!$a(e))return!1;var t=pr(e);return t==d||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Xa(e)}function Ua(e){if(!qa(e))return!1;var t=pr(e);return t==f||t==p||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Va(e){return"number"==typeof e&&e==is(e)}function Ga(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function qa(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $a(e){return null!=e&&"object"==typeof e}var Za=tt?Pt(tt):function(e){return $a(e)&&ro(e)==m};function Wa(e){return"number"==typeof e||$a(e)&&pr(e)==_}function Xa(e){if(!$a(e)||pr(e)!=g)return!1;var t=Ve(e);if(null===t)return!0;var n=Ee.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&we.call(n)==Me}var Ha=nt?Pt(nt):function(e){return $a(e)&&pr(e)==y};var Ya=rt?Pt(rt):function(e){return $a(e)&&ro(e)==v};function Ka(e){return"string"==typeof e||!La(e)&&$a(e)&&pr(e)==x}function Ja(e){return"symbol"==typeof e||$a(e)&&pr(e)==b}var Qa=it?Pt(it):function(e){return $a(e)&&Ga(e.length)&&!!Ne[pr(e)]};var es=Di(Mr),ts=Di((function(e,t){return e<=t}));function ns(e){if(!e)return[];if(Ra(e))return Ka(e)?Wt(e):yi(e);if(Ke&&e[Ke])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Ke]());var t=ro(e);return(t==m?Ut:t==v?qt:Is)(e)}function rs(e){return e?(e=as(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function is(e){var t=rs(e),n=t%1;return t==t?n?t-n:t:0}function os(e){return e?Yn(is(e),0,4294967295):0}function as(e){if("number"==typeof e)return e;if(Ja(e))return NaN;if(qa(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=qa(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=It(e);var n=oe.test(e);return n||se.test(e)?qe(e.slice(2),n?2:8):ie.test(e)?NaN:+e}function ss(e){return vi(e,ws(e))}function ls(e){return null==e?"":Jr(e)}var us=bi((function(e,t){if(fo(t)||Ra(t))vi(t,bs(t),e);else for(var n in t)Ee.call(t,n)&&qn(e,n,t[n])})),cs=bi((function(e,t){vi(t,ws(t),e)})),hs=bi((function(e,t,n,r){vi(t,ws(t),e,r)})),ds=bi((function(e,t,n,r){vi(t,bs(t),e,r)})),fs=$i(Hn);var ps=jr((function(e,t){e=pe(e);var n=-1,r=t.length,i=r>2?t[2]:void 0;for(i&&lo(t[0],t[1],i)&&(r=1);++n1),t})),vi(e,Wi(e),n),r&&(n=Kn(n,7,Gi));for(var i=t.length;i--;)ei(n,t[i]);return n}));var ks=$i((function(e,t){return null==e?{}:function(e,t){return Lr(e,t,(function(t,n){return gs(e,n)}))}(e,t)}));function Ms(e,t){if(null==e)return{};var n=ft(Wi(e),(function(e){return[e]}));return t=Ki(t),Lr(e,n,(function(e,n){return t(e,n[0])}))}var Cs=ji(bs),As=ji(ws);function Is(e){return null==e?[]:Ot(e,bs(e))}var Ps=Si((function(e,t,n){return t=t.toLowerCase(),e+(n?Os(t):t)}));function Os(e){return Ns(ls(e).toLowerCase())}function zs(e){return(e=ls(e))&&e.replace(ue,Bt).replace(ze,"")}var Ls=Si((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ds=Si((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Rs=Ti("toLowerCase");var Bs=Si((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Fs=Si((function(e,t,n){return e+(n?" ":"")+Ns(t)}));var js=Si((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Ns=Ti("toUpperCase");function Us(e,t,n){return e=ls(e),void 0===(t=n?void 0:t)?function(e){return Be.test(e)}(e)?function(e){return e.match(De)||[]}(e):function(e){return e.match(Q)||[]}(e):e.match(t)||[]}var Vs=jr((function(e,t){try{return ot(e,void 0,t)}catch(e){return Na(e)?e:new H(e)}})),Gs=$i((function(e,t){return st(t,(function(t){t=Mo(t),Xn(e,t,va(e[t],e))})),e}));function qs(e){return function(){return e}}var $s=Ci(),Zs=Ci(!0);function Ws(e){return e}function Xs(e){return Tr("function"==typeof e?e:Kn(e,1))}var Hs=jr((function(e,t){return function(n){return vr(n,e,t)}})),Ys=jr((function(e,t){return function(n){return vr(e,n,t)}}));function Ks(e,t,n){var r=bs(t),i=hr(t,r);null!=n||qa(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=hr(t,bs(t)));var o=!(qa(n)&&"chain"in n&&!n.chain),a=Ua(e);return st(i,(function(n){var r=t[n];e[n]=r,a&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__),i=n.__actions__=yi(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,pt([this.value()],arguments))})})),e}function Js(){}var Qs=Oi(ft),el=Oi(ut),tl=Oi(gt);function nl(e){return uo(e)?St(Mo(e)):function(e){return function(t){return dr(t,e)}}(e)}var rl=Li(),il=Li(!0);function ol(){return[]}function al(){return!1}var sl=Pi((function(e,t){return e+t}),0),ll=Bi("ceil"),ul=Pi((function(e,t){return e/t}),1),cl=Bi("floor");var hl,dl=Pi((function(e,t){return e*t}),1),fl=Bi("round"),pl=Pi((function(e,t){return e-t}),0);return An.after=function(e,t){if("function"!=typeof t)throw new ge(o);return e=is(e),function(){if(--e<1)return t.apply(this,arguments)}},An.ary=ga,An.assign=us,An.assignIn=cs,An.assignInWith=hs,An.assignWith=ds,An.at=fs,An.before=ya,An.bind=va,An.bindAll=Gs,An.bindKey=xa,An.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return La(e)?e:[e]},An.chain=na,An.chunk=function(e,t,n){t=(n?lo(e,t,n):void 0===t)?1:sn(is(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var o=0,a=0,s=r(Qt(i/t));oi?0:i+n),(r=void 0===r||r>i?i:is(r))<0&&(r+=i),r=n>r?0:os(r);n>>0)?(e=ls(e))&&("string"==typeof t||null!=t&&!Ha(t))&&!(t=Jr(t))&&Nt(e)?ci(Wt(e),0,n):e.split(t,n):[]},An.spread=function(e,t){if("function"!=typeof e)throw new ge(o);return t=null==t?0:sn(is(t),0),jr((function(n){var r=n[t],i=ci(n,0,t);return r&&pt(i,r),ot(e,this,i)}))},An.tail=function(e){var t=null==e?0:e.length;return t?Zr(e,1,t):[]},An.take=function(e,t,n){return e&&e.length?Zr(e,0,(t=n||void 0===t?1:is(t))<0?0:t):[]},An.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?Zr(e,(t=r-(t=n||void 0===t?1:is(t)))<0?0:t,r):[]},An.takeRightWhile=function(e,t){return e&&e.length?ni(e,Ki(t,3),!1,!0):[]},An.takeWhile=function(e,t){return e&&e.length?ni(e,Ki(t,3)):[]},An.tap=function(e,t){return t(e),e},An.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new ge(o);return qa(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),ba(e,t,{leading:r,maxWait:t,trailing:i})},An.thru=ra,An.toArray=ns,An.toPairs=Cs,An.toPairsIn=As,An.toPath=function(e){return La(e)?ft(e,Mo):Ja(e)?[e]:yi(ko(ls(e)))},An.toPlainObject=ss,An.transform=function(e,t,n){var r=La(e),i=r||Fa(e)||Qa(e);if(t=Ki(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:qa(e)&&Ua(o)?In(Ve(e)):{}}return(i?st:ur)(e,(function(e,r,i){return t(n,e,r,i)})),n},An.unary=function(e){return ga(e,1)},An.union=$o,An.unionBy=Zo,An.unionWith=Wo,An.uniq=function(e){return e&&e.length?Qr(e):[]},An.uniqBy=function(e,t){return e&&e.length?Qr(e,Ki(t,2)):[]},An.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?Qr(e,void 0,t):[]},An.unset=function(e,t){return null==e||ei(e,t)},An.unzip=Xo,An.unzipWith=Ho,An.update=function(e,t,n){return null==e?e:ti(e,t,si(n))},An.updateWith=function(e,t,n,r){return r="function"==typeof r?r:void 0,null==e?e:ti(e,t,si(n),r)},An.values=Is,An.valuesIn=function(e){return null==e?[]:Ot(e,ws(e))},An.without=Yo,An.words=Us,An.wrap=function(e,t){return Ma(si(t),e)},An.xor=Ko,An.xorBy=Jo,An.xorWith=Qo,An.zip=ea,An.zipObject=function(e,t){return oi(e||[],t||[],qn)},An.zipObjectDeep=function(e,t){return oi(e||[],t||[],Vr)},An.zipWith=ta,An.entries=Cs,An.entriesIn=As,An.extend=cs,An.extendWith=hs,Ks(An,An),An.add=sl,An.attempt=Vs,An.camelCase=Ps,An.capitalize=Os,An.ceil=ll,An.clamp=function(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=(n=as(n))==n?n:0),void 0!==t&&(t=(t=as(t))==t?t:0),Yn(as(e),t,n)},An.clone=function(e){return Kn(e,4)},An.cloneDeep=function(e){return Kn(e,5)},An.cloneDeepWith=function(e,t){return Kn(e,5,t="function"==typeof t?t:void 0)},An.cloneWith=function(e,t){return Kn(e,4,t="function"==typeof t?t:void 0)},An.conformsTo=function(e,t){return null==t||Jn(e,t,bs(t))},An.deburr=zs,An.defaultTo=function(e,t){return null==e||e!=e?t:e},An.divide=ul,An.endsWith=function(e,t,n){e=ls(e),t=Jr(t);var r=e.length,i=n=void 0===n?r:Yn(is(n),0,r);return(n-=t.length)>=0&&e.slice(n,i)==t},An.eq=Ia,An.escape=function(e){return(e=ls(e))&&j.test(e)?e.replace(B,Ft):e},An.escapeRegExp=function(e){return(e=ls(e))&&W.test(e)?e.replace(Z,"\\$&"):e},An.every=function(e,t,n){var r=La(e)?ut:rr;return n&&lo(e,t,n)&&(t=void 0),r(e,Ki(t,3))},An.find=aa,An.findIndex=zo,An.findKey=function(e,t){return vt(e,Ki(t,3),ur)},An.findLast=sa,An.findLastIndex=Lo,An.findLastKey=function(e,t){return vt(e,Ki(t,3),cr)},An.floor=cl,An.forEach=la,An.forEachRight=ua,An.forIn=function(e,t){return null==e?e:sr(e,Ki(t,3),ws)},An.forInRight=function(e,t){return null==e?e:lr(e,Ki(t,3),ws)},An.forOwn=function(e,t){return e&&ur(e,Ki(t,3))},An.forOwnRight=function(e,t){return e&&cr(e,Ki(t,3))},An.get=_s,An.gt=Pa,An.gte=Oa,An.has=function(e,t){return null!=e&&io(e,t,_r)},An.hasIn=gs,An.head=Ro,An.identity=Ws,An.includes=function(e,t,n,r){e=Ra(e)?e:Is(e),n=n&&!r?is(n):0;var i=e.length;return n<0&&(n=sn(i+n,0)),Ka(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&bt(e,t,n)>-1},An.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:is(n);return i<0&&(i=sn(r+i,0)),bt(e,t,i)},An.inRange=function(e,t,n){return t=rs(t),void 0===n?(n=t,t=0):n=rs(n),function(e,t,n){return e>=ln(t,n)&&e=-9007199254740991&&e<=9007199254740991},An.isSet=Ya,An.isString=Ka,An.isSymbol=Ja,An.isTypedArray=Qa,An.isUndefined=function(e){return void 0===e},An.isWeakMap=function(e){return $a(e)&&ro(e)==w},An.isWeakSet=function(e){return $a(e)&&"[object WeakSet]"==pr(e)},An.join=function(e,t){return null==e?"":on.call(e,t)},An.kebabCase=Ls,An.last=No,An.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=r;return void 0!==n&&(i=(i=is(n))<0?sn(r+i,0):ln(i,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,i):xt(e,Et,i,!0)},An.lowerCase=Ds,An.lowerFirst=Rs,An.lt=es,An.lte=ts,An.max=function(e){return e&&e.length?ir(e,Ws,mr):void 0},An.maxBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),mr):void 0},An.mean=function(e){return Tt(e,Ws)},An.meanBy=function(e,t){return Tt(e,Ki(t,2))},An.min=function(e){return e&&e.length?ir(e,Ws,Mr):void 0},An.minBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),Mr):void 0},An.stubArray=ol,An.stubFalse=al,An.stubObject=function(){return{}},An.stubString=function(){return""},An.stubTrue=function(){return!0},An.multiply=dl,An.nth=function(e,t){return e&&e.length?Or(e,is(t)):void 0},An.noConflict=function(){return We._===this&&(We._=Ce),this},An.noop=Js,An.now=_a,An.pad=function(e,t,n){e=ls(e);var r=(t=is(t))?Zt(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return zi(en(i),n)+e+zi(Qt(i),n)},An.padEnd=function(e,t,n){e=ls(e);var r=(t=is(t))?Zt(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var i=hn();return ln(e+i*(t-e+Ge("1e-"+((i+"").length-1))),t)}return Br(e,t)},An.reduce=function(e,t,n){var r=La(e)?mt:Mt,i=arguments.length<3;return r(e,Ki(t,4),n,i,tr)},An.reduceRight=function(e,t,n){var r=La(e)?_t:Mt,i=arguments.length<3;return r(e,Ki(t,4),n,i,nr)},An.repeat=function(e,t,n){return t=(n?lo(e,t,n):void 0===t)?1:is(t),Fr(ls(e),t)},An.replace=function(){var e=arguments,t=ls(e[0]);return e.length<3?t:t.replace(e[1],e[2])},An.result=function(e,t,n){var r=-1,i=(t=li(t,e)).length;for(i||(i=1,e=void 0);++r9007199254740991)return[];var n=4294967295,r=ln(e,4294967295);e-=4294967295;for(var i=At(r,t=Ki(t));++n=o)return e;var s=n-Zt(r);if(s<1)return r;var l=a?ci(a,0,s).join(""):e.slice(0,s);if(void 0===i)return l+r;if(a&&(s+=l.length-s),Ha(i)){if(e.slice(s).search(i)){var u,c=l;for(i.global||(i=me(i.source,ls(re.exec(i))+"g")),i.lastIndex=0;u=i.exec(c);)var h=u.index;l=l.slice(0,void 0===h?s:h)}}else if(e.indexOf(Jr(i),s)!=s){var d=l.lastIndexOf(i);d>-1&&(l=l.slice(0,d))}return l+r},An.unescape=function(e){return(e=ls(e))&&F.test(e)?e.replace(R,Ht):e},An.uniqueId=function(e){var t=++Te;return ls(e)+t},An.upperCase=js,An.upperFirst=Ns,An.each=la,An.eachRight=ua,An.first=Ro,Ks(An,(hl={},ur(An,(function(e,t){Ee.call(An.prototype,t)||(hl[t]=e)})),hl),{chain:!1}),An.VERSION="4.17.21",st(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){An[e].placeholder=An})),st(["drop","take"],(function(e,t){zn.prototype[e]=function(n){n=void 0===n?1:sn(is(n),0);var r=this.__filtered__&&!t?new zn(this):this.clone();return r.__filtered__?r.__takeCount__=ln(n,r.__takeCount__):r.__views__.push({size:ln(n,4294967295),type:e+(r.__dir__<0?"Right":"")}),r},zn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),st(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;zn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Ki(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),st(["head","last"],(function(e,t){var n="take"+(t?"Right":"");zn.prototype[e]=function(){return this[n](1).value()[0]}})),st(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");zn.prototype[e]=function(){return this.__filtered__?new zn(this):this[n](1)}})),zn.prototype.compact=function(){return this.filter(Ws)},zn.prototype.find=function(e){return this.filter(e).head()},zn.prototype.findLast=function(e){return this.reverse().find(e)},zn.prototype.invokeMap=jr((function(e,t){return"function"==typeof e?new zn(this):this.map((function(n){return vr(n,e,t)}))})),zn.prototype.reject=function(e){return this.filter(Sa(Ki(e)))},zn.prototype.slice=function(e,t){e=is(e);var n=this;return n.__filtered__&&(e>0||t<0)?new zn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),void 0!==t&&(n=(t=is(t))<0?n.dropRight(-t):n.take(t-e)),n)},zn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},zn.prototype.toArray=function(){return this.take(4294967295)},ur(zn.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),i=An[r?"take"+("last"==t?"Right":""):t],o=r||/^find/.test(t);i&&(An.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,s=t instanceof zn,l=a[0],u=s||La(t),c=function(e){var t=i.apply(An,pt([e],a));return r&&h?t[0]:t};u&&n&&"function"==typeof l&&1!=l.length&&(s=u=!1);var h=this.__chain__,d=!!this.__actions__.length,f=o&&!h,p=s&&!d;if(!o&&u){t=p?t:new zn(this);var m=e.apply(t,a);return m.__actions__.push({func:ra,args:[c],thisArg:void 0}),new On(m,h)}return f&&p?e.apply(this,a):(m=this.thru(c),f?r?m.value()[0]:m.value():m)})})),st(["pop","push","shift","sort","splice","unshift"],(function(e){var t=ye[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);An.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(La(i)?i:[],e)}return this[n]((function(n){return t.apply(La(n)?n:[],e)}))}})),ur(zn.prototype,(function(e,t){var n=An[t];if(n){var r=n.name+"";Ee.call(xn,r)||(xn[r]=[]),xn[r].push({name:t,func:n})}})),xn[Ai(void 0,2).name]=[{name:"wrapper",func:void 0}],zn.prototype.clone=function(){var e=new zn(this.__wrapped__);return e.__actions__=yi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=yi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=yi(this.__views__),e},zn.prototype.reverse=function(){if(this.__filtered__){var e=new zn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},zn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=La(e),r=t<0,i=n?e.length:0,o=function(e,t,n){var r=-1,i=n.length;for(;++r=this.__values__.length;return{done:e,value:e?void 0:this.__values__[this.__index__++]}},An.prototype.plant=function(e){for(var t,n=this;n instanceof Pn;){var r=Ao(n);r.__index__=0,r.__values__=void 0,t?i.__wrapped__=r:t=r;var i=r;n=n.__wrapped__}return i.__wrapped__=e,t},An.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof zn){var t=e;return this.__actions__.length&&(t=new zn(this)),(t=t.reverse()).__actions__.push({func:ra,args:[qo],thisArg:void 0}),new On(t,this.__chain__)}return this.thru(qo)},An.prototype.toJSON=An.prototype.valueOf=An.prototype.value=function(){return ri(this.__wrapped__,this.__actions__)},An.prototype.first=An.prototype.head,Ke&&(An.prototype[Ke]=function(){return this}),An}();We._=Yt,void 0===(i=function(){return Yt}.call(t,n,t,r))||(r.exports=i)}).call(this)}).call(this,n(21),n(92)(e))},function(e,t,n){"use strict";var r=n(0),i=n.n(r),o=n(13),a=n.n(o);function s(){return(s=Object.assign||function(e){for(var t=1;t=d.top+d.height||p.left+p.width>=d.left+d.width))break;u++}return l},f=0,p=Object(r.forwardRef)((function(e,t){var n=e.trigger,o=void 0===n?null:n,c=e.onOpen,h=void 0===c?function(){}:c,p=e.onClose,m=void 0===p?function(){}:p,_=e.defaultOpen,g=void 0!==_&&_,y=e.open,v=void 0===y?void 0:y,x=e.disabled,b=void 0!==x&&x,w=e.nested,E=void 0!==w&&w,T=e.closeOnDocumentClick,S=void 0===T||T,k=e.repositionOnResize,M=void 0===k||k,C=e.closeOnEscape,A=void 0===C||C,I=e.on,P=void 0===I?["click"]:I,O=e.contentStyle,z=void 0===O?{}:O,L=e.arrowStyle,D=void 0===L?{}:L,R=e.overlayStyle,B=void 0===R?{}:R,F=e.className,j=void 0===F?"":F,N=e.position,U=void 0===N?"bottom center":N,V=e.modal,G=void 0!==V&&V,q=e.lockScroll,$=void 0!==q&&q,Z=e.arrow,W=void 0===Z||Z,X=e.offsetX,H=void 0===X?0:X,Y=e.offsetY,K=void 0===Y?0:Y,J=e.mouseEnterDelay,Q=void 0===J?100:J,ee=e.mouseLeaveDelay,te=void 0===ee?100:ee,ne=e.keepTooltipInside,re=void 0!==ne&&ne,ie=e.children,oe=Object(r.useState)(v||g),ae=oe[0],se=oe[1],le=Object(r.useRef)(null),ue=Object(r.useRef)(null),ce=Object(r.useRef)(null),he=Object(r.useRef)(null),de=Object(r.useRef)("popup-"+ ++f),fe=!!G||!o,pe=Object(r.useRef)(0);l((function(){return ae?(he.current=document.activeElement,ke(),Ee(),be()):we(),function(){clearTimeout(pe.current)}}),[ae]),Object(r.useEffect)((function(){"boolean"==typeof v&&(v?me():_e())}),[v,b]);var me=function(e){ae||b||(se(!0),setTimeout((function(){return h(e)}),0))},_e=function(e){var t;ae&&!b&&(se(!1),fe&&(null===(t=he.current)||void 0===t||t.focus()),setTimeout((function(){return m(e)}),0))},ge=function(e){null==e||e.stopPropagation(),ae?_e(e):me(e)},ye=function(e){clearTimeout(pe.current),pe.current=setTimeout((function(){return me(e)}),Q)},ve=function(e){null==e||e.preventDefault(),ge()},xe=function(e){clearTimeout(pe.current),pe.current=setTimeout((function(){return _e(e)}),te)},be=function(){fe&&$&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},we=function(){fe&&$&&(document.getElementsByTagName("body")[0].style.overflow="auto")},Ee=function(){var e,t=null==ue||null===(e=ue.current)||void 0===e?void 0:e.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),n=Array.prototype.slice.call(t)[0];null==n||n.focus()};Object(r.useImperativeHandle)(t,(function(){return{open:function(){me()},close:function(){_e()},toggle:function(){ge()}}}));var Te,Se,ke=function(){if(!fe&&ae&&(null==le?void 0:le.current)&&(null==le?void 0:le.current)&&(null==ue?void 0:ue.current)){var e,t,n=le.current.getBoundingClientRect(),r=ue.current.getBoundingClientRect(),i=d(n,r,U,W,{offsetX:H,offsetY:K},re);if(ue.current.style.top=i.top+window.scrollY+"px",ue.current.style.left=i.left+window.scrollX+"px",W&&ce.current)ce.current.style.transform=i.transform,ce.current.style.setProperty("-ms-transform",i.transform),ce.current.style.setProperty("-webkit-transform",i.transform),ce.current.style.top=(null===(e=D.top)||void 0===e?void 0:e.toString())||i.arrowTop,ce.current.style.left=(null===(t=D.left)||void 0===t?void 0:t.toString())||i.arrowLeft}};Te=_e,void 0===(Se=A)&&(Se=!0),Object(r.useEffect)((function(){if(Se){var e=function(e){"Escape"===e.key&&Te(e)};return document.addEventListener("keyup",e),function(){Se&&document.removeEventListener("keyup",e)}}}),[Te,Se]),function(e,t){void 0===t&&(t=!0),Object(r.useEffect)((function(){if(t){var n=function(t){if(9===t.keyCode){var n,r=null==e||null===(n=e.current)||void 0===n?void 0:n.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),i=Array.prototype.slice.call(r);if(1===i.length)return void t.preventDefault();var o=i[0],a=i[i.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),a.focus()):document.activeElement===a&&(t.preventDefault(),o.focus())}};return document.addEventListener("keydown",n),function(){t&&document.removeEventListener("keydown",n)}}}),[e,t])}(ue,ae&&fe),function(e,t){void 0===t&&(t=!0),Object(r.useEffect)((function(){if(t){var n=function(){e()};return window.addEventListener("resize",n),function(){t&&window.removeEventListener("resize",n)}}}),[e,t])}(ke,M),function(e,t,n){void 0===n&&(n=!0),Object(r.useEffect)((function(){if(n){var r=function(n){var r=Array.isArray(e)?e:[e],i=!1;r.forEach((function(e){e.current&&!e.current.contains(n.target)||(i=!0)})),n.stopPropagation(),i||t(n)};return document.addEventListener("mousedown",r),document.addEventListener("touchstart",r),function(){n&&(document.removeEventListener("mousedown",r),document.removeEventListener("touchstart",r))}}}),[e,t,n])}(o?[ue,le]:[ue],_e,S&&!E);var Me,Ce=function(){return i.a.createElement("div",Object.assign({},(e=fe?u.popupContent.modal:u.popupContent.tooltip,t={className:"popup-content "+(""!==j?j.split(" ").map((function(e){return e+"-content"})).join(" "):""),style:s({},e,z,{pointerEvents:"auto"}),ref:ue,onClick:function(e){e.stopPropagation()}},!G&&P.indexOf("hover")>=0&&(t.onMouseEnter=ye,t.onMouseLeave=xe),t),{key:"C",role:fe?"dialog":"tooltip",id:de.current}),W&&!fe&&i.a.createElement("div",{ref:ce,style:u.popupArrow},i.a.createElement("svg",{"data-testid":"arrow",className:"popup-arrow "+(""!==j?j.split(" ").map((function(e){return e+"-arrow"})).join(" "):""),viewBox:"0 0 32 16",style:s({position:"absolute"},D)},i.a.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),ie&&"function"==typeof ie?ie(_e,ae):ie);var e,t},Ae=!(P.indexOf("hover")>=0),Ie=fe?u.overlay.modal:u.overlay.tooltip,Pe=[Ae&&i.a.createElement("div",{key:"O","data-testid":"overlay","data-popup":fe?"modal":"tooltip",className:"popup-overlay "+(""!==j?j.split(" ").map((function(e){return e+"-overlay"})).join(" "):""),style:s({},Ie,B,{pointerEvents:S&&E||fe?"auto":"none"}),onClick:S&&E?_e:void 0,tabIndex:-1},fe&&Ce()),!fe&&Ce()];return i.a.createElement(i.a.Fragment,null,function(){for(var e={key:"T",ref:le,"aria-describedby":de.current},t=Array.isArray(P)?P:[P],n=0,r=t.length;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}n.d(t,"a",(function(){return Pt}));var c=n(0),h=["defaultInputValue","defaultMenuIsOpen","defaultValue","inputValue","menuIsOpen","onChange","onInputChange","onMenuClose","onMenuOpen","value"];function d(){return(d=Object.assign?Object.assign.bind():function(e){for(var t=1;te.brand+"/"+e.version).join(" "):navigator.userAgent}function M(e){return e instanceof E(e).HTMLElement}function C(e){return e instanceof E(e).Element}function A(e){if("undefined"==typeof ShadowRoot)return!1;return e instanceof E(e).ShadowRoot||e instanceof ShadowRoot}function I(e){const{overflow:t,overflowX:n,overflowY:r}=T(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function P(){return!/^((?!chrome|android).)*safari/i.test(k())}Math.min,Math.max;const O=Math.round;function z(e,t,n){var r,i,o,a;void 0===t&&(t=!1),void 0===n&&(n=!1);const s=e.getBoundingClientRect();let l=1,u=1;t&&M(e)&&(l=e.offsetWidth>0&&O(s.width)/e.offsetWidth||1,u=e.offsetHeight>0&&O(s.height)/e.offsetHeight||1);const c=C(e)?E(e):window,h=!P()&&n,d=(s.left+(h&&null!=(r=null==(i=c.visualViewport)?void 0:i.offsetLeft)?r:0))/l,f=(s.top+(h&&null!=(o=null==(a=c.visualViewport)?void 0:a.offsetTop)?o:0))/u,p=s.width/l,m=s.height/u;return{width:p,height:m,top:f,right:d+p,bottom:f+m,left:d,x:d,y:f}}function L(e){return(t=e,(t instanceof E(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function D(e){return"html"===S(e)?e:e.assignedSlot||e.parentNode||(A(e)?e.host:null)||L(e)}function R(e,t){var n;void 0===t&&(t=[]);const r=function e(t){const n=D(t);return["html","body","#document"].includes(S(n))?t.ownerDocument.body:M(n)&&I(n)?n:e(n)}(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),o=E(r),a=i?[o].concat(o.visualViewport||[],I(r)?r:[]):r,s=t.concat(a);return i?s:s.concat(R(a))}var B=c.useLayoutEffect,F=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],j=function(){};function N(e,t){return t?"-"===t[0]?e+t:e+"__"+t:e}function U(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i-1}function Z(e){return $(e)?window.pageYOffset:e.scrollTop}function W(e,t){$(e)?window.scrollTo(0,t):e.scrollTop=t}function X(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function H(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:j,i=Z(e),o=t-i,a=10,s=0;function l(){var t=X(s+=a,i,o,n);W(e,t),sn.bottom?W(e,Math.min(t.offsetTop+t.clientHeight-e.offsetHeight+i,e.scrollHeight)):r.top-i=p)return{placement:"bottom",maxHeight:t};if(T>=p&&!a)return o&&H(l,S,160),{placement:"bottom",maxHeight:t};if(!a&&T>=r||a&&w>=r)return o&&H(l,S,160),{placement:"bottom",maxHeight:a?w-v:T-v};if("auto"===i||a){var M=t,C=a?b:E;return C>=r&&(M=Math.min(C-v-s,t)),{placement:"top",maxHeight:M}}if("bottom"===i)return o&&W(l,S),{placement:"bottom",maxHeight:t};break;case"top":if(b>=p)return{placement:"top",maxHeight:t};if(E>=p&&!a)return o&&H(l,k,160),{placement:"top",maxHeight:t};if(!a&&E>=r||a&&b>=r){var A=t;return(!a&&E>=r||a&&b>=r)&&(A=a?b-x:E-x),o&&H(l,k,160),{placement:"top",maxHeight:A}}return{placement:"bottom",maxHeight:t};default:throw new Error('Invalid placement provided "'.concat(i,'".'))}return u}var se,le=function(e){return"auto"===e?"bottom":e},ue=Object(c.createContext)(null),ce=function(e){var t=e.children,n=e.minMenuHeight,r=e.maxMenuHeight,i=e.menuPlacement,a=e.menuPosition,s=e.menuShouldScrollIntoView,u=e.theme,h=(Object(c.useContext)(ue)||{}).setPortalPlacement,d=Object(c.useRef)(null),f=l(Object(c.useState)(r),2),p=f[0],m=f[1],_=l(Object(c.useState)(null),2),g=_[0],y=_[1],v=u.spacing.controlHeight;return B((function(){var e=d.current;if(e){var t="fixed"===a,o=ae({maxHeight:r,menuEl:e,minHeight:n,placement:i,shouldScroll:s&&!t,isFixedPosition:t,controlHeight:v});m(o.maxHeight),y(o.placement),null==h||h(o.placement)}}),[r,i,a,s,n,h,v]),t({ref:d,placerProps:o(o({},e),{},{placement:g||le(i),maxHeight:p})})},he=function(e){var t=e.children,n=e.innerRef,r=e.innerProps;return Object(x.c)("div",d({},q(e,"menu",{menu:!0}),{ref:n},r),t)},de=function(e,t){var n=e.theme,r=n.spacing.baseUnit,i=n.colors;return o({textAlign:"center"},t?{}:{color:i.neutral40,padding:"".concat(2*r,"px ").concat(3*r,"px")})},fe=de,pe=de,me=["size"],_e=["innerProps","isRtl","size"];var ge,ye,ve={name:"8mmkcg",styles:"display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0"},xe=function(e){var t=e.size,n=u(e,me);return Object(x.c)("svg",d({height:t,width:t,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",css:ve},n))},be=function(e){return Object(x.c)(xe,d({size:20},e),Object(x.c)("path",{d:"M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"}))},we=function(e){return Object(x.c)(xe,d({size:20},e),Object(x.c)("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},Ee=function(e,t){var n=e.isFocused,r=e.theme,i=r.spacing.baseUnit,a=r.colors;return o({label:"indicatorContainer",display:"flex",transition:"color 150ms"},t?{}:{color:n?a.neutral60:a.neutral20,padding:2*i,":hover":{color:n?a.neutral80:a.neutral40}})},Te=Ee,Se=Ee,ke=Object(x.d)(se||(ge=["\n 0%, 80%, 100% { opacity: 0; }\n 40% { opacity: 1; }\n"],ye||(ye=ge.slice(0)),se=Object.freeze(Object.defineProperties(ge,{raw:{value:Object.freeze(ye)}})))),Me=function(e){var t=e.delay,n=e.offset;return Object(x.c)("span",{css:Object(x.b)({animation:"".concat(ke," 1s ease-in-out ").concat(t,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:n?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},Ce=function(e){var t=e.children,n=e.isDisabled,r=e.isFocused,i=e.innerRef,o=e.innerProps,a=e.menuIsOpen;return Object(x.c)("div",d({ref:i},q(e,"control",{control:!0,"control--is-disabled":n,"control--is-focused":r,"control--menu-is-open":a}),o),t)},Ae=["data"],Ie=function(e){var t=e.children,n=e.cx,r=e.getStyles,i=e.getClassNames,o=e.Heading,a=e.headingProps,s=e.innerProps,l=e.label,u=e.theme,c=e.selectProps;return Object(x.c)("div",d({},q(e,"group",{group:!0}),s),Object(x.c)(o,d({},a,{selectProps:c,theme:u,getStyles:r,getClassNames:i,cx:n}),l),Object(x.c)("div",null,t))},Pe=["innerRef","isDisabled","isHidden","inputClassName"],Oe={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},ze={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content","&:after":o({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre"},Oe)},Le=function(e){return o({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Oe)},De=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",n,t)};var Re={ClearIndicator:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"clearIndicator",{indicator:!0,"clear-indicator":!0}),n),t||Object(x.c)(be,null))},Control:Ce,DropdownIndicator:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"dropdownIndicator",{indicator:!0,"dropdown-indicator":!0}),n),t||Object(x.c)(we,null))},DownChevron:we,CrossIcon:be,Group:Ie,GroupHeading:function(e){var t=G(e);t.data;var n=u(t,Ae);return Object(x.c)("div",d({},q(e,"groupHeading",{"group-heading":!0}),n))},IndicatorsContainer:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"indicatorsContainer",{indicators:!0}),n),t)},IndicatorSeparator:function(e){var t=e.innerProps;return Object(x.c)("span",d({},t,q(e,"indicatorSeparator",{"indicator-separator":!0})))},Input:function(e){var t=e.cx,n=e.value,r=G(e),i=r.innerRef,o=r.isDisabled,a=r.isHidden,s=r.inputClassName,l=u(r,Pe);return Object(x.c)("div",d({},q(e,"input",{"input-container":!0}),{"data-value":n||""}),Object(x.c)("input",d({className:t({input:!0},s),ref:i,style:Le(a),disabled:o},l)))},LoadingIndicator:function(e){var t=e.innerProps,n=e.isRtl,r=e.size,i=void 0===r?4:r,a=u(e,_e);return Object(x.c)("div",d({},q(o(o({},a),{},{innerProps:t,isRtl:n,size:i}),"loadingIndicator",{indicator:!0,"loading-indicator":!0}),t),Object(x.c)(Me,{delay:0,offset:n}),Object(x.c)(Me,{delay:160,offset:!0}),Object(x.c)(Me,{delay:320,offset:!n}))},Menu:he,MenuList:function(e){var t=e.children,n=e.innerProps,r=e.innerRef,i=e.isMulti;return Object(x.c)("div",d({},q(e,"menuList",{"menu-list":!0,"menu-list--is-multi":i}),{ref:r},n),t)},MenuPortal:function(e){var t=e.appendTo,n=e.children,r=e.controlElement,i=e.innerProps,a=e.menuPlacement,s=e.menuPosition,u=Object(c.useRef)(null),h=Object(c.useRef)(null),f=l(Object(c.useState)(le(a)),2),p=f[0],m=f[1],_=Object(c.useMemo)((function(){return{setPortalPlacement:m}}),[]),g=l(Object(c.useState)(null),2),y=g[0],v=g[1],w=Object(c.useCallback)((function(){if(r){var e=function(e){var t=e.getBoundingClientRect();return{bottom:t.bottom,height:t.height,left:t.left,right:t.right,top:t.top,width:t.width}}(r),t="fixed"===s?0:window.pageYOffset,n=e[p]+t;n===(null==y?void 0:y.offset)&&e.left===(null==y?void 0:y.rect.left)&&e.width===(null==y?void 0:y.rect.width)||v({offset:n,rect:e})}}),[r,s,p,null==y?void 0:y.offset,null==y?void 0:y.rect.left,null==y?void 0:y.rect.width]);B((function(){w()}),[w]);var E=Object(c.useCallback)((function(){"function"==typeof h.current&&(h.current(),h.current=null),r&&u.current&&(h.current=function(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=!0,animationFrame:s=!1}=r,l=i&&!s,u=o&&!s,c=l||u?[...C(e)?R(e):[],...R(t)]:[];c.forEach(e=>{l&&e.addEventListener("scroll",n,{passive:!0}),u&&e.addEventListener("resize",n)});let h,d=null;if(a){let r=!0;d=new ResizeObserver(()=>{r||n(),r=!1}),C(e)&&!s&&d.observe(e),d.observe(t)}let f=s?z(e):null;return s&&function t(){const r=z(e);!f||r.x===f.x&&r.y===f.y&&r.width===f.width&&r.height===f.height||n();f=r,h=requestAnimationFrame(t)}(),n(),()=>{var e;c.forEach(e=>{l&&e.removeEventListener("scroll",n),u&&e.removeEventListener("resize",n)}),null==(e=d)||e.disconnect(),d=null,s&&cancelAnimationFrame(h)}}(r,u.current,w,{elementResize:"ResizeObserver"in window}))}),[r,w]);B((function(){E()}),[E]);var T=Object(c.useCallback)((function(e){u.current=e,E()}),[E]);if(!t&&"fixed"!==s||!y)return null;var S=Object(x.c)("div",d({ref:T},q(o(o({},e),{},{offset:y.offset,position:s,rect:y.rect}),"menuPortal",{"menu-portal":!0}),i),n);return Object(x.c)(ue.Provider,{value:_},t?Object(b.createPortal)(S,t):S)},LoadingMessage:function(e){var t=e.children,n=void 0===t?"Loading...":t,r=e.innerProps,i=u(e,oe);return Object(x.c)("div",d({},q(o(o({},i),{},{children:n,innerProps:r}),"loadingMessage",{"menu-notice":!0,"menu-notice--loading":!0}),r),n)},NoOptionsMessage:function(e){var t=e.children,n=void 0===t?"No options":t,r=e.innerProps,i=u(e,ie);return Object(x.c)("div",d({},q(o(o({},i),{},{children:n,innerProps:r}),"noOptionsMessage",{"menu-notice":!0,"menu-notice--no-options":!0}),r),n)},MultiValue:function(e){var t=e.children,n=e.components,r=e.data,i=e.innerProps,a=e.isDisabled,s=e.removeProps,l=e.selectProps,u=n.Container,c=n.Label,h=n.Remove;return Object(x.c)(u,{data:r,innerProps:o(o({},q(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":a})),i),selectProps:l},Object(x.c)(c,{data:r,innerProps:o({},q(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:l},t),Object(x.c)(h,{data:r,innerProps:o(o({},q(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(t||"option")},s),selectProps:l}))},MultiValueContainer:De,MultiValueLabel:De,MultiValueRemove:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({role:"button"},n),t||Object(x.c)(be,{size:14}))},Option:function(e){var t=e.children,n=e.isDisabled,r=e.isFocused,i=e.isSelected,o=e.innerRef,a=e.innerProps;return Object(x.c)("div",d({},q(e,"option",{option:!0,"option--is-disabled":n,"option--is-focused":r,"option--is-selected":i}),{ref:o,"aria-disabled":n},a),t)},Placeholder:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"placeholder",{placeholder:!0}),n),t)},SelectContainer:function(e){var t=e.children,n=e.innerProps,r=e.isDisabled,i=e.isRtl;return Object(x.c)("div",d({},q(e,"container",{"--is-disabled":r,"--is-rtl":i}),n),t)},SingleValue:function(e){var t=e.children,n=e.isDisabled,r=e.innerProps;return Object(x.c)("div",d({},q(e,"singleValue",{"single-value":!0,"single-value--is-disabled":n}),r),t)},ValueContainer:function(e){var t=e.children,n=e.innerProps,r=e.isMulti,i=e.hasValue;return Object(x.c)("div",d({},q(e,"valueContainer",{"value-container":!0,"value-container--is-multi":r,"value-container--has-value":i}),n),t)}},Be=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function Fe(e,t){if(e.length!==t.length)return!1;for(var n=0;n1?"s":""," ").concat(i.join(","),", selected.");case"select-option":return"option ".concat(r,o?" is disabled. Select another option.":", selected.");default:return""}},onFocus:function(e){var t=e.context,n=e.focused,r=e.options,i=e.label,o=void 0===i?"":i,a=e.selectValue,s=e.isDisabled,l=e.isSelected,u=function(e,t){return e&&e.length?"".concat(e.indexOf(t)+1," of ").concat(e.length):""};if("value"===t&&a)return"value ".concat(o," focused, ").concat(u(a,n),".");if("menu"===t){var c=s?" disabled":"",h="".concat(l?"selected":"focused").concat(c);return"option ".concat(o," ").concat(h,", ").concat(u(r,n),".")}return""},onFilter:function(e){var t=e.inputValue,n=e.resultsMessage;return"".concat(n).concat(t?" for search term "+t:"",".")}},Ve=function(e){var t=e.ariaSelection,n=e.focusedOption,r=e.focusedValue,i=e.focusableOptions,a=e.isFocused,s=e.selectValue,l=e.selectProps,u=e.id,h=l.ariaLiveMessages,d=l.getOptionLabel,f=l.inputValue,p=l.isMulti,m=l.isOptionDisabled,_=l.isSearchable,g=l.menuIsOpen,y=l.options,v=l.screenReaderStatus,b=l.tabSelectsValue,w=l["aria-label"],E=l["aria-live"],T=Object(c.useMemo)((function(){return o(o({},Ue),h||{})}),[h]),S=Object(c.useMemo)((function(){var e,n="";if(t&&T.onChange){var r=t.option,i=t.options,a=t.removedValue,l=t.removedValues,u=t.value,c=a||r||(e=u,Array.isArray(e)?null:e),h=c?d(c):"",f=i||l||void 0,p=f?f.map(d):[],_=o({isDisabled:c&&m(c,s),label:h,labels:p},t);n=T.onChange(_)}return n}),[t,T,m,s,d]),k=Object(c.useMemo)((function(){var e="",t=n||r,o=!!(n&&s&&s.includes(n));if(t&&T.onFocus){var a={focused:t,label:d(t),isDisabled:m(t,s),isSelected:o,options:i,context:t===n?"menu":"value",selectValue:s};e=T.onFocus(a)}return e}),[n,r,d,m,T,i,s]),M=Object(c.useMemo)((function(){var e="";if(g&&y.length&&T.onFilter){var t=v({count:i.length});e=T.onFilter({inputValue:f,resultsMessage:t})}return e}),[i,f,g,T,y,v]),C=Object(c.useMemo)((function(){var e="";if(T.guidance){var t=r?"value":g?"menu":"input";e=T.guidance({"aria-label":w,context:t,isDisabled:n&&m(n,s),isMulti:p,isSearchable:_,tabSelectsValue:b})}return e}),[w,n,r,p,m,_,g,T,s,b]),A="".concat(k," ").concat(M," ").concat(C),I=Object(x.c)(c.Fragment,null,Object(x.c)("span",{id:"aria-selection"},S),Object(x.c)("span",{id:"aria-context"},A)),P="initial-input-focus"===(null==t?void 0:t.action);return Object(x.c)(c.Fragment,null,Object(x.c)(Ne,{id:u},P&&I),Object(x.c)(Ne,{"aria-live":E,"aria-atomic":"false","aria-relevant":"additions text"},a&&!P&&I))},Ge=[{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ"},{base:"nj",letters:"nj"},{base:"o",letters:"oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],qe=new RegExp("["+Ge.map((function(e){return e.letters})).join("")+"]","g"),$e={},Ze=0;Ze1?t-1:0),r=1;r0,m=h-d-c,_=!1;m>t&&a.current&&(r&&r(e),a.current=!1),p&&s.current&&(o&&o(e),s.current=!1),p&&t>m?(n&&!a.current&&n(e),f.scrollTop=h,_=!0,a.current=!0):!p&&-t>c&&(i&&!s.current&&i(e),f.scrollTop=0,_=!0,s.current=!0),_&&function(e){e.preventDefault(),e.stopPropagation()}(e)}}),[n,r,i,o]),d=Object(c.useCallback)((function(e){h(e,e.deltaY)}),[h]),f=Object(c.useCallback)((function(e){l.current=e.changedTouches[0].clientY}),[]),p=Object(c.useCallback)((function(e){var t=l.current-e.changedTouches[0].clientY;h(e,t)}),[h]),m=Object(c.useCallback)((function(e){if(e){var t=!!te&&{passive:!1};e.addEventListener("wheel",d,t),e.addEventListener("touchstart",f,t),e.addEventListener("touchmove",p,t)}}),[p,f,d]),_=Object(c.useCallback)((function(e){e&&(e.removeEventListener("wheel",d,!1),e.removeEventListener("touchstart",f,!1),e.removeEventListener("touchmove",p,!1))}),[p,f,d]);return Object(c.useEffect)((function(){if(t){var e=u.current;return m(e),function(){_(e)}}}),[t,m,_]),function(e){u.current=e}}({isEnabled:void 0===r||r,onBottomArrive:e.onBottomArrive,onBottomLeave:e.onBottomLeave,onTopArrive:e.onTopArrive,onTopLeave:e.onTopLeave}),o=function(e){var t=e.isEnabled,n=e.accountForScrollbars,r=void 0===n||n,i=Object(c.useRef)({}),o=Object(c.useRef)(null),a=Object(c.useCallback)((function(e){if(st){var t=document.body,n=t&&t.style;if(r&&tt.forEach((function(e){var t=n&&n[e];i.current[e]=t})),r&<<1){var o=parseInt(i.current.paddingRight,10)||0,a=document.body?document.body.clientWidth:0,s=window.innerWidth-a+o||0;Object.keys(nt).forEach((function(e){var t=nt[e];n&&(n[e]=t)})),n&&(n.paddingRight="".concat(s,"px"))}t&&at()&&(t.addEventListener("touchmove",rt,ut),e&&(e.addEventListener("touchstart",ot,ut),e.addEventListener("touchmove",it,ut))),lt+=1}}),[r]),s=Object(c.useCallback)((function(e){if(st){var t=document.body,n=t&&t.style;lt=Math.max(lt-1,0),r&<<1&&tt.forEach((function(e){var t=i.current[e];n&&(n[e]=t)})),t&&at()&&(t.removeEventListener("touchmove",rt,ut),e&&(e.removeEventListener("touchstart",ot,ut),e.removeEventListener("touchmove",it,ut)))}}),[r]);return Object(c.useEffect)((function(){if(t){var e=o.current;return a(e),function(){s(e)}}}),[t,a,s]),function(e){o.current=e}}({isEnabled:n});return Object(x.c)(c.Fragment,null,n&&Object(x.c)("div",{onClick:ct,css:ht}),t((function(e){i(e),o(e)})))}var ft={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},pt=function(e){var t=e.name,n=e.onFocus;return Object(x.c)("input",{required:!0,name:t,tabIndex:-1,"aria-hidden":"true",onFocus:n,css:ft,value:"",onChange:function(){}})},mt={clearIndicator:Se,container:function(e){var t=e.isDisabled;return{label:"container",direction:e.isRtl?"rtl":void 0,pointerEvents:t?"none":void 0,position:"relative"}},control:function(e,t){var n=e.isDisabled,r=e.isFocused,i=e.theme,a=i.colors,s=i.borderRadius;return o({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:i.spacing.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},t?{}:{backgroundColor:n?a.neutral5:a.neutral0,borderColor:n?a.neutral10:r?a.primary:a.neutral20,borderRadius:s,borderStyle:"solid",borderWidth:1,boxShadow:r?"0 0 0 1px ".concat(a.primary):void 0,"&:hover":{borderColor:r?a.primary:a.neutral30}})},dropdownIndicator:Te,group:function(e,t){var n=e.theme.spacing;return t?{}:{paddingBottom:2*n.baseUnit,paddingTop:2*n.baseUnit}},groupHeading:function(e,t){var n=e.theme,r=n.colors,i=n.spacing;return o({label:"group",cursor:"default",display:"block"},t?{}:{color:r.neutral40,fontSize:"75%",fontWeight:500,marginBottom:"0.25em",paddingLeft:3*i.baseUnit,paddingRight:3*i.baseUnit,textTransform:"uppercase"})},indicatorsContainer:function(){return{alignItems:"center",alignSelf:"stretch",display:"flex",flexShrink:0}},indicatorSeparator:function(e,t){var n=e.isDisabled,r=e.theme,i=r.spacing.baseUnit,a=r.colors;return o({label:"indicatorSeparator",alignSelf:"stretch",width:1},t?{}:{backgroundColor:n?a.neutral10:a.neutral20,marginBottom:2*i,marginTop:2*i})},input:function(e,t){var n=e.isDisabled,r=e.value,i=e.theme,a=i.spacing,s=i.colors;return o(o({visibility:n?"hidden":"visible",transform:r?"translateZ(0)":""},ze),t?{}:{margin:a.baseUnit/2,paddingBottom:a.baseUnit/2,paddingTop:a.baseUnit/2,color:s.neutral80})},loadingIndicator:function(e,t){var n=e.isFocused,r=e.size,i=e.theme,a=i.colors,s=i.spacing.baseUnit;return o({label:"loadingIndicator",display:"flex",transition:"color 150ms",alignSelf:"center",fontSize:r,lineHeight:1,marginRight:r,textAlign:"center",verticalAlign:"middle"},t?{}:{color:n?a.neutral60:a.neutral20,padding:2*s})},loadingMessage:pe,menu:function(e,t){var n,i=e.placement,a=e.theme,s=a.borderRadius,l=a.spacing,u=a.colors;return o((r(n={label:"menu"},function(e){return e?{bottom:"top",top:"bottom"}[e]:"bottom"}(i),"100%"),r(n,"position","absolute"),r(n,"width","100%"),r(n,"zIndex",1),n),t?{}:{backgroundColor:u.neutral0,borderRadius:s,boxShadow:"0 0 0 1px hsla(0, 0%, 0%, 0.1), 0 4px 11px hsla(0, 0%, 0%, 0.1)",marginBottom:l.menuGutter,marginTop:l.menuGutter})},menuList:function(e,t){var n=e.maxHeight,r=e.theme.spacing.baseUnit;return o({maxHeight:n,overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},t?{}:{paddingBottom:r,paddingTop:r})},menuPortal:function(e){var t=e.rect,n=e.offset,r=e.position;return{left:t.left,position:r,top:n,width:t.width,zIndex:1}},multiValue:function(e,t){var n=e.theme,r=n.spacing,i=n.borderRadius,a=n.colors;return o({label:"multiValue",display:"flex",minWidth:0},t?{}:{backgroundColor:a.neutral10,borderRadius:i/2,margin:r.baseUnit/2})},multiValueLabel:function(e,t){var n=e.theme,r=n.borderRadius,i=n.colors,a=e.cropWithEllipsis;return o({overflow:"hidden",textOverflow:a||void 0===a?"ellipsis":void 0,whiteSpace:"nowrap"},t?{}:{borderRadius:r/2,color:i.neutral80,fontSize:"85%",padding:3,paddingLeft:6})},multiValueRemove:function(e,t){var n=e.theme,r=n.spacing,i=n.borderRadius,a=n.colors,s=e.isFocused;return o({alignItems:"center",display:"flex"},t?{}:{borderRadius:i/2,backgroundColor:s?a.dangerLight:void 0,paddingLeft:r.baseUnit,paddingRight:r.baseUnit,":hover":{backgroundColor:a.dangerLight,color:a.danger}})},noOptionsMessage:fe,option:function(e,t){var n=e.isDisabled,r=e.isFocused,i=e.isSelected,a=e.theme,s=a.spacing,l=a.colors;return o({label:"option",cursor:"default",display:"block",fontSize:"inherit",width:"100%",userSelect:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)"},t?{}:{backgroundColor:i?l.primary:r?l.primary25:"transparent",color:n?l.neutral20:i?l.neutral0:"inherit",padding:"".concat(2*s.baseUnit,"px ").concat(3*s.baseUnit,"px"),":active":{backgroundColor:n?void 0:i?l.primary:l.primary50}})},placeholder:function(e,t){var n=e.theme,r=n.spacing,i=n.colors;return o({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},t?{}:{color:i.neutral50,marginLeft:r.baseUnit/2,marginRight:r.baseUnit/2})},singleValue:function(e,t){var n=e.isDisabled,r=e.theme,i=r.spacing,a=r.colors;return o({label:"singleValue",gridArea:"1 / 1 / 2 / 3",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},t?{}:{color:n?a.neutral40:a.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},valueContainer:function(e,t){var n=e.theme.spacing,r=e.isMulti,i=e.hasValue,a=e.selectProps.controlShouldRenderValue;return o({alignItems:"center",display:r&&i&&a?"flex":"grid",flex:1,flexWrap:"wrap",WebkitOverflowScrolling:"touch",position:"relative",overflow:"hidden"},t?{}:{padding:"".concat(n.baseUnit/2,"px ").concat(2*n.baseUnit,"px")})}};var _t,gt={borderRadius:4,colors:{primary:"#2684FF",primary75:"#4C9AFF",primary50:"#B2D4FF",primary25:"#DEEBFF",danger:"#DE350B",dangerLight:"#FFBDAD",neutral0:"hsl(0, 0%, 100%)",neutral5:"hsl(0, 0%, 95%)",neutral10:"hsl(0, 0%, 90%)",neutral20:"hsl(0, 0%, 80%)",neutral30:"hsl(0, 0%, 70%)",neutral40:"hsl(0, 0%, 60%)",neutral50:"hsl(0, 0%, 50%)",neutral60:"hsl(0, 0%, 40%)",neutral70:"hsl(0, 0%, 30%)",neutral80:"hsl(0, 0%, 20%)",neutral90:"hsl(0, 0%, 10%)"},spacing:{baseUnit:4,controlHeight:38,menuGutter:8}},yt={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:K(),captureMenuScroll:!K(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:function(e,t){if(e.data.__isNew__)return!0;var n=o({ignoreCase:!0,ignoreAccents:!0,stringify:Je,trim:!0,matchFrom:"any"},_t),r=n.ignoreCase,i=n.ignoreAccents,a=n.stringify,s=n.trim,l=n.matchFrom,u=s?Ke(t):t,c=s?Ke(a(e)):a(e);return r&&(u=u.toLowerCase(),c=c.toLowerCase()),i&&(u=Ye(u),c=He(c)),"start"===l?c.substr(0,u.length)===u:c.indexOf(u)>-1},formatGroupLabel:function(e){return e.label},getOptionLabel:function(e){return e.label},getOptionValue:function(e){return e.value},isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:function(e){return!!e.isDisabled},loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!function(){try{return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}catch(e){return!1}}(),noOptionsMessage:function(){return"No options"},openMenuOnFocus:!1,openMenuOnClick:!0,options:[],pageSize:5,placeholder:"Select...",screenReaderStatus:function(e){var t=e.count;return"".concat(t," result").concat(1!==t?"s":""," available")},styles:{},tabIndex:0,tabSelectsValue:!0,unstyled:!1};function vt(e,t,n,r){return{type:"option",data:t,isDisabled:St(e,t,n),isSelected:kt(e,t,n),label:Et(e,t),value:Tt(e,t),index:r}}function xt(e,t){return e.options.map((function(n,r){if("options"in n){var i=n.options.map((function(n,r){return vt(e,n,t,r)})).filter((function(t){return wt(e,t)}));return i.length>0?{type:"group",data:n,options:i,index:r}:void 0}var o=vt(e,n,t,r);return wt(e,o)?o:void 0})).filter(ne)}function bt(e){return e.reduce((function(e,t){return"group"===t.type?e.push.apply(e,v(t.options.map((function(e){return e.data})))):e.push(t.data),e}),[])}function wt(e,t){var n=e.inputValue,r=void 0===n?"":n,i=t.data,o=t.isSelected,a=t.label,s=t.value;return(!Ct(e)||!o)&&Mt(e,{label:a,value:s,data:i},r)}var Et=function(e,t){return e.getOptionLabel(t)},Tt=function(e,t){return e.getOptionValue(t)};function St(e,t,n){return"function"==typeof e.isOptionDisabled&&e.isOptionDisabled(t,n)}function kt(e,t,n){if(n.indexOf(t)>-1)return!0;if("function"==typeof e.isOptionSelected)return e.isOptionSelected(t,n);var r=Tt(e,t);return n.some((function(t){return Tt(e,t)===r}))}function Mt(e,t,n){return!e.filterOption||e.filterOption(t,n)}var Ct=function(e){var t=e.hideSelectedOptions,n=e.isMulti;return void 0===t?n:t},At=1,It=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(a,e);var t,n,r,i=y(a);function a(e){var t;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=i.call(this,e)).state={ariaSelection:null,focusedOption:null,focusedValue:null,inputIsHidden:!1,isFocused:!1,selectValue:[],clearFocusValueOnUpdate:!1,prevWasFocused:!1,inputIsHiddenAfterUpdate:void 0,prevProps:void 0},t.blockOptionHover=!1,t.isComposing=!1,t.commonProps=void 0,t.initialTouchX=0,t.initialTouchY=0,t.instancePrefix="",t.openAfterFocus=!1,t.scrollToFocusedOptionOnUpdate=!1,t.userIsDragging=void 0,t.controlRef=null,t.getControlRef=function(e){t.controlRef=e},t.focusedOptionRef=null,t.getFocusedOptionRef=function(e){t.focusedOptionRef=e},t.menuListRef=null,t.getMenuListRef=function(e){t.menuListRef=e},t.inputRef=null,t.getInputRef=function(e){t.inputRef=e},t.focus=t.focusInput,t.blur=t.blurInput,t.onChange=function(e,n){var r=t.props,i=r.onChange,o=r.name;n.name=o,t.ariaOnChange(e,n),i(e,n)},t.setValue=function(e,n,r){var i=t.props,o=i.closeMenuOnSelect,a=i.isMulti,s=i.inputValue;t.onInputChange("",{action:"set-value",prevInputValue:s}),o&&(t.setState({inputIsHiddenAfterUpdate:!a}),t.onMenuClose()),t.setState({clearFocusValueOnUpdate:!0}),t.onChange(e,{action:n,option:r})},t.selectOption=function(e){var n=t.props,r=n.blurInputOnSelect,i=n.isMulti,o=n.name,a=t.state.selectValue,s=i&&t.isOptionSelected(e,a),l=t.isOptionDisabled(e,a);if(s){var u=t.getOptionValue(e);t.setValue(a.filter((function(e){return t.getOptionValue(e)!==u})),"deselect-option",e)}else{if(l)return void t.ariaOnChange(e,{action:"select-option",option:e,name:o});i?t.setValue([].concat(v(a),[e]),"select-option",e):t.setValue(e,"select-option")}r&&t.blurInput()},t.removeValue=function(e){var n=t.props.isMulti,r=t.state.selectValue,i=t.getOptionValue(e),o=r.filter((function(e){return t.getOptionValue(e)!==i})),a=re(n,o,o[0]||null);t.onChange(a,{action:"remove-value",removedValue:e}),t.focusInput()},t.clearValue=function(){var e=t.state.selectValue;t.onChange(re(t.props.isMulti,[],null),{action:"clear",removedValues:e})},t.popValue=function(){var e=t.props.isMulti,n=t.state.selectValue,r=n[n.length-1],i=n.slice(0,n.length-1),o=re(e,i,i[0]||null);t.onChange(o,{action:"pop-value",removedValue:r})},t.getValue=function(){return t.state.selectValue},t.cx=function(){for(var e=arguments.length,n=new Array(e),r=0;r5||o>5}},t.onTouchEnd=function(e){t.userIsDragging||(t.controlRef&&!t.controlRef.contains(e.target)&&t.menuListRef&&!t.menuListRef.contains(e.target)&&t.blurInput(),t.initialTouchX=0,t.initialTouchY=0)},t.onControlTouchEnd=function(e){t.userIsDragging||t.onControlMouseDown(e)},t.onClearIndicatorTouchEnd=function(e){t.userIsDragging||t.onClearIndicatorMouseDown(e)},t.onDropdownIndicatorTouchEnd=function(e){t.userIsDragging||t.onDropdownIndicatorMouseDown(e)},t.handleInputChange=function(e){var n=t.props.inputValue,r=e.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(r,{action:"input-change",prevInputValue:n}),t.props.menuIsOpen||t.onMenuOpen()},t.onInputFocus=function(e){t.props.onFocus&&t.props.onFocus(e),t.setState({inputIsHiddenAfterUpdate:!1,isFocused:!0}),(t.openAfterFocus||t.props.openMenuOnFocus)&&t.openMenu("first"),t.openAfterFocus=!1},t.onInputBlur=function(e){var n=t.props.inputValue;t.menuListRef&&t.menuListRef.contains(document.activeElement)?t.inputRef.focus():(t.props.onBlur&&t.props.onBlur(e),t.onInputChange("",{action:"input-blur",prevInputValue:n}),t.onMenuClose(),t.setState({focusedValue:null,isFocused:!1}))},t.onOptionHover=function(e){t.blockOptionHover||t.state.focusedOption===e||t.setState({focusedOption:e})},t.shouldHideSelectedOptions=function(){return Ct(t.props)},t.onValueInputFocus=function(e){e.preventDefault(),e.stopPropagation(),t.focus()},t.onKeyDown=function(e){var n=t.props,r=n.isMulti,i=n.backspaceRemovesValue,o=n.escapeClearsValue,a=n.inputValue,s=n.isClearable,l=n.isDisabled,u=n.menuIsOpen,c=n.onKeyDown,h=n.tabSelectsValue,d=n.openMenuOnFocus,f=t.state,p=f.focusedOption,m=f.focusedValue,_=f.selectValue;if(!(l||"function"==typeof c&&(c(e),e.defaultPrevented))){switch(t.blockOptionHover=!0,e.key){case"ArrowLeft":if(!r||a)return;t.focusValue("previous");break;case"ArrowRight":if(!r||a)return;t.focusValue("next");break;case"Delete":case"Backspace":if(a)return;if(m)t.removeValue(m);else{if(!i)return;r?t.popValue():s&&t.clearValue()}break;case"Tab":if(t.isComposing)return;if(e.shiftKey||!u||!h||!p||d&&t.isOptionSelected(p,_))return;t.selectOption(p);break;case"Enter":if(229===e.keyCode)break;if(u){if(!p)return;if(t.isComposing)return;t.selectOption(p);break}return;case"Escape":u?(t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange("",{action:"menu-close",prevInputValue:a}),t.onMenuClose()):s&&o&&t.clearValue();break;case" ":if(a)return;if(!u){t.openMenu("first");break}if(!p)return;t.selectOption(p);break;case"ArrowUp":u?t.focusOption("up"):t.openMenu("last");break;case"ArrowDown":u?t.focusOption("down"):t.openMenu("first");break;case"PageUp":if(!u)return;t.focusOption("pageup");break;case"PageDown":if(!u)return;t.focusOption("pagedown");break;case"Home":if(!u)return;t.focusOption("first");break;case"End":if(!u)return;t.focusOption("last");break;default:return}e.preventDefault()}},t.instancePrefix="react-select-"+(t.props.instanceId||++At),t.state.selectValue=V(e.value),e.menuIsOpen&&t.state.selectValue.length){var n=t.buildFocusableOptions(),r=n.indexOf(t.state.selectValue[0]);t.state.focusedOption=n[r]}return t}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n=t.prevProps,r=t.clearFocusValueOnUpdate,i=t.inputIsHiddenAfterUpdate,a=t.ariaSelection,s=t.isFocused,l=t.prevWasFocused,u=e.options,c=e.value,h=e.menuIsOpen,d=e.inputValue,f=e.isMulti,p=V(c),m={};if(n&&(c!==n.value||u!==n.options||h!==n.menuIsOpen||d!==n.inputValue)){var _=h?function(e,t){return bt(xt(e,t))}(e,p):[],g=r?function(e,t){var n=e.focusedValue,r=e.selectValue.indexOf(n);if(r>-1){if(t.indexOf(n)>-1)return n;if(r-1?n:t[0]}(t,_),focusedValue:g,clearFocusValueOnUpdate:!1}}var y=null!=i&&e!==n?{inputIsHidden:i,inputIsHiddenAfterUpdate:void 0}:{},v=a,x=s&&l;return s&&!x&&(v={value:re(f,p,p[0]||null),options:p,action:"initial-input-focus"},x=!l),"initial-input-focus"===(null==a?void 0:a.action)&&(v=null),o(o(o({},m),y),{},{prevProps:e,ariaSelection:v,prevWasFocused:x})}}],(n=[{key:"componentDidMount",value:function(){this.startListeningComposition(),this.startListeningToTouch(),this.props.closeMenuOnScroll&&document&&document.addEventListener&&document.addEventListener("scroll",this.onScroll,!0),this.props.autoFocus&&this.focusInput(),this.props.menuIsOpen&&this.state.focusedOption&&this.menuListRef&&this.focusedOptionRef&&Y(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(e){var t=this.props,n=t.isDisabled,r=t.menuIsOpen,i=this.state.isFocused;(i&&!n&&e.isDisabled||i&&r&&!e.menuIsOpen)&&this.focusInput(),i&&n&&!e.isDisabled?this.setState({isFocused:!1},this.onMenuClose):i||n||!e.isDisabled||this.inputRef!==document.activeElement||this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(Y(this.menuListRef,this.focusedOptionRef),this.scrollToFocusedOptionOnUpdate=!1)}},{key:"componentWillUnmount",value:function(){this.stopListeningComposition(),this.stopListeningToTouch(),document.removeEventListener("scroll",this.onScroll,!0)}},{key:"onMenuOpen",value:function(){this.props.onMenuOpen()}},{key:"onMenuClose",value:function(){this.onInputChange("",{action:"menu-close",prevInputValue:this.props.inputValue}),this.props.onMenuClose()}},{key:"onInputChange",value:function(e,t){this.props.onInputChange(e,t)}},{key:"focusInput",value:function(){this.inputRef&&this.inputRef.focus()}},{key:"blurInput",value:function(){this.inputRef&&this.inputRef.blur()}},{key:"openMenu",value:function(e){var t=this,n=this.state,r=n.selectValue,i=n.isFocused,o=this.buildFocusableOptions(),a="first"===e?0:o.length-1;if(!this.props.isMulti){var s=o.indexOf(r[0]);s>-1&&(a=s)}this.scrollToFocusedOptionOnUpdate=!(i&&this.menuListRef),this.setState({inputIsHiddenAfterUpdate:!1,focusedValue:null,focusedOption:o[a]},(function(){return t.onMenuOpen()}))}},{key:"focusValue",value:function(e){var t=this.state,n=t.selectValue,r=t.focusedValue;if(this.props.isMulti){this.setState({focusedOption:null});var i=n.indexOf(r);r||(i=-1);var o=n.length-1,a=-1;if(n.length){switch(e){case"previous":a=0===i?0:-1===i?o:i-1;break;case"next":i>-1&&i0&&void 0!==arguments[0]?arguments[0]:"first",t=this.props.pageSize,n=this.state.focusedOption,r=this.getFocusableOptions();if(r.length){var i=0,o=r.indexOf(n);n||(o=-1),"up"===e?i=o>0?o-1:r.length-1:"down"===e?i=(o+1)%r.length:"pageup"===e?(i=o-t)<0&&(i=0):"pagedown"===e?(i=o+t)>r.length-1&&(i=r.length-1):"last"===e&&(i=r.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:r[i],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?"function"==typeof this.props.theme?this.props.theme(gt):o(o({},gt),this.props.theme):gt}},{key:"getCommonProps",value:function(){var e=this.clearValue,t=this.cx,n=this.getStyles,r=this.getClassNames,i=this.getValue,o=this.selectOption,a=this.setValue,s=this.props,l=s.isMulti,u=s.isRtl,c=s.options;return{clearValue:e,cx:t,getStyles:n,getClassNames:r,getValue:i,hasValue:this.hasValue(),isMulti:l,isRtl:u,options:c,selectOption:o,selectProps:s,setValue:a,theme:this.getTheme()}}},{key:"hasValue",value:function(){return this.state.selectValue.length>0}},{key:"hasOptions",value:function(){return!!this.getFocusableOptions().length}},{key:"isClearable",value:function(){var e=this.props,t=e.isClearable,n=e.isMulti;return void 0===t?n:t}},{key:"isOptionDisabled",value:function(e,t){return St(this.props,e,t)}},{key:"isOptionSelected",value:function(e,t){return kt(this.props,e,t)}},{key:"filterOption",value:function(e,t){return Mt(this.props,e,t)}},{key:"formatOptionLabel",value:function(e,t){if("function"==typeof this.props.formatOptionLabel){var n=this.props.inputValue,r=this.state.selectValue;return this.props.formatOptionLabel(e,{context:t,inputValue:n,selectValue:r})}return this.getOptionLabel(e)}},{key:"formatGroupLabel",value:function(e){return this.props.formatGroupLabel(e)}},{key:"startListeningComposition",value:function(){document&&document.addEventListener&&(document.addEventListener("compositionstart",this.onCompositionStart,!1),document.addEventListener("compositionend",this.onCompositionEnd,!1))}},{key:"stopListeningComposition",value:function(){document&&document.removeEventListener&&(document.removeEventListener("compositionstart",this.onCompositionStart),document.removeEventListener("compositionend",this.onCompositionEnd))}},{key:"startListeningToTouch",value:function(){document&&document.addEventListener&&(document.addEventListener("touchstart",this.onTouchStart,!1),document.addEventListener("touchmove",this.onTouchMove,!1),document.addEventListener("touchend",this.onTouchEnd,!1))}},{key:"stopListeningToTouch",value:function(){document&&document.removeEventListener&&(document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd))}},{key:"renderInput",value:function(){var e=this.props,t=e.isDisabled,n=e.isSearchable,r=e.inputId,i=e.inputValue,a=e.tabIndex,s=e.form,l=e.menuIsOpen,u=e.required,h=this.getComponents().Input,f=this.state,p=f.inputIsHidden,m=f.ariaSelection,_=this.commonProps,g=r||this.getElementId("input"),y=o(o(o({"aria-autocomplete":"list","aria-expanded":l,"aria-haspopup":!0,"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":this.props["aria-invalid"],"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],"aria-required":u,role:"combobox"},l&&{"aria-controls":this.getElementId("listbox"),"aria-owns":this.getElementId("listbox")}),!n&&{"aria-readonly":!0}),this.hasValue()?"initial-input-focus"===(null==m?void 0:m.action)&&{"aria-describedby":this.getElementId("live-region")}:{"aria-describedby":this.getElementId("placeholder")});return n?c.createElement(h,d({},_,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:g,innerRef:this.getInputRef,isDisabled:t,isHidden:p,onBlur:this.onInputBlur,onChange:this.handleInputChange,onFocus:this.onInputFocus,spellCheck:"false",tabIndex:a,form:s,type:"text",value:i},y)):c.createElement(et,d({id:g,innerRef:this.getInputRef,onBlur:this.onInputBlur,onChange:j,onFocus:this.onInputFocus,disabled:t,tabIndex:a,inputMode:"none",form:s,value:""},y))}},{key:"renderPlaceholderOrValue",value:function(){var e=this,t=this.getComponents(),n=t.MultiValue,r=t.MultiValueContainer,i=t.MultiValueLabel,o=t.MultiValueRemove,a=t.SingleValue,s=t.Placeholder,l=this.commonProps,u=this.props,h=u.controlShouldRenderValue,f=u.isDisabled,p=u.isMulti,m=u.inputValue,_=u.placeholder,g=this.state,y=g.selectValue,v=g.focusedValue,x=g.isFocused;if(!this.hasValue()||!h)return m?null:c.createElement(s,d({},l,{key:"placeholder",isDisabled:f,isFocused:x,innerProps:{id:this.getElementId("placeholder")}}),_);if(p)return y.map((function(t,a){var s=t===v,u="".concat(e.getOptionLabel(t),"-").concat(e.getOptionValue(t));return c.createElement(n,d({},l,{components:{Container:r,Label:i,Remove:o},isFocused:s,isDisabled:f,key:u,index:a,removeProps:{onClick:function(){return e.removeValue(t)},onTouchEnd:function(){return e.removeValue(t)},onMouseDown:function(e){e.preventDefault()}},data:t}),e.formatOptionLabel(t,"value"))}));if(m)return null;var b=y[0];return c.createElement(a,d({},l,{data:b,isDisabled:f}),this.formatOptionLabel(b,"value"))}},{key:"renderClearIndicator",value:function(){var e=this.getComponents().ClearIndicator,t=this.commonProps,n=this.props,r=n.isDisabled,i=n.isLoading,o=this.state.isFocused;if(!this.isClearable()||!e||r||!this.hasValue()||i)return null;var a={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return c.createElement(e,d({},t,{innerProps:a,isFocused:o}))}},{key:"renderLoadingIndicator",value:function(){var e=this.getComponents().LoadingIndicator,t=this.commonProps,n=this.props,r=n.isDisabled,i=n.isLoading,o=this.state.isFocused;return e&&i?c.createElement(e,d({},t,{innerProps:{"aria-hidden":"true"},isDisabled:r,isFocused:o})):null}},{key:"renderIndicatorSeparator",value:function(){var e=this.getComponents(),t=e.DropdownIndicator,n=e.IndicatorSeparator;if(!t||!n)return null;var r=this.commonProps,i=this.props.isDisabled,o=this.state.isFocused;return c.createElement(n,d({},r,{isDisabled:i,isFocused:o}))}},{key:"renderDropdownIndicator",value:function(){var e=this.getComponents().DropdownIndicator;if(!e)return null;var t=this.commonProps,n=this.props.isDisabled,r=this.state.isFocused,i={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return c.createElement(e,d({},t,{innerProps:i,isDisabled:n,isFocused:r}))}},{key:"renderMenu",value:function(){var e=this,t=this.getComponents(),n=t.Group,r=t.GroupHeading,i=t.Menu,o=t.MenuList,a=t.MenuPortal,s=t.LoadingMessage,l=t.NoOptionsMessage,u=t.Option,h=this.commonProps,f=this.state.focusedOption,p=this.props,m=p.captureMenuScroll,_=p.inputValue,g=p.isLoading,y=p.loadingMessage,v=p.minMenuHeight,x=p.maxMenuHeight,b=p.menuIsOpen,w=p.menuPlacement,E=p.menuPosition,T=p.menuPortalTarget,S=p.menuShouldBlockScroll,k=p.menuShouldScrollIntoView,M=p.noOptionsMessage,C=p.onMenuScrollToTop,A=p.onMenuScrollToBottom;if(!b)return null;var I,P=function(t,n){var r=t.type,i=t.data,o=t.isDisabled,a=t.isSelected,s=t.label,l=t.value,p=f===i,m=o?void 0:function(){return e.onOptionHover(i)},_=o?void 0:function(){return e.selectOption(i)},g="".concat(e.getElementId("option"),"-").concat(n),y={id:g,onClick:_,onMouseMove:m,onMouseOver:m,tabIndex:-1};return c.createElement(u,d({},h,{innerProps:y,data:i,isDisabled:o,isSelected:a,key:g,label:s,type:r,value:l,isFocused:p,innerRef:p?e.getFocusedOptionRef:void 0}),e.formatOptionLabel(t.data,"menu"))};if(this.hasOptions())I=this.getCategorizedOptions().map((function(t){if("group"===t.type){var i=t.data,o=t.options,a=t.index,s="".concat(e.getElementId("group"),"-").concat(a),l="".concat(s,"-heading");return c.createElement(n,d({},h,{key:s,data:i,options:o,Heading:r,headingProps:{id:l,data:t.data},label:e.formatGroupLabel(t.data)}),t.options.map((function(e){return P(e,"".concat(a,"-").concat(e.index))})))}if("option"===t.type)return P(t,"".concat(t.index))}));else if(g){var O=y({inputValue:_});if(null===O)return null;I=c.createElement(s,h,O)}else{var z=M({inputValue:_});if(null===z)return null;I=c.createElement(l,h,z)}var L={minMenuHeight:v,maxMenuHeight:x,menuPlacement:w,menuPosition:E,menuShouldScrollIntoView:k},D=c.createElement(ce,d({},h,L),(function(t){var n=t.ref,r=t.placerProps,a=r.placement,s=r.maxHeight;return c.createElement(i,d({},h,L,{innerRef:n,innerProps:{onMouseDown:e.onMenuMouseDown,onMouseMove:e.onMenuMouseMove,id:e.getElementId("listbox")},isLoading:g,placement:a}),c.createElement(dt,{captureEnabled:m,onTopArrive:C,onBottomArrive:A,lockEnabled:S},(function(t){return c.createElement(o,d({},h,{innerRef:function(n){e.getMenuListRef(n),t(n)},isLoading:g,maxHeight:s,focusedOption:f}),I)})))}));return T||"fixed"===E?c.createElement(a,d({},h,{appendTo:T,controlElement:this.controlRef,menuPlacement:w,menuPosition:E}),D):D}},{key:"renderFormField",value:function(){var e=this,t=this.props,n=t.delimiter,r=t.isDisabled,i=t.isMulti,o=t.name,a=t.required,s=this.state.selectValue;if(a&&!this.hasValue()&&!r)return c.createElement(pt,{name:o,onFocus:this.onValueInputFocus});if(o&&!r){if(i){if(n){var l=s.map((function(t){return e.getOptionValue(t)})).join(n);return c.createElement("input",{name:o,type:"hidden",value:l})}var u=s.length>0?s.map((function(t,n){return c.createElement("input",{key:"i-".concat(n),name:o,type:"hidden",value:e.getOptionValue(t)})})):c.createElement("input",{name:o,type:"hidden",value:""});return c.createElement("div",null,u)}var h=s[0]?this.getOptionValue(s[0]):"";return c.createElement("input",{name:o,type:"hidden",value:h})}}},{key:"renderLiveRegion",value:function(){var e=this.commonProps,t=this.state,n=t.ariaSelection,r=t.focusedOption,i=t.focusedValue,o=t.isFocused,a=t.selectValue,s=this.getFocusableOptions();return c.createElement(Ve,d({},e,{id:this.getElementId("live-region"),ariaSelection:n,focusedOption:r,focusedValue:i,isFocused:o,selectValue:a,focusableOptions:s}))}},{key:"render",value:function(){var e=this.getComponents(),t=e.Control,n=e.IndicatorsContainer,r=e.SelectContainer,i=e.ValueContainer,o=this.props,a=o.className,s=o.id,l=o.isDisabled,u=o.menuIsOpen,h=this.state.isFocused,f=this.commonProps=this.getCommonProps();return c.createElement(r,d({},f,{className:a,innerProps:{id:s,onKeyDown:this.onKeyDown},isDisabled:l,isFocused:h}),this.renderLiveRegion(),c.createElement(t,d({},f,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:l,isFocused:h,menuIsOpen:u}),c.createElement(i,d({},f,{isDisabled:l}),this.renderPlaceholderOrValue(),this.renderInput()),c.createElement(n,d({},f,{isDisabled:l}),this.renderClearIndicator(),this.renderLoadingIndicator(),this.renderIndicatorSeparator(),this.renderDropdownIndicator())),this.renderMenu(),this.renderFormField())}}])&&f(t.prototype,n),r&&f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),a}(c.Component);It.defaultProps=yt;n(5),n(16),n(59),n(60),n(64),n(66),n(67),n(68),n(70),n(75),n(31),n(79),n(28);var Pt=Object(c.forwardRef)((function(e,t){var n,r,i,a,s,f,p,m,_,g,y,v,x,b,w,E,T,S,k,M,C,A,I,P,O,z,L,D,R,B,F,j=(r=(n=e).defaultInputValue,i=void 0===r?"":r,a=n.defaultMenuIsOpen,s=void 0!==a&&a,f=n.defaultValue,p=void 0===f?null:f,m=n.inputValue,_=n.menuIsOpen,g=n.onChange,y=n.onInputChange,v=n.onMenuClose,x=n.onMenuOpen,b=n.value,w=u(n,h),E=l(Object(c.useState)(void 0!==m?m:i),2),T=E[0],S=E[1],k=l(Object(c.useState)(void 0!==_?_:s),2),M=k[0],C=k[1],A=l(Object(c.useState)(void 0!==b?b:p),2),I=A[0],P=A[1],O=Object(c.useCallback)((function(e,t){"function"==typeof g&&g(e,t),P(e)}),[g]),z=Object(c.useCallback)((function(e,t){var n;"function"==typeof y&&(n=y(e,t)),S(void 0!==n?n:e)}),[y]),L=Object(c.useCallback)((function(){"function"==typeof x&&x(),C(!0)}),[x]),D=Object(c.useCallback)((function(){"function"==typeof v&&v(),C(!1)}),[v]),R=void 0!==m?m:T,B=void 0!==_?_:M,F=void 0!==b?b:I,o(o({},w),{},{inputValue:R,menuIsOpen:B,onChange:O,onInputChange:z,onMenuClose:D,onMenuOpen:L,value:F}));return c.createElement(It,d({ref:t},j))}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return Q}));var r=n(0),i=n.n(r),o=n(36);const a=()=>{},s=a(),l=Object,u=e=>e===s,c=e=>"function"==typeof e,h=(e,t)=>({...e,...t}),d=new WeakMap;let f=0;const p=e=>{const t=typeof e,n=e&&e.constructor,r=n==Date;let i,o;if(l(e)!==e||r||n==RegExp)i=r?e.toJSON():"symbol"==t?e.toString():"string"==t?JSON.stringify(e):""+e;else{if(i=d.get(e),i)return i;if(i=++f+"~",d.set(e,i),n==Array){for(i="@",o=0;o{const n=m.get(e);return[()=>!u(t)&&e.get(t)||_,r=>{if(!u(t)){const i=e.get(t);t in g||(g[t]=i),n[5](t,h(i,r),i||_)}},n[6],()=>!u(t)&&t in g?g[t]:!u(t)&&e.get(t)||_]};let b=!0;const[w,E]=y&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[a,a],T={isOnline:()=>b,isVisible:()=>{const e=v&&document.visibilityState;return u(e)||"hidden"!==e}},S={initFocus:e=>(v&&document.addEventListener("visibilitychange",e),w("focus",e),()=>{v&&document.removeEventListener("visibilitychange",e),E("focus",e)}),initReconnect:e=>{const t=()=>{b=!0,e()},n=()=>{b=!1};return w("online",t),w("offline",n),()=>{E("online",t),E("offline",n)}}},k=!i.a.useId,M=!y||"Deno"in window,C=e=>y&&void 0!==window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1),A=M?r.useEffect:r.useLayoutEffect,I="undefined"!=typeof navigator&&navigator.connection,P=!M&&I&&(["slow-2g","2g"].includes(I.effectiveType)||I.saveData),O=e=>{if(c(e))try{e=e()}catch(t){e=""}const t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?p(e):"",t]};let z=0;const L=()=>++z;var D=3,R=0,B=2,F=1;async function j(...e){const[t,n,r,i]=e,o=h({populateCache:!0,throwOnError:!0},"boolean"==typeof i?{revalidate:i}:i||{});let a=o.populateCache;const l=o.rollbackOnError;let d=o.optimisticData;const f=!1!==o.revalidate,p=o.throwOnError;if(c(n)){const e=n,r=[],i=t.keys();for(const n of i)!/^\$(inf|sub)\$/.test(n)&&e(t.get(n)._k)&&r.push(n);return Promise.all(r.map(_))}return _(n);async function _(n){const[i]=O(n);if(!i)return;const[o,h]=x(t,i),[_,g,y,v]=m.get(t),b=_[i],w=()=>f&&(delete y[i],delete v[i],b&&b[0])?b[0](2).then(()=>o().data):o().data;if(e.length<3)return w();let E,T=r;const S=L();g[i]=[S,0];const k=!u(d),M=o(),C=M.data,A=M._c,I=u(A)?C:A;if(k&&(d=c(d)?d(I,C):d,h({data:d,_c:I})),c(T))try{T=T(I)}catch(e){E=e}if(T&&c(T.then)){if(T=await T.catch(e=>{E=e}),S!==g[i][0]){if(E)throw E;return T}E&&k&&(e=>"function"==typeof l?l(e):!1!==l)(E)&&(a=!0,T=I,h({data:T,_c:s}))}a&&(E||(c(a)&&(T=a(T,I)),h({data:T,error:s,_c:s}))),g[i][1]=L();const P=await w();if(h({_c:s}),!E)return a?P:T;if(p)throw E}}const N=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},U=(e,t)=>{if(!m.has(e)){const n=h(S,t),r={},i=j.bind(s,e);let o=a;const l={},u=(e,t)=>{const n=l[e]||[];return l[e]=n,n.push(t),()=>n.splice(n.indexOf(t),1)},c=(t,n,r)=>{e.set(t,n);const i=l[t];if(i)for(const e of i)e(n,r)},d=()=>{if(!m.has(e)&&(m.set(e,[r,{},{},{},i,c,u]),!M)){const t=n.initFocus(setTimeout.bind(s,N.bind(s,r,0))),i=n.initReconnect(setTimeout.bind(s,N.bind(s,r,1)));o=()=>{t&&t(),i&&i(),m.delete(e)}}};return d(),[e,i,d,o]}return[e,m.get(e)[4]]},[V,G]=U(new Map),q=h({onLoadingSlow:a,onSuccess:a,onError:a,onErrorRetry:(e,t,n,r,i)=>{const o=n.errorRetryCount,a=i.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*n.errorRetryInterval;!u(o)&&a>o||setTimeout(r,s,i)},onDiscarded:a,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:P?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:P?5e3:3e3,compare:(e,t)=>p(e)==p(t),isPaused:()=>!1,cache:V,mutate:G,fallback:{}},T),$=(e,t)=>{const n=h(e,t);if(t){const{use:r,fallback:i}=e,{use:o,fallback:a}=t;r&&o&&(n.use=r.concat(o)),i&&a&&(n.fallback=h(i,a))}return n},Z=Object(r.createContext)({}),W=y&&window.__SWR_DEVTOOLS_USE__,X=W?window.__SWR_DEVTOOLS_USE__:[],H=e=>c(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],Y=X.concat(e=>(t,n,r)=>e(t,n&&((...e)=>{const[r]=O(t),[,,,i]=m.get(V),o=i[r];return u(o)?n(...e):(delete i[r],o)}),r));W&&(window.__SWR_DEVTOOLS_REACT__=i.a);const K=i.a.use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;throw"rejected"===e.status?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),J={dedupe:!0},Q=(l.defineProperty(e=>{const{value:t}=e,n=Object(r.useContext)(Z),i=c(t),o=Object(r.useMemo)(()=>i?t(n):t,[i,n,t]),a=Object(r.useMemo)(()=>i?o:$(n,o),[i,n,o]),l=o&&o.provider,u=Object(r.useRef)(s);l&&!u.current&&(u.current=U(l(a.cache||V),o));const d=u.current;return d&&(a.cache=d[0],a.mutate=d[1]),A(()=>{if(d)return d[2]&&d[2](),d[3]},[]),Object(r.createElement)(Z.Provider,h(e,{value:a}))},"defaultValue",{value:q}),ee=(e,t,n)=>{const{cache:i,compare:a,suspense:l,fallbackData:d,revalidateOnMount:f,revalidateIfStale:p,refreshInterval:_,refreshWhenHidden:g,refreshWhenOffline:y,keepPreviousData:v}=n,[b,w,E,T]=m.get(i),[S,I]=O(e),P=Object(r.useRef)(!1),z=Object(r.useRef)(!1),N=Object(r.useRef)(S),U=Object(r.useRef)(t),V=Object(r.useRef)(n),G=()=>V.current,q=()=>G().isVisible()&&G().isOnline(),[$,Z,W,X]=x(i,S),H=Object(r.useRef)({}).current,Y=u(d)?n.fallback[S]:d,Q=(e,t)=>{for(const n in H){const r=n;if("data"===r){if(!a(e[r],t[r])){if(!u(e[r]))return!1;if(!a(le,t[r]))return!1}}else if(t[r]!==e[r])return!1}return!0},ee=Object(r.useMemo)(()=>{const e=!!S&&!!t&&(u(f)?!G().isPaused()&&!l&&(!!u(p)||p):f),n=t=>{const n=h(t);return delete n._k,e?{isValidating:!0,isLoading:!0,...n}:n},r=$(),i=X(),o=n(r),a=r===i?o:n(i);let s=o;return[()=>{const e=n($());return Q(e,s)?(s.data=e.data,s.isLoading=e.isLoading,s.isValidating=e.isValidating,s.error=e.error,s):(s=e,e)},()=>a]},[i,S]),te=Object(o.useSyncExternalStore)(Object(r.useCallback)(e=>W(S,(t,n)=>{Q(n,t)||e()}),[i,S]),ee[0],ee[1]),ne=!P.current,re=b[S]&&b[S].length>0,ie=te.data,oe=u(ie)?Y:ie,ae=te.error,se=Object(r.useRef)(oe),le=v?u(ie)?se.current:ie:oe,ue=!(re&&!u(ae))&&(ne&&!u(f)?f:!G().isPaused()&&(l?!u(oe)&&p:u(oe)||p)),ce=!!(S&&t&&ne&&ue),he=u(te.isValidating)?ce:te.isValidating,de=u(te.isLoading)?ce:te.isLoading,fe=Object(r.useCallback)(async e=>{const t=U.current;if(!S||!t||z.current||G().isPaused())return!1;let r,i,o=!0;const l=e||{},h=!E[S]||!l.dedupe,d=()=>k?!z.current&&S===N.current&&P.current:S===N.current,f={isValidating:!1,isLoading:!1},p=()=>{Z(f)},m=()=>{const e=E[S];e&&e[1]===i&&delete E[S]},_={isValidating:!0};u($().data)&&(_.isLoading=!0);try{if(h&&(Z(_),n.loadingTimeout&&u($().data)&&setTimeout(()=>{o&&d()&&G().onLoadingSlow(S,n)},n.loadingTimeout),E[S]=[t(I),L()]),[r,i]=E[S],r=await r,h&&setTimeout(m,n.dedupingInterval),!E[S]||E[S][1]!==i)return h&&d()&&G().onDiscarded(S),!1;f.error=s;const e=w[S];if(!u(e)&&(i<=e[0]||i<=e[1]||0===e[1]))return p(),h&&d()&&G().onDiscarded(S),!1;const l=$().data;f.data=a(l,r)?l:r,h&&d()&&G().onSuccess(r,S,n)}catch(e){m();const t=G(),{shouldRetryOnError:n}=t;t.isPaused()||(f.error=e,h&&d()&&(t.onError(e,S,t),(!0===n||c(n)&&n(e))&&q()&&t.onErrorRetry(e,S,t,e=>{const t=b[S];t&&t[0]&&t[0](D,e)},{retryCount:(l.retryCount||0)+1,dedupe:!0})))}return o=!1,p(),!0},[S,i]),pe=Object(r.useCallback)((...e)=>j(i,N.current,...e),[]);if(A(()=>{U.current=t,V.current=n,u(ie)||(se.current=ie)}),A(()=>{if(!S)return;const e=fe.bind(s,J);let t=0;const n=((e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const e=r.indexOf(n);e>=0&&(r[e]=r[r.length-1],r.pop())}})(S,b,(n,r={})=>{if(n==R){const n=Date.now();G().revalidateOnFocus&&n>t&&q()&&(t=n+G().focusThrottleInterval,e())}else if(n==F)G().revalidateOnReconnect&&q()&&e();else{if(n==B)return fe();if(n==D)return fe(r)}});return z.current=!1,N.current=S,P.current=!0,Z({_k:I}),ue&&(u(oe)||M?e():C(e)),()=>{z.current=!0,n()}},[S]),A(()=>{let e;function t(){const t=c(_)?_($().data):_;t&&-1!==e&&(e=setTimeout(n,t))}function n(){$().error||!g&&!G().isVisible()||!y&&!G().isOnline()?t():fe(J).then(t)}return t(),()=>{e&&(clearTimeout(e),e=-1)}},[_,g,y,S]),Object(r.useDebugValue)(le),l&&u(oe)&&S){if(!k&&M)throw new Error("Fallback data is required when using suspense in SSR.");U.current=t,V.current=n,z.current=!1;const e=T[S];if(!u(e)){const t=pe(e);K(t)}if(!u(ae))throw ae;{const e=fe(J);u(le)||(e.status="fulfilled",e.value=!0),K(e)}}return{mutate:pe,get data(){return H.data=!0,le},get error(){return H.error=!0,ae},get isValidating(){return H.isValidating=!0,he},get isLoading(){return H.isLoading=!0,de}}},function(...e){const t=h(q,Object(r.useContext)(Z)),[n,i,o]=H(e),a=$(t,o);let s=ee;const{use:l}=a,u=(l||[]).concat(Y);for(let e=u.length;e--;)s=u[e](s);return s(n,i||a.fetcher||null,a)});var ee},,,function(e,t,n){"use strict"; + */(function(){var o="Expected a function",a="__lodash_placeholder__",s=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],l="[object Arguments]",u="[object Array]",c="[object Boolean]",h="[object Date]",d="[object Error]",f="[object Function]",p="[object GeneratorFunction]",m="[object Map]",g="[object Number]",_="[object Object]",y="[object RegExp]",v="[object Set]",x="[object String]",b="[object Symbol]",w="[object WeakMap]",E="[object ArrayBuffer]",T="[object DataView]",S="[object Float32Array]",A="[object Float64Array]",k="[object Int8Array]",M="[object Int16Array]",C="[object Int32Array]",I="[object Uint8Array]",P="[object Uint16Array]",O="[object Uint32Array]",z=/\b__p \+= '';/g,L=/\b(__p \+=) '' \+/g,D=/(__e\(.*?\)|\b__t\)) \+\n'';/g,R=/&(?:amp|lt|gt|quot|#39);/g,B=/[&<>"']/g,F=RegExp(R.source),j=RegExp(B.source),U=/<%-([\s\S]+?)%>/g,N=/<%([\s\S]+?)%>/g,V=/<%=([\s\S]+?)%>/g,G=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,q=/^\w*$/,$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Z=/[\\^$.*+?()[\]{}|]/g,W=RegExp(Z.source),X=/^\s+/,H=/\s/,Y=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,K=/\{\n\/\* \[wrapped with (.+)\] \*/,J=/,? & /,Q=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ee=/[()=,{}\[\]\/\s]/,te=/\\(\\)?/g,ne=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,re=/\w*$/,ie=/^[-+]0x[0-9a-f]+$/i,oe=/^0b[01]+$/i,ae=/^\[object .+?Constructor\]$/,se=/^0o[0-7]+$/i,le=/^(?:0|[1-9]\d*)$/,ue=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ce=/($^)/,he=/['\n\r\u2028\u2029\\]/g,de="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",fe="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",pe="[\\ud800-\\udfff]",me="["+fe+"]",ge="["+de+"]",_e="\\d+",ye="[\\u2700-\\u27bf]",ve="[a-z\\xdf-\\xf6\\xf8-\\xff]",xe="[^\\ud800-\\udfff"+fe+_e+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",be="\\ud83c[\\udffb-\\udfff]",we="[^\\ud800-\\udfff]",Ee="(?:\\ud83c[\\udde6-\\uddff]){2}",Te="[\\ud800-\\udbff][\\udc00-\\udfff]",Se="[A-Z\\xc0-\\xd6\\xd8-\\xde]",Ae="(?:"+ve+"|"+xe+")",ke="(?:"+Se+"|"+xe+")",Me="(?:"+ge+"|"+be+")"+"?",Ce="[\\ufe0e\\ufe0f]?"+Me+("(?:\\u200d(?:"+[we,Ee,Te].join("|")+")[\\ufe0e\\ufe0f]?"+Me+")*"),Ie="(?:"+[ye,Ee,Te].join("|")+")"+Ce,Pe="(?:"+[we+ge+"?",ge,Ee,Te,pe].join("|")+")",Oe=RegExp("['’]","g"),ze=RegExp(ge,"g"),Le=RegExp(be+"(?="+be+")|"+Pe+Ce,"g"),De=RegExp([Se+"?"+ve+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[me,Se,"$"].join("|")+")",ke+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[me,Se+Ae,"$"].join("|")+")",Se+"?"+Ae+"+(?:['’](?:d|ll|m|re|s|t|ve))?",Se+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",_e,Ie].join("|"),"g"),Re=RegExp("[\\u200d\\ud800-\\udfff"+de+"\\ufe0e\\ufe0f]"),Be=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Fe=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],je=-1,Ue={};Ue[S]=Ue[A]=Ue[k]=Ue[M]=Ue[C]=Ue[I]=Ue["[object Uint8ClampedArray]"]=Ue[P]=Ue[O]=!0,Ue[l]=Ue[u]=Ue[E]=Ue[c]=Ue[T]=Ue[h]=Ue[d]=Ue[f]=Ue[m]=Ue[g]=Ue[_]=Ue[y]=Ue[v]=Ue[x]=Ue[w]=!1;var Ne={};Ne[l]=Ne[u]=Ne[E]=Ne[T]=Ne[c]=Ne[h]=Ne[S]=Ne[A]=Ne[k]=Ne[M]=Ne[C]=Ne[m]=Ne[g]=Ne[_]=Ne[y]=Ne[v]=Ne[x]=Ne[b]=Ne[I]=Ne["[object Uint8ClampedArray]"]=Ne[P]=Ne[O]=!0,Ne[d]=Ne[f]=Ne[w]=!1;var Ve={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ge=parseFloat,qe=parseInt,$e="object"==typeof e&&e&&e.Object===Object&&e,Ze="object"==typeof self&&self&&self.Object===Object&&self,We=$e||Ze||Function("return this")(),Xe=t&&!t.nodeType&&t,He=Xe&&"object"==typeof r&&r&&!r.nodeType&&r,Ye=He&&He.exports===Xe,Ke=Ye&&$e.process,Je=function(){try{var e=He&&He.require&&He.require("util").types;return e||Ke&&Ke.binding&&Ke.binding("util")}catch(e){}}(),Qe=Je&&Je.isArrayBuffer,et=Je&&Je.isDate,tt=Je&&Je.isMap,nt=Je&&Je.isRegExp,rt=Je&&Je.isSet,it=Je&&Je.isTypedArray;function ot(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function at(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i-1}function dt(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function Dt(e,t){for(var n=e.length;n--&&bt(t,e[n],0)>-1;);return n}function Rt(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Bt=At({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Ft=At({"&":"&","<":"<",">":">",'"':""","'":"'"});function jt(e){return"\\"+Ve[e]}function Ut(e){return Re.test(e)}function Nt(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function Vt(e,t){return function(n){return e(t(n))}}function Gt(e,t){for(var n=-1,r=e.length,i=0,o=[];++n",""":'"',"'":"'"});var Yt=function e(t){var n,r=(t=null==t?We:Yt.defaults(We.Object(),t,Yt.pick(We,Fe))).Array,i=t.Date,H=t.Error,de=t.Function,fe=t.Math,pe=t.Object,me=t.RegExp,ge=t.String,_e=t.TypeError,ye=r.prototype,ve=de.prototype,xe=pe.prototype,be=t["__core-js_shared__"],we=ve.toString,Ee=xe.hasOwnProperty,Te=0,Se=(n=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Ae=xe.toString,ke=we.call(pe),Me=We._,Ce=me("^"+we.call(Ee).replace(Z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ie=Ye?t.Buffer:void 0,Pe=t.Symbol,Le=t.Uint8Array,Re=Ie?Ie.allocUnsafe:void 0,Ve=Vt(pe.getPrototypeOf,pe),$e=pe.create,Ze=xe.propertyIsEnumerable,Xe=ye.splice,He=Pe?Pe.isConcatSpreadable:void 0,Ke=Pe?Pe.iterator:void 0,Je=Pe?Pe.toStringTag:void 0,yt=function(){try{var e=eo(pe,"defineProperty");return e({},"",{}),e}catch(e){}}(),At=t.clearTimeout!==We.clearTimeout&&t.clearTimeout,Kt=i&&i.now!==We.Date.now&&i.now,Jt=t.setTimeout!==We.setTimeout&&t.setTimeout,Qt=fe.ceil,en=fe.floor,tn=pe.getOwnPropertySymbols,nn=Ie?Ie.isBuffer:void 0,rn=t.isFinite,on=ye.join,an=Vt(pe.keys,pe),sn=fe.max,ln=fe.min,un=i.now,cn=t.parseInt,hn=fe.random,dn=ye.reverse,fn=eo(t,"DataView"),pn=eo(t,"Map"),mn=eo(t,"Promise"),gn=eo(t,"Set"),_n=eo(t,"WeakMap"),yn=eo(pe,"create"),vn=_n&&new _n,xn={},bn=Mo(fn),wn=Mo(pn),En=Mo(mn),Tn=Mo(gn),Sn=Mo(_n),An=Pe?Pe.prototype:void 0,kn=An?An.valueOf:void 0,Mn=An?An.toString:void 0;function Cn(e){if($a(e)&&!La(e)&&!(e instanceof zn)){if(e instanceof On)return e;if(Ee.call(e,"__wrapped__"))return Co(e)}return new On(e)}var In=function(){function e(){}return function(t){if(!qa(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Pn(){}function On(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function zn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Ln(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Kn(e,t,n,r,i,o){var a,s=1&t,u=2&t,d=4&t;if(n&&(a=i?n(e,r,i,o):n(e)),void 0!==a)return a;if(!qa(e))return e;var w=La(e);if(w){if(a=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&Ee.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!s)return yi(e,a)}else{var z=ro(e),L=z==f||z==p;if(Fa(e))return di(e,s);if(z==_||z==l||L&&!i){if(a=u||L?{}:oo(e),!s)return u?function(e,t){return vi(e,no(e),t)}(e,function(e,t){return e&&vi(t,ws(t),e)}(a,e)):function(e,t){return vi(e,to(e),t)}(e,Wn(a,e))}else{if(!Ne[z])return i?e:{};a=function(e,t,n){var r=e.constructor;switch(t){case E:return fi(e);case c:case h:return new r(+e);case T:return function(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case S:case A:case k:case M:case C:case I:case"[object Uint8ClampedArray]":case P:case O:return pi(e,n);case m:return new r;case g:case x:return new r(e);case y:return function(e){var t=new e.constructor(e.source,re.exec(e));return t.lastIndex=e.lastIndex,t}(e);case v:return new r;case b:return i=e,kn?pe(kn.call(i)):{}}var i}(e,z,s)}}o||(o=new Fn);var D=o.get(e);if(D)return D;o.set(e,a),Ya(e)?e.forEach((function(r){a.add(Kn(r,t,n,r,e,o))})):Za(e)&&e.forEach((function(r,i){a.set(i,Kn(r,t,n,i,e,o))}));var R=w?void 0:(d?u?Wi:Zi:u?ws:bs)(e);return st(R||e,(function(r,i){R&&(r=e[i=r]),qn(a,i,Kn(r,t,n,i,e,o))})),a}function Jn(e,t,n){var r=n.length;if(null==e)return!r;for(e=pe(e);r--;){var i=n[r],o=t[i],a=e[i];if(void 0===a&&!(i in e)||!o(a))return!1}return!0}function Qn(e,t,n){if("function"!=typeof e)throw new _e(o);return bo((function(){e.apply(void 0,n)}),t)}function er(e,t,n,r){var i=-1,o=ht,a=!0,s=e.length,l=[],u=t.length;if(!s)return l;n&&(t=ft(t,Pt(n))),r?(o=dt,a=!1):t.length>=200&&(o=zt,a=!1,t=new Bn(t));e:for(;++i-1},Dn.prototype.set=function(e,t){var n=this.__data__,r=$n(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Rn.prototype.clear=function(){this.size=0,this.__data__={hash:new Ln,map:new(pn||Dn),string:new Ln}},Rn.prototype.delete=function(e){var t=Ji(this,e).delete(e);return this.size-=t?1:0,t},Rn.prototype.get=function(e){return Ji(this,e).get(e)},Rn.prototype.has=function(e){return Ji(this,e).has(e)},Rn.prototype.set=function(e,t){var n=Ji(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Bn.prototype.add=Bn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Bn.prototype.has=function(e){return this.__data__.has(e)},Fn.prototype.clear=function(){this.__data__=new Dn,this.size=0},Fn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Fn.prototype.get=function(e){return this.__data__.get(e)},Fn.prototype.has=function(e){return this.__data__.has(e)},Fn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Dn){var r=n.__data__;if(!pn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Rn(r)}return n.set(e,t),this.size=n.size,this};var tr=wi(ur),nr=wi(cr,!0);function rr(e,t){var n=!0;return tr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function ir(e,t,n){for(var r=-1,i=e.length;++r0&&n(s)?t>1?ar(s,t-1,n,r,i):pt(i,s):r||(i[i.length]=s)}return i}var sr=Ei(),lr=Ei(!0);function ur(e,t){return e&&sr(e,t,bs)}function cr(e,t){return e&&lr(e,t,bs)}function hr(e,t){return ct(t,(function(t){return Na(e[t])}))}function dr(e,t){for(var n=0,r=(t=li(t,e)).length;null!=e&&nt}function gr(e,t){return null!=e&&Ee.call(e,t)}function _r(e,t){return null!=e&&t in pe(e)}function yr(e,t,n){for(var i=n?dt:ht,o=e[0].length,a=e.length,s=a,l=r(a),u=1/0,c=[];s--;){var h=e[s];s&&t&&(h=ft(h,Pt(t))),u=ln(h.length,u),l[s]=!n&&(t||o>=120&&h.length>=120)?new Bn(s&&h):void 0}h=e[0];var d=-1,f=l[0];e:for(;++d=s)return l;var u=n[r];return l*("desc"==u?-1:1)}}return e.index-t.index}(e,t,n)}))}function Lr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)s!==e&&Xe.call(s,l,1),Xe.call(e,l,1);return e}function Rr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;so(i)?Xe.call(e,i,1):ei(e,i)}}return e}function Br(e,t){return e+en(hn()*(t-e+1))}function Fr(e,t){var n="";if(!e||t<1||t>9007199254740991)return n;do{t%2&&(n+=e),(t=en(t/2))&&(e+=e)}while(t);return n}function jr(e,t){return wo(go(e,t,Ws),e+"")}function Ur(e){return Un(Is(e))}function Nr(e,t){var n=Is(e);return So(n,Yn(t,0,n.length))}function Vr(e,t,n,r){if(!qa(e))return e;for(var i=-1,o=(t=li(t,e)).length,a=o-1,s=e;null!=s&&++io?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var a=r(o);++i>>1,a=e[o];null!==a&&!Ja(a)&&(n?a<=t:a=200){var u=t?null:Fi(e);if(u)return qt(u);a=!1,i=zt,l=new Bn}else l=t?[]:s;e:for(;++r=r?e:Zr(e,t,n)}var hi=At||function(e){return We.clearTimeout(e)};function di(e,t){if(t)return e.slice();var n=e.length,r=Re?Re(n):new e.constructor(n);return e.copy(r),r}function fi(e){var t=new e.constructor(e.byteLength);return new Le(t).set(new Le(e)),t}function pi(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function mi(e,t){if(e!==t){var n=void 0!==e,r=null===e,i=e==e,o=Ja(e),a=void 0!==t,s=null===t,l=t==t,u=Ja(t);if(!s&&!u&&!o&&e>t||o&&a&&l&&!s&&!u||r&&a&&l||!n&&l||!i)return 1;if(!r&&!o&&!u&&e1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,a&&lo(n[0],n[1],a)&&(o=i<3?void 0:o,i=1),t=pe(t);++r-1?i[o?t[a]:a]:void 0}}function Mi(e){return $i((function(t){var n=t.length,r=n,i=On.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new _e(o);if(i&&!s&&"wrapper"==Hi(a))var s=new On([],!0)}for(r=s?r:n;++r1&&v.reverse(),h&&us))return!1;var u=o.get(e),c=o.get(t);if(u&&c)return u==t&&c==e;var h=-1,d=!0,f=2&n?new Bn:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(Y,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return st(s,(function(n){var r="_."+n[0];t&n[1]&&!ht(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(K);return t?t[1].split(J):[]}(r),n)))}function To(e){var t=0,n=0;return function(){var r=un(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function So(e,t){var n=-1,r=e.length,i=r-1;for(t=void 0===t?r:t;++n1?e[t-1]:void 0;return n="function"==typeof n?(e.pop(),n):void 0,Ho(e,n)}));function na(e){var t=Cn(e);return t.__chain__=!0,t}function ra(e,t){return t(e)}var ia=$i((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,i=function(t){return Hn(t,e)};return!(t>1||this.__actions__.length)&&r instanceof zn&&so(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ra,args:[i],thisArg:void 0}),new On(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(void 0),e}))):this.thru(i)}));var oa=xi((function(e,t,n){Ee.call(e,n)?++e[n]:Xn(e,n,1)}));var aa=ki(zo),sa=ki(Lo);function la(e,t){return(La(e)?st:tr)(e,Ki(t,3))}function ua(e,t){return(La(e)?lt:nr)(e,Ki(t,3))}var ca=xi((function(e,t,n){Ee.call(e,n)?e[n].push(t):Xn(e,n,[t])}));var ha=jr((function(e,t,n){var i=-1,o="function"==typeof t,a=Ra(e)?r(e.length):[];return tr(e,(function(e){a[++i]=o?ot(t,e,n):vr(e,t,n)})),a})),da=xi((function(e,t,n){Xn(e,n,t)}));function fa(e,t){return(La(e)?ft:Mr)(e,Ki(t,3))}var pa=xi((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var ma=jr((function(e,t){if(null==e)return[];var n=t.length;return n>1&&lo(e,t[0],t[1])?t=[]:n>2&&lo(t[0],t[1],t[2])&&(t=[t[0]]),zr(e,ar(t,1),[])})),ga=Kt||function(){return We.Date.now()};function _a(e,t,n){return t=n?void 0:t,Ui(e,128,void 0,void 0,void 0,void 0,t=e&&null==t?e.length:t)}function ya(e,t){var n;if("function"!=typeof t)throw new _e(o);return e=is(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=void 0),n}}var va=jr((function(e,t,n){var r=1;if(n.length){var i=Gt(n,Yi(va));r|=32}return Ui(e,r,t,n,i)})),xa=jr((function(e,t,n){var r=3;if(n.length){var i=Gt(n,Yi(xa));r|=32}return Ui(t,r,e,n,i)}));function ba(e,t,n){var r,i,a,s,l,u,c=0,h=!1,d=!1,f=!0;if("function"!=typeof e)throw new _e(o);function p(t){var n=r,o=i;return r=i=void 0,c=t,s=e.apply(o,n)}function m(e){return c=e,l=bo(_,t),h?p(e):s}function g(e){var n=e-u;return void 0===u||n>=t||n<0||d&&e-c>=a}function _(){var e=ga();if(g(e))return y(e);l=bo(_,function(e){var n=t-(e-u);return d?ln(n,a-(e-c)):n}(e))}function y(e){return l=void 0,f&&r?p(e):(r=i=void 0,s)}function v(){var e=ga(),n=g(e);if(r=arguments,i=this,u=e,n){if(void 0===l)return m(u);if(d)return hi(l),l=bo(_,t),p(u)}return void 0===l&&(l=bo(_,t)),s}return t=as(t)||0,qa(n)&&(h=!!n.leading,a=(d="maxWait"in n)?sn(as(n.maxWait)||0,t):a,f="trailing"in n?!!n.trailing:f),v.cancel=function(){void 0!==l&&hi(l),c=0,r=u=i=l=void 0},v.flush=function(){return void 0===l?s:y(ga())},v}var wa=jr((function(e,t){return Qn(e,1,t)})),Ea=jr((function(e,t,n){return Qn(e,as(t)||0,n)}));function Ta(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new _e(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Ta.Cache||Rn),n}function Sa(e){if("function"!=typeof e)throw new _e(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Ta.Cache=Rn;var Aa=ui((function(e,t){var n=(t=1==t.length&&La(t[0])?ft(t[0],Pt(Ki())):ft(ar(t,1),Pt(Ki()))).length;return jr((function(r){for(var i=-1,o=ln(r.length,n);++i=t})),za=xr(function(){return arguments}())?xr:function(e){return $a(e)&&Ee.call(e,"callee")&&!Ze.call(e,"callee")},La=r.isArray,Da=Qe?Pt(Qe):function(e){return $a(e)&&pr(e)==E};function Ra(e){return null!=e&&Ga(e.length)&&!Na(e)}function Ba(e){return $a(e)&&Ra(e)}var Fa=nn||al,ja=et?Pt(et):function(e){return $a(e)&&pr(e)==h};function Ua(e){if(!$a(e))return!1;var t=pr(e);return t==d||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Xa(e)}function Na(e){if(!qa(e))return!1;var t=pr(e);return t==f||t==p||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Va(e){return"number"==typeof e&&e==is(e)}function Ga(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function qa(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $a(e){return null!=e&&"object"==typeof e}var Za=tt?Pt(tt):function(e){return $a(e)&&ro(e)==m};function Wa(e){return"number"==typeof e||$a(e)&&pr(e)==g}function Xa(e){if(!$a(e)||pr(e)!=_)return!1;var t=Ve(e);if(null===t)return!0;var n=Ee.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&we.call(n)==ke}var Ha=nt?Pt(nt):function(e){return $a(e)&&pr(e)==y};var Ya=rt?Pt(rt):function(e){return $a(e)&&ro(e)==v};function Ka(e){return"string"==typeof e||!La(e)&&$a(e)&&pr(e)==x}function Ja(e){return"symbol"==typeof e||$a(e)&&pr(e)==b}var Qa=it?Pt(it):function(e){return $a(e)&&Ga(e.length)&&!!Ue[pr(e)]};var es=Di(kr),ts=Di((function(e,t){return e<=t}));function ns(e){if(!e)return[];if(Ra(e))return Ka(e)?Wt(e):yi(e);if(Ke&&e[Ke])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Ke]());var t=ro(e);return(t==m?Nt:t==v?qt:Is)(e)}function rs(e){return e?(e=as(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function is(e){var t=rs(e),n=t%1;return t==t?n?t-n:t:0}function os(e){return e?Yn(is(e),0,4294967295):0}function as(e){if("number"==typeof e)return e;if(Ja(e))return NaN;if(qa(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=qa(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=It(e);var n=oe.test(e);return n||se.test(e)?qe(e.slice(2),n?2:8):ie.test(e)?NaN:+e}function ss(e){return vi(e,ws(e))}function ls(e){return null==e?"":Jr(e)}var us=bi((function(e,t){if(fo(t)||Ra(t))vi(t,bs(t),e);else for(var n in t)Ee.call(t,n)&&qn(e,n,t[n])})),cs=bi((function(e,t){vi(t,ws(t),e)})),hs=bi((function(e,t,n,r){vi(t,ws(t),e,r)})),ds=bi((function(e,t,n,r){vi(t,bs(t),e,r)})),fs=$i(Hn);var ps=jr((function(e,t){e=pe(e);var n=-1,r=t.length,i=r>2?t[2]:void 0;for(i&&lo(t[0],t[1],i)&&(r=1);++n1),t})),vi(e,Wi(e),n),r&&(n=Kn(n,7,Gi));for(var i=t.length;i--;)ei(n,t[i]);return n}));var As=$i((function(e,t){return null==e?{}:function(e,t){return Lr(e,t,(function(t,n){return _s(e,n)}))}(e,t)}));function ks(e,t){if(null==e)return{};var n=ft(Wi(e),(function(e){return[e]}));return t=Ki(t),Lr(e,n,(function(e,n){return t(e,n[0])}))}var Ms=ji(bs),Cs=ji(ws);function Is(e){return null==e?[]:Ot(e,bs(e))}var Ps=Si((function(e,t,n){return t=t.toLowerCase(),e+(n?Os(t):t)}));function Os(e){return Us(ls(e).toLowerCase())}function zs(e){return(e=ls(e))&&e.replace(ue,Bt).replace(ze,"")}var Ls=Si((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ds=Si((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Rs=Ti("toLowerCase");var Bs=Si((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Fs=Si((function(e,t,n){return e+(n?" ":"")+Us(t)}));var js=Si((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Us=Ti("toUpperCase");function Ns(e,t,n){return e=ls(e),void 0===(t=n?void 0:t)?function(e){return Be.test(e)}(e)?function(e){return e.match(De)||[]}(e):function(e){return e.match(Q)||[]}(e):e.match(t)||[]}var Vs=jr((function(e,t){try{return ot(e,void 0,t)}catch(e){return Ua(e)?e:new H(e)}})),Gs=$i((function(e,t){return st(t,(function(t){t=ko(t),Xn(e,t,va(e[t],e))})),e}));function qs(e){return function(){return e}}var $s=Mi(),Zs=Mi(!0);function Ws(e){return e}function Xs(e){return Tr("function"==typeof e?e:Kn(e,1))}var Hs=jr((function(e,t){return function(n){return vr(n,e,t)}})),Ys=jr((function(e,t){return function(n){return vr(e,n,t)}}));function Ks(e,t,n){var r=bs(t),i=hr(t,r);null!=n||qa(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=hr(t,bs(t)));var o=!(qa(n)&&"chain"in n&&!n.chain),a=Na(e);return st(i,(function(n){var r=t[n];e[n]=r,a&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__),i=n.__actions__=yi(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,pt([this.value()],arguments))})})),e}function Js(){}var Qs=Oi(ft),el=Oi(ut),tl=Oi(_t);function nl(e){return uo(e)?St(ko(e)):function(e){return function(t){return dr(t,e)}}(e)}var rl=Li(),il=Li(!0);function ol(){return[]}function al(){return!1}var sl=Pi((function(e,t){return e+t}),0),ll=Bi("ceil"),ul=Pi((function(e,t){return e/t}),1),cl=Bi("floor");var hl,dl=Pi((function(e,t){return e*t}),1),fl=Bi("round"),pl=Pi((function(e,t){return e-t}),0);return Cn.after=function(e,t){if("function"!=typeof t)throw new _e(o);return e=is(e),function(){if(--e<1)return t.apply(this,arguments)}},Cn.ary=_a,Cn.assign=us,Cn.assignIn=cs,Cn.assignInWith=hs,Cn.assignWith=ds,Cn.at=fs,Cn.before=ya,Cn.bind=va,Cn.bindAll=Gs,Cn.bindKey=xa,Cn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return La(e)?e:[e]},Cn.chain=na,Cn.chunk=function(e,t,n){t=(n?lo(e,t,n):void 0===t)?1:sn(is(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var o=0,a=0,s=r(Qt(i/t));oi?0:i+n),(r=void 0===r||r>i?i:is(r))<0&&(r+=i),r=n>r?0:os(r);n>>0)?(e=ls(e))&&("string"==typeof t||null!=t&&!Ha(t))&&!(t=Jr(t))&&Ut(e)?ci(Wt(e),0,n):e.split(t,n):[]},Cn.spread=function(e,t){if("function"!=typeof e)throw new _e(o);return t=null==t?0:sn(is(t),0),jr((function(n){var r=n[t],i=ci(n,0,t);return r&&pt(i,r),ot(e,this,i)}))},Cn.tail=function(e){var t=null==e?0:e.length;return t?Zr(e,1,t):[]},Cn.take=function(e,t,n){return e&&e.length?Zr(e,0,(t=n||void 0===t?1:is(t))<0?0:t):[]},Cn.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?Zr(e,(t=r-(t=n||void 0===t?1:is(t)))<0?0:t,r):[]},Cn.takeRightWhile=function(e,t){return e&&e.length?ni(e,Ki(t,3),!1,!0):[]},Cn.takeWhile=function(e,t){return e&&e.length?ni(e,Ki(t,3)):[]},Cn.tap=function(e,t){return t(e),e},Cn.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new _e(o);return qa(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),ba(e,t,{leading:r,maxWait:t,trailing:i})},Cn.thru=ra,Cn.toArray=ns,Cn.toPairs=Ms,Cn.toPairsIn=Cs,Cn.toPath=function(e){return La(e)?ft(e,ko):Ja(e)?[e]:yi(Ao(ls(e)))},Cn.toPlainObject=ss,Cn.transform=function(e,t,n){var r=La(e),i=r||Fa(e)||Qa(e);if(t=Ki(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:qa(e)&&Na(o)?In(Ve(e)):{}}return(i?st:ur)(e,(function(e,r,i){return t(n,e,r,i)})),n},Cn.unary=function(e){return _a(e,1)},Cn.union=$o,Cn.unionBy=Zo,Cn.unionWith=Wo,Cn.uniq=function(e){return e&&e.length?Qr(e):[]},Cn.uniqBy=function(e,t){return e&&e.length?Qr(e,Ki(t,2)):[]},Cn.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?Qr(e,void 0,t):[]},Cn.unset=function(e,t){return null==e||ei(e,t)},Cn.unzip=Xo,Cn.unzipWith=Ho,Cn.update=function(e,t,n){return null==e?e:ti(e,t,si(n))},Cn.updateWith=function(e,t,n,r){return r="function"==typeof r?r:void 0,null==e?e:ti(e,t,si(n),r)},Cn.values=Is,Cn.valuesIn=function(e){return null==e?[]:Ot(e,ws(e))},Cn.without=Yo,Cn.words=Ns,Cn.wrap=function(e,t){return ka(si(t),e)},Cn.xor=Ko,Cn.xorBy=Jo,Cn.xorWith=Qo,Cn.zip=ea,Cn.zipObject=function(e,t){return oi(e||[],t||[],qn)},Cn.zipObjectDeep=function(e,t){return oi(e||[],t||[],Vr)},Cn.zipWith=ta,Cn.entries=Ms,Cn.entriesIn=Cs,Cn.extend=cs,Cn.extendWith=hs,Ks(Cn,Cn),Cn.add=sl,Cn.attempt=Vs,Cn.camelCase=Ps,Cn.capitalize=Os,Cn.ceil=ll,Cn.clamp=function(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=(n=as(n))==n?n:0),void 0!==t&&(t=(t=as(t))==t?t:0),Yn(as(e),t,n)},Cn.clone=function(e){return Kn(e,4)},Cn.cloneDeep=function(e){return Kn(e,5)},Cn.cloneDeepWith=function(e,t){return Kn(e,5,t="function"==typeof t?t:void 0)},Cn.cloneWith=function(e,t){return Kn(e,4,t="function"==typeof t?t:void 0)},Cn.conformsTo=function(e,t){return null==t||Jn(e,t,bs(t))},Cn.deburr=zs,Cn.defaultTo=function(e,t){return null==e||e!=e?t:e},Cn.divide=ul,Cn.endsWith=function(e,t,n){e=ls(e),t=Jr(t);var r=e.length,i=n=void 0===n?r:Yn(is(n),0,r);return(n-=t.length)>=0&&e.slice(n,i)==t},Cn.eq=Ia,Cn.escape=function(e){return(e=ls(e))&&j.test(e)?e.replace(B,Ft):e},Cn.escapeRegExp=function(e){return(e=ls(e))&&W.test(e)?e.replace(Z,"\\$&"):e},Cn.every=function(e,t,n){var r=La(e)?ut:rr;return n&&lo(e,t,n)&&(t=void 0),r(e,Ki(t,3))},Cn.find=aa,Cn.findIndex=zo,Cn.findKey=function(e,t){return vt(e,Ki(t,3),ur)},Cn.findLast=sa,Cn.findLastIndex=Lo,Cn.findLastKey=function(e,t){return vt(e,Ki(t,3),cr)},Cn.floor=cl,Cn.forEach=la,Cn.forEachRight=ua,Cn.forIn=function(e,t){return null==e?e:sr(e,Ki(t,3),ws)},Cn.forInRight=function(e,t){return null==e?e:lr(e,Ki(t,3),ws)},Cn.forOwn=function(e,t){return e&&ur(e,Ki(t,3))},Cn.forOwnRight=function(e,t){return e&&cr(e,Ki(t,3))},Cn.get=gs,Cn.gt=Pa,Cn.gte=Oa,Cn.has=function(e,t){return null!=e&&io(e,t,gr)},Cn.hasIn=_s,Cn.head=Ro,Cn.identity=Ws,Cn.includes=function(e,t,n,r){e=Ra(e)?e:Is(e),n=n&&!r?is(n):0;var i=e.length;return n<0&&(n=sn(i+n,0)),Ka(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&bt(e,t,n)>-1},Cn.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:is(n);return i<0&&(i=sn(r+i,0)),bt(e,t,i)},Cn.inRange=function(e,t,n){return t=rs(t),void 0===n?(n=t,t=0):n=rs(n),function(e,t,n){return e>=ln(t,n)&&e=-9007199254740991&&e<=9007199254740991},Cn.isSet=Ya,Cn.isString=Ka,Cn.isSymbol=Ja,Cn.isTypedArray=Qa,Cn.isUndefined=function(e){return void 0===e},Cn.isWeakMap=function(e){return $a(e)&&ro(e)==w},Cn.isWeakSet=function(e){return $a(e)&&"[object WeakSet]"==pr(e)},Cn.join=function(e,t){return null==e?"":on.call(e,t)},Cn.kebabCase=Ls,Cn.last=Uo,Cn.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=r;return void 0!==n&&(i=(i=is(n))<0?sn(r+i,0):ln(i,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,i):xt(e,Et,i,!0)},Cn.lowerCase=Ds,Cn.lowerFirst=Rs,Cn.lt=es,Cn.lte=ts,Cn.max=function(e){return e&&e.length?ir(e,Ws,mr):void 0},Cn.maxBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),mr):void 0},Cn.mean=function(e){return Tt(e,Ws)},Cn.meanBy=function(e,t){return Tt(e,Ki(t,2))},Cn.min=function(e){return e&&e.length?ir(e,Ws,kr):void 0},Cn.minBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),kr):void 0},Cn.stubArray=ol,Cn.stubFalse=al,Cn.stubObject=function(){return{}},Cn.stubString=function(){return""},Cn.stubTrue=function(){return!0},Cn.multiply=dl,Cn.nth=function(e,t){return e&&e.length?Or(e,is(t)):void 0},Cn.noConflict=function(){return We._===this&&(We._=Me),this},Cn.noop=Js,Cn.now=ga,Cn.pad=function(e,t,n){e=ls(e);var r=(t=is(t))?Zt(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return zi(en(i),n)+e+zi(Qt(i),n)},Cn.padEnd=function(e,t,n){e=ls(e);var r=(t=is(t))?Zt(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var i=hn();return ln(e+i*(t-e+Ge("1e-"+((i+"").length-1))),t)}return Br(e,t)},Cn.reduce=function(e,t,n){var r=La(e)?mt:kt,i=arguments.length<3;return r(e,Ki(t,4),n,i,tr)},Cn.reduceRight=function(e,t,n){var r=La(e)?gt:kt,i=arguments.length<3;return r(e,Ki(t,4),n,i,nr)},Cn.repeat=function(e,t,n){return t=(n?lo(e,t,n):void 0===t)?1:is(t),Fr(ls(e),t)},Cn.replace=function(){var e=arguments,t=ls(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Cn.result=function(e,t,n){var r=-1,i=(t=li(t,e)).length;for(i||(i=1,e=void 0);++r9007199254740991)return[];var n=4294967295,r=ln(e,4294967295);e-=4294967295;for(var i=Ct(r,t=Ki(t));++n=o)return e;var s=n-Zt(r);if(s<1)return r;var l=a?ci(a,0,s).join(""):e.slice(0,s);if(void 0===i)return l+r;if(a&&(s+=l.length-s),Ha(i)){if(e.slice(s).search(i)){var u,c=l;for(i.global||(i=me(i.source,ls(re.exec(i))+"g")),i.lastIndex=0;u=i.exec(c);)var h=u.index;l=l.slice(0,void 0===h?s:h)}}else if(e.indexOf(Jr(i),s)!=s){var d=l.lastIndexOf(i);d>-1&&(l=l.slice(0,d))}return l+r},Cn.unescape=function(e){return(e=ls(e))&&F.test(e)?e.replace(R,Ht):e},Cn.uniqueId=function(e){var t=++Te;return ls(e)+t},Cn.upperCase=js,Cn.upperFirst=Us,Cn.each=la,Cn.eachRight=ua,Cn.first=Ro,Ks(Cn,(hl={},ur(Cn,(function(e,t){Ee.call(Cn.prototype,t)||(hl[t]=e)})),hl),{chain:!1}),Cn.VERSION="4.17.21",st(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Cn[e].placeholder=Cn})),st(["drop","take"],(function(e,t){zn.prototype[e]=function(n){n=void 0===n?1:sn(is(n),0);var r=this.__filtered__&&!t?new zn(this):this.clone();return r.__filtered__?r.__takeCount__=ln(n,r.__takeCount__):r.__views__.push({size:ln(n,4294967295),type:e+(r.__dir__<0?"Right":"")}),r},zn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),st(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;zn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Ki(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),st(["head","last"],(function(e,t){var n="take"+(t?"Right":"");zn.prototype[e]=function(){return this[n](1).value()[0]}})),st(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");zn.prototype[e]=function(){return this.__filtered__?new zn(this):this[n](1)}})),zn.prototype.compact=function(){return this.filter(Ws)},zn.prototype.find=function(e){return this.filter(e).head()},zn.prototype.findLast=function(e){return this.reverse().find(e)},zn.prototype.invokeMap=jr((function(e,t){return"function"==typeof e?new zn(this):this.map((function(n){return vr(n,e,t)}))})),zn.prototype.reject=function(e){return this.filter(Sa(Ki(e)))},zn.prototype.slice=function(e,t){e=is(e);var n=this;return n.__filtered__&&(e>0||t<0)?new zn(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),void 0!==t&&(n=(t=is(t))<0?n.dropRight(-t):n.take(t-e)),n)},zn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},zn.prototype.toArray=function(){return this.take(4294967295)},ur(zn.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),i=Cn[r?"take"+("last"==t?"Right":""):t],o=r||/^find/.test(t);i&&(Cn.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,s=t instanceof zn,l=a[0],u=s||La(t),c=function(e){var t=i.apply(Cn,pt([e],a));return r&&h?t[0]:t};u&&n&&"function"==typeof l&&1!=l.length&&(s=u=!1);var h=this.__chain__,d=!!this.__actions__.length,f=o&&!h,p=s&&!d;if(!o&&u){t=p?t:new zn(this);var m=e.apply(t,a);return m.__actions__.push({func:ra,args:[c],thisArg:void 0}),new On(m,h)}return f&&p?e.apply(this,a):(m=this.thru(c),f?r?m.value()[0]:m.value():m)})})),st(["pop","push","shift","sort","splice","unshift"],(function(e){var t=ye[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);Cn.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(La(i)?i:[],e)}return this[n]((function(n){return t.apply(La(n)?n:[],e)}))}})),ur(zn.prototype,(function(e,t){var n=Cn[t];if(n){var r=n.name+"";Ee.call(xn,r)||(xn[r]=[]),xn[r].push({name:t,func:n})}})),xn[Ci(void 0,2).name]=[{name:"wrapper",func:void 0}],zn.prototype.clone=function(){var e=new zn(this.__wrapped__);return e.__actions__=yi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=yi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=yi(this.__views__),e},zn.prototype.reverse=function(){if(this.__filtered__){var e=new zn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},zn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=La(e),r=t<0,i=n?e.length:0,o=function(e,t,n){var r=-1,i=n.length;for(;++r=this.__values__.length;return{done:e,value:e?void 0:this.__values__[this.__index__++]}},Cn.prototype.plant=function(e){for(var t,n=this;n instanceof Pn;){var r=Co(n);r.__index__=0,r.__values__=void 0,t?i.__wrapped__=r:t=r;var i=r;n=n.__wrapped__}return i.__wrapped__=e,t},Cn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof zn){var t=e;return this.__actions__.length&&(t=new zn(this)),(t=t.reverse()).__actions__.push({func:ra,args:[qo],thisArg:void 0}),new On(t,this.__chain__)}return this.thru(qo)},Cn.prototype.toJSON=Cn.prototype.valueOf=Cn.prototype.value=function(){return ri(this.__wrapped__,this.__actions__)},Cn.prototype.first=Cn.prototype.head,Ke&&(Cn.prototype[Ke]=function(){return this}),Cn}();We._=Yt,void 0===(i=function(){return Yt}.call(t,n,t,r))||(r.exports=i)}).call(this)}).call(this,n(17),n(102)(e))},function(e,t,n){"use strict";var r=n(0),i=n.n(r),o=n(18),a=n.n(o);function s(){return(s=Object.assign||function(e){for(var t=1;t=d.top+d.height||p.left+p.width>=d.left+d.width))break;u++}return l},f=0,p=Object(r.forwardRef)((function(e,t){var n=e.trigger,o=void 0===n?null:n,c=e.onOpen,h=void 0===c?function(){}:c,p=e.onClose,m=void 0===p?function(){}:p,g=e.defaultOpen,_=void 0!==g&&g,y=e.open,v=void 0===y?void 0:y,x=e.disabled,b=void 0!==x&&x,w=e.nested,E=void 0!==w&&w,T=e.closeOnDocumentClick,S=void 0===T||T,A=e.repositionOnResize,k=void 0===A||A,M=e.closeOnEscape,C=void 0===M||M,I=e.on,P=void 0===I?["click"]:I,O=e.contentStyle,z=void 0===O?{}:O,L=e.arrowStyle,D=void 0===L?{}:L,R=e.overlayStyle,B=void 0===R?{}:R,F=e.className,j=void 0===F?"":F,U=e.position,N=void 0===U?"bottom center":U,V=e.modal,G=void 0!==V&&V,q=e.lockScroll,$=void 0!==q&&q,Z=e.arrow,W=void 0===Z||Z,X=e.offsetX,H=void 0===X?0:X,Y=e.offsetY,K=void 0===Y?0:Y,J=e.mouseEnterDelay,Q=void 0===J?100:J,ee=e.mouseLeaveDelay,te=void 0===ee?100:ee,ne=e.keepTooltipInside,re=void 0!==ne&&ne,ie=e.children,oe=Object(r.useState)(v||_),ae=oe[0],se=oe[1],le=Object(r.useRef)(null),ue=Object(r.useRef)(null),ce=Object(r.useRef)(null),he=Object(r.useRef)(null),de=Object(r.useRef)("popup-"+ ++f),fe=!!G||!o,pe=Object(r.useRef)(0);l((function(){return ae?(he.current=document.activeElement,Ae(),Ee(),be()):we(),function(){clearTimeout(pe.current)}}),[ae]),Object(r.useEffect)((function(){"boolean"==typeof v&&(v?me():ge())}),[v,b]);var me=function(e){ae||b||(se(!0),setTimeout((function(){return h(e)}),0))},ge=function(e){var t;ae&&!b&&(se(!1),fe&&(null===(t=he.current)||void 0===t||t.focus()),setTimeout((function(){return m(e)}),0))},_e=function(e){null==e||e.stopPropagation(),ae?ge(e):me(e)},ye=function(e){clearTimeout(pe.current),pe.current=setTimeout((function(){return me(e)}),Q)},ve=function(e){null==e||e.preventDefault(),_e()},xe=function(e){clearTimeout(pe.current),pe.current=setTimeout((function(){return ge(e)}),te)},be=function(){fe&&$&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},we=function(){fe&&$&&(document.getElementsByTagName("body")[0].style.overflow="auto")},Ee=function(){var e,t=null==ue||null===(e=ue.current)||void 0===e?void 0:e.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),n=Array.prototype.slice.call(t)[0];null==n||n.focus()};Object(r.useImperativeHandle)(t,(function(){return{open:function(){me()},close:function(){ge()},toggle:function(){_e()}}}));var Te,Se,Ae=function(){if(!fe&&ae&&(null==le?void 0:le.current)&&(null==le?void 0:le.current)&&(null==ue?void 0:ue.current)){var e,t,n=le.current.getBoundingClientRect(),r=ue.current.getBoundingClientRect(),i=d(n,r,N,W,{offsetX:H,offsetY:K},re);if(ue.current.style.top=i.top+window.scrollY+"px",ue.current.style.left=i.left+window.scrollX+"px",W&&ce.current)ce.current.style.transform=i.transform,ce.current.style.setProperty("-ms-transform",i.transform),ce.current.style.setProperty("-webkit-transform",i.transform),ce.current.style.top=(null===(e=D.top)||void 0===e?void 0:e.toString())||i.arrowTop,ce.current.style.left=(null===(t=D.left)||void 0===t?void 0:t.toString())||i.arrowLeft}};Te=ge,void 0===(Se=C)&&(Se=!0),Object(r.useEffect)((function(){if(Se){var e=function(e){"Escape"===e.key&&Te(e)};return document.addEventListener("keyup",e),function(){Se&&document.removeEventListener("keyup",e)}}}),[Te,Se]),function(e,t){void 0===t&&(t=!0),Object(r.useEffect)((function(){if(t){var n=function(t){if(9===t.keyCode){var n,r=null==e||null===(n=e.current)||void 0===n?void 0:n.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),i=Array.prototype.slice.call(r);if(1===i.length)return void t.preventDefault();var o=i[0],a=i[i.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),a.focus()):document.activeElement===a&&(t.preventDefault(),o.focus())}};return document.addEventListener("keydown",n),function(){t&&document.removeEventListener("keydown",n)}}}),[e,t])}(ue,ae&&fe),function(e,t){void 0===t&&(t=!0),Object(r.useEffect)((function(){if(t){var n=function(){e()};return window.addEventListener("resize",n),function(){t&&window.removeEventListener("resize",n)}}}),[e,t])}(Ae,k),function(e,t,n){void 0===n&&(n=!0),Object(r.useEffect)((function(){if(n){var r=function(n){var r=Array.isArray(e)?e:[e],i=!1;r.forEach((function(e){e.current&&!e.current.contains(n.target)||(i=!0)})),n.stopPropagation(),i||t(n)};return document.addEventListener("mousedown",r),document.addEventListener("touchstart",r),function(){n&&(document.removeEventListener("mousedown",r),document.removeEventListener("touchstart",r))}}}),[e,t,n])}(o?[ue,le]:[ue],ge,S&&!E);var ke,Me=function(){return i.a.createElement("div",Object.assign({},(e=fe?u.popupContent.modal:u.popupContent.tooltip,t={className:"popup-content "+(""!==j?j.split(" ").map((function(e){return e+"-content"})).join(" "):""),style:s({},e,z,{pointerEvents:"auto"}),ref:ue,onClick:function(e){e.stopPropagation()}},!G&&P.indexOf("hover")>=0&&(t.onMouseEnter=ye,t.onMouseLeave=xe),t),{key:"C",role:fe?"dialog":"tooltip",id:de.current}),W&&!fe&&i.a.createElement("div",{ref:ce,style:u.popupArrow},i.a.createElement("svg",{"data-testid":"arrow",className:"popup-arrow "+(""!==j?j.split(" ").map((function(e){return e+"-arrow"})).join(" "):""),viewBox:"0 0 32 16",style:s({position:"absolute"},D)},i.a.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),ie&&"function"==typeof ie?ie(ge,ae):ie);var e,t},Ce=!(P.indexOf("hover")>=0),Ie=fe?u.overlay.modal:u.overlay.tooltip,Pe=[Ce&&i.a.createElement("div",{key:"O","data-testid":"overlay","data-popup":fe?"modal":"tooltip",className:"popup-overlay "+(""!==j?j.split(" ").map((function(e){return e+"-overlay"})).join(" "):""),style:s({},Ie,B,{pointerEvents:S&&E||fe?"auto":"none"}),onClick:S&&E?ge:void 0,tabIndex:-1},fe&&Me()),!fe&&Me()];return i.a.createElement(i.a.Fragment,null,function(){for(var e={key:"T",ref:le,"aria-describedby":de.current},t=Array.isArray(P)?P:[P],n=0,r=t.length;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}n.d(t,"a",(function(){return Pt}));var c=n(0),h=["defaultInputValue","defaultMenuIsOpen","defaultValue","inputValue","menuIsOpen","onChange","onInputChange","onMenuClose","onMenuOpen","value"];function d(){return(d=Object.assign?Object.assign.bind():function(e){for(var t=1;te.brand+"/"+e.version).join(" "):navigator.userAgent}function k(e){return e instanceof E(e).HTMLElement}function M(e){return e instanceof E(e).Element}function C(e){if("undefined"==typeof ShadowRoot)return!1;return e instanceof E(e).ShadowRoot||e instanceof ShadowRoot}function I(e){const{overflow:t,overflowX:n,overflowY:r}=T(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function P(){return!/^((?!chrome|android).)*safari/i.test(A())}Math.min,Math.max;const O=Math.round;function z(e,t,n){var r,i,o,a;void 0===t&&(t=!1),void 0===n&&(n=!1);const s=e.getBoundingClientRect();let l=1,u=1;t&&k(e)&&(l=e.offsetWidth>0&&O(s.width)/e.offsetWidth||1,u=e.offsetHeight>0&&O(s.height)/e.offsetHeight||1);const c=M(e)?E(e):window,h=!P()&&n,d=(s.left+(h&&null!=(r=null==(i=c.visualViewport)?void 0:i.offsetLeft)?r:0))/l,f=(s.top+(h&&null!=(o=null==(a=c.visualViewport)?void 0:a.offsetTop)?o:0))/u,p=s.width/l,m=s.height/u;return{width:p,height:m,top:f,right:d+p,bottom:f+m,left:d,x:d,y:f}}function L(e){return(t=e,(t instanceof E(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function D(e){return"html"===S(e)?e:e.assignedSlot||e.parentNode||(C(e)?e.host:null)||L(e)}function R(e,t){var n;void 0===t&&(t=[]);const r=function e(t){const n=D(t);return["html","body","#document"].includes(S(n))?t.ownerDocument.body:k(n)&&I(n)?n:e(n)}(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),o=E(r),a=i?[o].concat(o.visualViewport||[],I(r)?r:[]):r,s=t.concat(a);return i?s:s.concat(R(a))}var B=c.useLayoutEffect,F=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],j=function(){};function U(e,t){return t?"-"===t[0]?e+t:e+"__"+t:e}function N(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i-1}function Z(e){return $(e)?window.pageYOffset:e.scrollTop}function W(e,t){$(e)?window.scrollTo(0,t):e.scrollTop=t}function X(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function H(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:j,i=Z(e),o=t-i,a=10,s=0;function l(){var t=X(s+=a,i,o,n);W(e,t),sn.bottom?W(e,Math.min(t.offsetTop+t.clientHeight-e.offsetHeight+i,e.scrollHeight)):r.top-i=p)return{placement:"bottom",maxHeight:t};if(T>=p&&!a)return o&&H(l,S,160),{placement:"bottom",maxHeight:t};if(!a&&T>=r||a&&w>=r)return o&&H(l,S,160),{placement:"bottom",maxHeight:a?w-v:T-v};if("auto"===i||a){var k=t,M=a?b:E;return M>=r&&(k=Math.min(M-v-s,t)),{placement:"top",maxHeight:k}}if("bottom"===i)return o&&W(l,S),{placement:"bottom",maxHeight:t};break;case"top":if(b>=p)return{placement:"top",maxHeight:t};if(E>=p&&!a)return o&&H(l,A,160),{placement:"top",maxHeight:t};if(!a&&E>=r||a&&b>=r){var C=t;return(!a&&E>=r||a&&b>=r)&&(C=a?b-x:E-x),o&&H(l,A,160),{placement:"top",maxHeight:C}}return{placement:"bottom",maxHeight:t};default:throw new Error('Invalid placement provided "'.concat(i,'".'))}return u}var se,le=function(e){return"auto"===e?"bottom":e},ue=Object(c.createContext)(null),ce=function(e){var t=e.children,n=e.minMenuHeight,r=e.maxMenuHeight,i=e.menuPlacement,a=e.menuPosition,s=e.menuShouldScrollIntoView,u=e.theme,h=(Object(c.useContext)(ue)||{}).setPortalPlacement,d=Object(c.useRef)(null),f=l(Object(c.useState)(r),2),p=f[0],m=f[1],g=l(Object(c.useState)(null),2),_=g[0],y=g[1],v=u.spacing.controlHeight;return B((function(){var e=d.current;if(e){var t="fixed"===a,o=ae({maxHeight:r,menuEl:e,minHeight:n,placement:i,shouldScroll:s&&!t,isFixedPosition:t,controlHeight:v});m(o.maxHeight),y(o.placement),null==h||h(o.placement)}}),[r,i,a,s,n,h,v]),t({ref:d,placerProps:o(o({},e),{},{placement:_||le(i),maxHeight:p})})},he=function(e){var t=e.children,n=e.innerRef,r=e.innerProps;return Object(x.c)("div",d({},q(e,"menu",{menu:!0}),{ref:n},r),t)},de=function(e,t){var n=e.theme,r=n.spacing.baseUnit,i=n.colors;return o({textAlign:"center"},t?{}:{color:i.neutral40,padding:"".concat(2*r,"px ").concat(3*r,"px")})},fe=de,pe=de,me=["size"],ge=["innerProps","isRtl","size"];var _e,ye,ve={name:"8mmkcg",styles:"display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0"},xe=function(e){var t=e.size,n=u(e,me);return Object(x.c)("svg",d({height:t,width:t,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",css:ve},n))},be=function(e){return Object(x.c)(xe,d({size:20},e),Object(x.c)("path",{d:"M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"}))},we=function(e){return Object(x.c)(xe,d({size:20},e),Object(x.c)("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},Ee=function(e,t){var n=e.isFocused,r=e.theme,i=r.spacing.baseUnit,a=r.colors;return o({label:"indicatorContainer",display:"flex",transition:"color 150ms"},t?{}:{color:n?a.neutral60:a.neutral20,padding:2*i,":hover":{color:n?a.neutral80:a.neutral40}})},Te=Ee,Se=Ee,Ae=Object(x.d)(se||(_e=["\n 0%, 80%, 100% { opacity: 0; }\n 40% { opacity: 1; }\n"],ye||(ye=_e.slice(0)),se=Object.freeze(Object.defineProperties(_e,{raw:{value:Object.freeze(ye)}})))),ke=function(e){var t=e.delay,n=e.offset;return Object(x.c)("span",{css:Object(x.b)({animation:"".concat(Ae," 1s ease-in-out ").concat(t,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:n?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},Me=function(e){var t=e.children,n=e.isDisabled,r=e.isFocused,i=e.innerRef,o=e.innerProps,a=e.menuIsOpen;return Object(x.c)("div",d({ref:i},q(e,"control",{control:!0,"control--is-disabled":n,"control--is-focused":r,"control--menu-is-open":a}),o),t)},Ce=["data"],Ie=function(e){var t=e.children,n=e.cx,r=e.getStyles,i=e.getClassNames,o=e.Heading,a=e.headingProps,s=e.innerProps,l=e.label,u=e.theme,c=e.selectProps;return Object(x.c)("div",d({},q(e,"group",{group:!0}),s),Object(x.c)(o,d({},a,{selectProps:c,theme:u,getStyles:r,getClassNames:i,cx:n}),l),Object(x.c)("div",null,t))},Pe=["innerRef","isDisabled","isHidden","inputClassName"],Oe={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},ze={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content","&:after":o({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre"},Oe)},Le=function(e){return o({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Oe)},De=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",n,t)};var Re={ClearIndicator:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"clearIndicator",{indicator:!0,"clear-indicator":!0}),n),t||Object(x.c)(be,null))},Control:Me,DropdownIndicator:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"dropdownIndicator",{indicator:!0,"dropdown-indicator":!0}),n),t||Object(x.c)(we,null))},DownChevron:we,CrossIcon:be,Group:Ie,GroupHeading:function(e){var t=G(e);t.data;var n=u(t,Ce);return Object(x.c)("div",d({},q(e,"groupHeading",{"group-heading":!0}),n))},IndicatorsContainer:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"indicatorsContainer",{indicators:!0}),n),t)},IndicatorSeparator:function(e){var t=e.innerProps;return Object(x.c)("span",d({},t,q(e,"indicatorSeparator",{"indicator-separator":!0})))},Input:function(e){var t=e.cx,n=e.value,r=G(e),i=r.innerRef,o=r.isDisabled,a=r.isHidden,s=r.inputClassName,l=u(r,Pe);return Object(x.c)("div",d({},q(e,"input",{"input-container":!0}),{"data-value":n||""}),Object(x.c)("input",d({className:t({input:!0},s),ref:i,style:Le(a),disabled:o},l)))},LoadingIndicator:function(e){var t=e.innerProps,n=e.isRtl,r=e.size,i=void 0===r?4:r,a=u(e,ge);return Object(x.c)("div",d({},q(o(o({},a),{},{innerProps:t,isRtl:n,size:i}),"loadingIndicator",{indicator:!0,"loading-indicator":!0}),t),Object(x.c)(ke,{delay:0,offset:n}),Object(x.c)(ke,{delay:160,offset:!0}),Object(x.c)(ke,{delay:320,offset:!n}))},Menu:he,MenuList:function(e){var t=e.children,n=e.innerProps,r=e.innerRef,i=e.isMulti;return Object(x.c)("div",d({},q(e,"menuList",{"menu-list":!0,"menu-list--is-multi":i}),{ref:r},n),t)},MenuPortal:function(e){var t=e.appendTo,n=e.children,r=e.controlElement,i=e.innerProps,a=e.menuPlacement,s=e.menuPosition,u=Object(c.useRef)(null),h=Object(c.useRef)(null),f=l(Object(c.useState)(le(a)),2),p=f[0],m=f[1],g=Object(c.useMemo)((function(){return{setPortalPlacement:m}}),[]),_=l(Object(c.useState)(null),2),y=_[0],v=_[1],w=Object(c.useCallback)((function(){if(r){var e=function(e){var t=e.getBoundingClientRect();return{bottom:t.bottom,height:t.height,left:t.left,right:t.right,top:t.top,width:t.width}}(r),t="fixed"===s?0:window.pageYOffset,n=e[p]+t;n===(null==y?void 0:y.offset)&&e.left===(null==y?void 0:y.rect.left)&&e.width===(null==y?void 0:y.rect.width)||v({offset:n,rect:e})}}),[r,s,p,null==y?void 0:y.offset,null==y?void 0:y.rect.left,null==y?void 0:y.rect.width]);B((function(){w()}),[w]);var E=Object(c.useCallback)((function(){"function"==typeof h.current&&(h.current(),h.current=null),r&&u.current&&(h.current=function(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=!0,animationFrame:s=!1}=r,l=i&&!s,u=o&&!s,c=l||u?[...M(e)?R(e):[],...R(t)]:[];c.forEach(e=>{l&&e.addEventListener("scroll",n,{passive:!0}),u&&e.addEventListener("resize",n)});let h,d=null;if(a){let r=!0;d=new ResizeObserver(()=>{r||n(),r=!1}),M(e)&&!s&&d.observe(e),d.observe(t)}let f=s?z(e):null;return s&&function t(){const r=z(e);!f||r.x===f.x&&r.y===f.y&&r.width===f.width&&r.height===f.height||n();f=r,h=requestAnimationFrame(t)}(),n(),()=>{var e;c.forEach(e=>{l&&e.removeEventListener("scroll",n),u&&e.removeEventListener("resize",n)}),null==(e=d)||e.disconnect(),d=null,s&&cancelAnimationFrame(h)}}(r,u.current,w,{elementResize:"ResizeObserver"in window}))}),[r,w]);B((function(){E()}),[E]);var T=Object(c.useCallback)((function(e){u.current=e,E()}),[E]);if(!t&&"fixed"!==s||!y)return null;var S=Object(x.c)("div",d({ref:T},q(o(o({},e),{},{offset:y.offset,position:s,rect:y.rect}),"menuPortal",{"menu-portal":!0}),i),n);return Object(x.c)(ue.Provider,{value:g},t?Object(b.createPortal)(S,t):S)},LoadingMessage:function(e){var t=e.children,n=void 0===t?"Loading...":t,r=e.innerProps,i=u(e,oe);return Object(x.c)("div",d({},q(o(o({},i),{},{children:n,innerProps:r}),"loadingMessage",{"menu-notice":!0,"menu-notice--loading":!0}),r),n)},NoOptionsMessage:function(e){var t=e.children,n=void 0===t?"No options":t,r=e.innerProps,i=u(e,ie);return Object(x.c)("div",d({},q(o(o({},i),{},{children:n,innerProps:r}),"noOptionsMessage",{"menu-notice":!0,"menu-notice--no-options":!0}),r),n)},MultiValue:function(e){var t=e.children,n=e.components,r=e.data,i=e.innerProps,a=e.isDisabled,s=e.removeProps,l=e.selectProps,u=n.Container,c=n.Label,h=n.Remove;return Object(x.c)(u,{data:r,innerProps:o(o({},q(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":a})),i),selectProps:l},Object(x.c)(c,{data:r,innerProps:o({},q(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:l},t),Object(x.c)(h,{data:r,innerProps:o(o({},q(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(t||"option")},s),selectProps:l}))},MultiValueContainer:De,MultiValueLabel:De,MultiValueRemove:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({role:"button"},n),t||Object(x.c)(be,{size:14}))},Option:function(e){var t=e.children,n=e.isDisabled,r=e.isFocused,i=e.isSelected,o=e.innerRef,a=e.innerProps;return Object(x.c)("div",d({},q(e,"option",{option:!0,"option--is-disabled":n,"option--is-focused":r,"option--is-selected":i}),{ref:o,"aria-disabled":n},a),t)},Placeholder:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"placeholder",{placeholder:!0}),n),t)},SelectContainer:function(e){var t=e.children,n=e.innerProps,r=e.isDisabled,i=e.isRtl;return Object(x.c)("div",d({},q(e,"container",{"--is-disabled":r,"--is-rtl":i}),n),t)},SingleValue:function(e){var t=e.children,n=e.isDisabled,r=e.innerProps;return Object(x.c)("div",d({},q(e,"singleValue",{"single-value":!0,"single-value--is-disabled":n}),r),t)},ValueContainer:function(e){var t=e.children,n=e.innerProps,r=e.isMulti,i=e.hasValue;return Object(x.c)("div",d({},q(e,"valueContainer",{"value-container":!0,"value-container--is-multi":r,"value-container--has-value":i}),n),t)}},Be=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function Fe(e,t){if(e.length!==t.length)return!1;for(var n=0;n1?"s":""," ").concat(i.join(","),", selected.");case"select-option":return"option ".concat(r,o?" is disabled. Select another option.":", selected.");default:return""}},onFocus:function(e){var t=e.context,n=e.focused,r=e.options,i=e.label,o=void 0===i?"":i,a=e.selectValue,s=e.isDisabled,l=e.isSelected,u=function(e,t){return e&&e.length?"".concat(e.indexOf(t)+1," of ").concat(e.length):""};if("value"===t&&a)return"value ".concat(o," focused, ").concat(u(a,n),".");if("menu"===t){var c=s?" disabled":"",h="".concat(l?"selected":"focused").concat(c);return"option ".concat(o," ").concat(h,", ").concat(u(r,n),".")}return""},onFilter:function(e){var t=e.inputValue,n=e.resultsMessage;return"".concat(n).concat(t?" for search term "+t:"",".")}},Ve=function(e){var t=e.ariaSelection,n=e.focusedOption,r=e.focusedValue,i=e.focusableOptions,a=e.isFocused,s=e.selectValue,l=e.selectProps,u=e.id,h=l.ariaLiveMessages,d=l.getOptionLabel,f=l.inputValue,p=l.isMulti,m=l.isOptionDisabled,g=l.isSearchable,_=l.menuIsOpen,y=l.options,v=l.screenReaderStatus,b=l.tabSelectsValue,w=l["aria-label"],E=l["aria-live"],T=Object(c.useMemo)((function(){return o(o({},Ne),h||{})}),[h]),S=Object(c.useMemo)((function(){var e,n="";if(t&&T.onChange){var r=t.option,i=t.options,a=t.removedValue,l=t.removedValues,u=t.value,c=a||r||(e=u,Array.isArray(e)?null:e),h=c?d(c):"",f=i||l||void 0,p=f?f.map(d):[],g=o({isDisabled:c&&m(c,s),label:h,labels:p},t);n=T.onChange(g)}return n}),[t,T,m,s,d]),A=Object(c.useMemo)((function(){var e="",t=n||r,o=!!(n&&s&&s.includes(n));if(t&&T.onFocus){var a={focused:t,label:d(t),isDisabled:m(t,s),isSelected:o,options:i,context:t===n?"menu":"value",selectValue:s};e=T.onFocus(a)}return e}),[n,r,d,m,T,i,s]),k=Object(c.useMemo)((function(){var e="";if(_&&y.length&&T.onFilter){var t=v({count:i.length});e=T.onFilter({inputValue:f,resultsMessage:t})}return e}),[i,f,_,T,y,v]),M=Object(c.useMemo)((function(){var e="";if(T.guidance){var t=r?"value":_?"menu":"input";e=T.guidance({"aria-label":w,context:t,isDisabled:n&&m(n,s),isMulti:p,isSearchable:g,tabSelectsValue:b})}return e}),[w,n,r,p,m,g,_,T,s,b]),C="".concat(A," ").concat(k," ").concat(M),I=Object(x.c)(c.Fragment,null,Object(x.c)("span",{id:"aria-selection"},S),Object(x.c)("span",{id:"aria-context"},C)),P="initial-input-focus"===(null==t?void 0:t.action);return Object(x.c)(c.Fragment,null,Object(x.c)(Ue,{id:u},P&&I),Object(x.c)(Ue,{"aria-live":E,"aria-atomic":"false","aria-relevant":"additions text"},a&&!P&&I))},Ge=[{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ"},{base:"nj",letters:"nj"},{base:"o",letters:"oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],qe=new RegExp("["+Ge.map((function(e){return e.letters})).join("")+"]","g"),$e={},Ze=0;Ze1?t-1:0),r=1;r0,m=h-d-c,g=!1;m>t&&a.current&&(r&&r(e),a.current=!1),p&&s.current&&(o&&o(e),s.current=!1),p&&t>m?(n&&!a.current&&n(e),f.scrollTop=h,g=!0,a.current=!0):!p&&-t>c&&(i&&!s.current&&i(e),f.scrollTop=0,g=!0,s.current=!0),g&&function(e){e.preventDefault(),e.stopPropagation()}(e)}}),[n,r,i,o]),d=Object(c.useCallback)((function(e){h(e,e.deltaY)}),[h]),f=Object(c.useCallback)((function(e){l.current=e.changedTouches[0].clientY}),[]),p=Object(c.useCallback)((function(e){var t=l.current-e.changedTouches[0].clientY;h(e,t)}),[h]),m=Object(c.useCallback)((function(e){if(e){var t=!!te&&{passive:!1};e.addEventListener("wheel",d,t),e.addEventListener("touchstart",f,t),e.addEventListener("touchmove",p,t)}}),[p,f,d]),g=Object(c.useCallback)((function(e){e&&(e.removeEventListener("wheel",d,!1),e.removeEventListener("touchstart",f,!1),e.removeEventListener("touchmove",p,!1))}),[p,f,d]);return Object(c.useEffect)((function(){if(t){var e=u.current;return m(e),function(){g(e)}}}),[t,m,g]),function(e){u.current=e}}({isEnabled:void 0===r||r,onBottomArrive:e.onBottomArrive,onBottomLeave:e.onBottomLeave,onTopArrive:e.onTopArrive,onTopLeave:e.onTopLeave}),o=function(e){var t=e.isEnabled,n=e.accountForScrollbars,r=void 0===n||n,i=Object(c.useRef)({}),o=Object(c.useRef)(null),a=Object(c.useCallback)((function(e){if(st){var t=document.body,n=t&&t.style;if(r&&tt.forEach((function(e){var t=n&&n[e];i.current[e]=t})),r&<<1){var o=parseInt(i.current.paddingRight,10)||0,a=document.body?document.body.clientWidth:0,s=window.innerWidth-a+o||0;Object.keys(nt).forEach((function(e){var t=nt[e];n&&(n[e]=t)})),n&&(n.paddingRight="".concat(s,"px"))}t&&at()&&(t.addEventListener("touchmove",rt,ut),e&&(e.addEventListener("touchstart",ot,ut),e.addEventListener("touchmove",it,ut))),lt+=1}}),[r]),s=Object(c.useCallback)((function(e){if(st){var t=document.body,n=t&&t.style;lt=Math.max(lt-1,0),r&<<1&&tt.forEach((function(e){var t=i.current[e];n&&(n[e]=t)})),t&&at()&&(t.removeEventListener("touchmove",rt,ut),e&&(e.removeEventListener("touchstart",ot,ut),e.removeEventListener("touchmove",it,ut)))}}),[r]);return Object(c.useEffect)((function(){if(t){var e=o.current;return a(e),function(){s(e)}}}),[t,a,s]),function(e){o.current=e}}({isEnabled:n});return Object(x.c)(c.Fragment,null,n&&Object(x.c)("div",{onClick:ct,css:ht}),t((function(e){i(e),o(e)})))}var ft={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},pt=function(e){var t=e.name,n=e.onFocus;return Object(x.c)("input",{required:!0,name:t,tabIndex:-1,"aria-hidden":"true",onFocus:n,css:ft,value:"",onChange:function(){}})},mt={clearIndicator:Se,container:function(e){var t=e.isDisabled;return{label:"container",direction:e.isRtl?"rtl":void 0,pointerEvents:t?"none":void 0,position:"relative"}},control:function(e,t){var n=e.isDisabled,r=e.isFocused,i=e.theme,a=i.colors,s=i.borderRadius;return o({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:i.spacing.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},t?{}:{backgroundColor:n?a.neutral5:a.neutral0,borderColor:n?a.neutral10:r?a.primary:a.neutral20,borderRadius:s,borderStyle:"solid",borderWidth:1,boxShadow:r?"0 0 0 1px ".concat(a.primary):void 0,"&:hover":{borderColor:r?a.primary:a.neutral30}})},dropdownIndicator:Te,group:function(e,t){var n=e.theme.spacing;return t?{}:{paddingBottom:2*n.baseUnit,paddingTop:2*n.baseUnit}},groupHeading:function(e,t){var n=e.theme,r=n.colors,i=n.spacing;return o({label:"group",cursor:"default",display:"block"},t?{}:{color:r.neutral40,fontSize:"75%",fontWeight:500,marginBottom:"0.25em",paddingLeft:3*i.baseUnit,paddingRight:3*i.baseUnit,textTransform:"uppercase"})},indicatorsContainer:function(){return{alignItems:"center",alignSelf:"stretch",display:"flex",flexShrink:0}},indicatorSeparator:function(e,t){var n=e.isDisabled,r=e.theme,i=r.spacing.baseUnit,a=r.colors;return o({label:"indicatorSeparator",alignSelf:"stretch",width:1},t?{}:{backgroundColor:n?a.neutral10:a.neutral20,marginBottom:2*i,marginTop:2*i})},input:function(e,t){var n=e.isDisabled,r=e.value,i=e.theme,a=i.spacing,s=i.colors;return o(o({visibility:n?"hidden":"visible",transform:r?"translateZ(0)":""},ze),t?{}:{margin:a.baseUnit/2,paddingBottom:a.baseUnit/2,paddingTop:a.baseUnit/2,color:s.neutral80})},loadingIndicator:function(e,t){var n=e.isFocused,r=e.size,i=e.theme,a=i.colors,s=i.spacing.baseUnit;return o({label:"loadingIndicator",display:"flex",transition:"color 150ms",alignSelf:"center",fontSize:r,lineHeight:1,marginRight:r,textAlign:"center",verticalAlign:"middle"},t?{}:{color:n?a.neutral60:a.neutral20,padding:2*s})},loadingMessage:pe,menu:function(e,t){var n,i=e.placement,a=e.theme,s=a.borderRadius,l=a.spacing,u=a.colors;return o((r(n={label:"menu"},function(e){return e?{bottom:"top",top:"bottom"}[e]:"bottom"}(i),"100%"),r(n,"position","absolute"),r(n,"width","100%"),r(n,"zIndex",1),n),t?{}:{backgroundColor:u.neutral0,borderRadius:s,boxShadow:"0 0 0 1px hsla(0, 0%, 0%, 0.1), 0 4px 11px hsla(0, 0%, 0%, 0.1)",marginBottom:l.menuGutter,marginTop:l.menuGutter})},menuList:function(e,t){var n=e.maxHeight,r=e.theme.spacing.baseUnit;return o({maxHeight:n,overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},t?{}:{paddingBottom:r,paddingTop:r})},menuPortal:function(e){var t=e.rect,n=e.offset,r=e.position;return{left:t.left,position:r,top:n,width:t.width,zIndex:1}},multiValue:function(e,t){var n=e.theme,r=n.spacing,i=n.borderRadius,a=n.colors;return o({label:"multiValue",display:"flex",minWidth:0},t?{}:{backgroundColor:a.neutral10,borderRadius:i/2,margin:r.baseUnit/2})},multiValueLabel:function(e,t){var n=e.theme,r=n.borderRadius,i=n.colors,a=e.cropWithEllipsis;return o({overflow:"hidden",textOverflow:a||void 0===a?"ellipsis":void 0,whiteSpace:"nowrap"},t?{}:{borderRadius:r/2,color:i.neutral80,fontSize:"85%",padding:3,paddingLeft:6})},multiValueRemove:function(e,t){var n=e.theme,r=n.spacing,i=n.borderRadius,a=n.colors,s=e.isFocused;return o({alignItems:"center",display:"flex"},t?{}:{borderRadius:i/2,backgroundColor:s?a.dangerLight:void 0,paddingLeft:r.baseUnit,paddingRight:r.baseUnit,":hover":{backgroundColor:a.dangerLight,color:a.danger}})},noOptionsMessage:fe,option:function(e,t){var n=e.isDisabled,r=e.isFocused,i=e.isSelected,a=e.theme,s=a.spacing,l=a.colors;return o({label:"option",cursor:"default",display:"block",fontSize:"inherit",width:"100%",userSelect:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)"},t?{}:{backgroundColor:i?l.primary:r?l.primary25:"transparent",color:n?l.neutral20:i?l.neutral0:"inherit",padding:"".concat(2*s.baseUnit,"px ").concat(3*s.baseUnit,"px"),":active":{backgroundColor:n?void 0:i?l.primary:l.primary50}})},placeholder:function(e,t){var n=e.theme,r=n.spacing,i=n.colors;return o({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},t?{}:{color:i.neutral50,marginLeft:r.baseUnit/2,marginRight:r.baseUnit/2})},singleValue:function(e,t){var n=e.isDisabled,r=e.theme,i=r.spacing,a=r.colors;return o({label:"singleValue",gridArea:"1 / 1 / 2 / 3",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},t?{}:{color:n?a.neutral40:a.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},valueContainer:function(e,t){var n=e.theme.spacing,r=e.isMulti,i=e.hasValue,a=e.selectProps.controlShouldRenderValue;return o({alignItems:"center",display:r&&i&&a?"flex":"grid",flex:1,flexWrap:"wrap",WebkitOverflowScrolling:"touch",position:"relative",overflow:"hidden"},t?{}:{padding:"".concat(n.baseUnit/2,"px ").concat(2*n.baseUnit,"px")})}};var gt,_t={borderRadius:4,colors:{primary:"#2684FF",primary75:"#4C9AFF",primary50:"#B2D4FF",primary25:"#DEEBFF",danger:"#DE350B",dangerLight:"#FFBDAD",neutral0:"hsl(0, 0%, 100%)",neutral5:"hsl(0, 0%, 95%)",neutral10:"hsl(0, 0%, 90%)",neutral20:"hsl(0, 0%, 80%)",neutral30:"hsl(0, 0%, 70%)",neutral40:"hsl(0, 0%, 60%)",neutral50:"hsl(0, 0%, 50%)",neutral60:"hsl(0, 0%, 40%)",neutral70:"hsl(0, 0%, 30%)",neutral80:"hsl(0, 0%, 20%)",neutral90:"hsl(0, 0%, 10%)"},spacing:{baseUnit:4,controlHeight:38,menuGutter:8}},yt={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:K(),captureMenuScroll:!K(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:function(e,t){if(e.data.__isNew__)return!0;var n=o({ignoreCase:!0,ignoreAccents:!0,stringify:Je,trim:!0,matchFrom:"any"},gt),r=n.ignoreCase,i=n.ignoreAccents,a=n.stringify,s=n.trim,l=n.matchFrom,u=s?Ke(t):t,c=s?Ke(a(e)):a(e);return r&&(u=u.toLowerCase(),c=c.toLowerCase()),i&&(u=Ye(u),c=He(c)),"start"===l?c.substr(0,u.length)===u:c.indexOf(u)>-1},formatGroupLabel:function(e){return e.label},getOptionLabel:function(e){return e.label},getOptionValue:function(e){return e.value},isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:function(e){return!!e.isDisabled},loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!function(){try{return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}catch(e){return!1}}(),noOptionsMessage:function(){return"No options"},openMenuOnFocus:!1,openMenuOnClick:!0,options:[],pageSize:5,placeholder:"Select...",screenReaderStatus:function(e){var t=e.count;return"".concat(t," result").concat(1!==t?"s":""," available")},styles:{},tabIndex:0,tabSelectsValue:!0,unstyled:!1};function vt(e,t,n,r){return{type:"option",data:t,isDisabled:St(e,t,n),isSelected:At(e,t,n),label:Et(e,t),value:Tt(e,t),index:r}}function xt(e,t){return e.options.map((function(n,r){if("options"in n){var i=n.options.map((function(n,r){return vt(e,n,t,r)})).filter((function(t){return wt(e,t)}));return i.length>0?{type:"group",data:n,options:i,index:r}:void 0}var o=vt(e,n,t,r);return wt(e,o)?o:void 0})).filter(ne)}function bt(e){return e.reduce((function(e,t){return"group"===t.type?e.push.apply(e,v(t.options.map((function(e){return e.data})))):e.push(t.data),e}),[])}function wt(e,t){var n=e.inputValue,r=void 0===n?"":n,i=t.data,o=t.isSelected,a=t.label,s=t.value;return(!Mt(e)||!o)&&kt(e,{label:a,value:s,data:i},r)}var Et=function(e,t){return e.getOptionLabel(t)},Tt=function(e,t){return e.getOptionValue(t)};function St(e,t,n){return"function"==typeof e.isOptionDisabled&&e.isOptionDisabled(t,n)}function At(e,t,n){if(n.indexOf(t)>-1)return!0;if("function"==typeof e.isOptionSelected)return e.isOptionSelected(t,n);var r=Tt(e,t);return n.some((function(t){return Tt(e,t)===r}))}function kt(e,t,n){return!e.filterOption||e.filterOption(t,n)}var Mt=function(e){var t=e.hideSelectedOptions,n=e.isMulti;return void 0===t?n:t},Ct=1,It=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(a,e);var t,n,r,i=y(a);function a(e){var t;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=i.call(this,e)).state={ariaSelection:null,focusedOption:null,focusedValue:null,inputIsHidden:!1,isFocused:!1,selectValue:[],clearFocusValueOnUpdate:!1,prevWasFocused:!1,inputIsHiddenAfterUpdate:void 0,prevProps:void 0},t.blockOptionHover=!1,t.isComposing=!1,t.commonProps=void 0,t.initialTouchX=0,t.initialTouchY=0,t.instancePrefix="",t.openAfterFocus=!1,t.scrollToFocusedOptionOnUpdate=!1,t.userIsDragging=void 0,t.controlRef=null,t.getControlRef=function(e){t.controlRef=e},t.focusedOptionRef=null,t.getFocusedOptionRef=function(e){t.focusedOptionRef=e},t.menuListRef=null,t.getMenuListRef=function(e){t.menuListRef=e},t.inputRef=null,t.getInputRef=function(e){t.inputRef=e},t.focus=t.focusInput,t.blur=t.blurInput,t.onChange=function(e,n){var r=t.props,i=r.onChange,o=r.name;n.name=o,t.ariaOnChange(e,n),i(e,n)},t.setValue=function(e,n,r){var i=t.props,o=i.closeMenuOnSelect,a=i.isMulti,s=i.inputValue;t.onInputChange("",{action:"set-value",prevInputValue:s}),o&&(t.setState({inputIsHiddenAfterUpdate:!a}),t.onMenuClose()),t.setState({clearFocusValueOnUpdate:!0}),t.onChange(e,{action:n,option:r})},t.selectOption=function(e){var n=t.props,r=n.blurInputOnSelect,i=n.isMulti,o=n.name,a=t.state.selectValue,s=i&&t.isOptionSelected(e,a),l=t.isOptionDisabled(e,a);if(s){var u=t.getOptionValue(e);t.setValue(a.filter((function(e){return t.getOptionValue(e)!==u})),"deselect-option",e)}else{if(l)return void t.ariaOnChange(e,{action:"select-option",option:e,name:o});i?t.setValue([].concat(v(a),[e]),"select-option",e):t.setValue(e,"select-option")}r&&t.blurInput()},t.removeValue=function(e){var n=t.props.isMulti,r=t.state.selectValue,i=t.getOptionValue(e),o=r.filter((function(e){return t.getOptionValue(e)!==i})),a=re(n,o,o[0]||null);t.onChange(a,{action:"remove-value",removedValue:e}),t.focusInput()},t.clearValue=function(){var e=t.state.selectValue;t.onChange(re(t.props.isMulti,[],null),{action:"clear",removedValues:e})},t.popValue=function(){var e=t.props.isMulti,n=t.state.selectValue,r=n[n.length-1],i=n.slice(0,n.length-1),o=re(e,i,i[0]||null);t.onChange(o,{action:"pop-value",removedValue:r})},t.getValue=function(){return t.state.selectValue},t.cx=function(){for(var e=arguments.length,n=new Array(e),r=0;r5||o>5}},t.onTouchEnd=function(e){t.userIsDragging||(t.controlRef&&!t.controlRef.contains(e.target)&&t.menuListRef&&!t.menuListRef.contains(e.target)&&t.blurInput(),t.initialTouchX=0,t.initialTouchY=0)},t.onControlTouchEnd=function(e){t.userIsDragging||t.onControlMouseDown(e)},t.onClearIndicatorTouchEnd=function(e){t.userIsDragging||t.onClearIndicatorMouseDown(e)},t.onDropdownIndicatorTouchEnd=function(e){t.userIsDragging||t.onDropdownIndicatorMouseDown(e)},t.handleInputChange=function(e){var n=t.props.inputValue,r=e.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(r,{action:"input-change",prevInputValue:n}),t.props.menuIsOpen||t.onMenuOpen()},t.onInputFocus=function(e){t.props.onFocus&&t.props.onFocus(e),t.setState({inputIsHiddenAfterUpdate:!1,isFocused:!0}),(t.openAfterFocus||t.props.openMenuOnFocus)&&t.openMenu("first"),t.openAfterFocus=!1},t.onInputBlur=function(e){var n=t.props.inputValue;t.menuListRef&&t.menuListRef.contains(document.activeElement)?t.inputRef.focus():(t.props.onBlur&&t.props.onBlur(e),t.onInputChange("",{action:"input-blur",prevInputValue:n}),t.onMenuClose(),t.setState({focusedValue:null,isFocused:!1}))},t.onOptionHover=function(e){t.blockOptionHover||t.state.focusedOption===e||t.setState({focusedOption:e})},t.shouldHideSelectedOptions=function(){return Mt(t.props)},t.onValueInputFocus=function(e){e.preventDefault(),e.stopPropagation(),t.focus()},t.onKeyDown=function(e){var n=t.props,r=n.isMulti,i=n.backspaceRemovesValue,o=n.escapeClearsValue,a=n.inputValue,s=n.isClearable,l=n.isDisabled,u=n.menuIsOpen,c=n.onKeyDown,h=n.tabSelectsValue,d=n.openMenuOnFocus,f=t.state,p=f.focusedOption,m=f.focusedValue,g=f.selectValue;if(!(l||"function"==typeof c&&(c(e),e.defaultPrevented))){switch(t.blockOptionHover=!0,e.key){case"ArrowLeft":if(!r||a)return;t.focusValue("previous");break;case"ArrowRight":if(!r||a)return;t.focusValue("next");break;case"Delete":case"Backspace":if(a)return;if(m)t.removeValue(m);else{if(!i)return;r?t.popValue():s&&t.clearValue()}break;case"Tab":if(t.isComposing)return;if(e.shiftKey||!u||!h||!p||d&&t.isOptionSelected(p,g))return;t.selectOption(p);break;case"Enter":if(229===e.keyCode)break;if(u){if(!p)return;if(t.isComposing)return;t.selectOption(p);break}return;case"Escape":u?(t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange("",{action:"menu-close",prevInputValue:a}),t.onMenuClose()):s&&o&&t.clearValue();break;case" ":if(a)return;if(!u){t.openMenu("first");break}if(!p)return;t.selectOption(p);break;case"ArrowUp":u?t.focusOption("up"):t.openMenu("last");break;case"ArrowDown":u?t.focusOption("down"):t.openMenu("first");break;case"PageUp":if(!u)return;t.focusOption("pageup");break;case"PageDown":if(!u)return;t.focusOption("pagedown");break;case"Home":if(!u)return;t.focusOption("first");break;case"End":if(!u)return;t.focusOption("last");break;default:return}e.preventDefault()}},t.instancePrefix="react-select-"+(t.props.instanceId||++Ct),t.state.selectValue=V(e.value),e.menuIsOpen&&t.state.selectValue.length){var n=t.buildFocusableOptions(),r=n.indexOf(t.state.selectValue[0]);t.state.focusedOption=n[r]}return t}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n=t.prevProps,r=t.clearFocusValueOnUpdate,i=t.inputIsHiddenAfterUpdate,a=t.ariaSelection,s=t.isFocused,l=t.prevWasFocused,u=e.options,c=e.value,h=e.menuIsOpen,d=e.inputValue,f=e.isMulti,p=V(c),m={};if(n&&(c!==n.value||u!==n.options||h!==n.menuIsOpen||d!==n.inputValue)){var g=h?function(e,t){return bt(xt(e,t))}(e,p):[],_=r?function(e,t){var n=e.focusedValue,r=e.selectValue.indexOf(n);if(r>-1){if(t.indexOf(n)>-1)return n;if(r-1?n:t[0]}(t,g),focusedValue:_,clearFocusValueOnUpdate:!1}}var y=null!=i&&e!==n?{inputIsHidden:i,inputIsHiddenAfterUpdate:void 0}:{},v=a,x=s&&l;return s&&!x&&(v={value:re(f,p,p[0]||null),options:p,action:"initial-input-focus"},x=!l),"initial-input-focus"===(null==a?void 0:a.action)&&(v=null),o(o(o({},m),y),{},{prevProps:e,ariaSelection:v,prevWasFocused:x})}}],(n=[{key:"componentDidMount",value:function(){this.startListeningComposition(),this.startListeningToTouch(),this.props.closeMenuOnScroll&&document&&document.addEventListener&&document.addEventListener("scroll",this.onScroll,!0),this.props.autoFocus&&this.focusInput(),this.props.menuIsOpen&&this.state.focusedOption&&this.menuListRef&&this.focusedOptionRef&&Y(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(e){var t=this.props,n=t.isDisabled,r=t.menuIsOpen,i=this.state.isFocused;(i&&!n&&e.isDisabled||i&&r&&!e.menuIsOpen)&&this.focusInput(),i&&n&&!e.isDisabled?this.setState({isFocused:!1},this.onMenuClose):i||n||!e.isDisabled||this.inputRef!==document.activeElement||this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(Y(this.menuListRef,this.focusedOptionRef),this.scrollToFocusedOptionOnUpdate=!1)}},{key:"componentWillUnmount",value:function(){this.stopListeningComposition(),this.stopListeningToTouch(),document.removeEventListener("scroll",this.onScroll,!0)}},{key:"onMenuOpen",value:function(){this.props.onMenuOpen()}},{key:"onMenuClose",value:function(){this.onInputChange("",{action:"menu-close",prevInputValue:this.props.inputValue}),this.props.onMenuClose()}},{key:"onInputChange",value:function(e,t){this.props.onInputChange(e,t)}},{key:"focusInput",value:function(){this.inputRef&&this.inputRef.focus()}},{key:"blurInput",value:function(){this.inputRef&&this.inputRef.blur()}},{key:"openMenu",value:function(e){var t=this,n=this.state,r=n.selectValue,i=n.isFocused,o=this.buildFocusableOptions(),a="first"===e?0:o.length-1;if(!this.props.isMulti){var s=o.indexOf(r[0]);s>-1&&(a=s)}this.scrollToFocusedOptionOnUpdate=!(i&&this.menuListRef),this.setState({inputIsHiddenAfterUpdate:!1,focusedValue:null,focusedOption:o[a]},(function(){return t.onMenuOpen()}))}},{key:"focusValue",value:function(e){var t=this.state,n=t.selectValue,r=t.focusedValue;if(this.props.isMulti){this.setState({focusedOption:null});var i=n.indexOf(r);r||(i=-1);var o=n.length-1,a=-1;if(n.length){switch(e){case"previous":a=0===i?0:-1===i?o:i-1;break;case"next":i>-1&&i0&&void 0!==arguments[0]?arguments[0]:"first",t=this.props.pageSize,n=this.state.focusedOption,r=this.getFocusableOptions();if(r.length){var i=0,o=r.indexOf(n);n||(o=-1),"up"===e?i=o>0?o-1:r.length-1:"down"===e?i=(o+1)%r.length:"pageup"===e?(i=o-t)<0&&(i=0):"pagedown"===e?(i=o+t)>r.length-1&&(i=r.length-1):"last"===e&&(i=r.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:r[i],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?"function"==typeof this.props.theme?this.props.theme(_t):o(o({},_t),this.props.theme):_t}},{key:"getCommonProps",value:function(){var e=this.clearValue,t=this.cx,n=this.getStyles,r=this.getClassNames,i=this.getValue,o=this.selectOption,a=this.setValue,s=this.props,l=s.isMulti,u=s.isRtl,c=s.options;return{clearValue:e,cx:t,getStyles:n,getClassNames:r,getValue:i,hasValue:this.hasValue(),isMulti:l,isRtl:u,options:c,selectOption:o,selectProps:s,setValue:a,theme:this.getTheme()}}},{key:"hasValue",value:function(){return this.state.selectValue.length>0}},{key:"hasOptions",value:function(){return!!this.getFocusableOptions().length}},{key:"isClearable",value:function(){var e=this.props,t=e.isClearable,n=e.isMulti;return void 0===t?n:t}},{key:"isOptionDisabled",value:function(e,t){return St(this.props,e,t)}},{key:"isOptionSelected",value:function(e,t){return At(this.props,e,t)}},{key:"filterOption",value:function(e,t){return kt(this.props,e,t)}},{key:"formatOptionLabel",value:function(e,t){if("function"==typeof this.props.formatOptionLabel){var n=this.props.inputValue,r=this.state.selectValue;return this.props.formatOptionLabel(e,{context:t,inputValue:n,selectValue:r})}return this.getOptionLabel(e)}},{key:"formatGroupLabel",value:function(e){return this.props.formatGroupLabel(e)}},{key:"startListeningComposition",value:function(){document&&document.addEventListener&&(document.addEventListener("compositionstart",this.onCompositionStart,!1),document.addEventListener("compositionend",this.onCompositionEnd,!1))}},{key:"stopListeningComposition",value:function(){document&&document.removeEventListener&&(document.removeEventListener("compositionstart",this.onCompositionStart),document.removeEventListener("compositionend",this.onCompositionEnd))}},{key:"startListeningToTouch",value:function(){document&&document.addEventListener&&(document.addEventListener("touchstart",this.onTouchStart,!1),document.addEventListener("touchmove",this.onTouchMove,!1),document.addEventListener("touchend",this.onTouchEnd,!1))}},{key:"stopListeningToTouch",value:function(){document&&document.removeEventListener&&(document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd))}},{key:"renderInput",value:function(){var e=this.props,t=e.isDisabled,n=e.isSearchable,r=e.inputId,i=e.inputValue,a=e.tabIndex,s=e.form,l=e.menuIsOpen,u=e.required,h=this.getComponents().Input,f=this.state,p=f.inputIsHidden,m=f.ariaSelection,g=this.commonProps,_=r||this.getElementId("input"),y=o(o(o({"aria-autocomplete":"list","aria-expanded":l,"aria-haspopup":!0,"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":this.props["aria-invalid"],"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],"aria-required":u,role:"combobox"},l&&{"aria-controls":this.getElementId("listbox"),"aria-owns":this.getElementId("listbox")}),!n&&{"aria-readonly":!0}),this.hasValue()?"initial-input-focus"===(null==m?void 0:m.action)&&{"aria-describedby":this.getElementId("live-region")}:{"aria-describedby":this.getElementId("placeholder")});return n?c.createElement(h,d({},g,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:_,innerRef:this.getInputRef,isDisabled:t,isHidden:p,onBlur:this.onInputBlur,onChange:this.handleInputChange,onFocus:this.onInputFocus,spellCheck:"false",tabIndex:a,form:s,type:"text",value:i},y)):c.createElement(et,d({id:_,innerRef:this.getInputRef,onBlur:this.onInputBlur,onChange:j,onFocus:this.onInputFocus,disabled:t,tabIndex:a,inputMode:"none",form:s,value:""},y))}},{key:"renderPlaceholderOrValue",value:function(){var e=this,t=this.getComponents(),n=t.MultiValue,r=t.MultiValueContainer,i=t.MultiValueLabel,o=t.MultiValueRemove,a=t.SingleValue,s=t.Placeholder,l=this.commonProps,u=this.props,h=u.controlShouldRenderValue,f=u.isDisabled,p=u.isMulti,m=u.inputValue,g=u.placeholder,_=this.state,y=_.selectValue,v=_.focusedValue,x=_.isFocused;if(!this.hasValue()||!h)return m?null:c.createElement(s,d({},l,{key:"placeholder",isDisabled:f,isFocused:x,innerProps:{id:this.getElementId("placeholder")}}),g);if(p)return y.map((function(t,a){var s=t===v,u="".concat(e.getOptionLabel(t),"-").concat(e.getOptionValue(t));return c.createElement(n,d({},l,{components:{Container:r,Label:i,Remove:o},isFocused:s,isDisabled:f,key:u,index:a,removeProps:{onClick:function(){return e.removeValue(t)},onTouchEnd:function(){return e.removeValue(t)},onMouseDown:function(e){e.preventDefault()}},data:t}),e.formatOptionLabel(t,"value"))}));if(m)return null;var b=y[0];return c.createElement(a,d({},l,{data:b,isDisabled:f}),this.formatOptionLabel(b,"value"))}},{key:"renderClearIndicator",value:function(){var e=this.getComponents().ClearIndicator,t=this.commonProps,n=this.props,r=n.isDisabled,i=n.isLoading,o=this.state.isFocused;if(!this.isClearable()||!e||r||!this.hasValue()||i)return null;var a={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return c.createElement(e,d({},t,{innerProps:a,isFocused:o}))}},{key:"renderLoadingIndicator",value:function(){var e=this.getComponents().LoadingIndicator,t=this.commonProps,n=this.props,r=n.isDisabled,i=n.isLoading,o=this.state.isFocused;return e&&i?c.createElement(e,d({},t,{innerProps:{"aria-hidden":"true"},isDisabled:r,isFocused:o})):null}},{key:"renderIndicatorSeparator",value:function(){var e=this.getComponents(),t=e.DropdownIndicator,n=e.IndicatorSeparator;if(!t||!n)return null;var r=this.commonProps,i=this.props.isDisabled,o=this.state.isFocused;return c.createElement(n,d({},r,{isDisabled:i,isFocused:o}))}},{key:"renderDropdownIndicator",value:function(){var e=this.getComponents().DropdownIndicator;if(!e)return null;var t=this.commonProps,n=this.props.isDisabled,r=this.state.isFocused,i={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return c.createElement(e,d({},t,{innerProps:i,isDisabled:n,isFocused:r}))}},{key:"renderMenu",value:function(){var e=this,t=this.getComponents(),n=t.Group,r=t.GroupHeading,i=t.Menu,o=t.MenuList,a=t.MenuPortal,s=t.LoadingMessage,l=t.NoOptionsMessage,u=t.Option,h=this.commonProps,f=this.state.focusedOption,p=this.props,m=p.captureMenuScroll,g=p.inputValue,_=p.isLoading,y=p.loadingMessage,v=p.minMenuHeight,x=p.maxMenuHeight,b=p.menuIsOpen,w=p.menuPlacement,E=p.menuPosition,T=p.menuPortalTarget,S=p.menuShouldBlockScroll,A=p.menuShouldScrollIntoView,k=p.noOptionsMessage,M=p.onMenuScrollToTop,C=p.onMenuScrollToBottom;if(!b)return null;var I,P=function(t,n){var r=t.type,i=t.data,o=t.isDisabled,a=t.isSelected,s=t.label,l=t.value,p=f===i,m=o?void 0:function(){return e.onOptionHover(i)},g=o?void 0:function(){return e.selectOption(i)},_="".concat(e.getElementId("option"),"-").concat(n),y={id:_,onClick:g,onMouseMove:m,onMouseOver:m,tabIndex:-1};return c.createElement(u,d({},h,{innerProps:y,data:i,isDisabled:o,isSelected:a,key:_,label:s,type:r,value:l,isFocused:p,innerRef:p?e.getFocusedOptionRef:void 0}),e.formatOptionLabel(t.data,"menu"))};if(this.hasOptions())I=this.getCategorizedOptions().map((function(t){if("group"===t.type){var i=t.data,o=t.options,a=t.index,s="".concat(e.getElementId("group"),"-").concat(a),l="".concat(s,"-heading");return c.createElement(n,d({},h,{key:s,data:i,options:o,Heading:r,headingProps:{id:l,data:t.data},label:e.formatGroupLabel(t.data)}),t.options.map((function(e){return P(e,"".concat(a,"-").concat(e.index))})))}if("option"===t.type)return P(t,"".concat(t.index))}));else if(_){var O=y({inputValue:g});if(null===O)return null;I=c.createElement(s,h,O)}else{var z=k({inputValue:g});if(null===z)return null;I=c.createElement(l,h,z)}var L={minMenuHeight:v,maxMenuHeight:x,menuPlacement:w,menuPosition:E,menuShouldScrollIntoView:A},D=c.createElement(ce,d({},h,L),(function(t){var n=t.ref,r=t.placerProps,a=r.placement,s=r.maxHeight;return c.createElement(i,d({},h,L,{innerRef:n,innerProps:{onMouseDown:e.onMenuMouseDown,onMouseMove:e.onMenuMouseMove,id:e.getElementId("listbox")},isLoading:_,placement:a}),c.createElement(dt,{captureEnabled:m,onTopArrive:M,onBottomArrive:C,lockEnabled:S},(function(t){return c.createElement(o,d({},h,{innerRef:function(n){e.getMenuListRef(n),t(n)},isLoading:_,maxHeight:s,focusedOption:f}),I)})))}));return T||"fixed"===E?c.createElement(a,d({},h,{appendTo:T,controlElement:this.controlRef,menuPlacement:w,menuPosition:E}),D):D}},{key:"renderFormField",value:function(){var e=this,t=this.props,n=t.delimiter,r=t.isDisabled,i=t.isMulti,o=t.name,a=t.required,s=this.state.selectValue;if(a&&!this.hasValue()&&!r)return c.createElement(pt,{name:o,onFocus:this.onValueInputFocus});if(o&&!r){if(i){if(n){var l=s.map((function(t){return e.getOptionValue(t)})).join(n);return c.createElement("input",{name:o,type:"hidden",value:l})}var u=s.length>0?s.map((function(t,n){return c.createElement("input",{key:"i-".concat(n),name:o,type:"hidden",value:e.getOptionValue(t)})})):c.createElement("input",{name:o,type:"hidden",value:""});return c.createElement("div",null,u)}var h=s[0]?this.getOptionValue(s[0]):"";return c.createElement("input",{name:o,type:"hidden",value:h})}}},{key:"renderLiveRegion",value:function(){var e=this.commonProps,t=this.state,n=t.ariaSelection,r=t.focusedOption,i=t.focusedValue,o=t.isFocused,a=t.selectValue,s=this.getFocusableOptions();return c.createElement(Ve,d({},e,{id:this.getElementId("live-region"),ariaSelection:n,focusedOption:r,focusedValue:i,isFocused:o,selectValue:a,focusableOptions:s}))}},{key:"render",value:function(){var e=this.getComponents(),t=e.Control,n=e.IndicatorsContainer,r=e.SelectContainer,i=e.ValueContainer,o=this.props,a=o.className,s=o.id,l=o.isDisabled,u=o.menuIsOpen,h=this.state.isFocused,f=this.commonProps=this.getCommonProps();return c.createElement(r,d({},f,{className:a,innerProps:{id:s,onKeyDown:this.onKeyDown},isDisabled:l,isFocused:h}),this.renderLiveRegion(),c.createElement(t,d({},f,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:l,isFocused:h,menuIsOpen:u}),c.createElement(i,d({},f,{isDisabled:l}),this.renderPlaceholderOrValue(),this.renderInput()),c.createElement(n,d({},f,{isDisabled:l}),this.renderClearIndicator(),this.renderLoadingIndicator(),this.renderIndicatorSeparator(),this.renderDropdownIndicator())),this.renderMenu(),this.renderFormField())}}])&&f(t.prototype,n),r&&f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),a}(c.Component);It.defaultProps=yt;n(7),n(20),n(64),n(65),n(69),n(71),n(72),n(73),n(75),n(80),n(36),n(84),n(33);var Pt=Object(c.forwardRef)((function(e,t){var n,r,i,a,s,f,p,m,g,_,y,v,x,b,w,E,T,S,A,k,M,C,I,P,O,z,L,D,R,B,F,j=(r=(n=e).defaultInputValue,i=void 0===r?"":r,a=n.defaultMenuIsOpen,s=void 0!==a&&a,f=n.defaultValue,p=void 0===f?null:f,m=n.inputValue,g=n.menuIsOpen,_=n.onChange,y=n.onInputChange,v=n.onMenuClose,x=n.onMenuOpen,b=n.value,w=u(n,h),E=l(Object(c.useState)(void 0!==m?m:i),2),T=E[0],S=E[1],A=l(Object(c.useState)(void 0!==g?g:s),2),k=A[0],M=A[1],C=l(Object(c.useState)(void 0!==b?b:p),2),I=C[0],P=C[1],O=Object(c.useCallback)((function(e,t){"function"==typeof _&&_(e,t),P(e)}),[_]),z=Object(c.useCallback)((function(e,t){var n;"function"==typeof y&&(n=y(e,t)),S(void 0!==n?n:e)}),[y]),L=Object(c.useCallback)((function(){"function"==typeof x&&x(),M(!0)}),[x]),D=Object(c.useCallback)((function(){"function"==typeof v&&v(),M(!1)}),[v]),R=void 0!==m?m:T,B=void 0!==g?g:k,F=void 0!==b?b:I,o(o({},w),{},{inputValue:R,menuIsOpen:B,onChange:O,onInputChange:z,onMenuClose:D,onMenuOpen:L,value:F}));return c.createElement(It,d({ref:t},j))}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return Q}));n(89);var r=n(0),i=n.n(r),o=n(41);const a=()=>{},s=a(),l=Object,u=e=>e===s,c=e=>"function"==typeof e,h=(e,t)=>({...e,...t}),d=new WeakMap;let f=0;const p=e=>{const t=typeof e,n=e&&e.constructor,r=n==Date;let i,o;if(l(e)!==e||r||n==RegExp)i=r?e.toJSON():"symbol"==t?e.toString():"string"==t?JSON.stringify(e):""+e;else{if(i=d.get(e),i)return i;if(i=++f+"~",d.set(e,i),n==Array){for(i="@",o=0;o{const n=m.get(e);return[()=>!u(t)&&e.get(t)||g,r=>{if(!u(t)){const i=e.get(t);t in _||(_[t]=i),n[5](t,h(i,r),i||g)}},n[6],()=>!u(t)&&t in _?_[t]:!u(t)&&e.get(t)||g]};let b=!0;const[w,E]=y&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[a,a],T={isOnline:()=>b,isVisible:()=>{const e=v&&document.visibilityState;return u(e)||"hidden"!==e}},S={initFocus:e=>(v&&document.addEventListener("visibilitychange",e),w("focus",e),()=>{v&&document.removeEventListener("visibilitychange",e),E("focus",e)}),initReconnect:e=>{const t=()=>{b=!0,e()},n=()=>{b=!1};return w("online",t),w("offline",n),()=>{E("online",t),E("offline",n)}}},A=!i.a.useId,k=!y||"Deno"in window,M=e=>y&&void 0!==window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1),C=k?r.useEffect:r.useLayoutEffect,I="undefined"!=typeof navigator&&navigator.connection,P=!k&&I&&(["slow-2g","2g"].includes(I.effectiveType)||I.saveData),O=e=>{if(c(e))try{e=e()}catch(t){e=""}const t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?p(e):"",t]};let z=0;const L=()=>++z;var D=3,R=0,B=2,F=1;async function j(...e){const[t,n,r,i]=e,o=h({populateCache:!0,throwOnError:!0},"boolean"==typeof i?{revalidate:i}:i||{});let a=o.populateCache;const l=o.rollbackOnError;let d=o.optimisticData;const f=!1!==o.revalidate,p=o.throwOnError;if(c(n)){const e=n,r=[],i=t.keys();for(const n of i)!/^\$(inf|sub)\$/.test(n)&&e(t.get(n)._k)&&r.push(n);return Promise.all(r.map(g))}return g(n);async function g(n){const[i]=O(n);if(!i)return;const[o,h]=x(t,i),[g,_,y,v]=m.get(t),b=()=>{const e=g[i];return f&&(delete y[i],delete v[i],e&&e[0])?e[0](2).then(()=>o().data):o().data};if(e.length<3)return b();let w,E=r;const T=L();_[i]=[T,0];const S=!u(d),A=o(),k=A.data,M=A._c,C=u(M)?k:M;if(S&&(d=c(d)?d(C,k):d,h({data:d,_c:C})),c(E))try{E=E(C)}catch(e){w=e}if(E&&c(E.then)){if(E=await E.catch(e=>{w=e}),T!==_[i][0]){if(w)throw w;return E}w&&S&&(e=>"function"==typeof l?l(e):!1!==l)(w)&&(a=!0,h({data:C,_c:s}))}if(a&&!w)if(c(a)){const e=a(E,C);h({data:e,error:s,_c:s})}else h({data:E,error:s,_c:s});if(_[i][1]=L(),Promise.resolve(b()).then(()=>{h({_c:s})}),!w)return E;if(p)throw w}}const U=(e,t)=>{for(const n in e)e[n][0]&&e[n][0](t)},N=(e,t)=>{if(!m.has(e)){const n=h(S,t),r={},i=j.bind(s,e);let o=a;const l={},u=(e,t)=>{const n=l[e]||[];return l[e]=n,n.push(t),()=>n.splice(n.indexOf(t),1)},c=(t,n,r)=>{e.set(t,n);const i=l[t];if(i)for(const e of i)e(n,r)},d=()=>{if(!m.has(e)&&(m.set(e,[r,{},{},{},i,c,u]),!k)){const t=n.initFocus(setTimeout.bind(s,U.bind(s,r,0))),i=n.initReconnect(setTimeout.bind(s,U.bind(s,r,1)));o=()=>{t&&t(),i&&i(),m.delete(e)}}};return d(),[e,i,d,o]}return[e,m.get(e)[4]]},[V,G]=N(new Map),q=h({onLoadingSlow:a,onSuccess:a,onError:a,onErrorRetry:(e,t,n,r,i)=>{const o=n.errorRetryCount,a=i.retryCount,s=~~((Math.random()+.5)*(1<<(a<8?a:8)))*n.errorRetryInterval;!u(o)&&a>o||setTimeout(r,s,i)},onDiscarded:a,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:P?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:P?5e3:3e3,compare:(e,t)=>p(e)==p(t),isPaused:()=>!1,cache:V,mutate:G,fallback:{}},T),$=(e,t)=>{const n=h(e,t);if(t){const{use:r,fallback:i}=e,{use:o,fallback:a}=t;r&&o&&(n.use=r.concat(o)),i&&a&&(n.fallback=h(i,a))}return n},Z=Object(r.createContext)({}),W=y&&window.__SWR_DEVTOOLS_USE__,X=W?window.__SWR_DEVTOOLS_USE__:[],H=e=>c(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],Y=X.concat(e=>(t,n,r)=>e(t,n&&((...e)=>{const[r]=O(t),[,,,i]=m.get(V);if(r.startsWith("$inf$"))return n(...e);const o=i[r];return u(o)?n(...e):(delete i[r],o)}),r));W&&(window.__SWR_DEVTOOLS_REACT__=i.a);const K=i.a.use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;throw"rejected"===e.status?e.reason:(e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e)}),J={dedupe:!0},Q=(l.defineProperty(e=>{const{value:t}=e,n=Object(r.useContext)(Z),i=c(t),o=Object(r.useMemo)(()=>i?t(n):t,[i,n,t]),a=Object(r.useMemo)(()=>i?o:$(n,o),[i,n,o]),l=o&&o.provider,u=Object(r.useRef)(s);l&&!u.current&&(u.current=N(l(a.cache||V),o));const d=u.current;return d&&(a.cache=d[0],a.mutate=d[1]),C(()=>{if(d)return d[2]&&d[2](),d[3]},[]),Object(r.createElement)(Z.Provider,h(e,{value:a}))},"defaultValue",{value:q}),ee=(e,t,n)=>{const{cache:i,compare:a,suspense:l,fallbackData:d,revalidateOnMount:f,revalidateIfStale:p,refreshInterval:g,refreshWhenHidden:_,refreshWhenOffline:y,keepPreviousData:v}=n,[b,w,E,T]=m.get(i),[S,I]=O(e),P=Object(r.useRef)(!1),z=Object(r.useRef)(!1),U=Object(r.useRef)(S),N=Object(r.useRef)(t),V=Object(r.useRef)(n),G=()=>V.current,q=()=>G().isVisible()&&G().isOnline(),[$,Z,W,X]=x(i,S),H=Object(r.useRef)({}).current,Y=u(d)?n.fallback[S]:d,Q=(e,t)=>{for(const n in H){const r=n;if("data"===r){if(!a(e[r],t[r])){if(!u(e[r]))return!1;if(!a(le,t[r]))return!1}}else if(t[r]!==e[r])return!1}return!0},ee=Object(r.useMemo)(()=>{const e=!!S&&!!t&&(u(f)?!G().isPaused()&&!l&&(!!u(p)||p):f),n=t=>{const n=h(t);return delete n._k,e?{isValidating:!0,isLoading:!0,...n}:n},r=$(),i=X(),o=n(r),a=r===i?o:n(i);let s=o;return[()=>{const e=n($());return Q(e,s)?(s.data=e.data,s.isLoading=e.isLoading,s.isValidating=e.isValidating,s.error=e.error,s):(s=e,e)},()=>a]},[i,S]),te=Object(o.useSyncExternalStore)(Object(r.useCallback)(e=>W(S,(t,n)=>{Q(n,t)||e()}),[i,S]),ee[0],ee[1]),ne=!P.current,re=b[S]&&b[S].length>0,ie=te.data,oe=u(ie)?Y:ie,ae=te.error,se=Object(r.useRef)(oe),le=v?u(ie)?se.current:ie:oe,ue=!(re&&!u(ae))&&(ne&&!u(f)?f:!G().isPaused()&&(l?!u(oe)&&p:u(oe)||p)),ce=!!(S&&t&&ne&&ue),he=u(te.isValidating)?ce:te.isValidating,de=u(te.isLoading)?ce:te.isLoading,fe=Object(r.useCallback)(async e=>{const t=N.current;if(!S||!t||z.current||G().isPaused())return!1;let r,i,o=!0;const l=e||{},h=!E[S]||!l.dedupe,d=()=>A?!z.current&&S===U.current&&P.current:S===U.current,f={isValidating:!1,isLoading:!1},p=()=>{Z(f)},m=()=>{const e=E[S];e&&e[1]===i&&delete E[S]},g={isValidating:!0};u($().data)&&(g.isLoading=!0);try{if(h&&(Z(g),n.loadingTimeout&&u($().data)&&setTimeout(()=>{o&&d()&&G().onLoadingSlow(S,n)},n.loadingTimeout),E[S]=[t(I),L()]),[r,i]=E[S],r=await r,h&&setTimeout(m,n.dedupingInterval),!E[S]||E[S][1]!==i)return h&&d()&&G().onDiscarded(S),!1;f.error=s;const e=w[S];if(!u(e)&&(i<=e[0]||i<=e[1]||0===e[1]))return p(),h&&d()&&G().onDiscarded(S),!1;const l=$().data;f.data=a(l,r)?l:r,h&&d()&&G().onSuccess(r,S,n)}catch(e){m();const t=G(),{shouldRetryOnError:n}=t;t.isPaused()||(f.error=e,h&&d()&&(t.onError(e,S,t),(!0===n||c(n)&&n(e))&&q()&&t.onErrorRetry(e,S,t,e=>{const t=b[S];t&&t[0]&&t[0](D,e)},{retryCount:(l.retryCount||0)+1,dedupe:!0})))}return o=!1,p(),!0},[S,i]),pe=Object(r.useCallback)((...e)=>j(i,U.current,...e),[]);if(C(()=>{N.current=t,V.current=n,u(ie)||(se.current=ie)}),C(()=>{if(!S)return;const e=fe.bind(s,J);let t=0;const n=((e,t,n)=>{const r=t[e]||(t[e]=[]);return r.push(n),()=>{const e=r.indexOf(n);e>=0&&(r[e]=r[r.length-1],r.pop())}})(S,b,(n,r={})=>{if(n==R){const n=Date.now();G().revalidateOnFocus&&n>t&&q()&&(t=n+G().focusThrottleInterval,e())}else if(n==F)G().revalidateOnReconnect&&q()&&e();else{if(n==B)return fe();if(n==D)return fe(r)}});return z.current=!1,U.current=S,P.current=!0,Z({_k:I}),ue&&(u(oe)||k?e():M(e)),()=>{z.current=!0,n()}},[S]),C(()=>{let e;function t(){const t=c(g)?g($().data):g;t&&-1!==e&&(e=setTimeout(n,t))}function n(){$().error||!_&&!G().isVisible()||!y&&!G().isOnline()?t():fe(J).then(t)}return t(),()=>{e&&(clearTimeout(e),e=-1)}},[g,_,y,S]),Object(r.useDebugValue)(le),l&&u(oe)&&S){if(!A&&k)throw new Error("Fallback data is required when using suspense in SSR.");N.current=t,V.current=n,z.current=!1;const e=T[S];if(!u(e)){const t=pe(e);K(t)}if(!u(ae))throw ae;{const e=fe(J);u(le)||(e.status="fulfilled",e.value=!0),K(e)}}return{mutate:pe,get data(){return H.data=!0,le},get error(){return H.error=!0,ae},get isValidating(){return H.isValidating=!0,he},get isLoading(){return H.isLoading=!0,de}}},function(...e){const t=h(q,Object(r.useContext)(Z)),[n,i,o]=H(e),a=$(t,o);let s=ee;const{use:l}=a,u=(l||[]).concat(Y);for(let e=u.length;e--;)s=u[e](s);return s(n,i||a.fetcher||null,a)});var ee},,,function(e,t,n){"use strict"; /** * @license React * react-dom.production.min.js @@ -27,7 +27,7 @@ License: MIT * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var r=n(0),i=n(48);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n