diff --git a/assets/core.js b/assets/core.js index 088dd59f..1cc3c437 100644 --- a/assets/core.js +++ b/assets/core.js @@ -1 +1 @@ -(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,w=n(25),j=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(j.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(w.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),k=n(39);function I(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 N(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 N(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 N(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=A(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 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})))))};ce.propTypes={rows:p.a.arrayOf(p.a.array)};var se=ce,le=n(48),ue=function(e,t,n){void 0===n&&(n=[]);var a=e.url,r=e.yearRange,o=e.dataID,i=Object(le.a)(a||e.className||o,Object(l.a)(s.a.mark((function n(){var r;return s.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e.data||!Array.isArray(e.data)){n.next=2;break}return n.abrupt("return",e.data);case 2:if(!(a||o&&t)){n.next=5;break}return r=a?F(a):T(o,t),n.abrupt("return",r.then((function(t){return e.filters?B(t,e.filters):t})));case 5:return n.abrupt("return",[]);case 6:case"end":return n.stop()}}),n)})))),c=i.data,d=i.error,f=Object(u.useState)(n),p=f[0],b=f[1];if(d)return{data:[],years:[]};var m=Object(u.useMemo)((function(){return c?(r&&r.length,ee(c,e)):[]}),[c]);return{data:Object(u.useMemo)((function(){return c&&c.length?p.length?p.reduce((function(e,t){return"all"===t.value?e:M(e,t.dataProperty,t.value)}),c):c:[]}),[c,p]),years:m,filters:p,setFilters:b,updateFilter:function(e,t){p&&p.length&&b(p.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,e.baseAPIUrl),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(_,{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(w.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,baseAPIUrl:p.a.string},pe.defaultProps={subCounty:"all"};var be,me,ge=pe,he=function(e,t){(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(n){Array.prototype.forEach.call(n,(function(n){n.classList.add("dicharts--dimensions"),n.parentElement.classList.add("auto-height");var a=new window.DICharts.Chart(n.parentElement);a.showLoading();var r="all",i=Object(o.createRoot)(n);i.render(d.a.createElement(ge,{config:e,subCounty:r,baseAPIUrl:t})),window.DIState&&window.DIState.addListener((function(){var n=window.DIState.getState.subCounty;n&&n!==r&&(r=n,i.render(d.a.createElement(ge,{config:e,subCounty:r,baseAPIUrl:t})))})),a.hideLoading()}))}}})},ve=function(){if(window.DIState){var e=[];window.DIState.addListener((function(){var t=window.DIState.getState,n=t.charts,a=t.baseAPIUrl;n&&e.length!==n.length&&(e=n).forEach((function(e){return he(e,a)}))}))}else window.console.log("State is not defined")},ye=n(14),Oe=n.n(ye),we=function(e){var t=e.map,n=e.show,a=e.onAdd,r=Object(j.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};we.defaultProps={show:!0},we.propTypes={map:p.a.object,show:p.a.bool,onAdd:p.a.func};var je={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({},je,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===we?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:je,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};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},ke=function(e){var t=e.geometry&&e.geometry.coordinates;return t?new ye.LngLat(t[0],t[1]):null},Ie=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]),ke(Object(Ce.a)(Object(Se.f)([t])))}return ke(Object(Ce.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)},Pe=function(e,t,n){return t.find((function(t){var a=n?n(t.name):t.name;return e.toLowerCase()===(""+a).toLowerCase()}))},Ae=Object(u.createContext)(),Te=Object(u.createContext)(),Fe=n(43),De=function(e){function t(t){var n;return(n=e.call(this,t)||this).state={hasError:!1},n}Object(Fe.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);De.propTypes={children:p.a.any};var _e,Re=De,ze=function(e,t){return e.find((function(e){return e.id===t}))},Ue=function(e){return e.map((function(e){return{value:e.id,label:e.name}}))},qe=function(e,t){var n=ze(e,t);return n?n.indicators.map((function(e){return{value:e.id,label:e.name}})):[]},Ve=function(e,t,n){if(t&&n){var a=ze(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 A(r.yearRange).filter((function(e){return r.excludeYears?!r.excludeYears.includes(e):e})).reverse().map((function(e){return{value:e,label:e}}))}return[]},Me=function(e){var t=Object(u.useContext)(Te),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=ze(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=Ve(e,n.topic,n.indicator);t.length&&!t.find((function(e){return e.value===n.year}))&&a({year:t[0].value})}}),[n.indicator]),{topicOptions:Ue(e||[]),indicatorOptions:qe(e,n.topic),yearOptions:Ve(e,n.topic,n.indicator)}},Be=function(){var e=Object(u.useContext)(Te),t=e.filters,n=e.topics,a=e.filterOptions,o=e.updateFilterOptions,i=Me(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)(_e||(_e=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)(Te).activeIndicator;return d.a.createElement("div",{className:"spotlight__content"},d.a.createElement(Re,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=Ie(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"];function at(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 rt,ot=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=Pe(s,i);Ne(e,a,t.lngLat,s,Le(n,l))}else Ne(e,a,t.lngLat,s,"")}}(t,n,Object.assign({},a,{popup:e}))},it=new ye.Popup({offset:5}),ct=new ye.Popup({offset:5}),st=function(e,t,n,a){void 0===a&&(a={});var r=Object(u.useState)(),o=r[0],i=r[1],c=Object(u.useState)(a),d=c[0],f=c[1],p=Object(u.useState)([]),b=p[0],m=p[1],g=Object(u.useState)(),h=g[0],v=g[1],y=Object(u.useState)(""),O=y[0],w=y[1],j=Object(u.useCallback)((function(e){o.getCanvas().style.cursor="pointer",ot(it,o,e,Object.assign({},t,{data:b},d))}),[o,b,d]),x=Object(u.useCallback)((function(){o.getCanvas().style.cursor="",it.remove()}),[o,e]),C=Object(u.useCallback)((function(e){e.preventDefault(),o.off("mousemove","highlight",j),it.remove(),e.features.length&&o.setLayoutProperty("points","icon-size",["match",["get","name"],e.features[0].properties.name,.4,.2])}),[o,h]),S=Object(u.useCallback)((function(e){for(var t=e.features[0].geometry.coordinates.slice(),n=e.features[0].properties,a=n.name,r=n.parish,i=n.ownership;Math.abs(e.lngLat.lng-t[0])>180;)t[0]+=e.lngLat.lng>t[0]?360:-360;ct.setLngLat(t).setHTML('\n
\n
\n '+a+"\n
\n

Coordinates: "+t+"

\n

Ownership: "+i+"

\n

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

\n
\n ").addTo(o)})),E=Object(u.useCallback)((function(){o.on("mousemove","highlight",j),it.remove(),o.setLayoutProperty("points","icon-size",.2)}),[o,e]);return Object(u.useEffect)((function(){o&&(o.getLayer("points")&&o.removeLayer("points"),h&&o.loadImage("https://docs.mapbox.com/mapbox-gl-js/assets/custom_marker.png",(function(e,t){if(e)throw e;o.hasImage("custom-marker")||o.addImage("custom-marker",t,{sdf:!0}),o.getSource("points")||o.addSource("points",{type:"geojson",data:h,generateId:!0}),o.getLayer("points")||o.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}),o.getSource("points").setData(h)})))}),[o,b,h,O]),Object(u.useEffect)((function(){o&&(o.getStyle().layers.forEach((function(e){["background","highlight"].includes(e.id)||o.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)}(o,o.getContainer(),t),o.off("mousemove","points",C),o.off("mouseleave","highlight",x),o.off("mouseover","highlight",j),o.off("click","points",S),o.on("mousemove","highlight",j),o.on("mouseleave","highlight",x),o.on("mousemove","points",C),o.on("mouseleave","points",E),o.on("click","points",S))}),[o,e,d,b]),Object(u.useEffect)((function(){var t=function(){var e=Object(l.a)(s.a.mark((function e(t,a){var r,o;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t||a&&n)){e.next=6;break}return r=t?F(t):T(a,n),e.next=4,r;case 4:o=e.sent,m(Qe(o,d.indicator,d.year));case 6:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();d.indicator&&d.year&&(w(at(d.indicator.id)),v(function(e,t,n,a,r){var o={type:"FeatureCollection",features:[]};return t&&(n||a&&r)&&(n||a&&r)?((n?F(n):T(a,r)).then((function(n){var a=n.filter((function(t){return"Masindi"===e?!tt.includes(t.school_name):!nt.includes(t.school_name)}));"all"===t.ownership?a.filter((function(e){return e.level===t.level})).forEach((function(e){if(e.gps_coordinates){var t=et(e.gps_coordinates);t&&o.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}})}})):a.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&&o.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)})),o):o}(e.name,at(d.indicator.id),d.indicator.schoolLocationUrl,d.indicator.schoolLocationdataID,n)),t(d.indicator.url,d.indicator.dataID))}),[d.indicator,d.year]),{map:o,data:b,setData:m,setMap:i,setOptions:f}},lt=function(e,t,n,a,o){var i=[a].map((function(e){return Object(r.c)(we,{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)(we,{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)(we,{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}))},ut={topic:null,indicator:null,year:null},dt=m.a.div(rt||(rt=Object(b.a)(["\n position: absolute;\n top: 1.75em;\n z-index: 1;\n left: 1.4em;\n"])));function ft(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:ut});default:throw new Error}}var pt={filterOptions:ut},bt=function(e){var t=Object(u.useState)(!0),n=t[0],a=t[1],o=Object(u.useReducer)(ft,pt),i=o[0],c=o[1],s=i.filterOptions,l=i.activeIndicator,d=i.activeTopic,f=i.activeYear,p=st(e.location,e.configs.formatter?Object.assign({},Xe,{formatter:e.configs.formatter}):Xe,e.baseAPIUrl),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})},w=(v=e.configs.data,y=s.topic,v.find((function(e){return e.id===y}))),j=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)(Te.Provider,{value:j},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,w&&w.dashboardUrl?Object(r.c)(dt,null,Object(r.c)("a",{href:w.dashboardUrl,className:"button button--secondary--fill"},w.dashboardButtonCaption)):null,Object(r.c)(xe,{accessToken:"pk.eyJ1IjoiZWR3aW5tcCIsImEiOiJjazFsdHVtcG0wOG9mM2RueWJscHhmcXZqIn0.cDR43UvfMaOY9cNJsEKsvg",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)}},lt(n,b,e.location,e.configs.formatter?Object.assign({},Xe,{formatter:e.configs.formatter}):Xe,l?{range:l.range,colours:l.colours}:{})))))};bt.defaultProps={data:[]},bt.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}),baseAPIUrl:p.a.string};var mt,gt,ht,vt,yt,Ot,wt,jt=bt,xt=m.a.div(mt||(mt=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"]))),Ct=function(){return d.a.createElement(xt,null,d.a.createElement($,null))},St=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,o=e.baseAPIUrl;a?n.render(d.a.createElement(jt,{configs:a,location:r,filters:a.filters,baseAPIUrl:o})):n.render(d.a.createElement(Ct,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},Et=n(46),Lt=function(e){var t=e.close,n=e.description,a=e.source;return Object(r.c)("div",{className:"spotlight-modal",css:Object(r.b)(ht||(ht=Object(b.a)(["\n font-size: 12px;\n "])))},Object(r.c)("a",{className:"close",onClick:t,css:Object(r.b)(vt||(vt=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)(yt||(yt=Object(b.a)(["\n width: 100%;\n padding: 10px 5px 10px 5px;\n "])))},Object(r.c)("p",{className:"description",css:Object(r.b)(Ot||(Ot=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)(gt||(gt=Object(b.a)(["\n font-family: Geomanist Bold, sans-serif;\n "])))},"Source:"," "),a):null)," "):null))};Lt.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string,close:p.a.func.isRequired};var kt,It,Nt=Lt,Pt=function(e){return Object(r.c)(Et.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)(It||(It=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)(Nt,{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 At=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(At,{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,Dt=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)(At,{description:n.meta.description,source:n.meta.source}):null):null)};_t.propTypes={note:p.a.object,value:p.a.string};var Rt,zt=_t,Ut=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)};Ut.propTypes={children:p.a.any};var qt=Ut,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,Bt=function(e){var t=e.children,n=e.onClick;return d.a.createElement("div",{className:"tabs__content__header",onClick:n},t)};Bt.propTypes={children:p.a.any,onClick:p.a.func};var Gt,Zt,Wt,Yt,Ht,Jt=Bt,Kt=function(e){var t=Object(u.useContext)(Ae),n=t.data,a=t.location,o=t.options,i="education",c=V(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)(Jt,null,s?Object(r.c)("div",{css:Object(r.b)(Gt||(Gt=Object(b.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(Zt||(Zt=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(Wt||(Wt=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(Yt||(Yt=Object(b.a)(["\n font-size: 3rem;\n "])))},P(s.value)),Object(r.c)(At,{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)(Ht||(Ht=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(zt,{value:e.value})))})):null)))};Kt.propTypes={active:p.a.bool};var Xt,$t,Qt,en,tn,nn=Kt,an=function(e){var t=Object(u.useContext)(Ae),n=t.data,a=t.location,o=t.options,i="overview",c=V(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)(Jt,null,n&&n.population?Object(r.c)("div",{css:Object(r.b)(Xt||(Xt=Object(b.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)($t||($t=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(Qt||(Qt=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Total Population in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(en||(en=Object(b.a)(["\n font-size: 3rem;\n "])))},P(n.population.value)),Object(r.c)(At,{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)(tn||(tn=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(zt,{value:e.value})))})):null))):null};an.propTypes={active:p.a.bool};var rn,on,cn,sn,ln,un,dn=an,fn=function(e){var t=Object(u.useContext)(Ae),n=t.data,a=t.location,o=t.options,i="production",c=V(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)(Jt,null,Object(r.c)("div",{css:Object(r.b)(rn||(rn=Object(b.a)(["\n display: flex;\n "])))},s?Object(r.c)("div",{css:Object(r.b)(on||(on=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(cn||(cn=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(sn||(sn=Object(b.a)(["\n font-size: 3rem;\n "])))},P(s.value)),Object(r.c)(At,{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)(ln||(ln=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)(un||(un=Object(b.a)(["\n font-size: 16px;\n display: flex;\n justify-content: center;\n width: 100%;\n "])))},"No Production Data")))};fn.propTypes={active:p.a.bool};var pn,bn=fn,mn=function(e){var t=e.children;return Object(r.c)("div",{className:"tabs",css:Object(r.b)(pn||(pn=Object(b.a)(["\n z-index: 0;\n "])))},t)};mn.propTypes={children:p.a.any};var gn=mn,hn=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)(Ae.Provider,{value:Object.assign({},e,{data:n})},Object(r.c)(gn,null,Object(r.c)(dn,{active:!0}),Object(r.c)(nn,null),Object(r.c)(bn,null)))};hn.propTypes={data:p.a.array.isRequired,location:p.a.object.isRequired,options:p.a.object.isRequired};var vn=hn,yn=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,o=e.baseAPIUrl;(null==a?void 0:a.url)||(null==a?void 0:a.dataID)&&o?((null==a?void 0:a.url)?F(null==a?void 0:a.url):T(null==a?void 0:a.dataID,o)).then((function(e){Array.isArray(e)?n.render(d.a.createElement(vn,{data:e,options:a,location:r})):e.results?n.render(d.a.createElement(vn,{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(Ct,null)))})).catch((function(e){window.console.log(e),n.render(d.a.createElement(Ct,null))})):a&&a.data?n.render(d.a.createElement(vn,{data:a.data,options:a,location:r})):n.render(d.a.createElement(Ct,null));t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},On=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:M(e,t.property,t.value)}),a),u=Z(r,l,o);i.render(d.a.createElement(se,{rows:u}))}}},e.abrupt("return",R(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){if(window.DIState){var n=window.DIState.getState.baseAPIUrl;(e.url?F(e.url):T(e.dataID,n)).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&&On({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){wn(e)}))}))}else window.console.log("State is not defined")};n(103);window.addEventListener("load",(function(){R("district-selectors",{makeSticky:!0}),St("dicharts--district-map"),jn(),yn("dicharts--keyfacts"),ve()}))},50:function(e,t,n){e.exports=n(104)}},[[50,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(2),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,w=n(25),j=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(j.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(w.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,k=n(106),L=n(39);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 I(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 I(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 I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n=t[M]?"#3b8c62":Number(e)"+e.title+""}}}},color:X.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"}},Q=n(24),ee=n.n(Q),te=function(){return d.a.createElement("div",{className:"no-data"},"No Data")},ne=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]=ee()(e[r],t,n):-1===e.indexOf(t)&&a.push(t)})),a},ae=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()}))},re=function(e,t,n){var a=e.reduce((function(e,a){return a[n.mapping.series]===t?e+Number(Z(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},oe=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})))))};ue.propTypes={rows:p.a.arrayOf(p.a.array)};var de=ue,fe=n(48),pe=function(e,t,n){void 0===n&&(n=[]);var a=e.url,r=e.yearRange,o=e.dataID,i=Object(fe.a)(a||e.className||o,Object(l.a)(s.a.mark((function n(){var r;return s.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e.data||!Array.isArray(e.data)){n.next=2;break}return n.abrupt("return",e.data);case 2:if(!(a||o&&t)){n.next=5;break}return r=a?F(a):A(o,t),n.abrupt("return",r.then((function(t){return e.filters?G(t,e.filters):t})));case 5:return n.abrupt("return",[]);case 6:case"end":return n.stop()}}),n)})))),c=i.data,d=i.error,f=Object(u.useState)(n),p=f[0],b=f[1];if(d)return{data:[],years:[]};var m=Object(u.useMemo)((function(){return c?(r&&r.length,ae(c,e)):[]}),[c]);return{data:Object(u.useMemo)((function(){return c&&c.length?p.length?p.reduce((function(e,t){return"all"===t.value?e:B(e,t.dataProperty,t.value)}),c):c:[]}),[c,p]),years:m,filters:p,setFilters:b,updateFilter:function(e,t){p&&p.length&&b(p.map((function(n){return n.dataProperty===e?Object.assign({},n,{value:t}):n})))}}},be=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};be.propTypes={show:p.a.bool,onClickChart:p.a.func,onClickTable:p.a.func,activeButton:p.a.string,className:p.a.string},be.defaultProps={activeButton:"chart"};var me=be,ge=function(e){var t=pe(e.config,e.baseAPIUrl),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(_,{configs:e.config.selectors,onChange:function(e,t){o(e.dataProperty,t.value)}}):null,d.a.createElement(me,{show:!!e.config.table,onClickChart:function(){return s("chart")},onClickTable:function(){return s("table")},activeButton:c}),"chart"===c&&e.config.typeOptions?d.a.createElement(K,{options:e.config.typeOptions,onChange:p}):null),"chart"===c?d.a.createElement(ce,Object(w.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(de,{rows:Y(e.config.table,n,e.subCounty)}):null)};ge.propTypes={config:p.a.object,subCounty:p.a.string,baseAPIUrl:p.a.string},ge.defaultProps={subCounty:"all"};var he,ve,ye=ge,Oe=function(e,t){(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(n){Array.prototype.forEach.call(n,(function(n){n.classList.add("dicharts--dimensions"),n.parentElement.classList.add("auto-height");var a=new window.DICharts.Chart(n.parentElement);a.showLoading();var r="all",i=Object(o.createRoot)(n);i.render(d.a.createElement(ye,{config:e,subCounty:r,baseAPIUrl:t})),window.DIState&&window.DIState.addListener((function(){var n=window.DIState.getState.subCounty;n&&n!==r&&(r=n,i.render(d.a.createElement(ye,{config:e,subCounty:r,baseAPIUrl:t})))})),a.hideLoading()}))}}})},we=function(){if(window.DIState){var e=[];window.DIState.addListener((function(){var t=window.DIState.getState,n=t.charts,a=t.baseAPIUrl;n&&e.length!==n.length&&(e=n).forEach((function(e){return Oe(e,a)}))}))}else window.console.log("State is not defined")},je=n(14),xe=n.n(je),Ce=function(e){var t=e.map,n=e.show,a=e.onAdd,r=Object(j.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};Ce.defaultProps={show:!0},Ce.propTypes={map:p.a.object,show:p.a.bool,onAdd:p.a.func};var Se={width:"100%",position:"absolute",top:0,bottom:0,background:"#F3F3F3"},Ee=function(e){xe.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 xe.a.Map(Object.assign({container:t.current},e.options));e.showNavigationControls&&n.addControl(new xe.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({},Se,e.style),css:Object(r.b)(he||(he=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===Ce?Object(u.cloneElement)(e,{map:a}):null})),Object(r.c)(r.a,{styles:Object(r.b)(ve||(ve=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 "])))}))};Ee.defaultProps={style:Se,options:{minZoom:6,zoom:6.1},showNavigationControls:!0,background:"inherit"},Ee.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};var ke=n(29),Le=n(6),Ne=function(e,t){return t?t(e):e},Ie=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},Pe=function(e){var t=e.geometry&&e.geometry.coordinates;return t?new je.LngLat(t[0],t[1]):null},Te=function(e,t,n){var a=e.querySourceFeatures("composite",{sourceLayer:n.sourceLayer,filter:["in",n.nameProperty,Ne(t,n.formatter)]});return a&&a.length?function(e){if(Array.isArray(e)){var t=e.map((function(e){return Object(ke.a)(e.geometry).geometry.coordinates}));return t.push(t[0]),Pe(Object(ke.a)(Object(Le.f)([t])))}return Pe(Object(ke.a)(e))}(a):null},Ae=function(e,t,n,a,r){return t.setLngLat(n).setHTML('\n
\n
\n '+a.toLowerCase()+"\n
\n "+(r?''+r+"":"")+"\n
\n ").addTo(e)},Fe=function(e,t,n){return t.find((function(t){var a=n?n(t.name):t.name;return e.toLowerCase()===(""+a).toLowerCase()}))},De=Object(u.createContext)(),_e=Object(u.createContext)(),Re=n(43),ze=function(e){function t(t){var n;return(n=e.call(this,t)||this).state={hasError:!1},n}Object(Re.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);ze.propTypes={children:p.a.any};var Ue,qe=ze,Me=function(e,t){return e.find((function(e){return e.id===t}))},Ve=function(e){return e.map((function(e){return{value:e.id,label:e.name}}))},Be=function(e,t){var n=Me(e,t);return n?n.indicators.map((function(e){return{value:e.id,label:e.name}})):[]},Ge=function(e,t,n){if(t&&n){var a=Me(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[]},Ze=function(e){var t=Object(u.useContext)(_e),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=Me(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=Ge(e,n.topic,n.indicator);t.length&&!t.find((function(e){return e.value===n.year}))&&a({year:t[0].value})}}),[n.indicator]),{topicOptions:Ve(e||[]),indicatorOptions:Be(e,n.topic),yearOptions:Ge(e,n.topic,n.indicator)}},Ye=function(){var e=Object(u.useContext)(_e),t=e.filters,n=e.topics,a=e.filterOptions,o=e.updateFilterOptions,i=Ze(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)(Ue||(Ue=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))},We=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})))};We.propTypes={children:p.a.any};var He=We,Je=n(44),Ke=function(e){var t=e.children,n=e.className,a=e.bgColor,r=e.textColor,o=Je(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 "))};Ke.propTypes={children:p.a.any,className:p.a.string,bgColor:p.a.string,textColor:p.a.string};var Xe=Ke,$e=function(){var e,t,n=Object(u.useContext)(_e).activeIndicator;return d.a.createElement("div",{className:"spotlight__content"},d.a.createElement(qe,null,d.a.createElement(Ye,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(He,null,(e=n.range,t=n.colours,e&&t?e.map((function(n,a){return d.a.createElement(Xe,{className:"item-"+n,bgColor:t[a],key:n},0===a?"< "+e[0]:e[a-1]+"-"+n)})).concat([d.a.createElement(Xe,{className:"item-last",bgColor:t[t.length-1],key:e.length},"> "+e[e.length-1])]):null),d.a.createElement(Xe,null,"no data / not applicable"))):null)},Qe=n(45),et={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()}},tt=function(e,t,n,a){n&&(e.setFilter(t,["==",a.nameProperty,Ne(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=Te(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))},nt=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=G(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(Qe.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},at=function(e){return e.split(",").map((function(e){return parseFloat(e)}))},rt=["Waiga Primary School","Gods Mercy Primary School","Bukeeka COU Primary School"],ot=["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"];function it(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 ct,st=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=Fe(s,i);Ae(e,a,t.lngLat,s,Ie(n,l))}else Ae(e,a,t.lngLat,s,"")}}(t,n,Object.assign({},a,{popup:e}))},lt=new je.Popup({offset:5}),ut=new je.Popup({offset:5}),dt=function(e,t,n,a){void 0===a&&(a={});var r=Object(u.useState)(),o=r[0],i=r[1],c=Object(u.useState)(a),d=c[0],f=c[1],p=Object(u.useState)([]),b=p[0],m=p[1],g=Object(u.useState)(),h=g[0],v=g[1],y=Object(u.useState)(""),O=y[0],w=y[1],j=Object(u.useCallback)((function(e){o.getCanvas().style.cursor="pointer",st(lt,o,e,Object.assign({},t,{data:b},d))}),[o,b,d]),x=Object(u.useCallback)((function(){o.getCanvas().style.cursor="",lt.remove()}),[o,e]),C=Object(u.useCallback)((function(e){e.preventDefault(),o.off("mousemove","highlight",j),lt.remove(),e.features.length&&o.setLayoutProperty("points","icon-size",["match",["get","name"],e.features[0].properties.name,.4,.2])}),[o,h]),S=Object(u.useCallback)((function(e){for(var t=e.features[0].geometry.coordinates.slice(),n=e.features[0].properties,a=n.name,r=n.parish,i=n.ownership;Math.abs(e.lngLat.lng-t[0])>180;)t[0]+=e.lngLat.lng>t[0]?360:-360;ut.setLngLat(t).setHTML('\n
\n
\n '+a+"\n
\n

Coordinates: "+t+"

\n

Ownership: "+i+"

\n

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

\n
\n ").addTo(o)})),E=Object(u.useCallback)((function(){o.on("mousemove","highlight",j),lt.remove(),o.setLayoutProperty("points","icon-size",.2)}),[o,e]);return Object(u.useEffect)((function(){o&&(o.getLayer("points")&&o.removeLayer("points"),h&&o.loadImage("https://docs.mapbox.com/mapbox-gl-js/assets/custom_marker.png",(function(e,t){if(e)throw e;o.hasImage("custom-marker")||o.addImage("custom-marker",t,{sdf:!0}),o.getSource("points")||o.addSource("points",{type:"geojson",data:h,generateId:!0}),o.getLayer("points")||o.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}),o.getSource("points").setData(h)})))}),[o,b,h,O]),Object(u.useEffect)((function(){o&&(o.getStyle().layers.forEach((function(e){["background","highlight"].includes(e.id)||o.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)}(o,o.getContainer(),t),o.off("mousemove","points",C),o.off("mouseleave","highlight",x),o.off("mouseover","highlight",j),o.off("click","points",S),o.on("mousemove","highlight",j),o.on("mouseleave","highlight",x),o.on("mousemove","points",C),o.on("mouseleave","points",E),o.on("click","points",S))}),[o,e,d,b]),Object(u.useEffect)((function(){var t=function(){var e=Object(l.a)(s.a.mark((function e(t,a){var r,o;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t||a&&n)){e.next=6;break}return r=t?F(t):A(a,n),e.next=4,r;case 4:o=e.sent,m(nt(o,d.indicator,d.year));case 6:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}();d.indicator&&d.year&&(w(it(d.indicator.id)),v(function(e,t,n,a,r){var o={type:"FeatureCollection",features:[]};return t&&(n||a&&r)&&(n||a&&r)?((n?F(n):A(a,r)).then((function(n){var a=n.filter((function(t){return"Masindi"===e?!rt.includes(t.school_name):!ot.includes(t.school_name)}));"all"===t.ownership?a.filter((function(e){return e.level===t.level})).forEach((function(e){if(e.gps_coordinates){var t=at(e.gps_coordinates);t&&o.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}})}})):a.filter((function(e){return e.level===t.level&&e.ownership===t.ownership})).forEach((function(e){if(e.gps_coordinates){var t=at(e.gps_coordinates);t&&o.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)})),o):o}(e.name,it(d.indicator.id),d.indicator.schoolLocationUrl,d.indicator.schoolLocationdataID,n)),t(d.indicator.url,d.indicator.dataID))}),[d.indicator,d.year]),{map:o,data:b,setData:m,setMap:i,setOptions:f}},ft=function(e,t,n,a,o){var i=[a].map((function(e){return Object(r.c)(Ce,{key:"highlight-hidden",id:e.layerName,source:"composite","source-layer":e.sourceLayer,show:!1})}));function c(e,t){tt(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=Ne(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)(Ce,{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)(Ce,{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}))},pt={topic:null,indicator:null,year:null},bt=m.a.div(ct||(ct=Object(b.a)(["\n position: absolute;\n top: 1.75em;\n z-index: 1;\n left: 1.4em;\n"])));function mt(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:pt});default:throw new Error}}var gt={filterOptions:pt},ht=function(e){var t=Object(u.useState)(!0),n=t[0],a=t[1],o=Object(u.useReducer)(mt,gt),i=o[0],c=o[1],s=i.filterOptions,l=i.activeIndicator,d=i.activeTopic,f=i.activeYear,p=dt(e.location,e.configs.formatter?Object.assign({},et,{formatter:e.configs.formatter}):et,e.baseAPIUrl),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})},w=(v=e.configs.data,y=s.topic,v.find((function(e){return e.id===y}))),j=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)(_e.Provider,{value:j},Object(r.c)("div",{className:"spotlight"},Object(r.c)("div",{className:"spotlight__aside spotlight__aside--no-margin",css:{minHeight:"600px"}},Object(r.c)($e,null)),Object(r.c)("div",{className:"spotlight__main spotlight__main--map"},n?Object(r.c)("div",null,"Loading ..."):null,w&&w.dashboardUrl?Object(r.c)(bt,null,Object(r.c)("a",{href:w.dashboardUrl,className:"button button--secondary--fill"},w.dashboardButtonCaption)):null,Object(r.c)(Ee,{accessToken:"pk.eyJ1IjoiZWR3aW5tcCIsImEiOiJjazFsdHVtcG0wOG9mM2RueWJscHhmcXZqIn0.cDR43UvfMaOY9cNJsEKsvg",options:Object.assign({style:et.style,center:et.center,minZoom:et.minZoom||6,zoom:et.zoom||6.1,maxZoom:et.maxZoom||7,scrollZoom:!1},e.configs.options),style:{width:"100%",background:"#ffffff"},onLoad:function(e){a(!1),g(e)}},ft(n,b,e.location,e.configs.formatter?Object.assign({},et,{formatter:e.configs.formatter}):et,l?{range:l.range,colours:l.colours}:{})))))};ht.defaultProps={data:[]},ht.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}),baseAPIUrl:p.a.string};var vt,yt,Ot,wt,jt,xt,Ct,St=ht,Et=m.a.div(vt||(vt=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"]))),kt=function(){return d.a.createElement(Et,null,d.a.createElement(te,null))},Lt=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,o=e.baseAPIUrl;a?n.render(d.a.createElement(St,{configs:a,location:r,filters:a.filters,baseAPIUrl:o})):n.render(d.a.createElement(kt,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},Nt=n(46),It=function(e){var t=e.close,n=e.description,a=e.source;return Object(r.c)("div",{className:"spotlight-modal",css:Object(r.b)(Ot||(Ot=Object(b.a)(["\n font-size: 12px;\n "])))},Object(r.c)("a",{className:"close",onClick:t,css:Object(r.b)(wt||(wt=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)(jt||(jt=Object(b.a)(["\n width: 100%;\n padding: 10px 5px 10px 5px;\n "])))},Object(r.c)("p",{className:"description",css:Object(r.b)(xt||(xt=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)(Ct||(Ct=Object(b.a)(["\n text-align: left;\n "])))},a?Object(r.c)(d.a.Fragment,null,Object(r.c)("b",{css:Object(r.b)(yt||(yt=Object(b.a)(["\n font-family: Geomanist Bold, sans-serif;\n "])))},"Source:"," "),a):null)," "):null))};It.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string,close:p.a.func.isRequired};var Pt,Tt,At=It,Ft=function(e){return Object(r.c)(Nt.a,{trigger:Object(r.c)("span",{className:"spotlight__stat-icon",css:Object(r.b)(Pt||(Pt=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)(Tt||(Tt=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)(At,{close:t,description:e.description,source:e.source})}))};Ft.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string};var Dt=Ft,_t=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(Dt,{description:n.description,source:n.source}):null),r)};_t.defaultProps={meta:{}},_t.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 Rt,zt=_t,Ut=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)(Rt||(Rt=Object(b.a)(["\n transform: none;\n position: relative;\n top: -10px;\n "])))},n.content," ",n.meta?Object(r.c)(Dt,{description:n.meta.description,source:n.meta.source}):null):null)};Ut.propTypes={note:p.a.object,value:p.a.string};var qt,Mt=Ut,Vt=function(e){var t=e.children;return Object(r.c)("article",{className:"tabs__content",css:Object(r.b)(qt||(qt=Object(b.a)(["\n z-index: 200;\n "])))},t)};Vt.propTypes={children:p.a.any};var Bt=Vt,Gt=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===Bt?e:null})))};Gt.propTypes={id:p.a.string.isRequired,label:p.a.string.isRequired,active:p.a.bool,onActivate:p.a.func,children:p.a.any};var Zt=Gt,Yt=function(e){var t=e.children,n=e.onClick;return d.a.createElement("div",{className:"tabs__content__header",onClick:n},t)};Yt.propTypes={children:p.a.any,onClick:p.a.func};var Wt,Ht,Jt,Kt,Xt,$t=Yt,Qt=function(e){var t=Object(u.useContext)(De),n=t.data,a=t.location,o=t.options,i="education",c=V(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)(Zt,{id:i,label:c.label||"Education",active:!!e.active||c.active},Object(r.c)(Bt,null,Object(r.c)($t,null,s?Object(r.c)("div",{css:Object(r.b)(Wt||(Wt=Object(b.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(Ht||(Ht=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(Jt||(Jt=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(Kt||(Kt=Object(b.a)(["\n font-size: 3rem;\n "])))},P(s.value)),Object(r.c)(Dt,{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)(zt,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(Xt||(Xt=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(Mt,{value:e.value})))})):null)))};Qt.propTypes={active:p.a.bool};var en,tn,nn,an,rn,on=Qt,cn=function(e){var t=Object(u.useContext)(De),n=t.data,a=t.location,o=t.options,i="overview",c=V(o.tabs,i);return void 0===c.show||c.show?Object(r.c)(Zt,{id:i,label:c.label||"Overview",active:!!e.active||c.active},Object(r.c)(Bt,null,Object(r.c)($t,null,n&&n.population?Object(r.c)("div",{css:Object(r.b)(en||(en=Object(b.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(tn||(tn=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(nn||(nn=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Total Population in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(an||(an=Object(b.a)(["\n font-size: 3rem;\n "])))},P(n.population.value)),Object(r.c)(Dt,{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)(zt,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(rn||(rn=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(Mt,{value:e.value})))})):null))):null};cn.propTypes={active:p.a.bool};var sn,ln,un,dn,fn,pn,bn=cn,mn=function(e){var t=Object(u.useContext)(De),n=t.data,a=t.location,o=t.options,i="production",c=V(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)(Zt,{id:i,label:c.label||"Production",active:!!e.active||c.active},Object(r.c)(Bt,null,Object(r.c)($t,null,Object(r.c)("div",{css:Object(r.b)(sn||(sn=Object(b.a)(["\n display: flex;\n "])))},s?Object(r.c)("div",{css:Object(r.b)(ln||(ln=Object(b.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(un||(un=Object(b.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(dn||(dn=Object(b.a)(["\n font-size: 3rem;\n "])))},P(s.value)),Object(r.c)(Dt,{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)(zt,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(fn||(fn=Object(b.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(Mt,{value:e.value})))}))):Object(r.c)("div",{css:Object(r.b)(pn||(pn=Object(b.a)(["\n font-size: 16px;\n display: flex;\n justify-content: center;\n width: 100%;\n "])))},"No Production Data")))};mn.propTypes={active:p.a.bool};var gn,hn=mn,vn=function(e){var t=e.children;return Object(r.c)("div",{className:"tabs",css:Object(r.b)(gn||(gn=Object(b.a)(["\n z-index: 0;\n "])))},t)};vn.propTypes={children:p.a.any};var yn=vn,On=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)(De.Provider,{value:Object.assign({},e,{data:n})},Object(r.c)(yn,null,Object(r.c)(bn,{active:!0}),Object(r.c)(on,null),Object(r.c)(hn,null)))};On.propTypes={data:p.a.array.isRequired,location:p.a.object.isRequired,options:p.a.object.isRequired};var wn=On,jn=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,o=e.baseAPIUrl;(null==a?void 0:a.url)||(null==a?void 0:a.dataID)&&o?((null==a?void 0:a.url)?F(null==a?void 0:a.url):A(null==a?void 0:a.dataID,o)).then((function(e){Array.isArray(e)?n.render(d.a.createElement(wn,{data:e,options:a,location:r})):e.results?n.render(d.a.createElement(wn,{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(kt,null)))})).catch((function(e){window.console.log(e),n.render(d.a.createElement(kt,null))})):a&&a.data?n.render(d.a.createElement(wn,{data:a.data,options:a,location:r})):n.render(d.a.createElement(kt,null));t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},xn=function(e){var t=[{color:"#3b8c62",caption:"On target"},{color:"#cd2b2a",caption:"Below target"},{color:"#cdcfd1",caption:"No data"}];Object(u.useEffect)((function(){var e=document.createElement("div"),n=""+t.map((function(e){return'\n \n \n "})).join("");e.classList.add("custom-legend","score-table-legend"),e.innerHTML=n;var a=document.querySelector(".score-table-container"),r=a.firstChild;return r?a.insertBefore(e,r):a.appendChild(e),function(){a&&a.removeChild(e)}}));var n=function(t,n){return void 0===n&&(n=!1),t.map((function(t,a){return Object(r.c)("tr",{key:a},t.map((function(t,a){return n?Object(r.c)("th",{key:a},t):Object(r.c)("td",{css:{backgroundColor:H(t,e.thresholds),color:H(t,e.thresholds)?"white":"black"},key:a},0===Number(t)?"":t)})))}))};return Object(r.c)("div",{className:"score-table-container"},Object(r.c)(le,null,Object(r.c)("thead",null,n(e.rows.filter((function(e,t){return 0===t})),!0)),Object(r.c)("tbody",null,n(e.rows.filter((function(e,t){return t>0}))))))};xn.propTypes={rows:p.a.arrayOf(p.a.array),thresholds:p.a.object};var Cn=xn,Sn=function(){var e=Object(l.a)(s.a.mark((function e(t,n,a,r){var o,i,c,l,u,f;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t.data,i=t.config,c=t.subCounty,l=t.tableRoot,u=i.selectors.map((function(e){return{property:e.dataProperty,value:"all"}})),f=function(e,t){var n=Array.isArray(t)?t[0].value:t.value;if(n){var s=u.find((function(t){return t.property===e.config.dataProperty}));if(s){s.value=n;var f=u.reduce((function(e,t){return"all"===t.value?e:B(e,t.property,t.value)}),o);if("scoreCard"===a){var p=W(i,f,c);l.render(d.a.createElement(Cn,{rows:p,thresholds:r}))}else{var b=Y(i,f,c);l.render(d.a.createElement(de,{rows:b}))}}}},e.abrupt("return",R(i.selectorClassName,{selectors:i.selectors,onChange:f,makeSticky:!1,nodes:n}));case 4:case"end":return e.stop()}}),e)})));return function(t,n,a,r){return e.apply(this,arguments)}}(),En=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){if(window.DIState){var n=window.DIState.getState.baseAPIUrl;(e.url?F(e.url):A(e.dataID,n)).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,s=e.tableType,l=e.thresholds;if(o!==i){i=o||"all";var u=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;if("scoreCard"===s){var f=W(e,u,i);r.render(d.a.createElement(Cn,{rows:f,thresholds:l}))}else{var p=Y(e,u,i);r.render(d.a.createElement(de,{rows:p}))}e.selectors&&e.selectors.length&&Sn({data:u,subCounty:i,config:e,tableRoot:r},c,s,l).then((function(e){c=e})),a.hideLoading(),t.parentElement.classList.add("auto-height")}}))}))}))}}}})},kn=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){En(e)}))}))}else window.console.log("State is not defined")};n(103);window.addEventListener("load",(function(){R("district-selectors",{makeSticky:!0}),Lt("dicharts--district-map"),kn(),jn("dicharts--keyfacts"),we()}))},50:function(e,t,n){e.exports=n(104)}},[[50,1,2]]]); \ No newline at end of file diff --git a/assets/styles.css b/assets/styles.css index a654d6b2..45953adb 100644 --- a/assets/styles.css +++ b/assets/styles.css @@ -1,2 +1,2 @@ -.dicharts--dimensions,.dicharts--district-map{width:100%;height:600px}.dicharts--padding-top{padding-top:30px}.dicharts--actions{display:flex;align-items:flex-end}.button-group{margin-left:auto}.dicharts--actions.align-left .button-group{margin-left:0}.button.button-outline,button.button-outline{background:transparent;color:inherit}.button-group .button-outline{border:1px solid #357ba5;border-left:none;color:#357ba5}.button-group .button-outline:first-child{border-left:1px solid #357ba5}.button-group .button-outline.active,.button-group .button-outline:hover{color:#fff}.button-group .button-outline.active{background:#357ba5}.button-sm{padding:.9rem 1rem}.dicharts--learners-enrolment,.dicharts--number-of-schools,.dicharts--ple-performance-analysis{height:100%}.dicharts--keyfacts{background:#fceae9}.spotlight-banner.data-selector--wrapper{padding:1em 2em 2rem;min-height:95px}.spotlight-banner .labelled-data-selector--wrapper .data-selector{left:0}.labelled-data-selector--wrapper{display:inline-block}.charts__chart .table-styled table{width:100%}.auto-height{min-height:auto!important}.custom-legend{display:flex;justify-content:center;flex-flow:row wrap;min-height:160px}.custom-legend.right{display:block;width:350px;position:absolute;right:0;z-index:1;top:100px}@media (max-width:1350px){.custom-legend.right{position:relative;width:100%;top:auto}}@media screen and (max-width:412px){.custom-legend.right{display:block}}.legend-item{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;margin-right:5px}.right .legend-item{margin-bottom:5px}.badge{display:inline-block;font-size:75%;font-weight:700;line-height:1;text-align:center;white-space:nowrap;vertical-align:middle;border-radius:.25rem;width:20px;height:20px;padding:.7rem}.legend-item .text{vertical-align:top;margin-left:5px;font-size:12px}@media screen and (max-width:699px){.chart-container .charts__chart{display:block}}.legend-item.label{border-bottom:2px solid}.label .text{font-size:13px}.no-data--wrapper{display:table;position:absolute;width:100%;min-height:450px}.no-data{font-size:24px;text-align:center;vertical-align:middle;display:table-cell}.display-none{display:none}.invisible{visibility:hidden}.sticky{position:-webkit-sticky;position:sticky;top:0;z-index:1}.tabs .tabs__content{height:100%} -/*# sourceMappingURL=app.3b72bd1a.css.map */ \ No newline at end of file +.dicharts--dimensions,.dicharts--district-map{width:100%;height:600px}.dicharts--padding-top{padding-top:30px}.dicharts--actions{display:flex;align-items:flex-end}.button-group{margin-left:auto}.dicharts--actions.align-left .button-group{margin-left:0}.button.button-outline,button.button-outline{background:transparent;color:inherit}.button-group .button-outline{border:1px solid #357ba5;border-left:none;color:#357ba5}.button-group .button-outline:first-child{border-left:1px solid #357ba5}.button-group .button-outline.active,.button-group .button-outline:hover{color:#fff}.button-group .button-outline.active{background:#357ba5}.button-sm{padding:.9rem 1rem}.dicharts--learners-enrolment,.dicharts--number-of-schools,.dicharts--ple-performance-analysis{height:100%}.dicharts--keyfacts{background:#fceae9}.spotlight-banner.data-selector--wrapper{padding:1em 2em 2rem;min-height:95px}.spotlight-banner .labelled-data-selector--wrapper .data-selector{left:0}.labelled-data-selector--wrapper{display:inline-block}.charts__chart .table-styled table{width:100%}.auto-height{min-height:auto!important}.custom-legend{display:flex;justify-content:center;flex-flow:row wrap;min-height:160px}.custom-legend.right{display:block;width:350px;position:absolute;right:0;z-index:1;top:100px}@media (max-width:1350px){.custom-legend.right{position:relative;width:100%;top:auto}}@media screen and (max-width:412px){.custom-legend.right{display:block}}.legend-item{width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;margin-right:5px}.right .legend-item{margin-bottom:5px}.badge{display:inline-block;font-size:75%;font-weight:700;line-height:1;text-align:center;white-space:nowrap;vertical-align:middle;border-radius:.25rem;width:20px;height:20px;padding:.7rem}.legend-item .text{vertical-align:top;margin-left:5px;font-size:12px}@media screen and (max-width:699px){.chart-container .charts__chart{display:block}}.legend-item.label{border-bottom:2px solid}.label .text{font-size:13px}.no-data--wrapper{display:table;position:absolute;width:100%;min-height:450px}.no-data{font-size:24px;text-align:center;vertical-align:middle;display:table-cell}.display-none{display:none}.invisible{visibility:hidden}.sticky{position:-webkit-sticky;position:sticky;top:0;z-index:1}.tabs .tabs__content{height:100%}.score-table-legend{padding-top:5%}.score-table-legend>span{display:flex}.score-table-legend>span>i{height:20px}.score-table-legend>span>label{padding-left:5px;padding-right:10px} +/*# sourceMappingURL=app.8683e2c9.css.map */ \ No newline at end of file diff --git a/assets/vendor.js b/assets/vendor.js index 2c3a1562..08efa9e8 100644 --- a/assets/vendor.js +++ b/assets/vendor.js @@ -1,11 +1,11 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[2],[function(e,t,n){"use strict";e.exports=n(52)},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(7),i=n(0),o=n(8),a=n(12),s=n(13),l=(n(20),n(63),n(23),n(31),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"),_=e=>null!==e&&"object"==typeof e,g=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 T(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 E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:e,M=e=>!h(e)&&e!==E;const A=(I="undefined"!=typeof Uint8Array&&o(Uint8Array),e=>I&&e instanceof I);var I;const C=l("HTMLFormElement"),k=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),O=l("RegExp"),P=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};T(n,(n,i)=>{let o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)},R="abcdefghijklmnopqrstuvwxyz",D={DIGIT:"0123456789",ALPHA:R,ALPHA_DIGIT:R+R.toUpperCase()+"0123456789"};const L=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:_,isPlainObject:g,isUndefined:h,isDate:y,isFile:v,isBlob:x,isRegExp:O,isFunction:p,isStream:e=>_(e)&&p(e.pipe),isURLSearchParams:w,isTypedArray:A,isFileList:b,forEach:T,merge:function e(){const{caseless:t}=M(this)&&this||{},n={},r=(r,i)=>{const o=t&&S(n,i)||i;g(n[o])&&g(r)?n[o]=e(n[o],r):g(r)?n[o]=e({},r):c(r)?n[o]=r.slice():n[o]=r};for(let e=0,t=arguments.length;e(T(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:k,hasOwnProp:k,reduceDescriptors:P,freezeMethods:e=>{P(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:S,global:E,isContextDefined:M,ALPHABET:D,generateString:(e=16,t=D.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(_(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const i=c(e)?[]:{};return T(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:L,isThenable:e=>e&&(_(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{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"),_=e=>null!==e&&"object"==typeof e,g=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 T(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 E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:e,M=e=>!h(e)&&e!==E;const A=(I="undefined"!=typeof Uint8Array&&o(Uint8Array),e=>I&&e instanceof I);var I;const C=l("HTMLFormElement"),k=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),O=l("RegExp"),P=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};T(n,(n,i)=>{let o;!1!==(o=t(n,i,e))&&(r[i]=o||n)}),Object.defineProperties(e,r)},R="abcdefghijklmnopqrstuvwxyz",D={DIGIT:"0123456789",ALPHA:R,ALPHA_DIGIT:R+R.toUpperCase()+"0123456789"};const L=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:_,isPlainObject:g,isUndefined:h,isDate:y,isFile:v,isBlob:x,isRegExp:O,isFunction:p,isStream:e=>_(e)&&p(e.pipe),isURLSearchParams:w,isTypedArray:A,isFileList:b,forEach:T,merge:function e(){const{caseless:t}=M(this)&&this||{},n={},r=(r,i)=>{const o=t&&S(n,i)||i;g(n[o])&&g(r)?n[o]=e(n[o],r):g(r)?n[o]=e({},r):c(r)?n[o]=r.slice():n[o]=r};for(let e=0,t=arguments.length;e(T(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:k,hasOwnProp:k,reduceDescriptors:P,freezeMethods:e=>{P(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:S,global:E,isContextDefined:M,ALPHABET:D,generateString:(e=16,t=D.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(_(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const i=c(e)?[]:{};return T(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:L,isThenable:e=>e&&(_(e)||p(e))&&p(e.then)&&p(e.catch)}}).call(this,n(17))},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(3);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){(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="3.1.2";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,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},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);function x(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n=1)return 1;const t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function A(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x),i=Math.max(i,o.y);return{min:new v(t,n),max:new v(r,i)}}function I(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}function C(e,t,n,r){const i=new _(e,t,n,r);return function(e){return i.solve(e)}}const k=C(.25,.1,.25,1);function O(e,t,n){return Math.min(n,Math.max(t,e))}function P(e,t,n){return(n=O((n-e)/(t-e),0,1))*n*(3-2*n)}function R(e,t,n){const r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function D(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 L(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}function B(e,t){const n={};for(let r=0;r>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function U(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function V(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 G(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function q(e,t){return-1!==e.indexOf(t,e.length-t.length)}function W(e,t,n){const r={};for(const i in e)r[i]=t.call(n||this,e[i],i,e);return r}function Z(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 H(e){return Array.isArray(e)?e.map(H):"object"==typeof e&&e?W(e,H):e}const $={};function X(e){$[e]||("undefined"!=typeof console&&console.warn(e),$[e]=!0)}function Y(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function K(e){let t=0;for(let n,r,i=0,o=e.length,a=o-1;i0?Math.acos(n/r)*w:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*w+90:0;return o<0&&(o+=360),[r,o,i]}function ee(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function te(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\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 ne=null;function re(){return!!n.document.fullscreenElement||!!n.document.webkitFullscreenElement}function ie(e){try{const t=n[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function oe(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function ae(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]}function se(e,t){return[Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]}function le(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]}const ue="mapbox-tiles";let ce,he,de=500,fe=50;function pe(){try{return n.caches}catch(e){}}function me(){pe()&&!ce&&(ce=n.caches.open(ue))}function _e(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 ge=1/0;function ye(e){ge++,ge>fe&&(e.getActor().send("enforceCacheSizeLimit",de),ge=0)}const ve={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(ve);class xe extends Error{constructor(e,t,n){401===t&&Re(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 be=ee()?()=>self.worker&&self.worker.referrer:()=>("blob:"===n.location.protocol?n.parent:n).location.href,we=function(e,t){if(!(/^file:/.test(r=e.url)||/^file:/.test(be())&&!/^\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:be(),referrerPolicy:e.referrerPolicy,signal:r.signal});let o=!1,a=!1;const s=(l=i.url).indexOf("sku=")>0&&Re(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&&X(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 xe(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(me(),!ce)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=te(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===he)try{new Response(new ReadableStream),he=!0}catch(e){he=!1}he?t(e.body):e.blob().then(t)}(t,t=>{const r=new n.Response(t,i);me(),ce&&ce.then(t=>t.put(_e(e.url),r)).catch(e=>X(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(me(),!ce)return t(null);const n=_e(e.url);ce.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=te(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(ee()&&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 xe(r.statusText,r.status,e.url))},r.send(e.body),{cancel:()=>r.abort()}}(e,t)},Te=function(e,t){return we(z(e,{type:"json"}),t)},Se=function(e,t){return we(z(e,{type:"arrayBuffer"}),t)};function Ee(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 Ae,Ie;Ae=[],Ie=0;const Ce=function(e,t){if(a.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Ie>=o.MAX_PARALLEL_IMAGE_REQUESTS){const n={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return Ae.push(n),n}Ie++;let r=!1;const i=()=>{if(!r)for(r=!0,Ie--;Ae.length&&Ie{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()}}},ke="NO_ACCESS_TOKEN";class Oe{constructor(e,t,n){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!n,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",d,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!Pe(e))return e;const n=Fe(e);return n.params.push("sdk=js-3.1.2"),n.path="/styles/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!Pe(e))return e;const n=Fe(e);return n.path="/fonts/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeModelURL(e,t){if(!Pe(e))return e;const n=Fe(e);return n.path="/models/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeSourceURL(e,t,n,r){if(!Pe(e))return e;const i=Fe(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=Fe(e);return Pe(e)?(i.path=`/styles/v1${i.path}/sprite${t}${n}`,this._makeAPIURL(i,this._customAccessToken||r)):(i.path+=`${t}${n}`,je(i))}normalizeTileURL(e,t,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!Pe(e))return e;const r=Fe(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=Fe(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&&Pe(t),r=[];for(const t of e.tiles||[])Re(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=Fe(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 je(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||"")),je(e)}}function Pe(e){return 0===e.indexOf("mapbox:")}function Re(e){return o.API_URL_REGEX.test(e)}function De(e){return o.API_CDN_URL_REGEX.test(e)}function Le(e){return o.API_STYLE_REGEX.test(e)&&!ze(e)}function ze(e){return o.API_SPRITE_REGEX.test(e)}const Be=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Fe(e){const t=e.match(Be);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 je(e){const t=e.params.length?"?"+e.params.join("&"):"";return`${e.protocol}://${e.authority}${e.path}${t}`}const Ne="mapbox.eventData";function Ue(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 Ve{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=Ue(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?`${Ne}.${e}:${r}`:`${Ne}:${r}`}fetchEventData(){const e=ie("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){X("Unable to read from LocalStorage")}}saveEventData(){const e=ie("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){X("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,n,r){if(!o.EVENTS_URL)return;const i=Fe(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:je(i),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=function(e,t){return we(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 Ge=new class extends Ve{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){o.EVENTS_URL&&o.ACCESS_TOKEN&&Array.isArray(e)&&e.some(e=>Pe(e)||Re(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=Ue(o.ACCESS_TOKEN),n=t?t.u:o.ACCESS_TOKEN;let i=n!==this.eventData.tokenU;V(this.anonId)||(this.anonId=N(),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()}},qe=Ge.postTurnstileEvent.bind(Ge),We=new class extends Ve{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(ke)))}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(),V(this.anonId)||(this.anonId=N()),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))}},Ze=We.postMapLoadEvent.bind(We),He=new class extends Ve{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,tt)),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(Qe)){const t=Qe[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(Le(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)}},$e=He.postPerformanceEvent.bind(He),Xe=new class extends Ve{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,n,r){if(!o.API_URL||!o.SESSION_PATH)return;const i=Fe(o.API_URL+o.SESSION_PATH);i.params.push("sku="+(t||"")),i.params.push("access_token="+(r||o.ACCESS_TOKEN||""));const a={url:je(i),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return we(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(ke)))}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)}},Ye=Xe.getSessionAPI.bind(Xe),Ke=new Set;function Je(e,t){t?Ke.add(e):Ke.delete(e)}const Qe={create:"create",load:"load",fullLoad:"fullLoad"},et={mark(e){n.performance.mark(e)},measure(e,t,r){n.performance.measure(e,t,r)}};function tt(e){const t=e.name.split("?")[0];return De(t)&&t.includes("mapbox-gl.js")?"javascript":De(t)&&t.includes("mapbox-gl.css")?"css":function(e){return o.API_FONTS_REGEX.test(e)}(t)?"fontRange":ze(t)?"sprite":Le(t)?"style":function(e){return o.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}const nt=n.performance;function rt(e){const t=e?e.url.toString():void 0;return nt.getEntriesByName(t)}var it=ot;function ot(e){return!function(e){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,n=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(n);try{t=new Worker(r),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(r),e}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var n=t.getImageData(0,0,1,1);return n&&n.width===e.width}()?(void 0===at[t=e&&e.failIfMajorPerformanceCaveat]&&(at[t]=function(e){var t,n=function(e){var t=document.createElement("canvas"),n=Object.create(ot.webGLContextAttributes);return n.failIfMajorPerformanceCaveat=e,t.getContext("webgl",n)||t.getContext("experimental-webgl",n)}(e);if(!n)return!1;try{t=n.createShader(n.VERTEX_SHADER)}catch(e){return!1}return!(!t||n.isContextLost())&&(n.shaderSource(t,"void main() {}"),n.compileShader(t),!0===n.getShaderParameter(t,n.COMPILE_STATUS))}(t)),at[t]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var t}(e)}var at={};let st,lt,ut,ct,ht;function dt(){return null==st&&(st=n.OffscreenCanvas&&new n.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof n.createImageBitmap),st}ot.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const ft={now:()=>void 0!==ct?ct:n.performance.now(),setNow(e){ct=e},restoreNow(){ct=void 0},frame(e){const t=n.requestAnimationFrame(e);return{cancel:()=>n.cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:r,height:i}=e;ht||(ht=n.document.createElement("canvas"));const o=ht.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return(r>ht.width||i>ht.height)&&(ht.width=r,ht.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=>(lt||(lt=n.document.createElement("a")),lt.href=e,lt.href),get devicePixelRatio(){return n.devicePixelRatio},get prefersReducedMotion(){return!!n.matchMedia&&(null==ut&&(ut=n.matchMedia("(prefers-reduced-motion: reduce)")),ut.matches)},hasCanvasFingerprintNoise(){if(!dt())return!1;const e=new n.OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let r=0;for(let n=0;n{n.removeEventListener("click",bt,!0)},0)}function Tt(e,t){const n=e.getBoundingClientRect();return Mt(e,n,t)}function St(e,t){const n=e.getBoundingClientRect(),r=[];for(let i=0;i=0?0:e.button}function Mt(e,t,n){const r=e.offsetWidth===t.width?1:e.offsetWidth/t.width;return new v((n.clientX-t.left)*r,(n.clientY-t.top)*r)}function At(e,t,n){n[e]&&-1!==n[e].indexOf(t)||(n[e]=n[e]||[],n[e].push(t))}function It(e,t,n){if(n&&n[e]){const r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}class Ct{constructor(e,t={}){z(this,t),this.type=e}}class kt extends Ct{constructor(e,t={}){super("error",z({error:e},t))}}class Ot{on(e,t){return this._listeners=this._listeners||{},At(e,t,this._listeners),this}off(e,t){return It(e,t,this._listeners),It(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},At(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new Ct(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)It(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 kt&&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 Pt=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"required":false,"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"camera":{"type":"camera"},"imports":{"type":"array","value":"import"},"schema":{"type":"schema"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"},"models":{"type":"models"}},"model":{"type":"string","required":true},"import":{"id":{"type":"string","required":true},"url":{"type":"string","required":true},"config":{"type":"config"},"data":{"type":"$root"}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","required":true},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string","required":true},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"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},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false,"expression":{},"property-type":"data-constant"},"shadow-intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_ambient":{"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}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"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}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":1}},"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":1,"tms":1},"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":1}},"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},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":1}},"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},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"required":true,"type":"enum","values":{"raster-array":1}},"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},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":1}},"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":1}},"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":1}},"url":{"required":false,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_model":{"type":{"required":true,"type":"enum","values":{"model":1,"batched-model":1}},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"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_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"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":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"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","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"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","measure-light"],"relaxZoomRestriction":true},"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","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"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":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"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}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"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","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"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,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"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},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"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","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","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],"property-type":"constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"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","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"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"],"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,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-color-saturation":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{},"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-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","default":[0,1],"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"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":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"raster-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"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","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"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"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","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"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class Rt{constructor(e,t,n,r){this.message=(e?e+": ":"")+n,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}class Dt extends Rt{}function Lt(e,...t){for(const n of t)for(const t in n)e[t]=n[t];return e}function zt(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Bt(e){if(Array.isArray(e))return e.map(Bt);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const n in e)t[n]=Bt(e[n]);return t}return zt(e)}class Ft extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var jt=Ft;class Nt{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,n]of t)this.bindings[e]=n}concat(e){return new Nt(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 Ut=Nt;const Vt={kind:"null"},Gt={kind:"number"},qt={kind:"string"},Wt={kind:"boolean"},Zt={kind:"color"},Ht={kind:"object"},$t={kind:"value"},Xt={kind:"collator"},Yt={kind:"formatted"},Kt={kind:"resolvedImage"};function Jt(e,t){return{kind:"array",itemType:e,N:t}}function Qt(e){if("array"===e.kind){const t=Qt(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const en=[Vt,Gt,qt,Wt,Zt,Yt,Ht,Jt($t),Kt];function tn(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!tn(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 en)if(!tn(e,t))return null}return`Expected ${Qt(e)} but found ${Qt(t)} instead.`}function nn(e,t){return t.some(t=>t.kind===e.kind)}function rn(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 on,an={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 sn(e){return(e=Math.round(e))<0?0:e>255?255:e}function ln(e){return sn("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function un(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function cn(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{on={}.parseCSSColor=function(e){var t,n=e.replace(/ /g,"").toLowerCase();if(n in an)return an[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=un(a.pop());case"rgb":return 3!==a.length?null:[ln(a[0]),ln(a[1]),ln(a[2]),s];case"hsla":if(4!==a.length)return null;s=un(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,u=un(a[1]),c=un(a[2]),h=c<=.5?c*(u+1):c+u-c*u,d=2*c-h;return[sn(255*cn(d,h,l+1/3)),sn(255*cn(d,h,l)),sn(255*cn(d,h,l-1/3)),s];default:return null}}return null}}catch(e){}class hn{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 hn)return e;if("string"!=typeof e)return;const t=on(e);return t?new hn(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]}toArray01Scaled(e){const{r:t,g:n,b:r,a:i}=this;return 0===i?[0,0,0]:[t/i*e,n/i*e,r/i*e]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:n,a:r}=this;return[e,t,n,r]}toArray01Linear(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[Math.pow(e/r,2.2),Math.pow(t/r,2.2),Math.pow(n/r,2.2),r]}}hn.black=new hn(0,0,0,1),hn.white=new hn(1,1,1,1),hn.transparent=new hn(0,0,0,0),hn.red=new hn(1,0,0,1),hn.blue=new hn(0,0,1,1);var dn=hn;class fn{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 pn{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 mn{constructor(e){this.sections=e}static fromString(e){return new mn([new pn(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.namePrimary.length)}static factory(e){return e instanceof mn?e:mn.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.namePrimary]);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 _n{constructor(e){this.namePrimary=e.namePrimary,e.nameSecondary&&(this.nameSecondary=e.nameSecondary),this.available=e.available}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(e,t){return e?new _n({namePrimary:e,nameSecondary:t,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function gn(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 yn(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 dn)return!0;if(e instanceof fn)return!0;if(e instanceof mn)return!0;if(e instanceof _n)return!0;if(Array.isArray(e)){for(const t of e)if(!yn(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!yn(e[t]))return!1;return!0}return!1}function vn(e){if(null===e)return Vt;if("string"==typeof e)return qt;if("boolean"==typeof e)return Wt;if("number"==typeof e)return Gt;if(e instanceof dn)return Zt;if(e instanceof fn)return Xt;if(e instanceof mn)return Yt;if(e instanceof _n)return Kt;if(Array.isArray(e)){const t=e.length;let n;for(const t of e){const e=vn(t);if(n){if(n===e)continue;n=$t;break}n=e}return Jt(n||$t,t)}return Ht}function xn(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof dn||e instanceof mn||e instanceof _n?e.toString():JSON.stringify(e)}class bn{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(!yn(e[1]))return t.error("invalid value");const n=e[1];let r=vn(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 bn(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 dn?["rgba"].concat(this.value.toArray()):this.value instanceof mn?this.value.serialize():this.value}}var wn=bn,Tn=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const Sn={string:qt,number:Gt,boolean:Wt,object:Ht};class En{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 Sn)||"object"===n)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=Sn[n],r++}else i=$t;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=Jt(i,o)}else n=Sn[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 Mn=En;class An{constructor(e){this.type=Yt,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,Gt),!e))return null;let n=null;if(o["text-font"]&&(n=t.parse(o["text-font"],1,Jt(qt)),!n))return null;let a=null;if(o["text-color"]&&(a=t.parse(o["text-color"],1,Zt),!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,$t);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 An(r)}evaluate(e){return new mn(this.sections.map(t=>{const n=t.content.evaluate(e);return vn(n)===Kt?new pn("",n,null,null,null):new pn(xn(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 In{constructor(e,t){this.type=Kt,this.inputPrimary=e,this.inputSecondary=t}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");const n=t.parse(e[1],1,qt);if(!n)return t.error("No image name provided.");if(2===e.length)return new In(n);const r=t.parse(e[2],1,qt);return r?new In(n,r):t.error("Secondary image variant is not a string.")}evaluate(e){const t=_n.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return t&&e.availableImages&&(t.available=e.availableImages.indexOf(t.namePrimary)>-1,t.nameSecondary&&t.available&&e.availableImages&&(t.available=e.availableImages.indexOf(t.nameSecondary)>-1)),t}eachChild(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary)}outputDefined(){return!1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function Cn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}const kn={"to-boolean":Wt,"to-color":Zt,"to-number":Gt,"to-string":qt};class On{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],r=[];let i=Vt;if("to-array"===n){if(!Array.isArray(e[1]))return null;const n=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);i=Jt(t.expectedType.itemType,n)}else{if(!(n>0&&yn(e[1][0])))return null;i=Jt(vn(e[1][0]),n)}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:gn(t[0],t[1],t[2],t[3]),!n))return new dn(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Tn(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 Tn(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?mn.fromString(xn(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?_n.fromString(xn(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):xn(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 An([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new In(this.args[0]).serialize();const e="array"===this.type.kind?[]:["to-"+this.type.kind];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Pn=On;const Rn=["Unknown","Point","LineString","Polygon"];var Dn=class{constructor(e){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,this.options=e}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Rn[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||{}}measureLight(e){return this.globals.brightness||0}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]=dn.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}};class Ln{constructor(e,t,n,r,i){this.name=e,this.type=t,this._evaluate=n,this.args=r,this._overloadIndex=i}evaluate(e){if(!this._evaluate){const e=Ln.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1]}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=Ln.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=[];let s=null,l=-1;for(const[r,u]of o){if(Array.isArray(r)&&r.length!==e.length-1)continue;a.push(r),l++,s=new Zr(t.registry,t.path,null,t.scope,void 0,t.options);const o=[];let c=!1;for(let t=1;te)).map(zn).join(" | "),r=[];for(let n=1;ni;){if(o-i>600){var 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(n,r,Math.max(i,Math.floor(r-l*c/s+h)),Math.min(o,Math.floor(r+(s-l)*c/s+h)),a)}var d=n[r],f=i,p=o;for(t(n,i,r),a(n[o],d)>0&&t(n,i,o);f0;)p--}0===a(n[i],d)?t(n,i,p):t(n,++p,o),p<=r&&(i=p+1),r<=p&&(o=p-1)}}function t(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function n(e,t){return et?1:0}return function(t,r,i,o,a){e(t,r,i||0,o||t.length-1,a||n)}}();var Nn=f(jn.exports);function Un(e){let t=0;for(let n,r,i=0,o=e.length,a=o-1;i=t[2]||e[1]<=t[1]||e[3]>=t[3])}function qn(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 Wn(e,t,n=!1){let r=!1;for(let s=0,l=t.length;s(i=e)[1]!=(a=c)[1]>i[1]&&i[0]<(a[0]-o[0])*(i[1]-o[1])/(a[1]-o[1])+o[0]&&(r=!r)}}var i,o,a;return r}function Zn(e,t,n,r){const i=r[0]-n[0],o=r[1]-n[1],a=(e[0]-n[0])*o-i*(e[1]-n[1]),s=(t[0]-n[0])*o-i*(t[1]-n[1]);return a>0&&s<0||a<0&&s>0}function Hn(e,t,n,r){return 0!=(i=[r[0]-n[0],r[1]-n[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-i[1]*o[0]&&!(!Zn(e,t,n,r)||!Zn(n,r,e,t));var i,o}const $n=8192;function Xn(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*$n),Math.round(r*i*$n)]}function Yn(e,t){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}Vn(t,e)}function rr(e,t,n,r){const i=Math.pow(2,r.z)*$n,o=[r.x*$n,r.y*$n],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]];nr(r,t,n,i),a.push(r)}return a}function ir(e,t,n,r){const i=Math.pow(2,r.z)*$n,o=[r.x*$n,r.y*$n],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]];Vn(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)nr(r,t,n,i)}var s;return a}class or{constructor(e,t){this.type=Wt,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(yn(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e180;)e-=360;return e}return i.fromTile=function(e,t,n){var o=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),a=Math.atan(.5*(Math.exp(o)-Math.exp(-o)))/r;return new i(a,n)},o.units.get=function(){return e},i.prototype.distance=function(e,t){var n=l(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(n*n+r*r)},i.prototype.bearing=function(e,t){var n=l(t[0]-e[0])*this.kx;return Math.atan2(n,(t[1]-e[1])*this.ky)/r},i.prototype.destination=function(e,t,n){var i=n*r;return this.offset(e,Math.sin(i)*t,Math.cos(i)*t)},i.prototype.offset=function(e,t,n){return[e[0]+t/this.kx,e[1]+n/this.ky]},i.prototype.lineDistance=function(e){for(var t=0,n=0;nt)return s(i,o,(t-(n-a))/a)}return e[e.length-1]},i.prototype.pointToSegmentDistance=function(e,t,n){var r=t[0],i=t[1],o=l(n[0]-r)*this.kx,a=(n[1]-i)*this.ky,s=0;return 0===o&&0===a||((s=(l(e[0]-r)*this.kx*o+(e[1]-i)*this.ky*a)/(o*o+a*a))>1?(r=n[0],i=n[1]):s>0&&(r+=o/this.kx*s,i+=a/this.ky*s)),o=l(e[0]-r)*this.kx,a=(e[1]-i)*this.ky,Math.sqrt(o*o+a*a)},i.prototype.pointOnLine=function(e,t){for(var n,r,i,o,a=1/0,s=0;s1?(u=e[s+1][0],c=e[s+1][1]):f>0&&(u+=h/this.kx*f,c+=d/this.ky*f));var p=(h=l(t[0]-u)*this.kx)*h+(d=(t[1]-c)*this.ky)*d;pi.index||r.index===i.index&&r.t>i.t){var o=r;r=i,i=o}var s=[r.point],l=r.index+1,u=i.index;!a(n[l],s[0])&&l<=u&&s.push(n[l]);for(var c=l+1;c<=u;c++)s.push(n[c]);return a(n[u],i.point)||s.push(i.point),s},i.prototype.lineSliceAlong=function(e,t,n){for(var r=0,i=[],o=0;oe&&0===i.length&&i.push(s(a,l,(e-(r-u))/u)),r>=t)return i.push(s(a,l,(t-(r-u))/u)),i;r>e&&i.push(l)}return i},i.prototype.bufferPoint=function(e,t){var n=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-n,e[0]+r,e[1]+n]},i.prototype.bufferBBox=function(e,t){var n=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-n,e[2]+r,e[3]+n]},i.prototype.insideBBox=function(e,t){return l(e[0]-t[0])>=0&&l(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]},Object.defineProperties(i,o),i}();var lr=f(sr.exports),ur={exports:{}};ur.exports=function(){var e=function(e,n){if(void 0===e&&(e=[]),void 0===n&&(n=t),this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)};function t(e,t){return et?1:0}return e.prototype.push=function(e){this.data.push(e),this.length++,this._up(this.length-1)},e.prototype.pop=function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}},e.prototype.peek=function(){return this.data[0]},e.prototype._up=function(e){for(var t=this.data,n=this.compare,r=t[e];e>0;){var i=e-1>>1,o=t[i];if(n(r,o)>=0)break;t[e]=o,e=i}t[e]=r},e.prototype._down=function(e){for(var t=this.data,n=this.compare,r=this.length>>1,i=t[e];e=0)break;t[e]=a,e=o}t[e]=i},e}();var cr=f(ur.exports),hr=8192;function dr(e,t){return t.dist-e.dist}function fr(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(let n=0;n=e[0]&&e[1]e[1])return[null,null];const n=pr(e);if(t){if(2===n)return[e,null];const t=Math.floor(n/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===n)return[e,null];const t=Math.floor(n/2)-1;return[[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function gr(e,t){const n=[1/0,1/0,-1/0,-1/0];if(!mr(t,e.length))return n;for(let r=t[0];r<=t[1];++r)Vn(n,e[r]);return n}function yr(e){const t=[1/0,1/0,-1/0,-1/0];for(let n=0;nt[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(i=e[1]-t[3]),e[3]=r)return r;if(Gn(i,o)){if(Cr(e,t))return 0}else if(Cr(t,e))return 0;let a=r;for(const r of e)for(let e=0,i=r.length,o=i-1;e=o)continue;const u=i.range1;if(pr(u)<=s){if(!mr(u,e.length))return NaN;if(t){const t=Ir(e,u,n,r);if(0===(o=Math.min(o,t)))return o}else for(let t=u[0];t<=u[1];++t){const i=Ar(e[t],n,r);if(0===(o=Math.min(o,i)))return o}}else{const n=_r(u,t);if(null!==n[0]){const t=vr(gr(e,n[0]),l,r);t=a)continue;const c=o.range1,h=o.range2;if(pr(c)<=l&&pr(h)<=u){if(!mr(c,e.length)||!mr(h,n.length))return NaN;if(t&&r?a=Math.min(a,Er(e,c,n,h,i)):t||r?t&&!r?a=Math.min(a,Tr(n,h,e,c,i)):!t&&r&&(a=Math.min(a,Tr(e,c,n,h,i))):a=Math.min(a,Mr(e,c,n,h,i)),0===a)return a}else{const o=_r(c,t),l=_r(h,r);Or(s,a,i,e,n,o[0],l[0]),Or(s,a,i,e,n,o[0],l[1]),Or(s,a,i,e,n,o[1],l[0]),Or(s,a,i,e,n,o[1],l[1])}}return a}function Dr(e,t,n,r,i=1/0){let o=i;const a=gr(e,[0,e.length-1]);for(const i of n)if(!(o!==1/0&&vr(a,gr(i,[0,i.length-1]),r)>=o)&&(o=Math.min(o,Rr(e,t,i,!0,r,o)),0===o))return o;return o}function Lr(e,t,n,r,i=1/0){let o=i;const a=gr(e,[0,e.length-1]);for(const i of n){if(o!==1/0&&vr(a,yr(i),r)>=o)continue;const n=Pr(e,t,i,r,o);if(isNaN(n))return n;if(0===(o=Math.min(o,n)))return o}return o}function zr(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class Br{constructor(e,t){this.type=Gt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(yn(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e{t&&!jr(e)&&(t=!1)}),t}function Nr(e){if(e instanceof Bn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!Nr(e)&&(t=!1)}),t}function Ur(e){if(e instanceof Bn&&"config"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!Ur(e)&&(t=!1)}),t}function Vr(e,t){if(e instanceof Bn&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild(e=>{n&&!Vr(e,t)&&(n=!1)}),n}class Gr{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 Gr(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 qr=Gr;class Wr{constructor(e,t=[],n,r=new Ut,i=[],o){this.registry=e,this.path=t,this.key=t.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=i,this.expectedType=n,this.options=o}parse(e,t,n,r,i={}){return t||n?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return"assert"===n?new Mn(t,[e]):"coerce"===n?new Pn(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="string"==typeof e[0]?this.registry[e[0]]:void 0;if(r){let i=r.parse(e,this);if(!i)return null;if(this.expectedType){const e=this.expectedType,r=i.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else i=n(i,e,t.typeAnnotation||"coerce");else i=n(i,e,t.typeAnnotation||"assert")}if(!(i instanceof wn)&&"resolvedImage"!==i.type.kind&&function e(t){if(t instanceof qr)return e(t.boundExpression);if(t instanceof Bn&&"error"===t.name)return!1;if(t instanceof Bn&&"config"===t.name)return!1;if(t instanceof Fn)return!1;if(t instanceof ar)return!1;if(t instanceof Fr)return!1;const n=t instanceof Pn||t instanceof Mn;let r=!0;return t.eachChild(t=>{r=n?r&&e(t):r&&t instanceof wn}),!!r&&jr(t)&&Vr(t,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light"])}(i)){const t=new Dn(this.options);try{i=new wn(i.type,i.evaluate(t))}catch(e){return this.error(e.message),null}}return i}return Pn.parse(["to-array",e],this)}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 Wr(this.registry,r,t||null,i,this.errors,this.options)}error(e,...t){const n=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new jt(n,e))}checkSubtype(e,t){const n=tn(e,t);return n&&this.error(n),n}}var Zr=Wr;function Hr(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 Tn("Input is not a number.");a=s-1}return 0}class $r{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,Gt);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 $r(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[Hr(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 Xr=$r;function Yr(e,t,n){return e*(1-n)+t*n}function Kr(e,t,n){return e.map((e,r)=>Yr(e,t[r],n))}var Jr=Object.freeze({__proto__:null,array:Kr,color:function(e,t,n){return new dn(Yr(e.r,t.r,n),Yr(e.g,t.g,n),Yr(e.b,t.b,n),Yr(e.a,t.a,n))},number:Yr});const Qr=6/29,ei=3*Qr*Qr,ti=Math.PI/180,ni=180/Math.PI;function ri(e){return e>.008856451679035631?Math.pow(e,1/3):e/ei+4/29}function ii(e){return e>Qr?e*e*e:ei*(e-4/29)}function oi(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function ai(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function si(e){const t=ai(e.r),n=ai(e.g),r=ai(e.b),i=ri((.4124564*t+.3575761*n+.1804375*r)/.95047),o=ri((.2126729*t+.7151522*n+.072175*r)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-ri((.0193339*t+.119192*n+.9503041*r)/1.08883)),alpha:e.a}}function li(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*ii(t),n=.95047*ii(n),r=1.08883*ii(r),new dn(oi(3.2404542*n-1.5371385*t-.4985314*r),oi(-.969266*n+1.8760108*t+.041556*r),oi(.0556434*n-.2040259*t+1.0572252*r),e.alpha)}function ui(e,t,n){const r=t-e;return e+n*(r>180||r<-180?r-360*Math.round(r/360):r)}const ci={forward:si,reverse:li,interpolate:function(e,t,n){return{l:Yr(e.l,t.l,n),a:Yr(e.a,t.a,n),b:Yr(e.b,t.b,n),alpha:Yr(e.alpha,t.alpha,n)}}},hi={forward:function(e){const{l:t,a:n,b:r}=si(e),i=Math.atan2(r,n)*ni;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*ti,n=e.c;return li({l:e.l,a:Math.cos(t)*n,b:Math.sin(t)*n,alpha:e.alpha})},interpolate:function(e,t,n){return{h:ui(e.h,t.h,n),c:Yr(e.c,t.c,n),l:Yr(e.l,t.l,n),alpha:Yr(e.alpha,t.alpha,n)}}};var di=Object.freeze({__proto__:null,hcl:hi,lab:ci});class fi{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=pi(t,e.base,n,r);else if("linear"===e.name)i=pi(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(pi(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,Gt),!i)return null;const a=[];let s=null;"interpolate-hcl"===n||"interpolate-lab"===n?s=Zt: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 fi(s,n,r,i,a):t.error(`Type ${Qt(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=Hr(t,r),a=fi.interpolationFactor(this.interpolation,r,t[o],t[o+1]),s=n[o].evaluate(e),l=n[o+1].evaluate(e);return"interpolate"===this.operator?Jr[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?hi.reverse(hi.interpolate(hi.forward(s),hi.forward(l),a)):ci.reverse(ci.interpolate(ci.forward(s),ci.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;etn(r,e.type));return new _i(o?$t: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 _n&&!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 gi=_i;class yi{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 Tn(`Array index out of bounds: ${t} > ${n.length-1}.`);if(t!==Math.floor(t))throw new Tn(`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 bi=xi;class wi{constructor(e,t){this.type=Wt,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,$t),r=t.parse(e[2],2,$t);return n&&r?nn(n.type,[Wt,qt,Gt,Vt,$t])?new wi(n,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(n.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(null==n)return!1;if(!rn(t,["boolean","string","number","null"]))throw new Tn(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(vn(t))} instead.`);if(!rn(n,["string","array"]))throw new Tn(`Expected second argument to be of type array or string, but found ${Qt(vn(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 Ti=wi;class Si{constructor(e,t,n){this.type=Gt,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,$t),r=t.parse(e[2],2,$t);if(!n||!r)return null;if(!nn(n.type,[Wt,qt,Gt,Vt,$t]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,Gt);return i?new Si(n,r,i):null}return new Si(n,r)}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!rn(t,["boolean","string","number","null"]))throw new Tn(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(vn(t))} instead.`);if(!rn(n,["string","array"]))throw new Tn(`Expected second argument to be of type array or string, but found ${Qt(vn(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 Ei=Si;class Mi{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,vn(e)))return null}else n=vn(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,$t);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 Mi(n,r,a,i,o,s):null}evaluate(e){const t=this.input.evaluate(e);return(vn(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 Ai=Mi;class Ii{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 Ci=Ii;class ki{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,$t),r=t.parse(e[2],2,Gt);if(!n||!r)return null;if(!nn(n.type,[Jt($t),qt,$t]))return t.error(`Expected first argument to be of type array or string, but found ${Qt(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,Gt);return i?new ki(n.type,n,r,i):null}return new ki(n.type,n,r)}evaluate(e){const t=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!rn(t,["string","array"]))throw new Tn(`Expected first argument to be of type array or string, but found ${Qt(vn(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 Oi=ki;function Pi(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 Ri(e,t,n,r){return 0===r.compare(t,n)}function Di(e,t,n){const r="=="!==e&&"!="!==e;return class i{constructor(e,t,n){this.type=Wt,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,$t);if(!o)return null;if(!Pi(n,o.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${Qt(o.type)}'.`);let a=t.parse(e[2],2,$t);if(!a)return null;if(!Pi(n,a.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${Qt(a.type)}'.`);if(o.type.kind!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${Qt(o.type)}' and '${Qt(a.type)}'.`);r&&("value"===o.type.kind&&"value"!==a.type.kind?o=new Mn(a.type,[o]):"value"!==o.type.kind&&"value"===a.type.kind&&(a=new Mn(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,Xt),!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=vn(o),n=vn(a);if(t.kind!==n.kind||"string"!==t.kind&&"number"!==t.kind)throw new Tn(`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=vn(o),n=vn(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 Li=Di("==",(function(e,t,n){return t===n}),Ri),zi=Di("!=",(function(e,t,n){return t!==n}),(function(e,t,n,r){return!Ri(0,t,n,r)})),Bi=Di("<",(function(e,t,n){return t",(function(e,t,n){return t>n}),(function(e,t,n,r){return r.compare(t,n)>0})),ji=Di("<=",(function(e,t,n){return t<=n}),(function(e,t,n,r){return r.compare(t,n)<=0})),Ni=Di(">=",(function(e,t,n){return t>=n}),(function(e,t,n,r){return r.compare(t,n)>=0}));class Ui{constructor(e,t,n,r,i,o){this.type=qt,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,Gt);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,qt),!i))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,qt),!o))return null;let a=null;if(r.unit&&(a=t.parse(r.unit,1,qt),!a))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,Gt),!s))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,Gt),!l)?null:new Ui(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 Vi{constructor(e){this.type=Gt,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 ${Qt(n.type)} instead.`):new Vi(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 Tn(`Expected value to be of type string or array, but found ${Qt(vn(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}function Gi(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const qi={"==":Li,"!=":zi,">":Fi,"<":Bi,">=":Ni,"<=":ji,array:Mn,at:bi,boolean:Mn,case:Ci,coalesce:gi,collator:Fn,format:An,image:In,in:Ti,"index-of":Ei,interpolate:mi,"interpolate-hcl":mi,"interpolate-lab":mi,length:Vi,let:vi,literal:wn,match:Ai,number:Mn,"number-format":Ui,object:Mn,slice:Oi,step:Xr,string:Mn,"to-boolean":Pn,"to-color":Pn,"to-number":Pn,"to-string":Pn,var:qr,within:ar,distance:Fr};function Wi(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=gn(t,n,r,o);if(a)throw new Tn(a);return new dn(t/255*o,n/255*o,r/255*o,o)}function Zi(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=function(e,t,n,r){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof n&&n>=0&&n<=100?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid hsla value [${[e,t,n,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof r?[e,t,n,r]:[e,t,n]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof r?[e,t,n,r]:[e,t,n]).join(", ")}]: 'h' must be between 0 and 360.`}(t,n,r,o);if(a)throw new Tn(a);const s=`hsla(${t}, ${n}%, ${r}%, ${o})`,l=dn.parse(s);if(!l)throw new Tn("Failed to parse HSLA color: "+s);return l}function Hi(e,t){return e in t}function $i(e,t){const n=t[e];return void 0===n?null:n}function Xi(e,t){switch(e){case"string":return String(t);case"number":return+t;case"boolean":return!!t;case"color":return dn.parse(t)}return t}function Yi(e,t,n,r){return void 0!==r&&(e=r*Math.round(e/r)),void 0!==t&&en&&(e=n),e}function Ki(e,t,n){n.length&&(t+=""+n);const r=e.getConfig(t);if(!r)return null;const{type:i,value:o,values:a,minValue:s,maxValue:l,stepValue:u}=r,c=r.default.evaluate(e);let h=o?o.evaluate(e):c;return i&&(h=Xi(i,h)),void 0!==o&&void 0!==h&&a&&!a.includes(h)&&(h=c,i&&(h=Xi(i,h))),void 0===h||void 0===s&&void 0===l&&void 0===u||("number"==typeof h?h=Yi(h,s,l,u):Array.isArray(h)&&(h=h.map(e=>"number"==typeof e?Yi(e,s,l,u):e))),h}function Ji(e){return{type:e}}Bn.register(qi,{error:[{kind:"error"},[qt],(e,[t])=>{throw new Tn(t.evaluate(e))}],typeof:[qt,[$t],(e,[t])=>Qt(vn(t.evaluate(e)))],"to-rgba":[Jt(Gt,4),[Zt],(e,[t])=>t.evaluate(e).toArray()],rgb:[Zt,[Gt,Gt,Gt],Wi],rgba:[Zt,[Gt,Gt,Gt,Gt],Wi],hsl:[Zt,[Gt,Gt,Gt],Zi],hsla:[Zt,[Gt,Gt,Gt,Gt],Zi],has:{type:Wt,overloads:[[[qt],(e,[t])=>Hi(t.evaluate(e),e.properties())],[[qt,Ht],(e,[t,n])=>Hi(t.evaluate(e),n.evaluate(e))]]},get:{type:$t,overloads:[[[qt],(e,[t])=>$i(t.evaluate(e),e.properties())],[[qt,Ht],(e,[t,n])=>$i(t.evaluate(e),n.evaluate(e))]]},config:{type:$t,overloads:[[[qt],(e,[t])=>Ki(e,t.evaluate(e),"")],[[qt,qt],(e,[t,n])=>Ki(e,t.evaluate(e),n.evaluate(e))]]},"feature-state":[$t,[qt],(e,[t])=>$i(t.evaluate(e),e.featureState||{})],properties:[Ht,[],e=>e.properties()],"geometry-type":[qt,[],e=>e.geometryType()],id:[$t,[],e=>e.id()],zoom:[Gt,[],e=>e.globals.zoom],pitch:[Gt,[],e=>e.globals.pitch||0],"distance-from-center":[Gt,[],e=>e.distanceFromCenter()],"measure-light":[Gt,[qt],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Gt,[],e=>e.globals.heatmapDensity||0],"line-progress":[Gt,[],e=>e.globals.lineProgress||0],"raster-value":[Gt,[],e=>e.globals.rasterValue||0],"sky-radial-progress":[Gt,[],e=>e.globals.skyRadialProgress||0],accumulated:[$t,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Gt,Ji(Gt),(e,t)=>{let n=0;for(const r of t)n+=r.evaluate(e);return n}],"*":[Gt,Ji(Gt),(e,t)=>{let n=1;for(const r of t)n*=r.evaluate(e);return n}],"-":{type:Gt,overloads:[[[Gt,Gt],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[Gt],(e,[t])=>-t.evaluate(e)]]},"/":[Gt,[Gt,Gt],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[Gt,[Gt,Gt],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[Gt,[],()=>Math.LN2],pi:[Gt,[],()=>Math.PI],e:[Gt,[],()=>Math.E],"^":[Gt,[Gt,Gt],(e,[t,n])=>Math.pow(t.evaluate(e),n.evaluate(e))],sqrt:[Gt,[Gt],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Gt,[Gt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Gt,[Gt],(e,[t])=>Math.log(t.evaluate(e))],log2:[Gt,[Gt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Gt,[Gt],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Gt,[Gt],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Gt,[Gt],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Gt,[Gt],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Gt,[Gt],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Gt,[Gt],(e,[t])=>Math.atan(t.evaluate(e))],min:[Gt,Ji(Gt),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[Gt,Ji(Gt),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[Gt,[Gt],(e,[t])=>Math.abs(t.evaluate(e))],round:[Gt,[Gt],(e,[t])=>{const n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[Gt,[Gt],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Gt,[Gt],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Wt,[qt,$t],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[Wt,[$t],(e,[t])=>e.id()===t.value],"filter-type-==":[Wt,[qt],(e,[t])=>e.geometryType()===t.value],"filter-<":[Wt,[qt,$t],(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":[Wt,[qt,$t],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[Wt,[$t],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[Wt,[qt,$t],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[Wt,[$t],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[Wt,[qt,$t],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[Wt,[$t],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[Wt,[$t],(e,[t])=>t.value in e.properties()],"filter-has-id":[Wt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Wt,[Jt(qt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Wt,[Jt($t)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Wt,[qt,Jt($t)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Wt,[qt,Jt($t)],(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:Wt,overloads:[[[Wt,Wt],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[Ji(Wt),(e,t)=>{for(const n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:Wt,overloads:[[[Wt,Wt],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[Ji(Wt),(e,t)=>{for(const n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[Wt,[Wt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Wt,[qt],(e,[t])=>{const n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[qt,[qt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[qt,[qt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[qt,Ji($t),(e,t)=>t.map(t=>xn(t.evaluate(e))).join("")],"resolved-locale":[qt,[Xt],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Gt,[Gt,Gt,$t],(e,t)=>{const[n,r,i]=t.map(t=>t.evaluate(e));if(n>r)return n;if(n===r)return n;let o;if("string"==typeof i)o=function(e){let t=0;if(0===e.length)return t;for(let n=0;n-1}function ro(e){return"data-driven"===e["property-type"]}function io(e){return no(e.expression,"measure-light")}function oo(e){return no(e.expression,"zoom")}function ao(e){return!!e.expression&&e.expression.interpolated}function so(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function lo(e){return e}function uo(e,t,n){return void 0!==e?e:void 0!==t?t:void 0!==n?n:void 0}function co(e,t,n,r,i){return uo(typeof n===i?r[n]:void 0,e.default,t.default)}function ho(e,t,n){if("number"!==Cn(n))return uo(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=Hr(e.stops.map(e=>e[0]),n);return e.stops[i][1]}function fo(e,t,n){const r=void 0!==e.base?e.base:1;if("number"!==Cn(n))return uo(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=Hr(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=Jr[t.type]||lo;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=di[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 po(e,t,n){return"color"===t.type?n=dn.parse(n):"formatted"===t.type?n=mn.fromString(n.toString()):"resolvedImage"===t.type?n=_n.fromString(n.toString()):Cn(n)===t.type||"enum"===t.type&&t.values[n]||(n=void 0),uo(n,e.default,t.default)}class mo{constructor(e,t,n){this.expression=e,this._warningHistory={},this._evaluator=new Dn(n),this._defaultValue=t?function(e){return"color"===e.type&&(so(e.default)||Array.isArray(e.default))?new dn(0,0,0,0):"color"===e.type?dn.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 Tn(`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 _o(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Qi}function go(e,t,n){const r=new Zr(Qi,[],t?function(e){const t={color:Zt,string:qt,number:Gt,enum:qt,boolean:Wt,formatted:Yt,resolvedImage:Kt};return"array"===e.type?Jt(t[e.value]||$t,e.length):t[e.type]}(t):void 0,void 0,void 0,n),i=r.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return i?eo(new mo(i,t,n)):to(r.errors)}class yo{constructor(e,t,n){this.kind=e,this._styleExpression=t,this.isLightConstant=n,this.isStateDependent="constant"!==e&&!Nr(t.expression),this.isConfigDependent=!Ur(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 vo{constructor(e,t,n,r,i){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Nr(t.expression),this.isLightConstant=i,this.isConfigDependent=!Ur(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?mi.interpolationFactor(this.interpolationType,e,t,n):0}}function xo(e,t,n){if("error"===(e=go(e,t,n)).result)return e;const r=e.value.expression,i=jr(r);if(!i&&!ro(t))return to([new jt("","data expressions not supported")]);const o=Vr(r,["zoom","pitch","distance-from-center"]);if(!o&&!oo(t))return to([new jt("","zoom expressions not supported")]);const a=Vr(r,["measure-light"]);if(!a&&!io(t))return to([new jt("","measure-light expression not supported")]);const s=t.expression&&t.expression.relaxZoomRestriction,l=function e(t){let n=null;if(t instanceof vi)n=e(t.result);else if(t instanceof gi){for(const r of t.args)if(n=e(r),n)break}else(t instanceof Xr||t instanceof mi)&&t.input instanceof Bn&&"zoom"===t.input.name&&(n=t);return n instanceof jt||t.eachChild(t=>{const r=e(t);r instanceof jt?n=r:n&&r&&n!==r&&(n=new jt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),n}(r);return l||o||s?l instanceof jt?to([l]):l instanceof mi&&!ao(t)?to([new jt("",'"interpolate" expressions cannot be used with this property')]):eo(l?new vo(i?"camera":"composite",e.value,l.labels,l instanceof mi?l.interpolation:void 0,a):new yo(i?"constant":"source",e.value,a)):to([new jt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class bo{constructor(e,t){this._parameters=e,this._specification=t,Lt(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||(ao(n)?"exponential":"interval");if(r&&((t=Lt({},t)).stops&&(t.stops=t.stops.map(e=>[e[0],dn.parse(e[1])])),t.default=dn.parse(t.default?t.default:n.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!di[t.colorSpace])throw new Error("Unknown color space: "+t.colorSpace);let s,l,u;if("exponential"===a)s=fo;else if("interval"===a)s=ho;else if("categorical"===a){s=co,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=po}if(i){const r={},i=[];for(let e=0;ee[0]),evaluate:({zoom:e},r)=>fo({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:mi.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?uo(t.default,n.default):s(t,n,i,l,u)}}}(this._parameters,this._specification))}static deserialize(e){return new bo(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function wo(e){const t=e.key,n=e.value,r=e.valueSpec||{},i=e.objectElementValidators||{},o=e.style,a=e.styleSpec;let s=[];const l=Cn(n);if("object"!==l)return[new Rt(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=ea:i["*"]?u=i["*"]:r["*"]&&(u=ea),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 Dt(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 Rt(t,n,`missing required property "${e}"`));return s}function To(e){const t=e.value,n=e.valueSpec,r=e.style,i=e.styleSpec,o=e.key,a=e.arrayElementValidator||ea;if("array"!==Cn(t))return[new Rt(o,t,`array expected, ${Cn(t)} found`)];if(n.length&&t.length!==n.length)return[new Rt(o,t,`array length ${n.length} expected, length ${t.length} found`)];if(n["min-length"]&&t.lengthi)return[new Rt(t,n,`${n} is greater than the maximum value ${i}`)]}return[]}function Eo(e){const t=e.valueSpec,n=zt(e.value.type);let r,i,o,a={};const s="categorical"!==n&&void 0===e.value.property,l=!s,u="array"===Cn(e.value.stops)&&"array"===Cn(e.value.stops[0])&&"object"===Cn(e.value.stops[0][0]),c=wo({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 Rt(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(To({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Cn(r)&&0===r.length&&t.push(new Rt(e.key,r,"array must have at least one stop")),t},default:function(e){return ea({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===n&&s&&c.push(new Rt(e.key,e.value,'missing required property "property"')),"identity"===n||e.value.stops||c.push(new Rt(e.key,e.value,'missing required property "stops"')),"exponential"===n&&e.valueSpec.expression&&!ao(e.valueSpec)&&c.push(new Rt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!ro(e.valueSpec)?c.push(new Rt(e.key,e.value,"property functions not supported")):s&&!oo(e.valueSpec)&&c.push(new Rt(e.key,e.value,"zoom functions not supported"))),"categorical"!==n&&!u||void 0!==e.value.property||c.push(new Rt(e.key,e.value,'"property" property is required')),c;function h(e){let n=[];const r=e.value,s=e.key;if("array"!==Cn(r))return[new Rt(s,r,`array expected, ${Cn(r)} found`)];if(2!==r.length)return[new Rt(s,r,`array length 2 expected, length ${r.length} found`)];if(u){if("object"!==Cn(r[0]))return[new Rt(s,r,`object expected, ${Cn(r[0])} found`)];if(void 0===r[0].zoom)return[new Rt(s,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new Rt(s,r,"object stop key must have value")];const t=zt(r[0].zoom);if("number"!=typeof t)return[new Rt(s,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new Rt(s,r[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,i=void 0,a={}),n=n.concat(wo({key:s+"[0]",value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:So,value:d}}))}else n=n.concat(d({key:s+"[0]",value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return _o(Bt(r[1]))?n.concat([new Rt(s+"[1]",r[1],"expressions are not allowed in function stops.")]):n.concat(ea({key:s+"[1]",value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const s=Cn(e.value),l=zt(e.value),u=null!==e.value?e.value:o;if(r){if(s!==r)return[new Rt(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 Rt(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 ro(t)&&void 0===n&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Rt(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 Rt(`${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 Rt(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&&!Nr(n))return[new Rt(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 Bn&&r.has(t.name)?[new Rt(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(!Vr(n,["zoom","feature-state"]))return[new Rt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!jr(n))return[new Rt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ao(e){const t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?-1===r.values.indexOf(zt(n))&&i.push(new Rt(t,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(zt(n))&&i.push(new Rt(t,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),i}function Io(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(!Io(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Co(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Io(e)||(e=Do(e));const n=e;let r=!0;try{r=function(e){if(!ko(e))return e;let t=Bt(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=Pt["filter_"+t],o=go(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=go(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=!jr(e.value.expression)}return{filter:a,dynamicFilter:s||void 0,needGeometry:Ro(r),needFeature:!!l}}function ko(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 Po(e,t){return et?1:0}function Ro(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?Lo(e[1],e[2],t):"any"===t?(n=e.slice(1),["any"].concat(n.map(Do))):"all"===t?["all"].concat(e.slice(1).map(Do)):"none"===t?["all"].concat(e.slice(1).map(Do).map(Fo)):"in"===t?zo(e[1],e.slice(2)):"!in"===t?Fo(zo(e[1],e.slice(2))):"has"===t?Bo(e[1]):"!has"!==t||Fo(Bo(e[1]));var n}function Lo(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 zo(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(Po)]]:["filter-in-small",e,["literal",t]]}}function Bo(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Fo(e){return["!",e]}function jo(e){return Io(Bt(e.value))?Mo(Lt({},e,{expressionContext:"filter",valueSpec:e.styleSpec["filter_"+(e.layerType||"fill")]})):function e(t){const n=t.value,r=t.key;if("array"!==Cn(n))return[new Rt(r,n,`array expected, ${Cn(n)} found`)];const i=t.styleSpec;let o,a=[];if(n.length<1)return[new Rt(r,n,"filter array must have at least 1 element")];switch(a=a.concat(Ao({key:r+"[0]",value:n[0],valueSpec:i.filter_operator,style:t.style,styleSpec:t.styleSpec})),zt(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===zt(n[1])&&a.push(new Rt(r,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":3!==n.length&&a.push(new Rt(r,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&(o=Cn(n[1]),"string"!==o&&a.push(new Rt(r+"[1]",n[1],`string expected, ${o} found`)));for(let e=2;e{e in n&&t.push(new Rt(r,n[e],`"${e}" is prohibited for ref layers`))}),i.layers.forEach(t=>{zt(t.id)===s&&(e=t)}),e?e.ref?t.push(new Rt(r,n.ref,"ref cannot reference another ref layer")):a=zt(e.type):"string"==typeof s&&t.push(new Rt(r,n.ref,`ref layer "${s}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(n.source){const e=i.sources&&i.sources[n.source],o=e&&zt(e.type);e?"vector"===o&&"raster"===a?t.push(new Rt(r,n.source,`layer "${n.id}" requires a raster source`)):"raster"===o&&"raster"!==a?t.push(new Rt(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==o||n["source-layer"]?"raster-dem"===o&&"hillshade"!==a?t.push(new Rt(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 Rt(r,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Rt(r,n,`layer "${n.id}" must specify a "source-layer"`)):t.push(new Rt(r,n.source,`source "${n.source}" not found`))}else t.push(new Rt(r,n,'missing required property "source"'));return t=t.concat(wo({key:r,value:n,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ea({key:r+".type",value:n.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:n,objectKey:"type"}),filter:e=>jo(Lt({layerType:a},e)),layout:e=>wo({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Vo(Lt({layerType:a},e))}}),paint:e=>wo({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Uo(Lt({layerType:a,layer:n},e))}})}})),t}function qo(e){const t=e.value,n=e.key,r=Cn(t);return"string"!==r?[new Rt(n,t,`string expected, ${r} found`)]:[]}const Wo={promoteId:function({key:e,value:t}){if("string"===Cn(t))return qo({key:e,value:t});{const n=[];for(const r in t)n.push(...qo({key:`${e}.${r}`,value:t[r]}));return n}}};function Zo(e){const t=e.value,n=e.key,r=e.styleSpec,i=e.style;if(!t.type)return[new Rt(n,t,'"type" is required')];const o=zt(t.type);let a=[];switch(["vector","raster","raster-dem"].includes(o)&&(t.url||t.tiles||a.push(new Rt(n,t,'Either "url" or "tiles" is required.'))),o){case"vector":case"raster":case"raster-dem":return a=a.concat(wo({key:n,value:t,valueSpec:r["source_"+o.replace("-","_")],style:e.style,styleSpec:r,objectElementValidators:Wo})),a;case"geojson":if(a=wo({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,objectElementValidators:Wo}),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(...Mo({key:`${n}.${e}.map`,value:i,expressionContext:"cluster-map"})),a.push(...Mo({key:`${n}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return wo({key:n,value:t,valueSpec:r.source_video,style:i,styleSpec:r});case"image":return wo({key:n,value:t,valueSpec:r.source_image,style:i,styleSpec:r});case"canvas":return[new Rt(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Ao({key:n+".type",value:t.type,valueSpec:{values:Ho(r)},style:i,styleSpec:r})}}function Ho(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 $o(e){const t=e.value;let n=[];if(!t)return n;const r=Cn(t);return"string"!==r?(n=n.concat([new Rt(e.key,t,`string expected, "${r}" found`)]),n):(function(e){const t=-1===e.indexOf("://");try{return new URL(e,t?"http://example.com":void 0),!0}catch(e){return!1}}(t)||(n=n.concat([new Rt(e.key,t,`invalid url "${t}"`)])),n)}function Xo(e){const t=e.value,n=e.styleSpec,r=n.light,i=e.style;let o=[];const a=Cn(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new Rt("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?ea({key:e,value:t[e],valueSpec:n.transition,style:i,styleSpec:n}):r[e]?ea({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}):[new Rt(e,t[e],`unknown property "${e}"`)])}return o}function Yo(e){const t=e.value;let n=[];if(!t)return n;const r=Cn(t);if("object"!==r)return n=n.concat([new Rt("light-3d",t,`object expected, ${r} found`)]),n;const i=e.styleSpec,o=i["light-3d"],a=e.key,s=e.style,l=e.style.lights;for(const e of["type","id"])if(!(e in t))return n=n.concat([new Rt("light-3d",t,`missing property ${e} on light`)]),n;if(t.type&&l)for(let r=0;r[],array:To,boolean:function(e){const t=e.value,n=e.key,r=Cn(t);return"boolean"!==r?[new Rt(n,t,`boolean expected, ${r} found`)]:[]},number:So,color:function(e){const t=e.key,n=e.value,r=Cn(n);return"string"!==r?[new Rt(t,n,`color expected, ${r} found`)]:null===on(n)?[new Rt(t,n,`color expected, "${n}" found`)]:[]},enum:Ao,filter:jo,function:Eo,layer:Go,object:wo,source:Zo,model:$o,light:Xo,"light-3d":Yo,terrain:Ko,fog:Jo,string:qo,formatted:function(e){return 0===qo(e).length?[]:Mo(e)},resolvedImage:function(e){return 0===qo(e).length?[]:Mo(e)},projection:function(e){const t=e.value,n=e.styleSpec,r=n.projection,i=e.style;let o=[];const a=Cn(t);if("object"===a)for(const e in t)o=o.concat(ea({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}));else"string"!==a&&(o=o.concat([new Rt("projection",t,`object or string expected, ${a} found`)]));return o},import:function(e){const{value:t,styleSpec:n}=e,{data:r,...i}=t;Object.defineProperty(i,"__line__",{value:t.__line__,enumerable:!1});let o=wo(Lt({},e,{value:i,valueSpec:n.import}));return""===zt(i.id)&&o.push(new Rt(e.key+".id",i,"import id can't be an empty string")),r&&(o=o.concat(na(r,n,{key:e.key+".data"}))),o}};function ea(e,t=!1){const n=e.value,r=e.valueSpec,i=e.styleSpec;if(r.expression&&so(zt(n)))return Eo(e);if(r.expression&&_o(Bt(n)))return Mo(e);if(r.type&&Qo[r.type]){const n=Qo[r.type](e);return!0===t&&n.length>0&&"array"===Cn(e.value)?Mo(e):n}return wo(Lt({},e,{valueSpec:r.type?i[r.type]:r}))}function ta(e){const t=e.value,n=e.key,r=qo(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new Rt(n,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new Rt(n,t,'"glyphs" url must include a "{range}" token'))),r}function na(e,t=Pt,n={}){return ea({key:n.key||"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:ta,"*":()=>[]}})}function ra(e,t=Pt){return pa(na(e,t))}const ia=e=>pa(Zo(e)),oa=e=>pa(Xo(e)),aa=e=>pa(Yo(e)),sa=e=>pa(Ko(e)),la=e=>pa(Jo(e)),ua=e=>pa(Go(e)),ca=e=>pa(jo(e)),ha=e=>pa(Uo(e)),da=e=>pa(Vo(e)),fa=e=>pa($o(e));function pa(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function ma(e,t){let n=!1;if(t&&t.length)for(const r of t)r instanceof Dt?X(r.message):(e.fire(new kt(new Error(r.message))),n=!0);return n}var _a=ga;function ga(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}}},ga.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}},ga.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},ga.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},ga.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]=Ta(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 Sa(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||ba(e)||wa(e)||ArrayBuffer.isView(e)||e instanceof n.ImageData)return e;if(Array.isArray(e))return e.map(Sa);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=new Map;for(const n of Object.keys(e))"$name"!==n&&t.set(n,Sa(e[n]));return t}const{klass:n}=va[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]=Sa(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const Ea=e=>e>=128&&e<=255,Ma=e=>e>=1536&&e<=1791,Aa=e=>e>=1872&&e<=1919,Ia=e=>e>=2208&&e<=2303,Ca=e=>e>=4352&&e<=4607,ka=e=>e>=5120&&e<=5759,Oa=e=>e>=6016&&e<=6143,Pa=e=>e>=6320&&e<=6399,Ra=e=>e>=8192&&e<=8303,Da=e=>e>=8448&&e<=8527,La=e=>e>=8528&&e<=8591,za=e=>e>=8960&&e<=9215,Ba=e=>e>=9216&&e<=9279,Fa=e=>e>=9280&&e<=9311,ja=e=>e>=9312&&e<=9471,Na=e=>e>=9632&&e<=9727,Ua=e=>e>=9728&&e<=9983,Va=e=>e>=11008&&e<=11263,Ga=e=>e>=11904&&e<=12031,qa=e=>e>=12032&&e<=12255,Wa=e=>e>=12272&&e<=12287,Za=e=>e>=12288&&e<=12351,Ha=e=>e>=12352&&e<=12447,$a=e=>e>=12448&&e<=12543,Xa=e=>e>=12544&&e<=12591,Ya=e=>e>=12592&&e<=12687,Ka=e=>e>=12688&&e<=12703,Ja=e=>e>=12704&&e<=12735,Qa=e=>e>=12736&&e<=12783,es=e=>e>=12784&&e<=12799,ts=e=>e>=12800&&e<=13055,ns=e=>e>=13056&&e<=13311,rs=e=>e>=13312&&e<=19903,is=e=>e>=19904&&e<=19967,os=e=>e>=19968&&e<=40959,as=e=>e>=40960&&e<=42127,ss=e=>e>=42128&&e<=42191,ls=e=>e>=43360&&e<=43391,us=e=>e>=44032&&e<=55215,cs=e=>e>=55216&&e<=55295,hs=e=>e>=57344&&e<=63743,ds=e=>e>=63744&&e<=64255,fs=e=>e>=64336&&e<=65023,ps=e=>e>=65040&&e<=65055,ms=e=>e>=65072&&e<=65103,_s=e=>e>=65104&&e<=65135,gs=e=>e>=65136&&e<=65279,ys=e=>e>=65280&&e<=65519,vs=e=>e>=131072&&e<=173791;function xs(e){for(const t of e)if(Ts(t.charCodeAt(0)))return!0;return!1}function bs(e){for(const t of e)if(!ws(t.charCodeAt(0)))return!1;return!0}function ws(e){return!(Ma(e)||Aa(e)||Ia(e)||fs(e)||gs(e))}function Ts(e){return!(746!==e&&747!==e&&(e<4352||!(Ja(e)||Xa(e)||ms(e)&&!(e>=65097&&e<=65103)||ds(e)||ns(e)||Ga(e)||Qa(e)||!(!Za(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||rs(e)||os(e)||ts(e)||Ya(e)||ls(e)||cs(e)||Ca(e)||us(e)||Ha(e)||Wa(e)||Ka(e)||qa(e)||es(e)||$a(e)&&12540!==e||!(!ys(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)||!(!_s(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||ka(e)||Pa(e)||ps(e)||is(e)||as(e)||ss(e))))}function Ss(e){return!(Ts(e)||function(e){return!!(Ea(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||Ra(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)||Da(e)||La(e)||za(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)||Ba(e)&&9251!==e||Fa(e)||ja(e)||Na(e)||Ua(e)&&!(e>=9754&&e<=9759)||Va(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Za(e)||$a(e)||hs(e)||ms(e)||_s(e)||ys(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function Es(e){return e>=1424&&e<=2303||fs(e)||gs(e)}function Ms(e,t){return!(!t&&Es(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||Oa(e))}function As(e){for(const t of e)if(Es(t.charCodeAt(0)))return!0;return!1}const Is="deferred",Cs="loading",ks="loaded";let Os=null,Ps="unavailable",Rs=null;const Ds=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Ps="error"),Os&&Os(e)};function Ls(){zs.fire(new Ct("pluginStateChange",{pluginStatus:Ps,pluginURL:Rs}))}const zs=new Ot,Bs=function(){return Ps},Fs=function(){if(Ps!==Is||!Rs)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ps=Cs,Ls(),Rs&&Se({url:Rs},e=>{e?Ds(e):(Ps=ks,Ls())})},js={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ps===ks||null!=js.applyArabicShaping,isLoading:()=>Ps===Cs,setState(e){Ps=e.pluginStatus,Rs=e.pluginURL},isParsed:()=>null!=js.applyArabicShaping&&null!=js.processBidirectionalText&&null!=js.processStyledBidirectionalText,getPluginURL:()=>Rs};class Ns{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0)}isSupportedScript(e){return function(e,t){for(const n of e)if(!Ms(n.charCodeAt(0),t))return!1;return!0}(e,js.isLoaded())}}class Us{constructor(e,t,n){this.property=e,this.value=t,this.expression=function(e,t,n){if(so(e))return new bo(e,t);if(_o(e)||Array.isArray(e)&&e.length>0){const r=xo(e,t,n);if("error"===r.result)throw new Error(r.value.map(e=>`${e.key}: ${e.message}`).join(", "));return r.value}{let n=e;return"string"==typeof e&&"color"===t.type&&(n=dn.parse(e)),{kind:"constant",isConfigDependent:!1,evaluate:()=>n}}}(void 0===t?e.specification.default:t,e.specification,n)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class Vs{constructor(e,t){this.property=e,this.value=new Us(e,void 0,t)}transitioned(e,t){return new qs(this.property,this.value,t,z({},e.transition,this.transition),e.now)}untransitioned(){return new qs(this.property,this.value,null,{},0)}}class Gs{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._options=t,this.isConfigDependent=!1}getValue(e){return H(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Vs(this._values[e].property,this._options)),this._values[e].value=new Us(this._values[e].property,null===t?void 0:H(t),this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].value.expression.isConfigDependent}setTransitionOrValue(e,t){t&&(this._options=t);const n=this._properties.properties;if(e)for(const t in e){const r=e[t];if(q(t,"-transition")){const e=t.slice(0,-11);n[e]&&this.setTransition(e,r)}else n[t]&&this.setValue(t,r)}}getTransition(e){return H(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Vs(this._values[e].property)),this._values[e].transition=H(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 Ws(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 Ws(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class qs{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(r=0}function el(e,t){return t?`${e}${t}`:e}function tl(e){const t=e.indexOf("");return t>=0?e.slice(0,t):e}xa(Ys,"DataDrivenProperty"),xa(Xs,"DataConstantProperty"),xa(Ks,"ColorRampProperty");const nl="-transition";class rl extends Ot{constructor(e,t,n){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),this.options=n,e.slot&&(this.slot=e.slot),t.layout&&(this._unevaluatedLayout=new Zs(t.layout,n),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),t.paint)){this._transitionablePaint=new Gs(t.paint,n);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.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new $s(t.paint)}}setScope(e){this.scope=e,this.fqid=el(this.id,e)}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,n={}){if(null!=t&&this._validate(da,`layers.${this.id}.layout.${e}`,e,t,n))return;if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,"visibility"===e&&this.possiblyEvaluateVisibility())}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0})}getPaintProperty(e){return q(e,nl)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,n={}){if(null!=t&&this._validate(ha,`layers.${this.id}.paint.${e}`,e,t,n))return!1;const r=this._transitionablePaint,i=r._properties.properties;if(q(e,nl)){const n=e.slice(0,-11);return i[n]&&r.setTransition(n,t||void 0),!1}if(!i[e])return!1;const o=r._values[e],a=o.value.isDataDriven(),s=o.value;r.setValue(e,t),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,this._handleSpecialPaintPropertyUpdate(e);const l=r._values[e].value,u=l.isDataDriven(),c=q(e,"pattern")||"line-dasharray"===e;return u||a||c||this._handleOverridablePaintPropertyUpdate(e,s,l)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t){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(){return Z({id:this.id,type:this.type,slot:this.slot,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()},(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)&&ma(this,e.call(ra,{key:t,layerType:this.type,objectKey:n,value:r,styleSpec:Pt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}hasShadowPass(){return!1}canCastShadows(){return!1}hasLightBeamPass(){return!1}cutoffRange(){return 0}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Hs&&ro(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Co(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(){this._stats&&(this._stats.numRenderedVerticesInShadowPass=0,this._stats.numRenderedVerticesInTransparentPass=0)}}class il{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set}isDirty(){return this._changed}setDirty(){this._changed=!0}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty()}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e]}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty()}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty()}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id]}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty()}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty()}resetUpdatedImages(){this._updatedImages.clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear()}}const ol={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class al{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class sl{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);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 ll(e,t=1){let n=0,r=0;return{members:e.map(e=>{const i=ol[e.type].BYTES_PER_ELEMENT,o=n=ul(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:ul(n,Math.max(r,t)),alignment:t}}function ul(e,t){return Math.ceil(e/t)*t}class cl extends sl{_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}}cl.prototype.bytesPerElement=4,xa(cl,"StructArrayLayout2i4");class hl extends sl{_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}}hl.prototype.bytesPerElement=6,xa(hl,"StructArrayLayout3i6");class dl extends sl{_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}}dl.prototype.bytesPerElement=8,xa(dl,"StructArrayLayout4i8");class fl extends sl{_refreshViews(){this.uint8=new Uint8Array(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=5*e;return this.int16[a+0]=t,this.int16[a+1]=n,this.int16[a+2]=r,this.int16[a+3]=i,this.int16[a+4]=o,e}}fl.prototype.bytesPerElement=10,xa(fl,"StructArrayLayout5i10");class pl extends sl{_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}}pl.prototype.bytesPerElement=12,xa(pl,"StructArrayLayout2i4ub1f12");class ml extends sl{_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}}ml.prototype.bytesPerElement=16,xa(ml,"StructArrayLayout4f16");class _l extends sl{_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}}_l.prototype.bytesPerElement=12,xa(_l,"StructArrayLayout4ui1f12");class gl extends sl{_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}}gl.prototype.bytesPerElement=8,xa(gl,"StructArrayLayout4ui8");class yl extends sl{_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}}yl.prototype.bytesPerElement=12,xa(yl,"StructArrayLayout6i12");class vl extends sl{_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}}vl.prototype.bytesPerElement=24,xa(vl,"StructArrayLayout4i4ui4i24");class xl extends sl{_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}}xl.prototype.bytesPerElement=20,xa(xl,"StructArrayLayout3i3f20");class bl extends sl{_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}}bl.prototype.bytesPerElement=4,xa(bl,"StructArrayLayout1ul4");class wl extends sl{_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}}wl.prototype.bytesPerElement=4,xa(wl,"StructArrayLayout2ui4");class Tl extends sl{_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}}Tl.prototype.bytesPerElement=40,xa(Tl,"StructArrayLayout5i4f1i1ul2ui40");class Sl extends sl{_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}}Sl.prototype.bytesPerElement=16,xa(Sl,"StructArrayLayout3i2i2i16");class El extends sl{_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}}El.prototype.bytesPerElement=16,xa(El,"StructArrayLayout2f1f2i16");class Ml extends sl{_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}}Ml.prototype.bytesPerElement=12,xa(Ml,"StructArrayLayout2ub2f12");class Al extends sl{_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}}Al.prototype.bytesPerElement=6,xa(Al,"StructArrayLayout3ui6");class Il extends sl{_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,T=15*e,S=60*e;return this.int16[w+0]=t,this.int16[w+1]=n,this.int16[w+2]=r,this.float32[T+2]=i,this.float32[T+3]=o,this.uint16[w+8]=a,this.uint16[w+9]=s,this.uint32[T+5]=l,this.uint32[T+6]=u,this.uint32[T+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=f,this.float32[T+10]=p,this.float32[T+11]=m,this.uint8[S+48]=_,this.uint8[S+49]=g,this.uint8[S+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[S+58]=b,e}}Il.prototype.bytesPerElement=60,xa(Il,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Cl extends sl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(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,T,S,E,M,A,I,C,k,O){const P=this.length;return this.resize(P+1),this.emplace(P,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,T,S,E,M,A,I,C,k,O)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,T,S,E,M,A,I,C,k,O,P){const R=20*e,D=40*e,L=80*e;return this.float32[R+0]=t,this.float32[R+1]=n,this.int16[D+4]=r,this.int16[D+5]=i,this.int16[D+6]=o,this.int16[D+7]=a,this.int16[D+8]=s,this.int16[D+9]=l,this.int16[D+10]=u,this.int16[D+11]=c,this.int16[D+12]=h,this.uint16[D+13]=d,this.uint16[D+14]=f,this.uint16[D+15]=p,this.uint16[D+16]=m,this.uint16[D+17]=_,this.uint16[D+18]=g,this.uint16[D+19]=y,this.uint16[D+20]=v,this.uint16[D+21]=x,this.uint16[D+22]=b,this.uint16[D+23]=w,this.uint16[D+24]=T,this.uint16[D+25]=S,this.uint16[D+26]=E,this.uint16[D+27]=M,this.uint32[R+14]=A,this.float32[R+15]=I,this.float32[R+16]=C,this.float32[R+17]=k,this.float32[R+18]=O,this.uint8[L+76]=P,e}}Cl.prototype.bytesPerElement=80,xa(Cl,"StructArrayLayout2f9i15ui1ul4f1ub80");class kl extends sl{_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}}kl.prototype.bytesPerElement=4,xa(kl,"StructArrayLayout1f4");class Ol extends sl{_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}}Ol.prototype.bytesPerElement=20,xa(Ol,"StructArrayLayout5f20");class Pl extends sl{_refreshViews(){this.uint8=new Uint8Array(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=7*e;return this.float32[l+0]=t,this.float32[l+1]=n,this.float32[l+2]=r,this.float32[l+3]=i,this.float32[l+4]=o,this.float32[l+5]=a,this.float32[l+6]=s,e}}Pl.prototype.bytesPerElement=28,xa(Pl,"StructArrayLayout7f28");class Rl extends sl{_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}}Rl.prototype.bytesPerElement=12,xa(Rl,"StructArrayLayout1ul3ui12");class Dl extends sl{_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}}Dl.prototype.bytesPerElement=2,xa(Dl,"StructArrayLayout1ui2");class Ll extends sl{_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}}Ll.prototype.bytesPerElement=12,xa(Ll,"StructArrayLayout3f12");class zl extends sl{_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}}zl.prototype.bytesPerElement=8,xa(zl,"StructArrayLayout2f8");class Bl extends sl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=n,this.float32[g+2]=r,this.float32[g+3]=i,this.float32[g+4]=o,this.float32[g+5]=a,this.float32[g+6]=s,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=d,this.float32[g+12]=f,this.float32[g+13]=p,this.float32[g+14]=m,this.float32[g+15]=_,e}}Bl.prototype.bytesPerElement=64,xa(Bl,"StructArrayLayout16f64");class Fl extends sl{_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,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=10*e,u=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=n,this.uint16[l+2]=r,this.uint16[l+3]=i,this.float32[u+2]=o,this.float32[u+3]=a,this.float32[u+4]=s,e}}Fl.prototype.bytesPerElement=20,xa(Fl,"StructArrayLayout4ui3f20");class jl extends sl{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}jl.prototype.bytesPerElement=1,xa(jl,"StructArrayLayout1ub1");class Nl extends al{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]}}Nl.prototype.size=40;class Ul extends Tl{get(e){return new Nl(this,e)}}xa(Ul,"CollisionBoxArray");class Vl extends al{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}}Vl.prototype.size=60;class Gl extends Il{get(e){return new Vl(this,e)}}xa(Gl,"PlacedSymbolArray");class ql extends al{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}ql.prototype.size=80;class Wl extends Cl{get(e){return new ql(this,e)}}xa(Wl,"SymbolInstanceArray");class Zl extends kl{getoffsetX(e){return this.float32[1*e+0]}}xa(Zl,"GlyphOffsetArray");class Hl extends cl{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}xa(Hl,"SymbolLineVertexArray");class $l extends al{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]}}$l.prototype.size=12;class Xl extends Rl{get(e){return new $l(this,e)}}xa(Xl,"FeatureIndexArray");class Yl extends wl{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}xa(Yl,"FillExtrusionCentroidArray");const Kl=ll([{name:"a_pos",components:2,type:"Int16"}],4),Jl=ll([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class Ql{constructor(e=[]){this.segments=e}_prepareSegment(e,t,n,r){let i=this.segments[this.segments.length-1];return e>Ql.MAX_VERTEX_ARRAY_LENGTH&&X(`Max vertices per segment is ${Ql.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!i||i.vertexLength+e>Ql.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r)&&(i={vertexOffset:t,primitiveOffset:n,vertexLength:0,primitiveLength:0},void 0!==r&&(i.sortKey=r),this.segments.push(i)),i}prepareSegment(e,t,n,r){return this._prepareSegment(e,t.length,n.length,r)}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 Ql([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}function eu(e,t){return 256*(e=O(Math.floor(e),0,255))+O(Math.floor(t),0,255)}Ql.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,xa(Ql,"SegmentVector");const tu=ll([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),nu=ll([{name:"a_dash",components:4,type:"Uint16"}]);var ru={exports:{}},iu={exports:{}};!function(e){e.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}}(iu);var ou=iu.exports,au={exports:{}};!function(e){e.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}}(au);var su=ou,lu=au.exports;ru.exports=su,ru.exports.murmur3=su,ru.exports.murmur2=lu;var uu=f(ru.exports);class cu{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(hu(e)),this.positions.push(t,n,r)}eachPosition(e,t){const n=hu(e);let r=0,i=this.ids.length-1;for(;r>1;this.ids[e]>=n?i=e:r=e+1}for(;this.ids[r]===n;)t(this.positions[3*r],this.positions[3*r+1],this.positions[3*r+2]),r++}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;du(t,a,s),du(n,3*a,3*s),du(n,3*a+1,3*s+1),du(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 vu(e):new mu(e)}}class Iu{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 yu(e):new mu(e)}}class Cu{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,a){const s=this.paintVertexArray.length,l=this.expression.evaluate(new Ns(0,{brightness:o}),t,{},i,r,a);this.paintVertexArray.resize(e),this._setPaintValue(s,e,l)}updatePaintArray(e,t,n,r,i,o,a){const s=this.expression.evaluate({zoom:0,brightness:a},n,r,void 0,i);this._setPaintValue(e,t,s)}_setPaintValue(e,t,n){if("color"===this.type){const r=Mu(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,a){const s=this.expression.evaluate(new Ns(this.zoom,{brightness:o}),t,{},i,r,a),l=this.expression.evaluate(new Ns(this.zoom+1,{brightness:o}),t,{},i,r,a),u=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(u,e,s,l)}updatePaintArray(e,t,n,r,i,o,a){const s=this.expression.evaluate({zoom:this.zoom,brightness:a},n,r,void 0,i),l=this.expression.evaluate({zoom:this.zoom+1,brightness:a},n,r,void 0,i);this._setPaintValue(e,t,s,l)}_setPaintValue(e,t,n,r){if("color"===this.type){const i=Mu(n),o=Mu(r);for(let n=e;n!0)){this.binders={},this._buffers=[];const r=[];for(const i in e.paint._values){const o=e.paint.get(i);if(!n(i))continue;if(!(o instanceof Hs&&ro(o.property.specification)))continue;const a=Lu(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=Fu(i,l,"source");this.binders[i]=c?new Ou(s,a,l,t,e.id):new Cu(s,a,l,t),r.push("/a_"+i)}else{const e=Fu(i,l,"composite");this.binders[i]=new ku(s,a,l,u,t,e),r.push("/z_"+i)}else this.binders[i]=c?new Iu(s.value,a):new Au(s.value,a,l),r.push("/u_"+i)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Cu||t instanceof ku?t.maxValue:0}populatePaintArrays(e,t,n,r,i,o,a){for(const s in this.binders){const l=this.binders[s];(l instanceof Cu||l instanceof ku||l instanceof Ou)&&l.populatePaintArray(e,t,n,r,i,o,a)}}setConstantPatternPositions(e){for(const t in this.binders){const n=this.binders[t];n instanceof Iu&&n.setConstantPatternPositions(e)}}updatePaintArrays(e,t,n,r,i,o,a,s){let l=!1;const u=Object.keys(e),c=0!==u.length,h=c?u:t.uniqueIds;for(const u in this.binders){const d=this.binders[u];if((d instanceof Cu||d instanceof ku||d instanceof Ou)&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){const f=i.paint.get(u);d.expression=f.value;for(const n of h){const i=e[n.toString()];t.eachPosition(n,(e,t,n)=>{const l=r.feature(e);d.updatePaintArray(t,n,l,i,o,a,s)})}if(!c)for(const t of n.uniqueIds){const i=e[t.toString()];n.eachPosition(t,(e,t,n)=>{const l=r.feature(e);d.updatePaintArray(t,n,l,i,o,a,s)})}l=!0}}return l}defines(){const e=[];for(const t in this.binders){const n=this.binders[t];(n instanceof Au||n instanceof Iu)&&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 Cu||n instanceof ku||n instanceof Ou)for(let t=0;t!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Pu(r,t,n);this.needsUpload=!1,this._featureMap=new cu,this._featureMapWithoutIds=new cu,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,n,r,i,o,a,s){for(const n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r,i,o,a,s);void 0!==t.id?this._featureMap.add(t.id,n,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,n,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r,i,o){for(const a of n)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,a,r,i,o||0)||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 Du={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"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 Lu(e,t){return Du[e]||[e.replace(t+"-","").replace(/-/g,"_")]}const zu={"line-pattern":{source:_l,composite:_l},"fill-pattern":{source:_l,composite:_l},"fill-extrusion-pattern":{source:_l,composite:_l},"line-dasharray":{source:gl,composite:gl}},Bu={color:{source:zl,composite:ml},number:{source:kl,composite:zl}};function Fu(e,t,n){const r=zu[e];return r&&r[n]||Bu[t][n]}xa(Au,"ConstantBinder"),xa(Iu,"PatternConstantBinder"),xa(Cu,"SourceExpressionBinder"),xa(Ou,"PatternCompositeBinder"),xa(ku,"CompositeExpressionBinder"),xa(Pu,"ProgramConfiguration",{omit:["_buffers"]}),xa(Ru,"ProgramConfigurationSet");class ju{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 _f?new _f(e.lng,e.lat):_f.convert(e),this}setSouthWest(e){return this._sw=e instanceof _f?new _f(e.lng,e.lat):_f.convert(e),this}extend(e){const t=this._sw,n=this._ne;let r,i;if(e instanceof _f)r=e,i=e;else{if(!(e instanceof ju))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(ju.convert(e)):this.extend(_f.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(_f.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 _f(r.lng,r.lat),this._ne=new _f(i.lng,i.lat)),this}getCenter(){return new _f((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 _f(this.getWest(),this.getNorth())}getSouthEast(){return new _f(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}=_f.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 ju?e:new ju(e)}}var Nu={},Uu={};Object.defineProperty(Uu,"__esModule",{value:!0}),Uu.setMatrixArrayType=function(e){Uu.ARRAY_TYPE=Gu=e},Uu.toRadian=function(e){return e*Wu},Uu.equals=function(e,t){return Math.abs(e-t)<=Vu*Math.max(1,Math.abs(e),Math.abs(t))},Uu.RANDOM=Uu.ARRAY_TYPE=Uu.EPSILON=void 0;var Vu=1e-6;Uu.EPSILON=Vu;var Gu="undefined"!=typeof Float32Array?Float32Array:Array;Uu.ARRAY_TYPE=Gu;var qu=Math.random;Uu.RANDOM=qu;var Wu=Math.PI/180;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var Zu={};function Hu(e){return(Hu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(Zu,"__esModule",{value:!0}),Zu.create=function(){var e=new $u.ARRAY_TYPE(4);return $u.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},Zu.clone=function(e){var t=new $u.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Zu.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},Zu.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},Zu.fromValues=function(e,t,n,r){var i=new $u.ARRAY_TYPE(4);return i[0]=e,i[1]=t,i[2]=n,i[3]=r,i},Zu.set=function(e,t,n,r,i){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e},Zu.transpose=function(e,t){if(e===t){var n=t[1];e[1]=t[2],e[2]=n}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},Zu.invert=function(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},Zu.adjoint=function(e,t){var n=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=n,e},Zu.determinant=function(e){return e[0]*e[3]-e[2]*e[1]},Zu.multiply=Xu,Zu.rotate=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);return e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l,e},Zu.scale=function(e,t,n){var r=t[1],i=t[2],o=t[3],a=n[0],s=n[1];return e[0]=t[0]*a,e[1]=r*a,e[2]=i*s,e[3]=o*s,e},Zu.fromRotation=function(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=-n,e[3]=r,e},Zu.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},Zu.str=function(e){return"mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},Zu.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},Zu.LDU=function(e,t,n,r){return e[2]=r[2]/r[0],n[0]=r[0],n[1]=r[1],n[3]=r[3]-e[2]*n[1],[e,t,n]},Zu.add=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},Zu.subtract=Yu,Zu.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},Zu.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=t[0],s=t[1],l=t[2],u=t[3];return Math.abs(n-a)<=$u.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-s)<=$u.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-l)<=$u.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(o-u)<=$u.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))},Zu.multiplyScalar=function(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},Zu.multiplyScalarAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e},Zu.sub=Zu.mul=void 0;var $u=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Hu(e)&&"function"!=typeof e)return{default:e};var n=function(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return function(e){return e?n:t}(e)}(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(Uu);function Xu(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*s+o*l,e[1]=i*s+a*l,e[2]=r*u+o*c,e[3]=i*u+a*c,e}function Yu(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}Zu.mul=Xu,Zu.sub=Yu;var Ku={};function Ju(e){return(Ju="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(Ku,"__esModule",{value:!0}),Ku.create=function(){var e=new Qu.ARRAY_TYPE(6);return Qu.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e},Ku.clone=function(e){var t=new Qu.ARRAY_TYPE(6);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},Ku.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},Ku.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},Ku.fromValues=function(e,t,n,r,i,o){var a=new Qu.ARRAY_TYPE(6);return a[0]=e,a[1]=t,a[2]=n,a[3]=r,a[4]=i,a[5]=o,a},Ku.set=function(e,t,n,r,i,o,a){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=a,e},Ku.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=n*o-r*i;return l?(e[0]=o*(l=1/l),e[1]=-r*l,e[2]=-i*l,e[3]=n*l,e[4]=(i*s-o*a)*l,e[5]=(r*a-n*s)*l,e):null},Ku.determinant=function(e){return e[0]*e[3]-e[1]*e[2]},Ku.multiply=ec,Ku.rotate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=Math.sin(n),c=Math.cos(n);return e[0]=r*c+o*u,e[1]=i*c+a*u,e[2]=r*-u+o*c,e[3]=i*-u+a*c,e[4]=s,e[5]=l,e},Ku.scale=function(e,t,n){var r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=n[0],u=n[1];return e[0]=t[0]*l,e[1]=r*l,e[2]=i*u,e[3]=o*u,e[4]=a,e[5]=s,e},Ku.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=r*u+o*c+s,e[5]=i*u+a*c+l,e},Ku.fromRotation=function(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=-n,e[3]=r,e[4]=0,e[5]=0,e},Ku.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e},Ku.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e},Ku.str=function(e){return"mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},Ku.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},Ku.add=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[4]=t[4]+n[4],e[5]=t[5]+n[5],e},Ku.subtract=tc,Ku.multiplyScalar=function(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[4]=t[4]*n,e[5]=t[5]*n,e},Ku.multiplyScalarAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e},Ku.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]},Ku.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=t[0],u=t[1],c=t[2],h=t[3],d=t[4],f=t[5];return Math.abs(n-l)<=Qu.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(r-u)<=Qu.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(i-c)<=Qu.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(o-h)<=Qu.EPSILON*Math.max(1,Math.abs(o),Math.abs(h))&&Math.abs(a-d)<=Qu.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(s-f)<=Qu.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))},Ku.sub=Ku.mul=void 0;var Qu=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Ju(e)&&"function"!=typeof e)return{default:e};var n=function(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return function(e){return e?n:t}(e)}(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(Uu);function ec(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=n[0],c=n[1],h=n[2],d=n[3],f=n[4],p=n[5];return e[0]=r*u+o*c,e[1]=i*u+a*c,e[2]=r*h+o*d,e[3]=i*h+a*d,e[4]=r*f+o*p+s,e[5]=i*f+a*p+l,e}function tc(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[4]=t[4]-n[4],e[5]=t[5]-n[5],e}Ku.mul=ec,Ku.sub=tc;var nc={};function rc(e){return(rc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(nc,"__esModule",{value:!0}),nc.create=function(){var e=new ic.ARRAY_TYPE(9);return ic.ARRAY_TYPE!=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},nc.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},nc.clone=function(e){var t=new ic.ARRAY_TYPE(9);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},nc.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},nc.fromValues=function(e,t,n,r,i,o,a,s,l){var u=new ic.ARRAY_TYPE(9);return u[0]=e,u[1]=t,u[2]=n,u[3]=r,u[4]=i,u[5]=o,u[6]=a,u[7]=s,u[8]=l,u},nc.set=function(e,t,n,r,i,o,a,s,l,u){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=a,e[6]=s,e[7]=l,e[8]=u,e},nc.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},nc.transpose=function(e,t){if(e===t){var n=t[1],r=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=i}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},nc.invert=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],h=c*a-s*u,d=-c*o+s*l,f=u*o-a*l,p=n*h+r*d+i*f;return p?(e[0]=h*(p=1/p),e[1]=(-c*r+i*u)*p,e[2]=(s*r-i*a)*p,e[3]=d*p,e[4]=(c*n-i*l)*p,e[5]=(-s*n+i*o)*p,e[6]=f*p,e[7]=(-u*n+r*l)*p,e[8]=(a*n-r*o)*p,e):null},nc.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},nc.determinant=function(e){var t=e[3],n=e[4],r=e[5],i=e[6],o=e[7],a=e[8];return e[0]*(a*n-r*o)+e[1]*(-a*t+r*i)+e[2]*(o*t-n*i)},nc.multiply=oc,nc.translate=function(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];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=d*r+f*a+u,e[7]=d*i+f*s+c,e[8]=d*o+f*l+h,e},nc.rotate=function(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=Math.sin(n),f=Math.cos(n);return e[0]=f*r+d*a,e[1]=f*i+d*s,e[2]=f*o+d*l,e[3]=f*a-d*r,e[4]=f*s-d*i,e[5]=f*l-d*o,e[6]=u,e[7]=c,e[8]=h,e},nc.scale=function(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},nc.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e},nc.fromRotation=function(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=-n,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},nc.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},nc.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},nc.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,f=i*s,p=i*l,m=o*a,_=o*s,g=o*l;return e[0]=1-h-p,e[3]=c-g,e[6]=d+_,e[1]=c+g,e[4]=1-u-p,e[7]=f-m,e[2]=d-_,e[5]=f+m,e[8]=1-u-h,e},nc.normalFromMat4=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],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,T=i*u-o*l,S=c*m-h*p,E=c*_-d*p,M=c*g-f*p,A=h*_-d*m,I=h*g-f*m,C=d*g-f*_,k=y*C-v*I+x*A+b*M-w*E+T*S;return k?(e[0]=(s*C-l*I+u*A)*(k=1/k),e[1]=(l*M-a*C-u*E)*k,e[2]=(a*I-s*M+u*S)*k,e[3]=(i*I-r*C-o*A)*k,e[4]=(n*C-i*M+o*E)*k,e[5]=(r*M-n*I-o*S)*k,e[6]=(m*T-_*w+g*b)*k,e[7]=(_*x-p*T-g*v)*k,e[8]=(p*w-m*x+g*y)*k,e):null},nc.projection=function(e,t,n){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/n,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},nc.str=function(e){return"mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},nc.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},nc.add=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[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e},nc.subtract=ac,nc.multiplyScalar=function(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[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e},nc.multiplyScalarAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e[6]=t[6]+n[6]*r,e[7]=t[7]+n[7]*r,e[8]=t[8]+n[8]*r,e},nc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]},nc.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=t[0],d=t[1],f=t[2],p=t[3],m=t[4],_=t[5],g=t[6],y=t[7],v=t[8];return Math.abs(n-h)<=ic.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(r-d)<=ic.EPSILON*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(i-f)<=ic.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(o-p)<=ic.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(a-m)<=ic.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(s-_)<=ic.EPSILON*Math.max(1,Math.abs(s),Math.abs(_))&&Math.abs(l-g)<=ic.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(u-y)<=ic.EPSILON*Math.max(1,Math.abs(u),Math.abs(y))&&Math.abs(c-v)<=ic.EPSILON*Math.max(1,Math.abs(c),Math.abs(v))},nc.sub=nc.mul=void 0;var ic=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==rc(e)&&"function"!=typeof e)return{default:e};var n=function(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return function(e){return e?n:t}(e)}(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(Uu);function oc(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 ac(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[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e}nc.mul=oc,nc.sub=ac;var sc={};function lc(e){return(lc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(sc,"__esModule",{value:!0}),sc.create=function(){var e=new uc.ARRAY_TYPE(16);return uc.ARRAY_TYPE!=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},sc.clone=function(e){var t=new uc.ARRAY_TYPE(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},sc.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},sc.fromValues=function(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m){var _=new uc.ARRAY_TYPE(16);return _[0]=e,_[1]=t,_[2]=n,_[3]=r,_[4]=i,_[5]=o,_[6]=a,_[7]=s,_[8]=l,_[9]=u,_[10]=c,_[11]=h,_[12]=d,_[13]=f,_[14]=p,_[15]=m,_},sc.set=function(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=a,e[6]=s,e[7]=l,e[8]=u,e[9]=c,e[10]=h,e[11]=d,e[12]=f,e[13]=p,e[14]=m,e[15]=_,e},sc.identity=cc,sc.transpose=function(e,t){if(e===t){var n=t[1],r=t[2],i=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=i,e[13]=a,e[14]=s}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},sc.invert=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],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,T=i*u-o*l,S=c*m-h*p,E=c*_-d*p,M=c*g-f*p,A=h*_-d*m,I=h*g-f*m,C=d*g-f*_,k=y*C-v*I+x*A+b*M-w*E+T*S;return k?(e[0]=(s*C-l*I+u*A)*(k=1/k),e[1]=(i*I-r*C-o*A)*k,e[2]=(m*T-_*w+g*b)*k,e[3]=(d*w-h*T-f*b)*k,e[4]=(l*M-a*C-u*E)*k,e[5]=(n*C-i*M+o*E)*k,e[6]=(_*x-p*T-g*v)*k,e[7]=(c*T-d*x+f*v)*k,e[8]=(a*I-s*M+u*S)*k,e[9]=(r*M-n*I-o*S)*k,e[10]=(p*w-m*x+g*y)*k,e[11]=(h*x-c*w-f*y)*k,e[12]=(s*E-a*A-l*S)*k,e[13]=(n*A-r*E+i*S)*k,e[14]=(m*v-p*b-_*y)*k,e[15]=(c*b-h*v+d*y)*k,e):null},sc.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],h=t[9],d=t[10],f=t[11],p=t[12],m=t[13],_=t[14],g=t[15];return e[0]=s*(d*g-f*_)-h*(l*g-u*_)+m*(l*f-u*d),e[1]=-(r*(d*g-f*_)-h*(i*g-o*_)+m*(i*f-o*d)),e[2]=r*(l*g-u*_)-s*(i*g-o*_)+m*(i*u-o*l),e[3]=-(r*(l*f-u*d)-s*(i*f-o*d)+h*(i*u-o*l)),e[4]=-(a*(d*g-f*_)-c*(l*g-u*_)+p*(l*f-u*d)),e[5]=n*(d*g-f*_)-c*(i*g-o*_)+p*(i*f-o*d),e[6]=-(n*(l*g-u*_)-a*(i*g-o*_)+p*(i*u-o*l)),e[7]=n*(l*f-u*d)-a*(i*f-o*d)+c*(i*u-o*l),e[8]=a*(h*g-f*m)-c*(s*g-u*m)+p*(s*f-u*h),e[9]=-(n*(h*g-f*m)-c*(r*g-o*m)+p*(r*f-o*h)),e[10]=n*(s*g-u*m)-a*(r*g-o*m)+p*(r*u-o*s),e[11]=-(n*(s*f-u*h)-a*(r*f-o*h)+c*(r*u-o*s)),e[12]=-(a*(h*_-d*m)-c*(s*_-l*m)+p*(s*d-l*h)),e[13]=n*(h*_-d*m)-c*(r*_-i*m)+p*(r*d-i*h),e[14]=-(n*(s*_-l*m)-a*(r*_-i*m)+p*(r*l-i*s)),e[15]=n*(s*d-l*h)-a*(r*d-i*h)+c*(r*l-i*s),e},sc.determinant=function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],f=e[12],p=e[13],m=e[14],_=e[15];return(t*a-n*o)*(h*_-d*m)-(t*s-r*o)*(c*_-d*p)+(t*l-i*o)*(c*m-h*p)+(n*s-r*a)*(u*_-d*f)-(n*l-i*a)*(u*m-h*f)+(r*l-i*s)*(u*p-c*f)},sc.multiply=hc,sc.translate=function(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},sc.scale=function(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},sc.rotate=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,T,S,E,M,A,I=r[0],C=r[1],k=r[2],O=Math.hypot(I,C,k);return O0?(n[0]=2*(s*a+c*r+l*o-u*i)/h,n[1]=2*(l*a+c*i+u*r-s*o)/h,n[2]=2*(u*a+c*o+s*i-l*r)/h):(n[0]=2*(s*a+c*r+l*o-u*i),n[1]=2*(l*a+c*i+u*r-s*o),n[2]=2*(u*a+c*o+s*i-l*r)),dc(e,t,n),e},sc.getTranslation=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},sc.getScaling=fc,sc.getRotation=function(e,t){var n=new uc.ARRAY_TYPE(3);fc(n,t);var r=1/n[0],i=1/n[1],o=1/n[2],a=t[0]*r,s=t[1]*i,l=t[2]*o,u=t[4]*r,c=t[5]*i,h=t[6]*o,d=t[8]*r,f=t[9]*i,p=t[10]*o,m=a+c+p,_=0;return m>0?(_=2*Math.sqrt(m+1),e[3]=.25*_,e[0]=(h-f)/_,e[1]=(d-l)/_,e[2]=(s-u)/_):a>c&&a>p?(_=2*Math.sqrt(1+a-c-p),e[3]=(h-f)/_,e[0]=.25*_,e[1]=(s+u)/_,e[2]=(d+l)/_):c>p?(_=2*Math.sqrt(1+c-a-p),e[3]=(d-l)/_,e[0]=(s+u)/_,e[1]=.25*_,e[2]=(h+f)/_):(_=2*Math.sqrt(1+p-a-c),e[3]=(s-u)/_,e[0]=(d+l)/_,e[1]=(h+f)/_,e[2]=.25*_),e},sc.fromRotationTranslationScale=function(e,t,n,r){var i=t[0],o=t[1],a=t[2],s=t[3],l=i+i,u=o+o,c=a+a,h=i*l,d=i*u,f=i*c,p=o*u,m=o*c,_=a*c,g=s*l,y=s*u,v=s*c,x=r[0],b=r[1],w=r[2];return e[0]=(1-(p+_))*x,e[1]=(d+v)*x,e[2]=(f-y)*x,e[3]=0,e[4]=(d-v)*b,e[5]=(1-(h+_))*b,e[6]=(m+g)*b,e[7]=0,e[8]=(f+y)*w,e[9]=(m-g)*w,e[10]=(1-(h+p))*w,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e},sc.fromRotationTranslationScaleOrigin=function(e,t,n,r,i){var o=t[0],a=t[1],s=t[2],l=t[3],u=o+o,c=a+a,h=s+s,d=o*u,f=o*c,p=o*h,m=a*c,_=a*h,g=s*h,y=l*u,v=l*c,x=l*h,b=r[0],w=r[1],T=r[2],S=i[0],E=i[1],M=i[2],A=(1-(m+g))*b,I=(f+x)*b,C=(p-v)*b,k=(f-x)*w,O=(1-(d+g))*w,P=(_+y)*w,R=(p+v)*T,D=(_-y)*T,L=(1-(d+m))*T;return e[0]=A,e[1]=I,e[2]=C,e[3]=0,e[4]=k,e[5]=O,e[6]=P,e[7]=0,e[8]=R,e[9]=D,e[10]=L,e[11]=0,e[12]=n[0]+S-(A*S+k*E+R*M),e[13]=n[1]+E-(I*S+O*E+D*M),e[14]=n[2]+M-(C*S+P*E+L*M),e[15]=1,e},sc.fromQuat=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,f=i*s,p=i*l,m=o*a,_=o*s,g=o*l;return e[0]=1-h-p,e[1]=c+g,e[2]=d-_,e[3]=0,e[4]=c-g,e[5]=1-u-p,e[6]=f+m,e[7]=0,e[8]=d+_,e[9]=f-m,e[10]=1-u-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},sc.frustum=function(e,t,n,r,i,o,a){var s=1/(n-t),l=1/(i-r),u=1/(o-a);return e[0]=2*o*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(n+t)*s,e[9]=(i+r)*l,e[10]=(a+o)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*u,e[15]=0,e},sc.perspectiveNO=pc,sc.perspectiveZO=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*(o=1/(r-i)),e[14]=i*r*o):(e[10]=-1,e[14]=-r),e},sc.perspectiveFromFieldOfView=function(e,t,n,r){var i=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),a=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),l=2/(a+s),u=2/(i+o);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=u,e[6]=0,e[7]=0,e[8]=-(a-s)*l*.5,e[9]=(i-o)*u*.5,e[10]=r/(n-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*n/(n-r),e[15]=0,e},sc.orthoNO=mc,sc.orthoZO=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]=u,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=o*u,e[15]=1,e},sc.lookAt=function(e,t,n,r){var i,o,a,s,l,u,c,h,d,f,p=t[0],m=t[1],_=t[2],g=r[0],y=r[1],v=r[2],x=n[0],b=n[1],w=n[2];return Math.abs(p-x)0&&(c*=f=1/Math.sqrt(f),h*=f,d*=f);var p=l*d-u*h,m=u*c-s*d,_=s*h-l*c;return(f=p*p+m*m+_*_)>0&&(p*=f=1/Math.sqrt(f),m*=f,_*=f),e[0]=p,e[1]=m,e[2]=_,e[3]=0,e[4]=h*_-d*m,e[5]=d*p-c*_,e[6]=c*m-h*p,e[7]=0,e[8]=c,e[9]=h,e[10]=d,e[11]=0,e[12]=i,e[13]=o,e[14]=a,e[15]=1,e},sc.str=function(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},sc.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},sc.add=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[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e[9]=t[9]+n[9],e[10]=t[10]+n[10],e[11]=t[11]+n[11],e[12]=t[12]+n[12],e[13]=t[13]+n[13],e[14]=t[14]+n[14],e[15]=t[15]+n[15],e},sc.subtract=_c,sc.multiplyScalar=function(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[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12]*n,e[13]=t[13]*n,e[14]=t[14]*n,e[15]=t[15]*n,e},sc.multiplyScalarAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e[6]=t[6]+n[6]*r,e[7]=t[7]+n[7]*r,e[8]=t[8]+n[8]*r,e[9]=t[9]+n[9]*r,e[10]=t[10]+n[10]*r,e[11]=t[11]+n[11]*r,e[12]=t[12]+n[12]*r,e[13]=t[13]+n[13]*r,e[14]=t[14]+n[14]*r,e[15]=t[15]+n[15]*r,e},sc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},sc.equals=function(e,t){var n=e[0],r=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],m=e[13],_=e[14],g=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],T=t[5],S=t[6],E=t[7],M=t[8],A=t[9],I=t[10],C=t[11],k=t[12],O=t[13],P=t[14],R=t[15];return Math.abs(n-y)<=uc.EPSILON*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(r-v)<=uc.EPSILON*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(i-x)<=uc.EPSILON*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(o-b)<=uc.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(a-w)<=uc.EPSILON*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(s-T)<=uc.EPSILON*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(l-S)<=uc.EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(u-E)<=uc.EPSILON*Math.max(1,Math.abs(u),Math.abs(E))&&Math.abs(c-M)<=uc.EPSILON*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(h-A)<=uc.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(d-I)<=uc.EPSILON*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(f-C)<=uc.EPSILON*Math.max(1,Math.abs(f),Math.abs(C))&&Math.abs(p-k)<=uc.EPSILON*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(m-O)<=uc.EPSILON*Math.max(1,Math.abs(m),Math.abs(O))&&Math.abs(_-P)<=uc.EPSILON*Math.max(1,Math.abs(_),Math.abs(P))&&Math.abs(g-R)<=uc.EPSILON*Math.max(1,Math.abs(g),Math.abs(R))},sc.sub=sc.mul=sc.ortho=sc.perspective=void 0;var uc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==lc(e)&&"function"!=typeof e)return{default:e};var n=function(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return function(e){return e?n:t}(e)}(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(Uu);function cc(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 hc(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 dc(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=r+r,l=i+i,u=o+o,c=r*s,h=r*l,d=r*u,f=i*l,p=i*u,m=o*u,_=a*s,g=a*l,y=a*u;return e[0]=1-(f+m),e[1]=h+y,e[2]=d-g,e[3]=0,e[4]=h-y,e[5]=1-(c+m),e[6]=p+_,e[7]=0,e[8]=d+g,e[9]=p-_,e[10]=1-(c+f),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function fc(e,t){var n=t[4],r=t[5],i=t[6],o=t[8],a=t[9],s=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(n,r,i),e[2]=Math.hypot(o,a,s),e}function pc(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}function mc(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}function _c(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[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e[9]=t[9]-n[9],e[10]=t[10]-n[10],e[11]=t[11]-n[11],e[12]=t[12]-n[12],e[13]=t[13]-n[13],e[14]=t[14]-n[14],e[15]=t[15]-n[15],e}sc.perspective=pc,sc.ortho=mc,sc.mul=hc,sc.sub=_c;var gc={},yc={};function vc(e){return(vc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(yc,"__esModule",{value:!0}),yc.create=bc,yc.clone=function(e){var t=new xc.ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},yc.length=wc,yc.fromValues=function(e,t,n){var r=new xc.ARRAY_TYPE(3);return r[0]=e,r[1]=t,r[2]=n,r},yc.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},yc.set=function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},yc.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e},yc.subtract=Tc,yc.multiply=Sc,yc.divide=Ec,yc.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},yc.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},yc.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e},yc.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e},yc.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},yc.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e},yc.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e},yc.distance=Mc,yc.squaredDistance=Ac,yc.squaredLength=Ic,yc.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},yc.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},yc.normalize=function(e,t){var n=t[0],r=t[1],i=t[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},yc.dot=Cc,yc.cross=function(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},yc.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e},yc.hermite=function(e,t,n,r,i,o){var a=o*o,s=a*(2*o-3)+1,l=a*(o-2)+o,u=a*(o-1),c=a*(3-2*o);return e[0]=t[0]*s+n[0]*l+r[0]*u+i[0]*c,e[1]=t[1]*s+n[1]*l+r[1]*u+i[1]*c,e[2]=t[2]*s+n[2]*l+r[2]*u+i[2]*c,e},yc.bezier=function(e,t,n,r,i,o){var a=1-o,s=a*a,l=o*o,u=s*a,c=3*o*s,h=3*l*a,d=l*o;return e[0]=t[0]*u+n[0]*c+r[0]*h+i[0]*d,e[1]=t[1]*u+n[1]*c+r[1]*h+i[1]*d,e[2]=t[2]*u+n[2]*c+r[2]*h+i[2]*d,e},yc.random=function(e,t){t=t||1;var n=2*xc.RANDOM()*Math.PI,r=2*xc.RANDOM()-1,i=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(n)*i,e[1]=Math.sin(n)*i,e[2]=r*t,e},yc.transformMat4=function(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},yc.transformMat3=function(e,t,n){var r=t[0],i=t[1],o=t[2];return e[0]=r*n[0]+i*n[3]+o*n[6],e[1]=r*n[1]+i*n[4]+o*n[7],e[2]=r*n[2]+i*n[5]+o*n[8],e},yc.transformQuat=function(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},yc.rotateX=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0],o[1]=i[1]*Math.cos(r)-i[2]*Math.sin(r),o[2]=i[1]*Math.sin(r)+i[2]*Math.cos(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},yc.rotateY=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[2]*Math.sin(r)+i[0]*Math.cos(r),o[1]=i[1],o[2]=i[2]*Math.cos(r)-i[0]*Math.sin(r),e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},yc.rotateZ=function(e,t,n,r){var i=[],o=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],o[0]=i[0]*Math.cos(r)-i[1]*Math.sin(r),o[1]=i[0]*Math.sin(r)+i[1]*Math.cos(r),o[2]=i[2],e[0]=o[0]+n[0],e[1]=o[1]+n[1],e[2]=o[2]+n[2],e},yc.angle=function(e,t){var n=e[0],r=e[1],i=e[2],o=t[0],a=t[1],s=t[2],l=Math.sqrt(n*n+r*r+i*i)*Math.sqrt(o*o+a*a+s*s),u=l&&Cc(e,t)/l;return Math.acos(Math.min(Math.max(u,-1),1))},yc.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e},yc.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},yc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},yc.equals=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)<=xc.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=xc.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=xc.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))},yc.forEach=yc.sqrLen=yc.len=yc.sqrDist=yc.dist=yc.div=yc.mul=yc.sub=void 0;var xc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==vc(e)&&"function"!=typeof e)return{default:e};var n=function(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return function(e){return e?n:t}(e)}(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(Uu);function bc(){var e=new xc.ARRAY_TYPE(3);return xc.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function wc(e){return Math.hypot(e[0],e[1],e[2])}function Tc(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Sc(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function Ec(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e}function Mc(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function Ac(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2];return n*n+r*r+i*i}function Ic(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r}function Cc(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}yc.sub=Tc,yc.mul=Sc,yc.div=Ec,yc.dist=Mc,yc.sqrDist=Ac,yc.len=wc,yc.sqrLen=Ic;var kc,Oc=(kc=bc(),function(e,t,n,r,i,o){var a,s;for(t||(t=3),n||(n=0),s=r?Math.min(r*t+n,e.length):e.length,a=n;a0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=r*a,e[2]=i*a,e[3]=o*a,e},Pc.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},Pc.cross=function(e,t,n,r){var i=n[0]*r[1]-n[1]*r[0],o=n[0]*r[2]-n[2]*r[0],a=n[0]*r[3]-n[3]*r[0],s=n[1]*r[2]-n[2]*r[1],l=n[1]*r[3]-n[3]*r[1],u=n[2]*r[3]-n[3]*r[2],c=t[0],h=t[1],d=t[2],f=t[3];return e[0]=h*u-d*l+f*s,e[1]=-c*u+d*a-f*o,e[2]=c*l-h*a+f*i,e[3]=-c*s+h*o-d*i,e},Pc.lerp=function(e,t,n,r){var i=t[0],o=t[1],a=t[2],s=t[3];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e[2]=a+r*(n[2]-a),e[3]=s+r*(n[3]-s),e},Pc.random=function(e,t){var n,r,i,o,a,s;t=t||1;do{a=(n=2*Dc.RANDOM()-1)*n+(r=2*Dc.RANDOM()-1)*r}while(a>=1);do{s=(i=2*Dc.RANDOM()-1)*i+(o=2*Dc.RANDOM()-1)*o}while(s>=1);var l=Math.sqrt((1-a)/s);return e[0]=t*n,e[1]=t*r,e[2]=t*i*l,e[3]=t*o*l,e},Pc.transformMat4=function(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},Pc.transformQuat=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2],u=n[3],c=u*r+s*o-l*i,h=u*i+l*r-a*o,d=u*o+a*i-s*r,f=-a*r-s*i-l*o;return e[0]=c*u+f*-a+h*-l-d*-s,e[1]=h*u+f*-s+d*-a-c*-l,e[2]=d*u+f*-l+c*-s-h*-a,e[3]=t[3],e},Pc.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},Pc.str=function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},Pc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},Pc.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=t[0],s=t[1],l=t[2],u=t[3];return Math.abs(n-a)<=Dc.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-s)<=Dc.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-l)<=Dc.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(o-u)<=Dc.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))},Pc.forEach=Pc.sqrLen=Pc.len=Pc.sqrDist=Pc.dist=Pc.div=Pc.mul=Pc.sub=void 0;var Dc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Rc(e)&&"function"!=typeof e)return{default:e};var n=function(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return function(e){return e?n:t}(e)}(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(Uu);function Lc(){var e=new Dc.ARRAY_TYPE(4);return Dc.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function zc(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}function Bc(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}function Fc(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}function jc(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3])}function Nc(e,t){var n=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],o=t[3]-e[3];return n*n+r*r+i*i+o*o}function Uc(e){return Math.hypot(e[0],e[1],e[2],e[3])}function Vc(e){var t=e[0],n=e[1],r=e[2],i=e[3];return t*t+n*n+r*r+i*i}Pc.sub=zc,Pc.mul=Bc,Pc.div=Fc,Pc.dist=jc,Pc.sqrDist=Nc,Pc.len=Uc,Pc.sqrLen=Vc;var Gc=function(){var e=Lc();return function(t,n,r,i,o,a){var s,l;for(n||(n=4),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;sWc.EPSILON?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),n},gc.getAngle=function(e,t){var n=oh(e,t);return Math.acos(2*n*n-1)},gc.multiply=Qc,gc.rotateX=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+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e},gc.rotateY=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-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e},gc.rotateZ=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},gc.calculateW=function(e,t){var n=t[0],r=t[1],i=t[2];return e[0]=n,e[1]=r,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-i*i)),e},gc.exp=eh,gc.ln=th,gc.pow=function(e,t,n){return th(e,t),ih(e,e,n),eh(e,e),e},gc.slerp=nh,gc.random=function(e){var t=Wc.RANDOM(),n=Wc.RANDOM(),r=Wc.RANDOM(),i=Math.sqrt(1-t),o=Math.sqrt(t);return e[0]=i*Math.sin(2*Math.PI*n),e[1]=i*Math.cos(2*Math.PI*n),e[2]=o*Math.sin(2*Math.PI*r),e[3]=o*Math.cos(2*Math.PI*r),e},gc.invert=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o,s=a?1/a:0;return e[0]=-n*s,e[1]=-r*s,e[2]=-i*s,e[3]=o*s,e},gc.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},gc.fromMat3=rh,gc.fromEuler=function(e,t,n,r){var i=.5*Math.PI/180;t*=i,n*=i,r*=i;var o=Math.sin(t),a=Math.cos(t),s=Math.sin(n),l=Math.cos(n),u=Math.sin(r),c=Math.cos(r);return e[0]=o*l*c-a*s*u,e[1]=a*s*c+o*l*u,e[2]=a*l*u-o*s*c,e[3]=a*l*c+o*s*u,e},gc.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},gc.setAxes=gc.sqlerp=gc.rotationTo=gc.equals=gc.exactEquals=gc.normalize=gc.sqrLen=gc.squaredLength=gc.len=gc.length=gc.lerp=gc.dot=gc.scale=gc.mul=gc.add=gc.set=gc.copy=gc.fromValues=gc.clone=void 0;var Wc=Yc(Uu),Zc=Yc(nc),Hc=Yc(yc),$c=Yc(Pc);function Xc(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(Xc=function(e){return e?n:t})(e)}function Yc(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==qc(e)&&"function"!=typeof e)return{default:e};var n=Xc(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}function Kc(){var e=new Wc.ARRAY_TYPE(4);return Wc.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Jc(e,t,n){n*=.5;var r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function Qc(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*c+a*s+i*u-o*l,e[1]=i*c+a*l+o*s-r*u,e[2]=o*c+a*u+r*l-i*s,e[3]=a*c-r*s-i*l-o*u,e}function eh(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=Math.sqrt(n*n+r*r+i*i),s=Math.exp(o),l=a>0?s*Math.sin(a)/a:0;return e[0]=n*l,e[1]=r*l,e[2]=i*l,e[3]=s*Math.cos(a),e}function th(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=Math.sqrt(n*n+r*r+i*i),s=a>0?Math.atan2(a,o)/a:0;return e[0]=n*s,e[1]=r*s,e[2]=i*s,e[3]=.5*Math.log(n*n+r*r+i*i+o*o),e}function nh(e,t,n,r){var i,o,a,s,l,u=t[0],c=t[1],h=t[2],d=t[3],f=n[0],p=n[1],m=n[2],_=n[3];return(o=u*f+c*p+h*m+d*_)<0&&(o=-o,f=-f,p=-p,m=-m,_=-_),1-o>Wc.EPSILON?(i=Math.acos(o),a=Math.sin(i),s=Math.sin((1-r)*i)/a,l=Math.sin(r*i)/a):(s=1-r,l=r),e[0]=s*u+l*f,e[1]=s*c+l*p,e[2]=s*h+l*m,e[3]=s*d+l*_,e}function rh(e,t){var n,r=t[0]+t[4]+t[8];if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,e[0]=(t[5]-t[7])*(n=.5/n),e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var o=(i+1)%3,a=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*o+o]-t[3*a+a]+1),e[i]=.5*n,e[3]=(t[3*o+a]-t[3*a+o])*(n=.5/n),e[o]=(t[3*o+i]+t[3*i+o])*n,e[a]=(t[3*a+i]+t[3*i+a])*n}return e}gc.clone=$c.clone,gc.fromValues=$c.fromValues,gc.copy=$c.copy,gc.set=$c.set,gc.add=$c.add,gc.mul=Qc;var ih=$c.scale;gc.scale=ih;var oh=$c.dot;gc.dot=oh,gc.lerp=$c.lerp;var ah=$c.length;gc.length=ah,gc.len=ah;var sh=$c.squaredLength;gc.squaredLength=sh,gc.sqrLen=sh;var lh=$c.normalize;gc.normalize=lh,gc.exactEquals=$c.exactEquals,gc.equals=$c.equals;var uh,ch,hh,dh=(uh=Hc.create(),ch=Hc.fromValues(1,0,0),hh=Hc.fromValues(0,1,0),function(e,t,n){var r=Hc.dot(t,n);return r<-.999999?(Hc.cross(uh,ch,t),Hc.len(uh)<1e-6&&Hc.cross(uh,hh,t),Hc.normalize(uh,uh),Jc(e,uh,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(Hc.cross(uh,t,n),e[0]=uh[0],e[1]=uh[1],e[2]=uh[2],e[3]=1+r,lh(e,e))});gc.rotationTo=dh;var fh,ph,mh=(fh=Kc(),ph=Kc(),function(e,t,n,r,i,o){return nh(fh,t,i,o),nh(ph,n,r,o),nh(e,fh,ph,2*o*(1-o)),e});gc.sqlerp=mh;var _h,gh=(_h=Zc.create(),function(e,t,n,r){return _h[0]=n[0],_h[3]=n[1],_h[6]=n[2],_h[1]=r[0],_h[4]=r[1],_h[7]=r[2],_h[2]=-t[0],_h[5]=-t[1],_h[8]=-t[2],lh(e,rh(e,_h))});gc.setAxes=gh;var yh={};function vh(e){return(vh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(yh,"__esModule",{value:!0}),yh.create=function(){var e=new xh.ARRAY_TYPE(8);return xh.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e},yh.clone=function(e){var t=new xh.ARRAY_TYPE(8);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},yh.fromValues=function(e,t,n,r,i,o,a,s){var l=new xh.ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=n,l[3]=r,l[4]=i,l[5]=o,l[6]=a,l[7]=s,l},yh.fromRotationTranslationValues=function(e,t,n,r,i,o,a){var s=new xh.ARRAY_TYPE(8);s[0]=e,s[1]=t,s[2]=n,s[3]=r;var l=.5*i,u=.5*o,c=.5*a;return s[4]=l*r+u*n-c*t,s[5]=u*r+c*e-l*n,s[6]=c*r+l*t-u*e,s[7]=-l*e-u*t-c*n,s},yh.fromRotationTranslation=Eh,yh.fromTranslation=function(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e},yh.fromRotation=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},yh.fromMat4=function(e,t){var n=bh.create();wh.getRotation(n,t);var r=new xh.ARRAY_TYPE(3);return wh.getTranslation(r,t),Eh(e,n,r),e},yh.copy=Mh,yh.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},yh.set=function(e,t,n,r,i,o,a,s,l){return e[0]=t,e[1]=n,e[2]=r,e[3]=i,e[4]=o,e[5]=a,e[6]=s,e[7]=l,e},yh.getDual=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},yh.setDual=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},yh.getTranslation=function(e,t){var n=t[4],r=t[5],i=t[6],o=t[7],a=-t[0],s=-t[1],l=-t[2],u=t[3];return e[0]=2*(n*u+o*a+r*l-i*s),e[1]=2*(r*u+o*s+i*a-n*l),e[2]=2*(i*u+o*l+n*s-r*a),e},yh.translate=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=.5*n[0],l=.5*n[1],u=.5*n[2],c=t[4],h=t[5],d=t[6],f=t[7];return e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=a*s+i*u-o*l+c,e[5]=a*l+o*s-r*u+h,e[6]=a*u+r*l-i*s+d,e[7]=-r*s-i*l-o*u+f,e},yh.rotateX=function(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=s*a+c*r+l*o-u*i,d=l*a+c*i+u*r-s*o,f=u*a+c*o+s*i-l*r,p=c*a-s*r-l*i-u*o;return bh.rotateX(e,t,n),e[4]=h*(a=e[3])+p*(r=e[0])+d*(o=e[2])-f*(i=e[1]),e[5]=d*a+p*i+f*r-h*o,e[6]=f*a+p*o+h*i-d*r,e[7]=p*a-h*r-d*i-f*o,e},yh.rotateY=function(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=s*a+c*r+l*o-u*i,d=l*a+c*i+u*r-s*o,f=u*a+c*o+s*i-l*r,p=c*a-s*r-l*i-u*o;return bh.rotateY(e,t,n),e[4]=h*(a=e[3])+p*(r=e[0])+d*(o=e[2])-f*(i=e[1]),e[5]=d*a+p*i+f*r-h*o,e[6]=f*a+p*o+h*i-d*r,e[7]=p*a-h*r-d*i-f*o,e},yh.rotateZ=function(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=s*a+c*r+l*o-u*i,d=l*a+c*i+u*r-s*o,f=u*a+c*o+s*i-l*r,p=c*a-s*r-l*i-u*o;return bh.rotateZ(e,t,n),e[4]=h*(a=e[3])+p*(r=e[0])+d*(o=e[2])-f*(i=e[1]),e[5]=d*a+p*i+f*r-h*o,e[6]=f*a+p*o+h*i-d*r,e[7]=p*a-h*r-d*i-f*o,e},yh.rotateByQuatAppend=function(e,t,n){var r=n[0],i=n[1],o=n[2],a=n[3],s=t[0],l=t[1],u=t[2],c=t[3];return e[0]=s*a+c*r+l*o-u*i,e[1]=l*a+c*i+u*r-s*o,e[2]=u*a+c*o+s*i-l*r,e[3]=c*a-s*r-l*i-u*o,e[4]=(s=t[4])*a+(c=t[7])*r+(l=t[5])*o-(u=t[6])*i,e[5]=l*a+c*i+u*r-s*o,e[6]=u*a+c*o+s*i-l*r,e[7]=c*a-s*r-l*i-u*o,e},yh.rotateByQuatPrepend=function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[0],l=n[1],u=n[2],c=n[3];return e[0]=r*c+a*s+i*u-o*l,e[1]=i*c+a*l+o*s-r*u,e[2]=o*c+a*u+r*l-i*s,e[3]=a*c-r*s-i*l-o*u,e[4]=r*(c=n[7])+a*(s=n[4])+i*(u=n[6])-o*(l=n[5]),e[5]=i*c+a*l+o*s-r*u,e[6]=o*c+a*u+r*l-i*s,e[7]=a*c-r*s-i*l-o*u,e},yh.rotateAroundAxis=function(e,t,n,r){if(Math.abs(r)0){n=Math.sqrt(n);var r=t[0]/n,i=t[1]/n,o=t[2]/n,a=t[3]/n,s=t[4],l=t[5],u=t[6],c=t[7],h=r*s+i*l+o*u+a*c;e[0]=r,e[1]=i,e[2]=o,e[3]=a,e[4]=(s-r*h)/n,e[5]=(l-i*h)/n,e[6]=(u-o*h)/n,e[7]=(c-a*h)/n}return e},yh.str=function(e){return"quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},yh.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]},yh.equals=function(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=t[0],h=t[1],d=t[2],f=t[3],p=t[4],m=t[5],_=t[6],g=t[7];return Math.abs(n-c)<=xh.EPSILON*Math.max(1,Math.abs(n),Math.abs(c))&&Math.abs(r-h)<=xh.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(i-d)<=xh.EPSILON*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(o-f)<=xh.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(a-p)<=xh.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(s-m)<=xh.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(l-_)<=xh.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(u-g)<=xh.EPSILON*Math.max(1,Math.abs(u),Math.abs(g))},yh.sqrLen=yh.squaredLength=yh.len=yh.length=yh.dot=yh.mul=yh.setReal=yh.getReal=void 0;var xh=Sh(Uu),bh=Sh(gc),wh=Sh(sc);function Th(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(Th=function(e){return e?n:t})(e)}function Sh(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==vh(e)&&"function"!=typeof e)return{default:e};var n=Th(t);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}function Eh(e,t,n){var r=.5*n[0],i=.5*n[1],o=.5*n[2],a=t[0],s=t[1],l=t[2],u=t[3];return e[0]=a,e[1]=s,e[2]=l,e[3]=u,e[4]=r*u+i*l-o*s,e[5]=i*u+o*a-r*l,e[6]=o*u+r*s-i*a,e[7]=-r*a-i*s-o*l,e}function Mh(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e}function Ah(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=n[4],l=n[5],u=n[6],c=n[7],h=t[4],d=t[5],f=t[6],p=t[7],m=n[0],_=n[1],g=n[2],y=n[3];return e[0]=r*y+a*m+i*g-o*_,e[1]=i*y+a*_+o*m-r*g,e[2]=o*y+a*g+r*_-i*m,e[3]=a*y-r*m-i*_-o*g,e[4]=r*c+a*s+i*u-o*l+h*y+p*m+d*g-f*_,e[5]=i*c+a*l+o*s-r*u+d*y+p*_+f*m-h*g,e[6]=o*c+a*u+r*l-i*s+f*y+p*g+h*_-d*m,e[7]=a*c-r*s-i*l-o*u+p*y-h*m-d*_-f*g,e}yh.getReal=bh.copy,yh.setReal=bh.copy,yh.mul=Ah;var Ih=bh.dot;yh.dot=Ih;var Ch=bh.length;yh.length=Ch,yh.len=Ch;var kh=bh.squaredLength;yh.squaredLength=kh,yh.sqrLen=kh;var Oh={};function Ph(e){return(Ph="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(Oh,"__esModule",{value:!0}),Oh.create=Dh,Oh.clone=function(e){var t=new Rh.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},Oh.fromValues=function(e,t){var n=new Rh.ARRAY_TYPE(2);return n[0]=e,n[1]=t,n},Oh.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},Oh.set=function(e,t,n){return e[0]=t,e[1]=n,e},Oh.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},Oh.subtract=Lh,Oh.multiply=zh,Oh.divide=Bh,Oh.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},Oh.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},Oh.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e},Oh.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e},Oh.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},Oh.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},Oh.scaleAndAdd=function(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e},Oh.distance=Fh,Oh.squaredDistance=jh,Oh.length=Nh,Oh.squaredLength=Uh,Oh.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},Oh.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},Oh.normalize=function(e,t){var n=t[0],r=t[1],i=n*n+r*r;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e},Oh.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},Oh.cross=function(e,t,n){var r=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=r,e},Oh.lerp=function(e,t,n,r){var i=t[0],o=t[1];return e[0]=i+r*(n[0]-i),e[1]=o+r*(n[1]-o),e},Oh.random=function(e,t){t=t||1;var n=2*Rh.RANDOM()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},Oh.transformMat2=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i,e[1]=n[1]*r+n[3]*i,e},Oh.transformMat2d=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[2]*i+n[4],e[1]=n[1]*r+n[3]*i+n[5],e},Oh.transformMat3=function(e,t,n){var r=t[0],i=t[1];return e[0]=n[0]*r+n[3]*i+n[6],e[1]=n[1]*r+n[4]*i+n[7],e},Oh.transformMat4=function(e,t,n){var 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},Oh.rotate=function(e,t,n,r){var i=t[0]-n[0],o=t[1]-n[1],a=Math.sin(r),s=Math.cos(r);return e[0]=i*s-o*a+n[0],e[1]=i*a+o*s+n[1],e},Oh.angle=function(e,t){var n=e[0],r=e[1],i=t[0],o=t[1],a=Math.sqrt(n*n+r*r)*Math.sqrt(i*i+o*o);return Math.acos(Math.min(Math.max(a&&(n*i+r*o)/a,-1),1))},Oh.zero=function(e){return e[0]=0,e[1]=0,e},Oh.str=function(e){return"vec2("+e[0]+", "+e[1]+")"},Oh.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Oh.equals=function(e,t){var n=e[0],r=e[1],i=t[0],o=t[1];return Math.abs(n-i)<=Rh.EPSILON*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=Rh.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))},Oh.forEach=Oh.sqrLen=Oh.sqrDist=Oh.dist=Oh.div=Oh.mul=Oh.sub=Oh.len=void 0;var Rh=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Ph(e)&&"function"!=typeof e)return{default:e};var n=function(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return function(e){return e?n:t}(e)}(void 0);if(n&&n.has(e))return n.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,n&&n.set(e,r),r}(Uu);function Dh(){var e=new Rh.ARRAY_TYPE(2);return Rh.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function Lh(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function zh(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e}function Bh(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e}function Fh(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function jh(e,t){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function Nh(e){return Math.hypot(e[0],e[1])}function Uh(e){var t=e[0],n=e[1];return t*t+n*n}Oh.len=Nh,Oh.sub=Lh,Oh.mul=zh,Oh.div=Bh,Oh.dist=Fh,Oh.sqrDist=jh,Oh.sqrLen=Uh;var Vh=function(){var e=Dh();return function(t,n,r,i,o,a){var s,l;for(n||(n=2),r||(r=0),l=i?Math.min(i*n+r,t.length):t.length,s=r;s0;o--)r=1<this.canonical.z?new _d(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new _d(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 gd(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return gd(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 _d(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 _d(t,this.wrap,t,n,r),new _d(t,this.wrap,t,n+1,r),new _d(t,this.wrap,t,n,r+1),new _d(t,this.wrap,t,n+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,n=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,n=e.wrap;return t===1<new _d(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new _d(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<=0;if(0===o)return 0;o!==t.length&&(n=!1)}return n?2:1}function Td(e,t){for(const n of e.projections){const r=bd(t,e.points[0],n.axis);if(n.projection[1]r[1])return 0}return 1}function Sd(e,t){let n=0;const r=[0,0,0,0];for(let i=0;i=0&&n++;return n}class Ed{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=Md.fromPoints(this.points),this.projections=[],this.frustumEdges=[id.sub([],this.points[2],this.points[3]),id.sub([],this.points[0],this.points[3]),id.sub([],this.points[4],this.points[0]),id.sub([],this.points[5],this.points[1]),id.sub([],this.points[6],this.points[2]),id.sub([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],n=[e[2],0,-e[0]];this.projections.push({axis:t,projection:bd(this.points,this.points[0],t)}),this.projections.push({axis:n,projection:bd(this.points,this.points[0],n)})}}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=qh.transformMat4([],n,e),a=1/o[3]/t*i;return qh.mul(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=id.sub([],o[e[0]],o[e[1]]),n=id.sub([],o[e[2]],o[e[1]]),r=id.normalize([],id.cross([],t,n)),i=-id.dot(r,o[e[1]]);return r.concat(i)}),s=[];for(let e=0;ea[1]||a[0]>o[1])return 0}return 1}}class Md{static fromPoints(e){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const r of e)id.min(t,t,r),id.max(n,n,r);return new Md(t,n)}static fromTileIdAndHeight(e,t,n){const r=1<e.max[t]||e.min[t]>this.max[t])return!1;return!0}intersectsAabbXY(e){return!(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t])}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t])}closestPoint(e){return[Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}xa(Md,"Aabb");const Ad=hr/Math.PI/2,Id=[64,32,16],Cd=-Ad,kd=Ad,Od=[new Md([Cd,Cd,Cd],[kd,kd,kd]),new Md([Cd,Cd,Cd],[0,0,kd]),new Md([0,Cd,Cd],[kd,0,kd]),new Md([Cd,0,Cd],[0,kd,kd]),new Md([0,0,Cd],[kd,kd,kd])];function Pd(e){return e*Ad/ff}function Rd(e,t,n,r=!0){const i=id.scale([],e._camera.position,e.worldSize),o=[t,n,1,1];qh.transformMat4(o,o,e.pixelMatrixInverse),qh.scale(o,o,1/o[3]);const a=id.sub([],o,i),s=id.normalize([],a),l=e.globeMatrix,u=[l[12],l[13],l[14]],c=id.sub([],u,i),h=id.length(c),d=id.normalize([],c),f=e.worldSize/(2*Math.PI),p=id.dot(d,s),m=Math.asin(f/h);if(m1?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,O(n,0,1))+e.center[t]}function zd(e){if(e.z<=1)return Od[e.z+2*e.y+e.x];const t=Vd(Ud(e));return Md.fromPoints(t)}function Bd(e,t,n){return id.scale(e,e,1-n),id.scaleAndAdd(e,e,t,n)}function Fd(e,t){const n=ef(t.zoom);if(0===n)return zd(e);const r=Ud(e),i=Vd(r),o=yf(r.getWest())*t.worldSize,a=yf(r.getEast())*t.worldSize,s=vf(r.getNorth())*t.worldSize,l=vf(r.getSouth())*t.worldSize,u=[o,s,0],c=[a,s,0],h=[o,l,0],d=[a,l,0],f=Jh.invert([],t.globeMatrix);return id.transformMat4(u,u,f),id.transformMat4(c,c,f),id.transformMat4(h,h,f),id.transformMat4(d,d,f),i[0]=Bd(i[0],h,n),i[1]=Bd(i[1],d,n),i[2]=Bd(i[2],c,n),i[3]=Bd(i[3],u,n),Md.fromPoints(i)}function jd(e,t,n){for(const r of e)id.transformMat4(r,r,t),id.scale(r,r,n)}function Nd(e,t,n,r){const i=t/e.worldSize,o=e.globeMatrix;if(n.z<=1){const e=zd(n).getCorners();return jd(e,o,i),Md.fromPoints(e)}const a=Ud(n,r),s=Vd(a);jd(s,o,i);const l=Number.MAX_VALUE,u=[-l,-l,-l],c=[l,l,l];if(a.contains(e.center)){for(const e of s)id.min(c,c,e),id.max(u,u,e);u[2]=0;const t=e.point,n=[t.x*i,t.y*i,0];return id.min(c,c,n),id.max(u,u,n),new Md(c,u)}const h=[o[12]*i,o[13]*i,o[14]*i],d=a.getCenter(),f=O(e.center.lat,-Sf,Sf),p=O(d.lat,-Sf,Sf),m=yf(e.center.lng),_=vf(f);let g=m-yf(d.lng);const y=_-vf(p);g>.5?g-=1:g<-.5&&(g+=1);let v=0;if(Math.abs(g)>Math.abs(y))v=g>=0?1:3;else{v=y>=0?0:2;const e=[o[4]*i,o[5]*i,o[6]*i],t=-Math.sin(T(y>=0?a.getSouth():a.getNorth()))*Ad;id.scaleAndAdd(h,h,e,t)}const x=s[v],b=s[(v+1)%4],w=new Dd(x,b,h),S=[Ld(w,0)||x[0],Ld(w,1)||x[1],Ld(w,2)||x[2]],E=ef(e.zoom);if(E>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,m,_);for(let e=0;e0;return 0===r&&!i&&!o}function rf(e,t,n,r){const i=t.getNorth(),o=t.getSouth(),a=t.getWest(),s=t.getEast(),l=1<0){const e=180/r;Yh.multiply(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}function of(e){const t=Sf-5;e=O(e,-t,t)/t*90;const n=Math.pow(Math.abs(Math.sin(T(e))),3);return Math.round(n*(Id.length-1))}function af(e){const t=[0,0,0],n=Jh.identity(new Float64Array(16));return Jh.multiply(n,e.pixelMatrix,e.globeMatrix),id.transformMat4(t,t,n),new v(t[0],t[1])}function sf(e,t){const n=qd(t.lat,t.lng),r=function(e){const t=qd(e._center.lat,e._center.lng),n=id.fromValues(0,1,0);let r=id.cross([],n,t);const i=Jh.fromRotation([],-e.angle,t);r=id.transformMat4(r,r,i),Jh.fromRotation(i,-e._pitch,r);const o=id.normalize([],t);return id.scale(o,o,Pd(e.cameraToCenterDistance/e.pixelsPerMeter)),id.transformMat4(o,o,i),id.add([],t,o)}(e),i=id.subtract([],r,n);return id.angle(i,n)}function lf(e,t){return sf(e,t)>Math.PI/2*1.01}const uf=T(85),cf=Math.cos(uf),hf=Math.sin(uf);class df{constructor(e){this._createGrid(e),this._createPoles(e)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy()}_fillGridMeshWithLods(e,t){const n=new cl,r=new Al,i=[],o=e+1+2,a=t[0]+1,s=t[0]+1+(1+t.length),l=(e,t,n)=>{let r=e===o-1?e-2:0===e?e:e-1;return r+=n?24575:0,[r,t]};for(let e=0;e90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new mf(R(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 ff*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 ju(new mf(this.lng-n,this.lat-t),new mf(this.lng+n,this.lat+t))}toEcef(e){const t=Pd(e);return qd(this.lat,this.lng,Ad+t)}static convert(e){if(e instanceof mf)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new mf(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new mf(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 _f=mf;function gf(e){return pf*Math.cos(e*Math.PI/180)}function yf(e){return(180+e)/360}function vf(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function xf(e,t){return e/gf(t)}function bf(e){return 360*e-180}function wf(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Tf(e,t){return e*gf(wf(t))}const Sf=85.051129;function Ef(e){return Math.cos(T(O(e,-Sf,Sf)))}function Mf(e,t){const n=O(t,0,25.5),r=Math.pow(2,n);return Ef(e)*pf/(512*r)}function Af(e){return 1/Math.cos(e*Math.PI/180)}function If(e,t=0){const n=Math.exp(Math.PI*(1-(e.y+t/hr)/(1<=l?(kf(e,t,n,u,c,o,h,s,l),kf(e,u,c,r,i,h,a,s,l)):e.push(a)}function Of(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)&&X("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Bf(e,t,n){const r=e.loadGeometry(),i=e.extent,o=hr/i;if(t&&n&&n.projection.isReprojectedInTileSpace){const o=1<{const n=bf((t.x+e.x/i)/o),r=wf((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)zf(t,o);return r}function Ff(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Bf(e):[]}}function jf(e,t,n,r,i){e.emplaceBack(2*t+(r+1)/2,2*n+(i+1)/2)}function Nf(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class Uf{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new cl,this.indexArray=new Al,this.segments=new Ql,this.programConfigurations=new Ru(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=Ff(t,e);if(!this.layers[0]._featureFilter.filter(new Ns(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:Bf(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 yl,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.brightness),t.featureIndex.insert(l,i,o,a,this.index)}}update(e,t,n,r,i){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,n,r,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Kl.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Jl.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,a){for(const n of t)for(const t of n){const n=t.x,r=t.y;if(n<0||n>=hr||r<0||r>=hr)continue;if(o){const e=o.projectTilePoint(n,r,i),t=o.upVector(i,n,r),a=this.globeExtVertexArray;Nf(a,e,t),Nf(a,e,t),Nf(a,e,t),Nf(a,e,t)}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;jf(this.layoutVertexArray,n,r,-1,-1),jf(this.layoutVertexArray,n,r,1,-1),jf(this.layoutVertexArray,n,r,1,1),jf(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,a)}}function Vf(e,t){for(let n=0;n1){if(Zf(e,t))return!0;for(let r=0;r1?n:n.sub(t)._mult(i)._add(t))}function Yf(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 Kf(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 Jf(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(Kf(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=Y(e,t,n[0]);return o!==Y(e,t,n[1])||o!==Y(e,t,n[2])||o!==Y(e,t,n[3])}function ep(e,t,n,r,i,o){let a=t.y-e.y,s=e.x-t.x;if(o=o||0){const e=a*a+s*s;if(0===e)return!0;const t=Math.sqrt(e);a/=t,s/=t}return!((n.x-e.x)*a+(n.y-e.y)*s-o<0||(r.x-e.x)*a+(r.y-e.y)*s-o<0||(i.x-e.x)*a+(i.y-e.y)*s-o<0)}function tp(e,t,n,r,i,o,a){return!(ep(e,t,r,i,o,a)||ep(t,n,r,i,o,a)||ep(n,e,r,i,o,a)||ep(r,i,e,t,n,a)||ep(i,o,e,t,n,a)||ep(o,r,e,t,n,a))}function np(e,t,n){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function rp(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ip(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;t{const a=e.transform,s="globe"===a.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(s){const e=Kd(a.zoom,t.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=a.calculatePixelsToTileUnitsMatrix(n);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(a.projection),u_matrix:e.translatePosMatrix(t.projMatrix,n,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:ft.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:lp,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(s){u.u_inv_rot_matrix=r,u.u_merc_center=i,u.u_tile_id=[t.canonical.x,t.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};function hp(e,t,n,r,i,o,a,s,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const u=e.tileID.canonical,c=n.projection.upVectorScale(u,n.center.lat,n.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(s),d=i&&n.elevation?n.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,f=n.projection.projectTilePoint(h.x,h.y,u);if(d>0){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:dp(f.x,f.y,f.z,r),m=o?e.tilespaceRays.map(e=>mp(e,d)):e.queryGeometry.screenGeometry,_=qh.transformMat4([],[f.x,f.y,f.z,1],r);if(!a&&o?l*=_[3]/n.cameraToCenterDistance:a&&!o&&(l*=n.cameraToCenterDistance/_[3]),o){const e=wf((t.y/hr+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);a&&(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 Dp(d,f,n,r,i,u,0),f}function Pp(e,t,n,r,i){var o,a;if(i===nm(e,t,n,r)>0)for(o=t;o=t;o-=r)a=Qp(o,e[o],e[o+1],a);return a&&Hp(a,a.next)&&(em(a),a=a.next),a}function Rp(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!Hp(r,r.next)&&0!==Zp(r.prev,r,r.next))r=r.next;else{if(em(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function Dp(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=Vp(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?zp(e,r,i,o):Lp(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),em(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?Dp(e=Bp(Rp(e),t,n),t,n,r,i,o,2):2===a&&Fp(e,t,n,r,i,o):Dp(Rp(e),t,n,r,i,o,1);break}}}function Lp(e){var t=e.prev,n=e,r=e.next;if(Zp(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&&qp(i,s,o,l,a,u,p.x,p.y)&&Zp(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function zp(e,t,n,r){var i=e.prev,o=e,a=e.next;if(Zp(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=Vp(f,p,t,n,r),y=Vp(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&&qp(s,c,l,h,u,d,v.x,v.y)&&Zp(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&&qp(s,c,l,h,u,d,x.x,x.y)&&Zp(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&&qp(s,c,l,h,u,d,v.x,v.y)&&Zp(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&&qp(s,c,l,h,u,d,x.x,x.y)&&Zp(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Bp(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!Hp(i,o)&&$p(i,r,r.next,o)&&Kp(i,o)&&Kp(o,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),em(r),em(r.next),r=e=o),r=r.next}while(r!==e);return Rp(r)}function Fp(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Wp(a,s)){var l=Jp(a,s);return a=Rp(a,a.next),l=Rp(l,l.next),Dp(a,t,n,r,i,o,0),void Dp(l,t,n,r,i,o,0)}s=s.next}a=a.next}while(a!==e)}function jp(e,t){return e.x-t.x}function Np(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&&qp(on.x||r.x===n.x&&Up(n,r)))&&(n=r,d=l)),r=r.next}while(r!==u);return n}(e,t);if(!n)return t;var r=Jp(n,e);return Rp(r,r.next),Rp(n,n.next)}function Up(e,t){return Zp(e.prev,e,t.prev)<0&&Zp(t.next,e,e.next)<0}function Vp(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 Gp(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 Wp(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&&$p(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Kp(e,t)&&Kp(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)&&(Zp(e.prev,e,t.prev)||Zp(e,t.prev,t))||Hp(e,t)&&Zp(e.prev,e,e.next)>0&&Zp(t.prev,t,t.next)>0)}function Zp(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Hp(e,t){return e.x===t.x&&e.y===t.y}function $p(e,t,n,r){var i=Yp(Zp(e,t,n)),o=Yp(Zp(e,t,r)),a=Yp(Zp(n,r,e)),s=Yp(Zp(n,r,t));return i!==o&&a!==s||!(0!==i||!Xp(e,n,t))||!(0!==o||!Xp(e,r,t))||!(0!==a||!Xp(n,e,r))||!(0!==s||!Xp(n,t,r))}function Xp(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 Yp(e){return e>0?1:e<0?-1:0}function Kp(e,t){return Zp(e.prev,e,e.next)<0?Zp(e,t,e.next)>=0&&Zp(e,e.prev,t)>=0:Zp(e,t,e.prev)<0||Zp(e,e.next,t)<0}function Jp(e,t){var n=new tm(e.i,e.x,e.y),r=new tm(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 Qp(e,t,n,r){var i=new tm(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 em(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 tm(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 nm(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 rm=f(kp.exports);function im(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.fqid),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new cl,this.indexArray=new Al,this.indexArray2=new wl,this.programConfigurations=new Ru(e.layers,e.zoom),this.segments=new Ql,this.segments2=new Ql,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection}populate(e,t,n,r){this.hasPattern=am("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=Ff(a,e);if(!this.layers[0]._featureFilter.filter(new Ns(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:Bf(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=sm("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,{},t.availableImages,t.brightness);t.featureIndex.insert(e[o].feature,i,o,a,this.index)}}update(e,t,n,r,i){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,n,r,i)}addFeatures(e,t,n,r,i,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r,o)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Cp),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=[],a){for(const e of im(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 ym(o,a));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&s.push(t),s},xm.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]},xm.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=xm.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))}Em.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 Tm(this._pbf,t,this.extent,this._keys,this._values)};var Am=Sm;function Im(e,t,n){if(3===e){var r=new Am(n,n.readVarint()+n.pos);r.length&&(t[r.name]=r)}}var Cm=gm.VectorTile=function(e,t){this.layers=e.readFields(Im,{},t)},km=gm.VectorTileFeature=vm;function Om(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}gm.VectorTileLayer=Sm;class Pm{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t */ -read: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)},write: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}};function Lm(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}Lm.Varint=0,Lm.Fixed64=1,Lm.Bytes=2,Lm.Fixed32=5;var zm=4294967296,Bm=1/zm,Fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function jm(e){return e.type===Lm.Bytes?e.readVarint()+e.pos:e.pos+1}function Nm(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Um(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 Vm(e,t){for(var n=0;n>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Qm(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}Lm.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=Km(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Qm(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Km(this.buf,this.pos)+Km(this.buf,this.pos+4)*zm;return this.pos+=8,e},readSFixed64:function(){var e=Km(this.buf,this.pos)+Qm(this.buf,this.pos+4)*zm;return this.pos+=8,e},readFloat:function(){var e=Dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Dm.read(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 Nm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return Nm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return Nm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return Nm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return Nm(e,r,t);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return Nm(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&&Fm?function(e,t,n){return Fm.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!==Lm.Bytes)return e.push(this.readVarint(t));var n=jm(this);for(e=e||[];this.pos127;);else if(t===Lm.Bytes)this.pos=this.readVarint()+this.pos;else if(t===Lm.Fixed32)this.pos+=4;else{if(t!==Lm.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&&Um(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),Dm.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Dm.write(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&&Um(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,Lm.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,Vm,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Gm,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Zm,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,qm,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Wm,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Hm,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,$m,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Xm,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Ym,t)},writeBytesField:function(e,t){this.writeTag(e,Lm.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,Lm.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,Lm.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,Lm.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,Lm.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,Lm.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,Lm.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,Lm.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,Lm.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,Lm.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var e_=f(Rm);const t_=["tile","layer","source","sourceLayer","state"];class n_{constructor(e,t,n,r,i){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=n,this._y=r,this.properties=e.properties,this.id=i}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};void 0!==this.id&&(e.id=this.id);for(const t of t_)void 0!==this[t]&&(e[t]=this[t]);return e}}class r_{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,n){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},z(this.stateChanges[e][r],n),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])n[t]||(this.deletedStates[e][r][t]=null)}else for(const t in n)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,n){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},n&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][n]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(n in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][n]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){const n=String(t),r=z({},(this.state[e]||{})[n],(this.stateChanges[e]||{})[n]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const n=this.deletedStates[e][t];if(null===n)return{};for(const e in n)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,t){const n={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const n in this.stateChanges[e])this.state[e][n]||(this.state[e][n]={}),z(this.state[e][n],this.stateChanges[e][n]),t[n]=this.state[e][n];n[e]=t}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const n in this.state[e])t[n]={},this.state[e][n]={};else for(const n in this.deletedStates[e]){if(null===this.deletedStates[e][n])this.state[e][n]={};else if(this.state[e][n])for(const t of Object.keys(this.deletedStates[e][n]))delete this.state[e][n][t];t[n]=this.state[e][n]}n[e]=n[e]||{},z(n[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(const r in e)e[r].setFeatureState(n,t)}}class i_{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const n=this.toIdx(e,t);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function o_(e,t,n,r){let i=0,o=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(r[a])<1e-15){if(n[a]t[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 a_(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,T=u[1]-t,S=u[2]-n,E=(w*g+T*y+S*v)*b;if(E<0||E>1)return null;const M=T*f-S*d,A=S*h-w*f,I=w*d-T*h,C=(c[0]*M+c[1]*A+c[2]*I)*b;return C<0||E+C>1?null:(p*M+m*A+_*I)*b}function s_(e,t,n){return(e-t)/(n-t)}function l_(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 i_(r);const s=[];for(let t=0;t=1;r/=2){const e=n[n.length-1];a=new i_(r);for(let t=0;t0;){const{idx:s,t:f,nodex:p,nodey:m,depth:_}=d.pop();if(this.leaves[s]){l_(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=h_(l,d,this.dem)*a,v=h_(u,d,this.dem)*a,x=h_(u,g,this.dem)*a,b=h_(l,g,this.dem)*a,w=a_(c[0],c[1],y,h[0],c[1],v,h[0],h[1],x,i,o),T=a_(h[0],h[1],x,c[0],h[1],b,c[0],c[1],y,i,o),S=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(S!==Number.MAX_VALUE)return S;{const e=id.scaleAndAdd([],i,o,f);if(c_(y,v,b,x,s_(e[0],c[0],h[0]),s_(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=m_.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 wp({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=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Cm(new e_(this.rawTileData)).layers,this.sourceLayerCoder=new Pm(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=Co(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)=>Jf(a.bufferedTilespaceGeometry,e,t,n,r));u.sort(v_);let c=null;s.elevation&&u.length>0&&(c=__.create(s.elevation,this.tileID));const h={};let d;for(let s=0;s(p||(p=Bf(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=Ff(m,!0);if(!n.filter(new Ns(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new Ns(this.tileID.overscaledZ),m))return;const _=this.getId(m,p);for(let t=0;t{const a=t instanceof $s?t.get(o):null;return a&&a.evaluate?a.evaluate(n,r,i):a})}function v_(e,t){return t-e}xa(g_,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const x_=ll([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),b_=ll([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),w_=ll([{name:"a_projected_pos",components:4,type:"Float32"}],4);ll([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const T_=ll([{name:"a_z_offset",components:1,type:"Float32"}],4),S_=ll([{name:"a_texb",components:2,type:"Uint16"}]),E_=ll([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),M_=ll([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_z_offset",components:1,type:"Float32"}]);ll([{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 A_=ll([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),I_=ll([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ll([{name:"triangle",components:3,type:"Uint16"}]),ll([{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"}]),ll([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),ll([{type:"Float32",name:"offsetX"}]),ll([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const C_=128;function k_(e,t){const{expression:n}=t;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new Ns(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()),js.applyArabicShaping&&(e=js.applyArabicShaping(e)),e}(e.text,t,n)}),e}const L_={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function z_(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function B_(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}function F_(e,t,n){t.glyphs=[],1===e&&n.readMessage(j_,t)}function j_(e,t,n){if(3===e){const{id:e,bitmap:r,width:i,height:o,left:a,top:s,advance:l}=n.readMessage(N_,{});t.glyphs.push({id:e,bitmap:new xp({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 N_(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())}const U_={horizontal:1,vertical:2,horizontalOnly:3};class V_{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const n=new V_;return n.scale=e||1,n.fontStack=t,n}static forImage(e){const t=new V_;return t.imageName=e,t}}class G_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const n=new G_;for(let r=0;r=0&&n>=e&&W_[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 G_;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(V_.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 q_(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=G_.fromFeature(e,i);h===U_.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]&&(S=e[m]);const r=t[s.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(v=o.metrics,M=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 rg(e){let t=0;for(let n=0;nu){const c=(u-l)/o,h=Yr(r.x,i.x,c),d=Yr(r.y,i.y,c),f=new tg(h,d,0,i.angleTo(r),n);return!a||ng(e,f,s,a,t)?f:void 0}l+=o}}function sg(e,t,n,r,i,o,a,s,l){const u=ig(r,o,a),c=og(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 tg(g,y,0,m,e);i&&!ng(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 lg(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}function ug(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,n)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,n);for(const r in e.getUpdatedImages(n))this.patchUpdatedImage(this.iconPositions[r],e.getImage(r,n),t),this.patchUpdatedImage(this.patternPositions[r],e.getImage(r,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})}}xa(cg,"ImagePosition"),xa(hg,"ImageAtlas");const dg=1e20;function fg(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]=dg}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 o=r.glyphs[t];if(void 0!==o)return void n(null,{stack:e,id:t,glyph:o});if(o=this._tinySDF(r,e,t),o)return r.glyphs[t]=o,void n(null,{stack:e,id:t,glyph:o});const a=Math.floor(t/256);if(256*a>65535)return void n(new Error("glyphs > 65535 not supported"));if(r.ranges[a])return void n(null,{stack:e,id:t,glyph:o});let s=r.requests[a];s||(s=r.requests[a]=[],mg.loadGlyphRange(e,a,i,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[a]=!0}for(const n of s)n(e,t);delete r.requests[a]})),s.push((r,i)=>{r?n(r):i&&n(null,{stack:e,id:t,glyph:i.glyphs[t]||null})})},(e,t)=>{if(e)n(e);else if(t){const e={};for(const{stack:n,id:r,glyph:i}of t)void 0===e[n]&&(e[n]={}),void 0===e[n].glyphs&&(e[n].glyphs={}),e[n].glyphs[r]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[n].ascender=this.entries[n].ascender,e[n].descender=this.entries[n].descender;n(null,e)}})}_doesCharSupportLocalGlyph(e){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&(os(e)||us(e)||Ha(e)||$a(e)||Za(e)||rs(e)||vs(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 mg.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.fromCodePoint(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 xp({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 _g(e,t,n,r){const i=[],o=e.imagePrimary,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,T=0,S=_,E=0,M=g;if(o.content&&r){const e=o.content;y=gg(h,0,e[0]),b=gg(d,0,e[1]),x=gg(h,e[0],e[2]),w=gg(d,e[1],e[3]),T=e[0]-y,E=e[1]-b,S=e[2]-e[0]-x,M=e[3]-e[1]-w}const A=(r,i,s,l)=>{const h=vg(r.stretch-y,x,u,e.left),d=xg(r.fixed-T,S,r.stretch,p),f=vg(i.stretch-b,w,c,e.top),_=xg(i.fixed-E,M,i.stretch,m),g=vg(s.stretch-y,x,u,e.left),A=xg(s.fixed-T,S,s.stretch,p),I=vg(l.stretch-b,w,c,e.top),C=xg(l.fixed-E,M,l.stretch,m),k=new v(h,f),O=new v(g,f),P=new v(g,I),R=new v(h,I),D=new v(d/a,_/a),L=new v(A/a,C/a),z=t*Math.PI/180;if(z){const e=Math.sin(z),t=Math.cos(z),n=[t,-e,e,t];k._matMult(n),O._matMult(n),R._matMult(n),P._matMult(n)}const B=r.stretch+r.fixed,F=s.stretch+s.fixed,j=i.stretch+i.fixed,N=l.stretch+l.fixed,U=e.imageSecondary;return{tl:k,tr:O,bl:R,br:P,texPrimary:{x:o.paddedRect.x+1+B,y:o.paddedRect.y+1+j,w:F-B,h:N-j},texSecondary:U?{x:U.paddedRect.x+1+B,y:U.paddedRect.y+1+j,w:F-B,h:N-j}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:L,minFontScaleX:S/a/u,minFontScaleY:M/a/c,isSDF:n}};if(r&&(o.stretchX||o.stretchY)){const e=yg(h,_,p),t=yg(d,g,m);for(let n=0;no)&&(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 cr([],Tg);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 Sg(r.p.x-u,r.p.y-u,u,e)),c.push(new Sg(r.p.x+u,r.p.y-u,u,e)),c.push(new Sg(r.p.x-u,r.p.y+u,u,e)),c.push(new Sg(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 Tg(e,t){return t.max-e.max}mg.loadGlyphRange=function(e,t,n,r,i){const o=256*t,a=o+255,s=r.transformRequest(r.normalizeGlyphsURL(n).replace("{fontstack}",e).replace("{range}",`${o}-${a}`),ve.Glyphs);Se(s,(e,t)=>{if(e)i(e);else if(t){const e={},n=function(e){return new e_(e).readFields(F_,{})}(t);for(const t of n.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:n.ascender,descender:n.descender})}})},mg.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(dg,0,h),_.fill(0,0,h);for(let e=0;e0?e*e:0,_[r]=e<0?e*e:0}}fg(g,0,0,u,c,u,this.f,this.v,this.z),fg(_,m,m,s,l,u,this.f,this.v,this.z);for(let e=0;ee.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,Xf(e,i,s))}}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}}const Eg=Number.POSITIVE_INFINITY,Mg=Math.sqrt(2);function Ag(e,[t,n]){let r=0,i=0;if(n===Eg){t<0&&(t=0);const n=t/Mg;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 Ig(e,t,n,r,i,o,a,s,l,u,c){e.createArrays(),e.tilePixelRatio=hr/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,f={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:n}=e.textSizeData;f.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ns(t),s),d["text-size"].possiblyEvaluate(new Ns(n),s)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:n}=e.iconSizeData;f.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ns(t),s),d["icon-size"].possiblyEvaluate(new Ns(n),s)]}f.layoutTextSize=d["text-size"].possiblyEvaluate(new Ns(l+1),s),f.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ns(l+1),s),f.textMaxSize=d["text-size"].possiblyEvaluate(new Ns(18),s);const p="map"===h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement"),m=h.get("text-size");let _=!1;for(const t of e.features)if(t.icon&&t.icon.nameSecondary){_=!0;break}for(const o of e.features){const l=h.get("text-font").evaluate(o,{},s).join(","),d=m.evaluate(o,{},s),g=f.layoutTextSize.evaluate(o,{},s),y=(f.layoutIconSize.evaluate(o,{},s),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const r=v.toString(),a=24*h.get("text-letter-spacing").evaluate(o,{},s),u=24*h.get("text-line-height").evaluate(o,{},s),c=bs(r)?a:0,f=h.get("text-anchor").evaluate(o,{},s),m=h.get("text-variable-anchor");if(!m){const e=h.get("text-radial-offset").evaluate(o,{},s);b=e?Ag(f,[24*e,Eg]):h.get("text-offset").evaluate(o,{},s).map(e=>24*e)}let _=p?"center":h.get("text-justify").evaluate(o,{},s);const x="point"===h.get("symbol-placement"),w=x?24*h.get("text-max-width").evaluate(o,{},s):1/0,T=o=>{e.allowVerticalPlacement&&xs(r)&&(y.vertical=q_(v,t,n,i,l,w,u,f,o,c,b,U_.vertical,!0,g,d))};if(!p&&m){const e="auto"===_?m.map(e=>Cg(e)):[_];let r=!1;for(let o=0;o=0||!xs(r)){const e=q_(v,t,n,i,l,w,u,f,_,c,b,U_.horizontal,!1,g,d);e&&(y.horizontal[_]=e)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const t=r[o.icon.namePrimary];t&&(x=Q_(i[o.icon.namePrimary],o.icon.nameSecondary?i[o.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(o,{},s),h.get("icon-anchor").evaluate(o,{},s)),w=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&X("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const T=Dg(y.horizontal)||y.vertical;e.iconsInText||(e.iconsInText=!!T&&T.iconsInText),(T||x)&&kg(e,o,y,x,r,f,g,0,b,w,a,s,u,c,_)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Cg(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 kg(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){let m=o.textMaxSize.evaluate(t,{},h);void 0===m&&(m=a);const _=e.layers[0].layout,g=_.get("icon-offset").evaluate(t,{},h),y=Dg(n.horizontal)||n.vertical,v="globe"===d.name,x=a/24,b=e.tilePixelRatio*m/24,w=(O=e.overscaling,e.zoom>18&&O>2&&(O>>=1),Math.max(hr/(512*O),1)*_.get("symbol-spacing")),S=_.get("text-padding")*e.tilePixelRatio,E=_.get("icon-padding")*e.tilePixelRatio,M=T(_.get("text-max-angle")),A="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),I="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),C=_.get("symbol-placement"),k=w/2;var O;const P=_.get("icon-text-fit").evaluate(t,{},h),R=_.get("icon-text-fit-padding").evaluate(t,{},h),D="none"!==P;let L;!1===e.hasAnyIconTextFit&&D&&(e.hasAnyIconTextFit=!0),r&&D&&(e.allowVerticalPlacement&&n.vertical&&(L=eg(r,n.vertical,P,R,g,x)),y&&(r=eg(r,y,P,R,g,x)));const z=(a,s,m)=>{if(s.x<0||s.x>=hr||s.y<0||s.y>=hr)return;let _=null;if(v){const{x:e,y:t,z:n}=d.projectTilePoint(s.x,s.y,m);_={anchor:new tg(e,t,n,0,void 0),up:d.upVector(m,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,T,S,E,M){const A=e.addToLineVertexArray(t,r);let I,C,k,O,P,R,D,L=0,z=0,B=0,F=0,j=-1,N=-1;const U={};let V=uu("");const G=n?n.anchor:t,q="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let W=0,Z=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[W,Z]=l.layout.get("text-offset").evaluate(x,{},S).map(e=>24*e):(W=24*l.layout.get("text-radial-offset").evaluate(x,{},S),Z=Eg),e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(p)R=zg(e),s&&(D=zg(s));else{const n=l.layout.get("text-rotate").evaluate(x,{},S)+90;k=Lg(u,G,t,c,h,d,e,f,n,m),s&&(O=Lg(u,G,t,c,h,d,s,g,n))}}if(o){const r=l.layout.get("icon-rotate").evaluate(x,{},S),i=_g(o,r,w,q),a=s?_g(s,r,w,q):void 0;C=Lg(u,G,t,c,h,d,o,g,r),L=4*i.length;const f=e.iconSizeData;let p=null;"source"===f.kind?(p=[C_*l.layout.get("icon-size").evaluate(x,{},S)],p[0]>Pg&&X(`${e.layerIds[0]}: Value for "icon-size" is >= ${Og}. Reduce your "icon-size".`)):"composite"===f.kind&&(p=[C_*b.compositeIconSizes[0].evaluate(x,{},S),C_*b.compositeIconSizes[1].evaluate(x,{},S)],(p[0]>Pg||p[1]>Pg)&&X(`${e.layerIds[0]}: Value for "icon-size" is >= ${Og}. Reduce your "icon-size".`)),e.addSymbols(e.icon,i,p,v,y,x,!1,n,t,A.lineStartIndex,A.lineLength,-1,T,S,E,M),j=e.icon.placedSymbolArray.length-1,a&&(z=4*a.length,e.addSymbols(e.icon,a,p,v,y,x,U_.vertical,n,t,A.lineStartIndex,A.lineLength,-1,T,S,E,M),N=e.icon.placedSymbolArray.length-1)}for(const r in i.horizontal){const o=i.horizontal[r];I||(V=uu(o.text),p?P=zg(o):I=Lg(u,G,t,c,h,d,o,f,l.layout.get("text-rotate").evaluate(x,{},S),m));const s=1===o.positionedLines.length;if(B+=Rg(e,n,t,o,a,l,p,x,m,A,i.vertical?U_.horizontal:U_.horizontalOnly,s?Object.keys(i.horizontal):[r],U,j,b,T,S,E),s)break}i.vertical&&(F+=Rg(e,n,t,i.vertical,a,l,p,x,m,A,U_.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const $=(e,t)=>e?Math.max(e,t):t;H=$(P,H),H=$(R,H),H=$(D,H);const Y=H>-1?1:0;e.glyphOffsetArray.length>=Ey.MAX_GLYPHS&&X("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(t.x,t.y,G.x,G.y,G.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,j,N,V,void 0!==I?I:e.collisionBoxArray.length,void 0!==I?I+1:e.collisionBoxArray.length,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,O||e.collisionBoxArray.length,O?O+1:e.collisionBoxArray.length,c,B,F,L,z,Y,0,W,Z,H,0,q?1:0)}(e,s,_,a,n,r,i,L,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,S,A,l,0,E,I,g,t,o,u,c,h,f,p)};if("line"===C)for(const i of lg(t.geometry,0,0,hr,hr)){const t=sg(i,w,M,n.vertical||y,r,24,b,e.overscaling,hr);for(const n of t)y&&Bg(e,y.text,k,n)||z(i,n,h)}else if("line-center"===C){for(const e of t.geometry)if(e.length>1){const t=ag(e,M,n.vertical||y,r,24,b);t&&z(e,t,h)}}else if("Polygon"===t.type)for(const e of im(t.geometry,0)){const t=wg(e,16);z(e[0],new tg(t.x,t.y,0,0,void 0),h)}else if("LineString"===t.type)for(const e of t.geometry)z(e,new tg(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)z([t],new tg(t.x,t.y,0,0,void 0),h)}const Og=255,Pg=Og*C_;function Rg(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g){const y=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;ePg&&X(`${e.layerIds[0]}: Value for "text-size" is >= ${Og}. Reduce your "text-size".`)):"composite"===x.kind&&(b=[C_*p.compositeTextSizes[0].evaluate(s,{},_),C_*p.compositeTextSizes[1].evaluate(s,{},_)],(b[0]>Pg||b[1]>Pg)&&X(`${e.layerIds[0]}: Value for "text-size" is >= ${Og}. Reduce your "text-size".`)),e.addSymbols(e.text,y,b,l,a,s,c,t,n,u.lineStartIndex,u.lineLength,f,m,_,g,!1);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function Dg(e){for(const t in e)return e[t];return null}function Lg(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=T(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 zg(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 Bg(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}}function Ng(e,t,n,r,i,o,a,s,l){if("globe"===l.name)return Nd(e,t,new pd(n,r,i),!1);const u=jg({z:n,x:r,y:i},l);return new Md([(o+u.x/u.scale)*t,t*(u.y/u.scale),a],[(o+u.x2/u.scale)*t,t*(u.y2/u.scale),s])}function Ug(e,{x:t,y:n},r=0){return new v(((t-r)*e.scale-e.x)*hr,(n*e.scale-e.y)*hr)}function Vg(e,t,n=0){return id.fromValues(((t.x-n)*e.scale-e.x)*hr,(t.y*e.scale-e.y)*hr,Tf(t.z,t.y))}const Gg=Jh.identity(new Float32Array(16));class qg{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 _f(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 xf(1,e)*t}pixelSpaceConversion(e,t,n){return 1}farthestPixelDistance(e){return Fg(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<-Qg+n&&(t=-Qg+n):t>Qg-n&&(t=Qg-n);const o=i/Math.pow(ey(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=O(S(s/n)+this.center[0],-180,180),u=O(S(2*Math.atan(Math.pow(r/a,1/n))-Qg),-Sf,Sf);return new _f(l,this.southernCenter?-u:u)}}class ny extends qg{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:yf(e),y:vf(t),z:0}}unproject(e,t){const n=bf(e),r=wf(t);return new _f(n,r)}}const ry=T(Sf);class iy extends qg{project(e,t){const n=(t=T(t))*t,r=n*n;return{x:.5*((e=T(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=O(n-i,-ry,ry)}while(Math.abs(i)>1e-6&&--r>0);o=n*n;const a=O(S(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=S(n);return new _f(a,s)}}const oy=T(Sf);class ay extends qg{project(e,t){t=T(t),e=T(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),T=.5*_*(u*h+g*p*i)+.5,S=b*w-T*x;a=(v*b-y*T)/S,s=(y*w-v*x)/S,n=O(n-a,-Math.PI,Math.PI),r=O(r-s,-oy,oy)}while((Math.abs(a)>o||Math.abs(s)>o)&&--i>0);return new _f(S(n),S(r))}}class sy extends qg{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(T(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:T(e)*r*n+.5,y:-Math.sin(T(t))/r*n+.5,z:0}}unproject(e,t){const{scale:n,cosPhi:r}=this,i=-(t-.5)/n,o=O(S((e-.5)/n)/r,-180,180),a=Math.asin(O(i*r,-1,1)),s=O(S(a),-Sf,Sf);return new _f(o,s)}}class ly extends ny{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=Wd(e,t,n),i=$d(zd(n));return id.transformMat4(r,r,i),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const n=qd(t.lat,t.lng),r=id.normalize([],n),i=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude,o=xf(1,0)*hr*i;id.scaleAndAdd(n,n,r,o);const a=Jh.identity(new Float64Array(16));return Jh.multiply(a,e.pixelMatrix,e.globeMatrix),id.transformMat4(n,n,a),new v(n[0],n[1])}pixelsPerMeter(e,t){return xf(1,0)*t}pixelSpaceConversion(e,t,n){const r=xf(1,e)*t,i=Yr(xf(1,45)*t,r,n);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,n){const r=Xd(zd(n.canonical));return Jh.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:n}=e,r=$d(zd(t));return Jh.rotateY(r,r,T(n.lng)),Jh.rotateX(r,r,T(n.lat)),Jh.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,n,r){return Rd(e,t,n,!0)||new Cf(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!Rd(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=id.add([],id.scale([],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=id.scale([],i.up(),c),d=id.scale([],i.right(),c*u),f=id.normalize([],id.add([],id.add([],o,h),d)),p=[];let m;if(new vd(a,f).closestPointOnSphere(l,s,p)){const t=id.add([],p,l),n=id.sub([],t,a);m=Math.cos(e.fovAboveCenter)*id.length(n)}else{const e=id.sub([],a,l),t=id.sub([],l,a);id.normalize(t,t);const n=id.length(e)-s;m=Math.sqrt(n*(n+2*s));const r=Math.acos(m/(s+n))-Math.acos(id.dot(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=ef(e.zoom);if(n>0){const r=Fg(e,xf(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Yr(t,r+i*(1-Math.cos(o)),Math.pow(n,10))}return t}upVector(e,t,n){return Wd(t,n,e,1)}upVectorScale(e){return{metersToTile:Pd(Zd(zd(e)))}}}function uy(e){const t=e.parallels,n=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new ny(e);case"equirectangular":return new Jg(e);case"naturalEarth":return new iy(e);case"equalEarth":return new Kg(e);case"winkelTripel":return new ay(e);case"albers":return n?new sy(e):new Wg(e);case"lambertConformalConic":return n?new sy(e):new ty(e);case"globe":return new ly(e)}throw new Error("Invalid projection name: "+e.name)}const cy=new Js({"symbol-placement":new Xs(Pt.layout_symbol["symbol-placement"]),"symbol-spacing":new Xs(Pt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Xs(Pt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ys(Pt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Xs(Pt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Xs(Pt.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Xs(Pt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Xs(Pt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Xs(Pt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Xs(Pt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ys(Pt.layout_symbol["icon-size"]),"icon-text-fit":new Ys(Pt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ys(Pt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ys(Pt.layout_symbol["icon-image"]),"icon-rotate":new Ys(Pt.layout_symbol["icon-rotate"]),"icon-padding":new Xs(Pt.layout_symbol["icon-padding"]),"icon-keep-upright":new Xs(Pt.layout_symbol["icon-keep-upright"]),"icon-offset":new Ys(Pt.layout_symbol["icon-offset"]),"icon-anchor":new Ys(Pt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Xs(Pt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Xs(Pt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Xs(Pt.layout_symbol["text-rotation-alignment"]),"text-field":new Ys(Pt.layout_symbol["text-field"]),"text-font":new Ys(Pt.layout_symbol["text-font"]),"text-size":new Ys(Pt.layout_symbol["text-size"]),"text-max-width":new Ys(Pt.layout_symbol["text-max-width"]),"text-line-height":new Ys(Pt.layout_symbol["text-line-height"]),"text-letter-spacing":new Ys(Pt.layout_symbol["text-letter-spacing"]),"text-justify":new Ys(Pt.layout_symbol["text-justify"]),"text-radial-offset":new Ys(Pt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Xs(Pt.layout_symbol["text-variable-anchor"]),"text-anchor":new Ys(Pt.layout_symbol["text-anchor"]),"text-max-angle":new Xs(Pt.layout_symbol["text-max-angle"]),"text-writing-mode":new Xs(Pt.layout_symbol["text-writing-mode"]),"text-rotate":new Ys(Pt.layout_symbol["text-rotate"]),"text-padding":new Xs(Pt.layout_symbol["text-padding"]),"text-keep-upright":new Xs(Pt.layout_symbol["text-keep-upright"]),"text-transform":new Ys(Pt.layout_symbol["text-transform"]),"text-offset":new Ys(Pt.layout_symbol["text-offset"]),"text-allow-overlap":new Xs(Pt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Xs(Pt.layout_symbol["text-ignore-placement"]),"text-optional":new Xs(Pt.layout_symbol["text-optional"]),visibility:new Xs(Pt.layout_symbol.visibility)});var hy={paint:new Js({"icon-opacity":new Ys(Pt.paint_symbol["icon-opacity"]),"icon-emissive-strength":new Ys(Pt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ys(Pt.paint_symbol["text-emissive-strength"]),"icon-color":new Ys(Pt.paint_symbol["icon-color"]),"icon-halo-color":new Ys(Pt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ys(Pt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ys(Pt.paint_symbol["icon-halo-blur"]),"icon-translate":new Xs(Pt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Xs(Pt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Ys(Pt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Ys(Pt.paint_symbol["text-opacity"]),"text-color":new Ys(Pt.paint_symbol["text-color"],{runtimeType:Zt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Ys(Pt.paint_symbol["text-halo-color"]),"text-halo-width":new Ys(Pt.paint_symbol["text-halo-width"]),"text-halo-blur":new Ys(Pt.paint_symbol["text-halo-blur"]),"text-translate":new Xs(Pt.paint_symbol["text-translate"]),"text-translate-anchor":new Xs(Pt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Xs(Pt.paint_symbol["icon-color-saturation"])}),layout:cy};class dy{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Vt,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}}xa(dy,"FormatSectionOverride",{omit:["defaultValue"]});class fy extends rl{constructor(e,t){super(e,hy,t)}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()||_o(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 Ey(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of hy.paint.overridableProperties){if(!fy.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),n=new dy(t),r=new mo(n,t.property.specification);let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new yo("source",r):new vo("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Hs(t.property,i,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&fy.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const n=e.get("text-field"),r=hy.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 mn)o(n.value.value.sections);else if("source"===n.value.kind){const e=t=>{i||(t instanceof wn&&vn(t.value)===Yt?o(t.value.sections):t instanceof An?o(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}getProgramIds(){const e=0!==this.paint.get("icon-opacity").constantOr(1),t=0!==this.paint.get("text-opacity").constantOr(1),n=[];return e&&n.push("symbolIcon"),t&&n.push("symbolSDF"),n}getDefaultProgramParams(e,t){return{config:new Pu(this,t),overrideFog:!1}}}const py=km.types,my=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function _y(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=s?Math.min(Pg,Math.round(s[0])):0,p=s?Math.min(Pg,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 gy(e,t,n){e.emplaceBack(t,n)}function yy(e,t,n,r,i,o,a){e.emplaceBack(t,n,r,i,o,a)}function vy(e,t,n,r,i){const o=5*t+2;e.float32[o+0]=n,e.float32[o+1]=r,e.float32[o+2]=i}function xy(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 by(e){for(const t of e.sections)if(As(t.text))return!0;return!1}class wy{constructor(e){this.layoutVertexArray=new vl,this.indexArray=new Al,this.programConfigurations=e,this.segments=new Ql,this.dynamicLayoutVertexArray=new ml,this.opacityVertexArray=new bl,this.placedSymbolArray=new Gl,this.iconTransitioningVertexArray=new wl,this.globeExtVertexArray=new xl,this.zOffsetVertexArray=new kl}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,t,n,r,i){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,x_.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,w_.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,my,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,S_.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,b_.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,T_.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.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}xa(wy,"SymbolBuffers");class Ty{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new Ql,this.collisionVertexArray=new Ml,this.collisionVertexArrayExt=new ml}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,E_.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,M_.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}xa(Ty,"CollisionBuffers");class Sy{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.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Jh.identity([]),this.placementViewportMatrix=Jh.identity([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=k_(this.zoom,t["text-size"]),this.iconSizeData=k_(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=>U_[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate")}createArrays(){this.text=new wy(new Ru(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new wy(new Ru(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Zl,this.lineVertexArray=new Hl,this.symbolInstances=new Wl}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 Ns(this.zoom);for(const{feature:t,id:l,index:u,sourceLayerIndex:g}of e){const e=i._featureFilter.needGeometry,y=Ff(t,e);if(!i._featureFilter.filter(_,y,n))continue;if(e||(y.geometry=Bf(t,n,r)),a&&1!==t.type&&n.z<=5){const e=y.geometry,t=.98078528056,r=(e,r)=>{const i=Wd(e.x,e.y,n,1),o=Wd(r.x,r.y,n,1);return id.dot(i,o)=0;for(const n of v.sections)if(n.image)f[n.image.namePrimary]=!0;else{const r=xs(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,i){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const a=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,t,a,n,r,i),this.icon.programConfigurations.updatePaintArrays(e,t,a,n,r,i)}updateZOffset(){const e=(e,t,r)=>{n+=t,n>e.length&&e.resize(n);for(let i=-t;i<0;i++)e.emplace(i+n,r)},t=(e,t,n)=>{r+=t,r>e.length&&e.resize(r);for(let i=-t;i<0;i++)e.emplace(i+r,n)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let n=0,r=0;for(let n=0;n0;if((i>0||o>0)&&(e(this.text.zOffsetVertexArray,i,s),e(this.text.zOffsetVertexArray,o,s)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:n}=r;e>=0&&t(this.icon.zOffsetVertexArray,a,s),n>=0&&t(this.icon.zOffsetVertexArray,r.numVerticalIconVertices,s)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}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.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=uy(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,p,m){const _=e.indexArray,g=e.layoutVertexArray,y=e.globeExtVertexArray,v=e.segments.prepareSegment(4*t.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&a===U_.vertical?Math.PI/2:0,T=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=O_(this.textSizeData,e,i)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,n){const r=this.icon.placedSymbolArray.get(n),i=O_(this.iconSizeData,e,r);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,n,r){e.emplaceBack(t,-n,-n,r),e.emplaceBack(t,n,-n,r),e.emplaceBack(t,n,n,r),e.emplaceBack(t,-n,n,r)}_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}hasIconTextFit(){return this.hasAnyIconTextFit}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}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}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)}}}xa(Sy,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Sy.MAX_GLYPHS=65535,Sy.addDynamicAttributes=xy;var Ey=Sy;const My=ll([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Ay}=My,Iy=ll([{name:"a_packed",components:4,type:"Float32"}]),{members:Cy}=Iy,ky=km.types,Oy=Math.cos(Math.PI/180*37.5);class Py{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),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 pl,this.layoutVertexArray2=new ml,this.indexArray=new Al,this.programConfigurations=new Ru(e.layers,e.zoom),this.segments=new Ql,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){this.hasPattern=am("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=Ff(t,e);if(!this.layers[0]._featureFilter.filter(new Ns(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:Bf(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=sm("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,a.positions,t.availableImages,t.brightness);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,i){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,n,r,i)}addFeatures(e,t,n,r,i,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r,o)}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,Cy)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ay),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,a){const s=this.layers[0].layout,l=s.get("line-join").evaluate(e,{}),u=s.get("line-cap").evaluate(e,{}),c=s.get("line-miter-limit"),h=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const n of t)this.addLine(n,e,l,u,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r,a)}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 T=d&&f;let S=T?n:a?"butt":r;if(T&&"round"===S&&(vi&&(S="bevel"),"bevel"===S&&(v>2&&(S="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"===S||"fakeround"===S){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"===S){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()}}xa(Py,"LineBucket",{omit:["layers","patternFeatures"]});class Ry{constructor(e,t,n,r){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this.update(t,r)}update(e,t,r){const{width:i,height:o}=e,{context:a}=this,{gl:s}=a,{HTMLImageElement:l,HTMLCanvasElement:u,HTMLVideoElement:c,ImageData:h,ImageBitmap:d}=n;if(s.bindTexture(s.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!t||!1!==t.premultiply)),r||this.size&&this.size[0]===i&&this.size[1]===o){const{x:t,y:n}=r||{x:0,y:0};if(e instanceof l||e instanceof u||e instanceof c||e instanceof h||d&&e instanceof d)s.texSubImage2D(s.TEXTURE_2D,0,t,n,s.RGBA,s.UNSIGNED_BYTE,e);else{let r=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(r=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,t,n,i,o,r,a,e.data)}}else if(this.size=[i,o],e instanceof l||e instanceof u||e instanceof c||e instanceof h||d&&e instanceof d){let t=this.format;this.format===s.R8&&(t=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,t,s.UNSIGNED_BYTE,e)}else{let t=this.format,n=this.format,r=s.UNSIGNED_BYTE;this.format===s.DEPTH_COMPONENT&&(t=s.DEPTH_COMPONENT16,r=s.UNSIGNED_SHORT),this.format===s.R32F&&(r=s.FLOAT,n=s.RED),s.texImage2D(s.TEXTURE_2D,0,t,i,o,0,n,r,e.data)}this.useMipmap=Boolean(t&&t.useMipmap),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(e,t){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}bindExtraParam(e,t,n,r){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),n!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,n),this.wrapS=n),r!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapT=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Dy{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}}const Ly=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,n=0,r=0,i=0,o=0,a=0,s=0;for(1&t?i=o=a=32:n=r=s=32;(t>>=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;Ly[l+0]=n,Ly[l+1]=r,Ly[l+2]=i,Ly[l+3]=o}const zy=new Uint16Array(2178),By=new Uint8Array(1089),Fy=new Uint16Array(1089);function jy(e){return 0===e?-.03125:32===e?.03125:0}var Ny=ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Uy={type:2,extent:hr,loadGeometry:()=>[[new v(0,0),new v(8193,0),new v(8193,8193),new v(0,8193),new v(0,0)]]};class Vy{constructor(e,t,n,r,i){this.tileID=e,this.uid=j(),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,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),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.fqid]=r}}return n}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Ey){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 Ey&&t.hasRTLText){this.hasRTLText=!0,js.isLoading()||js.isLoaded()||"deferred"!==Bs()||Fs();break}}this.queryPadding=0;for(const e in this.buckets){const n=this.buckets[e],r=t.style.getOwnLayer(e);if(!r)continue;const i=r.queryRadius(n);this.queryPadding=Math.max(this.queryPadding,i)}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness}else this.collisionBoxArray=new Ul}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.fqid]}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 Ry(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ry(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Ry(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e,t,n){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,n),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const r=t.style.getBrightness();(this._lastUpdatedBrightness||r)&&(this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this._lastUpdatedBrightness=r,this.updateBuckets(void 0,t)))}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=Co(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=Ly[t+0],r=Ly[t+1],i=Ly[t+2],o=Ly[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((zy[2*c+0]+zy[2*h+0])/2-zy[2*d+0],(zy[2*c+1]+zy[2*h+1])/2-zy[2*d+1])>=16;By[d]=By[d]||(f?1:0),e<1022&&(By[d]=By[d]||By[33*(r+u>>1)+(n+l>>1)]||By[33*(o+u>>1)+(i+l>>1)])}const i=new dl,o=new Al;let a=0;function s(e,t){const n=33*t+e;return 0===Fy[n]&&(i.emplaceBack(zy[2*n+0],zy[2*n+1],e*hr/32,t*hr/32),Fy[n]=++a),Fy[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&&By[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 dl,i=new Al;for(const{x:e,y:t}of n)r.emplaceBack(e,t,0,0);const e=rm(r.int16,void 0,4);for(let t=0;t0&&(a=Jh.invert(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=Wd(e,t,n);if(o){const i=1<.5?h=-1:c<-.5&&(h=1);let d=(e/hr+n.x)/i+h,f=(t/hr+n.y)/i;d=(d-l)*r._pixelsPerMercatorPixel+l,f=(f-u)*r._pixelsPerMercatorPixel+u;const p=[d*r.worldSize,f*r.worldSize,0];id.transformMat4(p,p,o),s=Bd(s,p,a)}return id.transformMat4(s,s,i)}_makeGlobeTileDebugBorderBuffer(e,t,n,r,i,o){const a=new cl,s=new Dl,l=new hl,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;e{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 qy{constructor(e,t,n,r){this.id=qy.uniqueIdxCounter,qy.uniqueIdxCounter++,this.context=e;const i=e.gl;this.buffer=i.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||r||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=qy.uniqueIdxCounter,qy.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}qy.uniqueIdxCounter=0;const Wy={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Zy{constructor(e,t,n,r,i,o){this.length=t.length,this.attributes=n,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,this.context=e;const a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||i||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let n=0;n0&&e.vertexAttribDivisor(i,n)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Hy{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class $y extends Hy{getDefault(){return dn.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Xy extends Hy{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Yy extends Hy{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class Ky extends Hy{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Jy extends Hy{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Qy extends Hy{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class ev extends Hy{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class tv extends Hy{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class nv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class rv extends Hy{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class iv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class ov extends Hy{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class av extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class sv extends Hy{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class lv extends Hy{getDefault(){return dn.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class uv extends Hy{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class cv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class hv extends Hy{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class dv extends Hy{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let fv=class extends Hy{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class pv extends Hy{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class mv extends Hy{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class _v extends Hy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class gv extends Hy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class yv extends Hy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class vv extends Hy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class xv extends Hy{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class bv extends Hy{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class wv extends Hy{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Tv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class Sv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Ev extends Hy{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Mv extends Ev{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Av extends Ev{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Iv extends Ev{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Cv extends Av{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class kv{constructor(e,t,n,r,i){this.context=e,this.width=t,this.height=n;const o=this.framebuffer=e.gl.createFramebuffer();r&&(this.colorAttachment=new Mv(e,o)),i&&(this.depthAttachmentType=i,this.depthAttachment="renderbuffer"===i?new Av(e,o):new Iv(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}else{const t=this.depthAttachment.get();t&&e.deleteTexture(t)}e.deleteFramebuffer(this.framebuffer)}}class Ov{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}Ov.ReadOnly=!1,Ov.ReadWrite=!0,Ov.disabled=new Ov(519,Ov.ReadOnly,[0,1]);class Pv{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}}Pv.disabled=new Pv({func:519,mask:0},0,0,7680,7680,7680);class Rv{constructor(e,t,n,r){this.blendFunction=e,this.blendColor=t,this.mask=n,this.blendEquation=r}}Rv.Replace=[1,0,1,0],Rv.disabled=new Rv(Rv.Replace,dn.transparent,[!1,!1,!1,!1]),Rv.unblended=new Rv(Rv.Replace,dn.transparent,[!0,!0,!0,!0]),Rv.alphaBlended=new Rv([1,771,1,771],dn.transparent,[!0,!0,!0,!0]),Rv.multiply=new Rv([774,0,774,0],dn.transparent,[!0,!0,!0,!0]);class Dv{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}Dv.disabled=new Dv(!1,1029,2305),Dv.backCCW=new Dv(!0,1029,2305),Dv.backCW=new Dv(!0,1029,2304),Dv.frontCW=new Dv(!0,1028,2304),Dv.frontCCW=new Dv(!0,1028,2305);class Lv{constructor(e,t){this.gl=e,this.clearColor=new $y(this),this.clearDepth=new Xy(this),this.clearStencil=new Yy(this),this.colorMask=new Ky(this),this.depthMask=new Jy(this),this.stencilMask=new Qy(this),this.stencilFunc=new ev(this),this.stencilOp=new tv(this),this.stencilTest=new nv(this),this.depthRange=new rv(this),this.depthTest=new iv(this),this.depthFunc=new ov(this),this.blend=new av(this),this.blendFunc=new sv(this),this.blendColor=new lv(this),this.blendEquation=new uv(this),this.cullFace=new cv(this),this.cullFaceSide=new hv(this),this.frontFace=new dv(this),this.program=new fv(this),this.activeTexture=new pv(this),this.viewport=new mv(this),this.bindFramebuffer=new _v(this),this.bindRenderbuffer=new gv(this),this.bindTexture=new yv(this),this.bindVertexBuffer=new vv(this),this.bindElementBuffer=new xv(this),this.bindVertexArrayOES=new bv(this),this.pixelStoreUnpack=new wv(this),this.pixelStoreUnpackPremultiplyAlpha=new Tv(this),this.pixelStoreUnpackFlipY=new Sv(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t,n){return new qy(this,e,t,n)}createVertexBuffer(e,t,n,r,i){return new Zy(this,e,t,n,r,i)}createRenderbuffer(e,t,n){const r=this.gl,i=r.createRenderbuffer();return this.bindRenderbuffer.set(i),r.renderbufferStorage(r.RENDERBUFFER,e,t,n),this.bindRenderbuffer.set(null),i}createFramebuffer(e,t,n,r){return new kv(this,e,t,n,r)}clear({color:e,depth:t,stencil:n,colorMask:r}){const i=this.gl;let o=0;e&&(o|=i.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(r||[!0,!0,!0,!0])),void 0!==t&&(o|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==n&&(o|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),i.clear(o)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){x(e.blendFunction,Rv.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}class zv extends Ot{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 Gy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this._coveredTiles={},this._shadowCasterTiles={},this._state=new r_,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("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))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,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],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,this.map?this.map.painter:null,this._source.scope)}}getIds(){return L(this._tiles).map(e=>e.tileID).sort(Bv).map(e=>e.key)}getRenderableIds(e,t){const n=[];for(const r in this._tiles)this._isIdRenderable(+r,e,t)&&n.push(this._tiles[r]);return e?n.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):n.map(e=>e.tileID).sort(Bv).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(n||!this._shadowCasterTiles[e])}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 kt(r,{tile:e}));else{if(!(e.tileID.key in this._loadedParentTiles))return void this._source.fire(new Ct("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));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=ft.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 Ct("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,r){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;let i;if(this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new _d(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(i=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&&(i=i.filter(e=>this._source.hasTile(e)))):i=[],i.length>0&&this.castsShadows&&r&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Fv(this._source.type)){const o=e.coveringZoomLevel({tileSize:t||this._source.tileSize,roundZoom:this._source.roundZoom&&!n}),a=Math.min(o,this._source.maxzoom),s=e.extendTileCoverForShadows(i,r,a);for(const e of s)this._shadowCasterTiles[e.key]=!0,i.push(e)}const o=this._updateRetainedTiles(i);if(Fv(this._source.type)&&0!==i.length){const e={},t={},n=Object.keys(o);for(const r of n){const n=o[r],i=this._tiles[r];if(!i||i.fadeEndTime&&i.fadeEndTime<=ft.now())continue;const a=this.findLoadedParent(n,Math.max(n.overscaledZ-zv.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),t[r]=n}const r=i[i.length-1].overscaledZ;for(const e in this._tiles){const n=this._tiles[e];if(o[e]||!n.hasData())continue;let i=n.tileID;for(;i.overscaledZ>r;){i=i.scaledTo(i.overscaledZ-1);const r=this._tiles[i.key];if(r&&r.hasData()&&t[i.key]){o[e]=n.tileID;break}}}for(const t in e)o[t]||(this._coveredTiles[t]=!0,o[t]=e[t])}for(const e in o)this._tiles[e].clearFadeHold();const a=function(e,t){const n=[];for(const r in e)r in t||n.push(r);return n}(this._tiles,o);for(const e of a){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-zv.maxOverzooming,this._source.minzoom),a=Math.max(i+zv.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!0!==t.isExtraShadowCaster||!!this._shadowCasterTiles[e.key]||this._reloadTile(e.key,"reloading"),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 Vy(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 Ct("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=yf(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(O(a,...jv(e,-1))-a),Math.abs(O(a,...jv(e,1))-a)];u=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(O(a,...jv(e,-1))-a),Math.abs(O(a,...jv(e,0))-a),Math.abs(O(a,...jv(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}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const n=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),r="globe"===this.transform.projection.name;for(const e of n)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=r?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return n}sortCoordinatesByDistance(e){const t=e.slice(),n=this.transform._camera.position,r=this.transform._camera.forward(),i={};for(const e of t){const t=1/(1<i[e.key]-i[t.key]),t}hasTransition(){if(this._source.hasTransition())return!0;if(Fv(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=ft.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)}D(Array.from(n.values()),(e,t)=>{const n=new Vy(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 Bv(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 Fv(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function jv(e,t){const n=1<=1e-15){const e=id.normalize([],n);id.scale(r,e,id.dot(r,e)),t[0]=r[0],t[1]=r[1]}const i=id.cross([],t,e);if(id.len(i)<1e-15)return null;const o=Math.atan2(-i[1],i[0]);return Xv(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),o)}class Kv{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(e){if(e){const t=e instanceof Cf?e:new Cf(e[0],e[1],e[2]);this._renderWorldCopies&&(t.x=R(t.x,0,1)),this._position=t}else this._position=null}lookAtPoint(e,t){if(this.orientation=null,!this.position)return;const n=this.position,r=this._elevation?this._elevation.getAtPointOrZero(Cf.fromLngLat(e)):0,i=Cf.fromLngLat(e,r),o=[i.x-n.x,i.y-n.y,i.z-n.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=Yv(o,t)}setPitchBearing(e,t){this.orientation=Xv(T(e),T(-t))}}class Jv{constructor(e,t){this._transform=Jh.identity([]),this.orientation=t,this.position=e}get mercatorPosition(){const e=this.position;return new Cf(e[0],e[1],e[2])}get position(){const e=oe(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var t;e&&ae(this._transform,3,[(t=e)[0],t[1],t[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||ed.identity([]),e&&$v(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=Xv(e,t),$v(this._transform,this._orientation)}forward(){const e=oe(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=oe(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=oe(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,t){const n=new Float64Array(16);return Jh.invert(n,this.getWorldToCamera(e,t)),n}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(e,t,n){const r=this.position;id.scale(r,r,-e);const i=new Float64Array(16);return Jh.fromScaling(i,[n,n,n]),Jh.translate(i,i,r),i[10]*=t,i}getWorldToCamera(e,t){const n=new Float64Array(16),r=new Float64Array(4),i=this.position;return ed.conjugate(r,this._orientation),id.scale(i,i,-e),Jh.fromQuat(n,r),Jh.translate(n,n,i),n[1]*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=t,n[9]*=t,n[10]*=t,n[11]*=t,n}getCameraToClipPerspective(e,t,n,r){const i=new Float64Array(16);return Jh.perspective(i,e,t,n,r),i}getCameraToClipOrthographic(e,t,n,r,i,o){const a=new Float64Array(16);return Jh.ortho(a,e,t,n,r,i,o),a}getDistanceToElevation(e,t=!1){const n=0===e?0:xf(e,t?wf(this.position[1]):this.position[1]),r=this.forward();return(n-this.position[2])/r[2]}clone(){return new Jv([...this.position],[...this.orientation])}}function Qv(e,t){const n=tx(e.projection,e.zoom,e.width,e.height),r=function(e,t,n,r,i){const o=new _f(n.lng-180*nx,n.lat),a=new _f(n.lng+180*nx,n.lat),s=e.project(o.lng,o.lat),l=e.project(a.lng,a.lat),u=-Math.atan2(l.y-s.y,l.x-s.x),c=Cf.fromLngLat(n);c.y=O(c.y,-1+nx,1-nx);const h=c.toLngLat(),d=e.project(h.lng,h.lat),f=Cf.fromLngLat(h);f.x+=nx;const p=f.toLngLat(),m=e.project(p.lng,p.lat),_=ix(m.x-d.x,m.y-d.y,u),g=Cf.fromLngLat(h);g.y+=nx;const y=g.toLngLat(),v=e.project(y.lng,y.lat),x=ix(v.x-d.x,v.y-d.y,u),b=Math.abs(_.x)/Math.abs(x.y),w=Jh.identity([]);Jh.rotateZ(w,w,-u*(1-(i?0:r)));const T=Jh.identity([]);return Jh.scale(T,T,[1,1-(1-b)*r,1]),T[4]=-x.x/x.y*r,Jh.rotateZ(T,T,u),Jh.multiply(T,w,T),T}(e.projection,0,e.center,n,t),i=ex(e);return Jh.scale(r,r,[i,i,1]),r}function ex(e){const t=e.projection,n=tx(e.projection,e.zoom,e.width,e.height),r=rx(t,e.center),i=rx(t,_f.convert(t.center));return Math.pow(2,r*n+(1-n)*i)}function tx(e,t,n,r,i=1/0){const o=e.range;if(!o)return 0;const a=Math.min(i,Math.max(n,r)),s=Math.log(a/1024)/Math.LN2;return P(o[0]+s,o[1]+s,t)}const nx=1/4e4;function rx(e,t){const n=O(t.lat,-Sf,Sf),r=new _f(t.lng-180*nx,n),i=new _f(t.lng+180*nx,n),o=e.project(r.lng,n),a=e.project(i.lng,n),s=Cf.fromLngLat(r),l=Cf.fromLngLat(i),u=a.x-o.x,c=a.y-o.y,h=l.x-s.x,d=l.y-s.y,f=Math.sqrt((h*h+d*d)/(u*u+c*c));return Math.log(f)/Math.LN2}function ix(e,t,n){const r=Math.cos(n),i=Math.sin(n);return{x:e*r-t*i,y:e*i+t*r}}function ox(e,t,n){return t*(hr/(e.tileSize*Math.pow(2,n-e.tileID.overscaledZ)))}const ax=0,sx=1,lx=2,ux=Math.tan(85*Math.PI/180);function cx(e,t,n,r,i,o,a){const s=Jh.create();if(n)if("globe"===o.name){const e=function(e,t){const{x:n,y:r}=e.point,i=Jd(n,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return Jh.multiply(i,i,Xd(zd(t)))}(i,t);Jh.multiply(s,s,e)}else{const e=Hh.invert([],a);s[0]=e[0],s[1]=e[1],s[4]=e[2],s[5]=e[3],r||Jh.rotateZ(s,s,i.angle)}else Jh.multiply(s,i.labelPlaneMatrix,e);return s}function hx(e,t,n,r,i,o,a){const s=cx(e,t,n,r,i,o,a);return"globe"===o.name&&n||(s[2]=s[6]=s[10]=s[14]=0),s}function dx(e,t,n,r,i,o,a){if(n){if("globe"===o.name){const s=cx(e,t,n,r,i,o,a);return Jh.invert(s,s),Jh.multiply(s,e,s),s}{const t=Jh.clone(e),n=Jh.identity([]);return n[0]=a[0],n[1]=a[1],n[4]=a[2],n[5]=a[3],Jh.multiply(t,t,n),r||Jh.rotateZ(t,t,-i.angle),t}}return i.glCoordMatrix}function fx(e,t,n,r){const i=[e,t,n,1];n?qh.transformMat4(i,i,r):Sx(i,i,r);const o=i[3];return i[0]/=o,i[1]/=o,i[2]/=o,i}function px(e,t){return Math.min(.5+e/t*.5,1.5)}function mx(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 _x(e,t,n,r,i,o,a,s,l,u){const c=n.transform,h=r?e.textSizeData:e.iconSizeData,d=P_(h,n.transform.zoom),f="globe"===c.projection.name,p=[256/n.width*2+1,256/n.height*2+1],m=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;m.clear();let _=null;f&&(_=r?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const g=e.lineVertexArray,y=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,x=n.transform.width/n.transform.height;let b,w=!1;for(let r=0;rMath.abs(n)?{useVertical:!0}:e===U_.vertical?r>0?{needsFlipping:!0}:null:t!==ax&&function(e,t){return 0===e||Math.abs(t/e)>ux}(n,r)?t===sx?{needsFlipping:!0}:null:n<0?{needsFlipping:!0}:null}function vx(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y){const x=t/24,b=e.lineOffsetX*x,w=e.lineOffsetY*x,{lineStartIndex:T,glyphStartIndex:S,numGlyphs:E,segment:M,writingMode:A,flipState:I}=e,C=T+e.lineLength,k=e=>{if(c){const[t,n,r]=e.up,i=u.length;vy(c,i+0,t,n,r),vy(c,i+1,t,n,r),vy(c,i+2,t,n,r),vy(c,i+3,t,n,r)}const[t,n,r]=e.point;xy(u,t,n,r,e.angle)};if(E>1){const t=gx(x,s,b,w,n,h,d,e,l,o,f,m,!1,_,g,y);if(!t)return{notEnoughRoom:!0};if(r&&!n){let[n,r,i]=t.first.point,[o,s,l]=t.last.point;[n,r]=fx(n,r,i,a),[o,s]=fx(o,s,l,a);const u=yx(A,I,(o-n)*p,s-r);if(e.flipState=u&&u.needsFlipping?sx:lx,u)return u}k(t.first);for(let e=S+1;e0?o:bx(d,r,t,1,i,void 0,_,g.canonical),s=yx(A,I,(a[0]-t[0])*p,a[1]-t[1]);if(e.flipState=s&&s.needsFlipping?sx:lx,s)return s}const t=wx(x*s.getoffsetX(S),b,w,n,h,d,M,T,C,l,o,f,m,!1,!1,_,g,y);if(!t)return{notEnoughRoom:!0};k(t)}return{}}function xx(e,t,n,r,i){const{x:o,y:a,z:s}=r.projectTilePoint(e.x,e.y,t);if(!i)return fx(o,a,s,n);const[l,u,c]=i(e);return fx(o+l,a+u,s+c,n)}function bx(e,t,n,r,i,o,a,s){const l=xx(e.sub(t)._unit()._add(e),s,i,a,o);return id.sub(l,n,l),id.normalize(l,l),id.scaleAndAdd(l,n,l,r)}function wx(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g){const y=r?e-t:e+t;let x=y>0?1:-1,b=0;r&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=s+a+(x>0?0:1)|0,T=i,S=i,E=0,M=0;const A=Math.abs(y),I=[],C=[];let k=o,O=k;const P=()=>bx(O,k,S,A-E+1,c,d,m,_.canonical);for(;E+M<=A;){if(w+=x,w=l)return null;if(S=T,O=k,I.push(S),f&&C.push(O),k=new v(u.getx(w),u.gety(w)),T=h[w],!T){const e=xx(k,_.canonical,c,m,d);T=e[3]>0?h[w]=e:P()}E+=M,M=id.distance(S,T)}p&&d&&(h[w]&&(T=P(),M=id.distance(S,T)),h[w]=T);const R=(A-E)/M,D=k.sub(O)._mult(R)._add(O),L=id.sub([],T,S),z=id.scaleAndAdd([],S,L,R);let B=[0,0,1],F=L[0],j=L[1];if(g&&(B=m.upVector(_.canonical,D.x,D.y),0!==B[0]||0!==B[1]||1!==B[2])){const e=[B[2],0,-B[0]],t=id.cross([],B,e);id.normalize(e,e),id.normalize(t,t),F=id.dot(L,e),j=id.dot(L,t)}if(n){const e=id.cross([],B,L);id.normalize(e,e),id.scaleAndAdd(z,z,e,n*x)}const N=b+Math.atan2(j,F);return I.push(z),f&&C.push(D),{point:z,angle:N,path:I,tilePath:C,up:B}}function Tx(e,t){const n=t.length,r=n+4*e;t.resize(r),t.float32.fill(-1/0,4*n,4*r)}function Sx(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 Ex=(e,t,n)=>(1-n)*e+n*t,Mx=e=>e*e*e*e*e;class Ax{constructor(e,t,n,r,i,o,a){this.tileSize=512,this._renderWorldCopies=void 0===i||i,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=null==n?0:n,this._maxPitch=null==r?60:r,this.setProjection(o),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new _f(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 Hv,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Jv,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1}clone(){const e=new Ax(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._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,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 isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}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 B(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=uy(this.projectionOptions);const n=!x(t,this.getProjection());return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=uy({name:"mercator"});const t=e!==this.projection.name;return t&&this._calcMatrices(),t}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 xf(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new v(this.width,this.height)}get bearing(){return R(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;this.angle!==t&&(this._unmodified=!1,this.angle=t,this._calcMatrices(),this.rotationMatrix=Hh.create(),Hh.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=O(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,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(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=T(e),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(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const n=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&n.exaggeration()&&this._centerAltitudeValidForExaggeration!==n.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*n.exaggeration(),this._centerAltitudeValidForExaggeration=n.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=n.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,t=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],n=this.horizonLineFromTop();let r=0,i=0;for(let o=0;o0,u=e.y+10,h=n.wrap-(l?0:1),d=n.wrap+(s?0:1),f=l?e.x-1:a-1,p=s?e.x+1:0;t[0]<0?(r.push(new _d(i,d,e.z,p,e.y)),t[1]<0&&u&&(r.push(new _d(i,o,e.z,e.x,e.y+1)),r.push(new _d(i,d,e.z,p,e.y+1))),t[1]>0&&c&&(r.push(new _d(i,o,e.z,e.x,e.y-1)),r.push(new _d(i,d,e.z,p,e.y-1)))):t[0]>0?(r.push(new _d(i,h,e.z,f,e.y)),t[1]<0&&u&&(r.push(new _d(i,o,e.z,e.x,e.y+1)),r.push(new _d(i,h,e.z,f,e.y+1))),t[1]>0&&c&&(r.push(new _d(i,o,e.z,e.x,e.y-1)),r.push(new _d(i,h,e.z,f,e.y-1)))):t[1]<0&&u?r.push(new _d(i,o,e.z,e.x,e.y+1)):c&&r.push(new _d(i,o,e.z,e.x,e.y-1))}if(r.length>1){r.sort((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y);let e=0,t=0;for(;te.isChildOf(t))||i.push(e);return r=i.filter(t=>!e.some(e=>!!(t.overscaledZe.maxzoom&&(t=e.maxzoom);const a=this.locationCoordinate(this.center),s=this.center.lat,l=1<{const t=1/4e4,n=new Cf(e.x+t,e.y,e.z),r=new Cf(e.x,e.y+t,e.z),i=e.toLngLat(),o=n.toLngLat(),a=r.toLngLat(),s=this.locationCoordinate(i),l=this.locationCoordinate(o),u=this.locationCoordinate(a),c=Math.hypot(l.x-s.x,l.y-s.y),h=Math.hypot(u.x-s.x,u.y-s.y);return Math.sqrt(c*h)*w/t},S=e=>{const t=x,n=b;return{aabb:Ng(this,l,0,0,0,e,n,t,this.projection),zoom:0,x:0,y:0,minZ:n,maxZ:t,wrap:e,fullyVisible:!1}},M=[];let A=[];const I=t,C=e.reparseOverscaled?n:t,k=e=>e*e,O=k((m-this._centerAltitude)*p),P=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=R(e),e.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},R=e=>{if(e.zoom=.9)return!0}else if(i&&(o=k(e.aabb.distanceZ(_)*p)),this.projection.isReprojectedInTileSpace&&n<=5){const t=Math.pow(2,e.zoom),n=T(new Cf((e.x+.5)/t,(e.y+.5)/t));a=n>.85?1:n}const l=t*t+r*r+o;return l{if(t*k(.707)0;){const n=M.pop(),r=n.x,a=n.y;let s=n.fullyVisible;const h=()=>"globe"===this.projection.name&&(0===n.y||n.y===(1<>1),h={aabb:o?n.aabb.quadrant(e):Ng(this,l,n.zoom+1,t,u,n.wrap,n.minZ,n.maxZ,this.projection),zoom:n.zoom+1,x:t,y:u,wrap:n.wrap,fullyVisible:s,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};i&&!c&&(h.tileID=new _d(n.zoom+1===I?C:n.zoom+1,n.wrap,n.zoom+1,t,u),P(h)),M.push(h)}else{const i=n.zoom===I?C:n.zoom;if(e.minzoom&&e.minzoom>i)continue;if(!s){let e=g?n.aabb.intersectsPrecise(d):n.aabb.intersectsPreciseFlat(d);if(0===e&&h()){const t=new pd(n.zoom,r,a);e=Nd(this,l,t,!0).intersectsPrecise(d)}if(0===e)continue}const o=u[0]-(.5+r+(n.wrap<{const i=[0,0,0,1],o=[hr,hr,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());qh.transformMat4(i,i,a),qh.transformMat4(o,o,a);const s=function(e,t,n){let r=0;for(let n=0;n<2;++n){const i=0;e[n]>i&&(r+=(e[n]-i)*(e[n]-i)),t[n]t&&0!==n){const t=this.calculateProjMatrix(r.tileID.toUnwrapped());let i;e.isTerrainDEM||(i=u.getMinMaxForTile(r.tileID)),i||(i={min:b,max:x});const o=function(e){const t=Math.round((e+45+360)%360/90)%4;return E[t]}(this.rotation),a=[o[0]*hr,o[1]*hr,i.max];id.transformMat4(a,a,t),l=(1-a[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(e){const t=O(e.lat,-Sf,Sf),n=this.projection.project(e.lng,t);return new v(n.x*this.worldSize,n.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/xf(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,t){let n,r;const i=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;n=(t.x-i.x)/e,r=(t.y-i.y)/e}else{const e=this.pointCoordinate(t),o=this.pointCoordinate(i);n=e.x-o.x,r=e.y-o.y}const o=this.locationCoordinate(e);this.setLocation(new Cf(o.x-n,o.y-r))}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(e,t){const n=t?xf(t,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new Cf(r.x,r.y,n)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const n=null!=t?t:this._centerAltitude,r=[e.x,e.y,0,1],i=[e.x,e.y,1,1];qh.transformMat4(r,r,this.pixelMatrixInverse),qh.transformMat4(i,i,this.pixelMatrixInverse);const o=i[3];qh.scale(r,r,1/r[3]),qh.scale(i,i,1/o);const a=r[2],s=i[2];return{p0:r,p1:i,t:a===s?0:(n-a)/(s-a)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],n=[e.x,e.y,1,1];return qh.transformMat4(t,t,this.pixelMatrixInverse),qh.transformMat4(n,n,this.pixelMatrixInverse),qh.scale(t,t,1/t[3]),qh.scale(n,n,1/n[3]),t[2]=xf(t[2],this._center.lat)*this.worldSize,n[2]=xf(n[2],this._center.lat)*this.worldSize,qh.scale(t,t,1/this.worldSize),qh.scale(n,n,1/this.worldSize),new vd([t[0],t[1],t[2]],id.normalize([],id.sub([],n,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:n,t:r}=e,i=xf(t[2],this._center.lat),o=xf(n[2],this._center.lat);return new Cf(Yr(t[0],n[0],r)/this.worldSize,Yr(t[1],n[1],r)/this.worldSize,Yr(i,o,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let t=this.projection.pointCoordinate3D(this,e.x,e.y);if(t)return new Cf(t[0],t[1],t[2]);let n=0,r=this.horizonLineFromTop();if(e.y>r)return this.pointCoordinate(e);const i=.02*r,o=e.clone();for(let e=0;e<10&&r-n>i;e++){o.y=Yr(n,r,.66);const e=this.projection.pointCoordinate3D(this,o.x,o.y);e?(r=o.y,t=e):n=o.y}return t?new Cf(t[0],t[1],t[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return!1;if(this.elevation||this.zoom>=6)return!this.isPointAboveHorizon(e);const t=this.pointCoordinate(e);return t.y>=0&&t.y<=1}_coordinatePoint(e,t){const n=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,r=[e.x*this.worldSize,e.y*this.worldSize,n+e.toAltitude(),1];return qh.transformMat4(r,r,this.pixelMatrix),r[3]>0?new v(r[0]/r[3],r[1]/r[3]):new v(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:t}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,i=this.pointLocation3D(new v(t,e)),o=this.pointLocation3D(new v(r,e)),a=this.pointLocation3D(new v(r,n)),s=this.pointLocation3D(new v(t,n));let l=Math.min(i.lng,o.lng,a.lng,s.lng),u=Math.max(i.lng,o.lng,a.lng,s.lng),c=Math.min(i.lat,o.lat,a.lat,s.lat),h=Math.max(i.lat,o.lat,a.lat,s.lat);const d=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,p=(e,t,n,r,i)=>{const o=(e+n)/2,a=(t+r)/2,s=new v(o,a),{lng:m,lat:_}=this.pointLocation3D(s),g=Math.max(0,l-m,c-_,m-u,_-h);l=Math.min(l,m),u=Math.max(u,m),c=Math.min(c,_),h=Math.max(h,_),(id)&&(p(e,t,o,a,i+1),p(o,a,n,r,i+1))};if(p(t,e,r,e,1),p(r,e,r,n,1),p(r,n,t,n,1),p(t,n,t,e,1),"globe"===this.projection.name){const[e,t]=function(e){const t=Jh.identity(new Float64Array(16));Jh.multiply(t,e.pixelMatrix,e.globeMatrix);const n=[0,Cd,0],r=[0,kd,0];return id.transformMat4(n,n,t),id.transformMat4(r,r,t),[n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!lf(e,new _f(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!lf(e,new _f(e.center.lat,-90))]}(this);e?(h=90,u=180,l=-180):t&&(c=-90,u=180,l=-180)}return new ju(new _f(l,c),new _f(u,h))}_getBoundsRectangular(e,t){const{top:n,left:r}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,a=new v(r,n),s=new v(o,n),l=new v(o,i),u=new v(r,i);let c=this.pointCoordinate(a,e),h=this.pointCoordinate(s,e);const d=this.pointCoordinate(l,t),f=this.pointCoordinate(u,t),p=(e,t)=>(t.y-e.y)/(t.x-e.x);return c.y>1&&h.y>=0?c=new Cf((1-f.y)/p(f,c)+f.x,1):c.y<0&&h.y<=1&&(c=new Cf(-f.y/p(f,c)+f.x,0)),h.y>1&&c.y>=0?h=new Cf((1-d.y)/p(d,h)+d.x,1):h.y<0&&c.y<=1&&(h=new Cf(-d.y/p(d,h)+d.x,0)),(new ju).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(d))}_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(e){this.maxBounds=e,this.minLat=-Sf,this.maxLat=Sf,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLngc&&(a=c-l),c-ut&&(o=t-s),t-e{for(let i=0;i<16;i++)e[i]=Ex(t[i],n[i],r)})(a,a,s,Mx(this.pitch>=15?1:this.pitch/15))}else a=s;const l=Jh.mul([],s,o);let u=Jh.mul([],a,o);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),t=Jh.identity([]);Jh.translate(t,t,[e.x*this.worldSize,e.y*this.worldSize,0]),Jh.multiply(t,t,Qv(this)),Jh.translate(t,t,[-e.x*this.worldSize,-e.y*this.worldSize,0]),Jh.multiply(u,u,t),Jh.multiply(l,l,t),this.inverseAdjustmentMatrix=function(e){const t=Qv(e,!0);return Hh.invert([],[t[0],t[1],t[4],t[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=Jh.scale([],u,[this.worldSize,this.worldSize,this.worldSize/i,1]),this.projMatrix=u,this.invProjMatrix=Jh.invert(new Float64Array(16),this.projMatrix),t){const t=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);t[8]=2*-e.x/this.width,t[9]=2*e.y/this.height,this.expandedFarZProjMatrix=Jh.mul([],t,o)}else this.expandedFarZProjMatrix=this.projMatrix;const c=Jh.invert([],a);this.frustumCorners=xd.fromInvProjectionMatrix(c,this.horizonLineFromTop(),this.height),this.cameraFrustum=Ed.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!t);const h=new Float32Array(16);Jh.identity(h),Jh.scale(h,h,[1,-1,1]),Jh.rotateX(h,h,this._pitch),Jh.rotateZ(h,h,this.angle);const d=Jh.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=Jh.clone(d);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;d[8]=2*-e.x/this.width,d[9]=2*(e.y+f)/this.height,this.skyboxMatrix=Jh.multiply(h,d,h);const p=this.point,m=p.x,_=p.y,g=this.width%2/2,y=this.height%2/2,v=Math.cos(this.angle),x=Math.sin(this.angle),b=m-Math.round(m)+v*g+x*y,w=_-Math.round(_)+v*y+x*g,T=new Float64Array(u);if(Jh.translate(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=T,u=Jh.create(),Jh.scale(u,u,[this.width/2,-this.height/2,1]),Jh.translate(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=Jh.create(),Jh.scale(u,u,[1,-1,1]),Jh.translate(u,u,[-1,-1,0]),Jh.scale(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=Jh.multiply(new Float64Array(16),this.labelPlaneMatrix,l),this._calcFogMatrices(),this._distanceTileDataCache={},u=Jh.invert(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=function(e){const{x:t,y:n}=e.point,{lng:r,lat:i}=e._center;return Jd(t,n,e.worldSize,r,i)}(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=id.transformMat4(e,e,o),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,t=this.cameraPixelsPerMeter,n=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,i=[e,e,t];id.scale(i,i,r),id.scale(n,n,-1),id.multiply(n,n,i);const o=Jh.create();Jh.translate(o,o,n),Jh.scale(o,o,i),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,r)}_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(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=this._camera.position[2],r=e[2];let i=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(i=Math.min((t-n)/r,1)),this._camera.position=id.scaleAndAdd([],this._camera.position,e,i),this._updateStateFromCamera()}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:n,bearing:r}=this._camera.getPitchBearing(),i=xf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(T(this._maxPitch)),a=Math.max((e[2]-i)/Math.cos(n),o),s=this._zoomFromMercatorZ(a);id.scaleAndAdd(e,e,t,a),this._pitch=O(n,T(this.minPitch),T(this.maxPitch)),this.angle=R(r,-Math.PI,Math.PI),this._setZoom(O(s,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new Cf(e[0],e[1],e[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(e){let t=0,n=6,r=0,i=1/0;for(;n-t>1e-6&&n>t;){const o=t+.5*(n-t),a=this.tileSize*Math.pow(2,o),s=this.getCameraToCenterDistance(this.projection,o,a),l=this.scaleZoom(s/(e*this.tileSize)),u=Math.abs(o-l);ul||n.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+S(this.fovAboveCenter)>88||this.anyCornerOffEdge(new v(0,0),new v(this.width,this.height))}zoomDeltaToMovement(e,t){const n=id.length(id.sub([],this._camera.position,e)),r=this._zoomFromMercatorZ(n)+t;return n-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function([e,t,n],r){const i=[e,t,n,1];qh.transformMat4(i,i,r);const o=i[3]=Math.max(i[3],1e-6);return i[0]/=o,i[1]/=o,i[2]/=o,i}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new v(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new v(0,e))}}getCameraToCenterDistance(e,t=this.zoom,n=this.worldSize){const r=tx(e,t,this.width,this.height,1024),i=e.pixelSpaceConversion(this.center.lat,n,r);let o=.5/Math.tan(.5*this._fov)*this.height*i;return this.isOrthographic&&(o=Ex(1,o,Mx(this.pitch>=15?1:this.pitch/15))),o}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&Jh.multiply(e,e,this.globeMatrix),e}getFrustum(e){return Ed.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,"meters"===this.projection.zAxisUnit)}}function Ix(e,t,n){Jh.identity(e),Jh.rotateZ(e,e,T(t[2])),Jh.rotateX(e,e,T(t[0])),Jh.rotateY(e,e,T(t[1])),Jh.scale(e,e,n),Jh.multiply(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function Cx(e,t,n,r,i,o,a,s){const l=[n[0]-t[0],n[1]-t[1],0],u=[r[0]-t[0],r[1]-t[1],0];if(id.length(l)<1e-12||id.length(u)<1e-12)return ed.identity(e);const c=id.cross([],l,u);id.normalize(c,c),id.subtract(u,r,t),l[2]=(o-i)*s,u[2]=(a-i)*s;const h=l;return id.cross(h,l,u),id.normalize(h,h),ed.rotationTo(e,c,h)}function kx(e,t,n=!1){const r=ef(t.zoom),i=function(e,t,n){const r=t.worldSize,i=[e[12],e[13],e[14]],o=wf(i[1]/r),a=bf(i[0]/r),s=Jh.identity([]),l=xf(1,o)*r,u=xf(1,0)*r*Mf(o,t.zoom),c=1/Yd(r);let h=u*c;if(n){const e=tx(t.projection,t.zoom,t.width,t.height,1024);h=c*t.projection.pixelSpaceConversion(t.center.lat,r,e)}const d=qd(o,a);id.add(d,d,id.scale([],id.normalize([],d),l*h*i[2]));const f=function(e){const t=[e[0],e[1],e[2]];let n=[0,1,0];const r=id.cross([],n,t);return id.cross(n,t,r),0===id.squaredLength(n)&&(n=[0,1,0],id.cross(r,t,n)),id.normalize(r,r),id.normalize(n,n),id.normalize(t,t),[r[0],r[1],r[2],0,n[0],n[1],n[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(d);Jh.scale(s,s,[h,h,h*l]),Jh.translate(s,s,[-i[0],-i[1],-i[2]]);const p=Jh.multiply([],t.globeMatrix,f);return Jh.multiply(p,p,s),Jh.multiply(p,p,e),p}(e,t,n);return r>0?function(e,t,n){const r=(e,t,n)=>{const r=id.length(e),i=id.length(t),o=Bd(e,t,n);return id.scale(o,o,1/id.length(o)*Yr(r,i,n))},i=r([e[0],e[1],e[2]],[t[0],t[1],t[2]],n),o=r([e[4],e[5],e[6]],[t[4],t[5],t[6]],n),a=r([e[8],e[9],e[10]],[t[8],t[9],t[10]],n),s=Bd([e[12],e[13],e[14]],[t[12],t[13],t[14]],n);return[i[0],i[1],i[2],0,o[0],o[1],o[2],0,a[0],a[1],a[2],0,s[0],s[1],s[2],1]}(i,function(e,t){const n=t.worldSize,r=xf(1,0)*n*Mf(t.center.lat,t.zoom)/Yd(n),i=xf(1,t.center.lat)*n,o=Jh.identity([]);return Jh.rotateY(o,o,T(t.center.lng)),Jh.rotateX(o,o,T(t.center.lat)),Jh.translate(o,o,[0,0,Ad]),Jh.scale(o,o,[r,r,r*i]),Jh.translate(o,o,[t.point.x-.5*n,t.point.y-.5*n,0]),Jh.multiply(o,o,e),Jh.multiply(o,t.globeMatrix,o)}(e,t),r):i}const Ox=[1,1,1];class Px{constructor(e,t,n,r){this.id=e,this.position=null!=t?new _f(t[0],t[1]):new _f(0,0),this.orientation=null!=n?n:[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new Md([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,t){if(Jh.multiply(e.matrix,t,e.matrix),e.meshes)for(const t of e.meshes){const n=Md.applyTransform(t.aabb,e.matrix);this.aabb.encapsulate(n)}if(e.children)for(const t of e.children)this._applyTransformations(t,e.matrix)}computeBoundsAndApplyParent(){const e=Jh.identity([]);for(const t of this.nodes)this._applyTransformations(t,e)}_positionModelOnTerrain(e,t){const n=e.elevation;if(!n)return 0;const r=Md.projectAabbCorners(this.aabb,this.matrix),i=xf(1,this.position.lat)*e.worldSize,o=function(e,t){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const i of r){const r=e[i.corners[0]],o=e[i.corners[1]],a=e[i.corners[2]],s=[o[0]-r[0],o[1]-r[1],t*(o[2]-r[2])],l=id.cross(s,s,[a[0]-r[0],a[1]-r[1],t*(a[2]-r[2])]);id.normalize(l,l),i.dotProductWithUp=id.dot(l,n)}return r.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),r[0].corners}(r,i),a=r[o[0]],s=r[o[1]],l=r[o[2]],u=r[o[3]],c=n.getAtPointOrZero(new Cf(a[0]/e.worldSize,a[1]/e.worldSize),0),h=n.getAtPointOrZero(new Cf(s[0]/e.worldSize,s[1]/e.worldSize),0),d=n.getAtPointOrZero(new Cf(l[0]/e.worldSize,l[1]/e.worldSize),0),f=n.getAtPointOrZero(new Cf(u[0]/e.worldSize,u[1]/e.worldSize),0),p=(c+f)/2,m=(h+d)/2;return p>m?h=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function Dx(e,t,n){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Nv.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,qv.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Gv.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Uv:Vv).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Zv.members,!0)),e.segments=Ql.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&Rx(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&Rx(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&Rx(r.normalTexture,t),r.occlusionTexture&&Rx(r.occlusionTexture,t,n),r.emissionTexture&&Rx(r.emissionTexture,t)}function Lx(e,t,n){if(e.meshes)for(const r of e.meshes)Dx(r,t,n);if(e.children)for(const r of e.children)Lx(r,t,n)}function zx(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)zx(t)}function Bx(e){if(e.meshes)for(const n of e.meshes)n.vertexBuffer&&(n.vertexBuffer.destroy(),n.indexBuffer.destroy(),n.normalBuffer&&n.normalBuffer.destroy(),n.texcoordBuffer&&n.texcoordBuffer.destroy(),n.colorBuffer&&n.colorBuffer.destroy(),n.pbrBuffer&&n.pbrBuffer.destroy(),n.segments.destroy(),n.material&&((t=n.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));var t;if(e.children)for(const t of e.children)Bx(t)}class Fx{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class jx{constructor(){this.instancedDataArray=new Bl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Nx{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0}}populate(e,t,n,r){this.tileToMeter=If(n);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:a,index:s,sourceLayerIndex:l}of e){const e=Ff(o,i);if(!this.layers[0]._featureFilter.filter(new Ns(this.zoom),e,n))continue;const u={id:a,sourceLayerIndex:l,index:s,geometry:i?e.geometry:Bf(o,n,r),properties:o.properties,type:o.type,patterns:{}},c=this.addFeature(u,u.geometry,e);c&&t.featureIndex.insert(o,u.geometry,s,l,this.index,this.instancesPerModel[c].instancedDataArray.length)}this.lookup=null}update(e,t,n,r){for(const t in this.instancesPerModel){const n=this.instancesPerModel[t];for(const t in e)n.idToFeaturesIndex.hasOwnProperty(t)&&this.evaluate(n.features[n.idToFeaturesIndex[t]],e[t],n,!0)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const t in this.instancesPerModel){const n=this.instancesPerModel[t];for(const t of n.features){const r=this.layers[0],i=t.feature,o=this.canonical,a=r.paint.get("model-rotation").evaluate(i,{},o),s=r.paint.get("model-scale").evaluate(i,{},o),l=r.paint.get("model-translation").evaluate(i,{},o);id.exactEquals(t.rotation,a)&&id.exactEquals(t.scale,s)&&id.exactEquals(t.translation,l)||(this.evaluate(t,t.featureStates,n,!0),e=!0)}}return e}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const n=this.instancesPerModel[t];n.instancedDataArray.length<0||0===n.instancedDataArray.length||(n.instancedDataBuffer?n.instancedDataBuffer.updateData(n.instancedDataArray):n.instancedDataBuffer=e.createVertexBuffer(n.instancedDataArray,Wv.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}}addFeature(e,t,n){const r=this.layers[0],i=r.layout.get("model-id").evaluate(n,{},this.canonical);if(!i)return X(`modelId is not evaluated for layer ${r.id} and it is not going to get rendered.`),i;this.instancesPerModel[i]||(this.instancesPerModel[i]=new jx);const o=this.instancesPerModel[i],a=o.instancedDataArray,s=new Fx(n,a.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=hr||t.y<0||t.y>=hr)continue;const e=(this.lookupDim-1)/hr,n=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[n])continue;this.lookup[n]=1}this.instanceCount++;const r=a.length;a.resize(r+1),o.instancesEvaluatedElevation.push(0),a.float32[16*r]=t.x,a.float32[16*r+1]=t.y}return s.instancedDataCount=o.instancedDataArray.length-s.instancedDataOffset,s.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(s),this.evaluate(s,{},o,!1)),i}evaluate(e,t,n,r){const i=this.layers[0],o=e.feature,a=this.canonical,s=e.rotation=i.paint.get("model-rotation").evaluate(o,t,a),l=e.scale=i.paint.get("model-scale").evaluate(o,t,a),u=e.translation=i.paint.get("model-translation").evaluate(o,t,a),c=i.paint.get("model-color").evaluate(o,t,a);c.a=i.paint.get("model-color-mix-intensity").evaluate(o,t,a);const h=[];this.maxVerticalOffset10?this.tileToMeter:If(a,f)),s[o+4]=u[0],s[o+5]=u[1],s[o+6]=u[2]+l,s[o+7]=h[0],s[o+8]=h[1],s[o+9]=h[2],s[o+10]=h[4],s[o+11]=h[5],s[o+12]=h[6],s[o+13]=h[8],s[o+14]=h[9],s[o+15]=h[10],n.instancesEvaluatedElevation[i]=u[2]}}}xa(Nx,"ModelBucket",{omit:["layers"]}),xa(jx,"PerModelAttributes"),xa(Fx,"ModelFeature");const Ux=new Js({visibility:new Xs(Pt.layout_model.visibility),"model-id":new Ys(Pt.layout_model["model-id"])});var Vx={paint:new Js({"model-opacity":new Xs(Pt.paint_model["model-opacity"]),"model-rotation":new Ys(Pt.paint_model["model-rotation"]),"model-scale":new Ys(Pt.paint_model["model-scale"]),"model-translation":new Ys(Pt.paint_model["model-translation"]),"model-color":new Ys(Pt.paint_model["model-color"]),"model-color-mix-intensity":new Ys(Pt.paint_model["model-color-mix-intensity"]),"model-type":new Xs(Pt.paint_model["model-type"]),"model-cast-shadows":new Xs(Pt.paint_model["model-cast-shadows"]),"model-receive-shadows":new Xs(Pt.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new Xs(Pt.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Ys(Pt.paint_model["model-emissive-strength"]),"model-roughness":new Ys(Pt.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Ys(Pt.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new Xs(Pt.paint_model["model-cutoff-fade-range"])}),layout:Ux};const Gx=new Float32Array(262144),qx=new Uint8Array(262144);function Wx(e){let t=0;if(e.meshes)for(const n of e.meshes)t=Math.max(t,n.aabb.max[2]);if(e.children)for(const n of e.children)t=Math.max(t,Wx(n));return t}const Zx=["","wall","door","roof","window","lamp","logo"];class Hx{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:e.id,geometry:[],properties:{height:Wx(e)}}}}class $x{constructor(e,t,n,r){this.nodes=e,this.id=t,this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=4),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const n of t){const t=n.node;this.uploaded?this.updatePbrBuffer(t):Lx(t,e,!0)}for(const e of t)zx(e.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const n of e.meshes)n.pbrBuffer&&(n.pbrBuffer.updateData(n.featureArray),t=!0);return t}needsReEvaluation(e,t,n){const r=e.transform.projectionOptions,i=e.style.getBrightness(),o=this.brightness!==i;return!!(!this.uploaded||this.dirty||r.name!==this.projection.name||Xx(n.paint.get("model-color").value,o)||Xx(n.paint.get("model-color-mix-intensity").value,o)||Xx(n.paint.get("model-roughness").value,o)||Xx(n.paint.get("model-emissive-strength").value,o)||Xx(n.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=r,this.brightness=i,!0)}evaluateScale(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const n=this.getNodesInfo(),r=this.id.canonical;for(const e of n){const n=e.feature;e.evaluatedScale=t.paint.get("model-scale").evaluate(n,{},r)}}evaluate(e){const t=this.getNodesInfo();for(const n of t){if(!n.node.meshes)continue;const t=n.feature,r=n.node.meshes&&n.node.meshes[0].featureData,i=n.evaluatedColor[2],o=n.evaluatedRMEA[2],a=this.id.canonical;if(n.hasTranslucentParts=!1,r){for(let r=0;r=e)continue;const h=Gx[u],d=Math.abs(h);d>s&&(a=h,s=d,l=i,c=t)}if(s>.1){const o=1-(e+.5*Math.abs(l*c))/u;let s=t._dem.get(r,n)+a*o;const h=t._dem.get(r+l,n+c),d=t._dem.get(r-l,n-c,!0);(s-h)*(s-d)>0&&(s=(h+d)/2),Gx[i]=t._dem.set(r,n,s),qx[i]=e}}}}}a&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=ft.now())}getNodesInfo(){if(!this.nodesInfo){this.nodesInfo=[];for(const e of this.nodes)this.nodesInfo.push(new Hx(e));this.freeNodes()}return this.nodesInfo}freeNodes(){if(this.nodes){for(const e of this.nodes)Bx(e);this.nodes.splice(0,this.nodes.length)}}destroy(){this.freeNodes();const e=this.getNodesInfo();for(const t of e)zx(t.node),Bx(t.node)}isEmpty(){return!this.nodes.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped()),r=this.getNodesInfo();for(let e=0;ee.footprint===t.footprint)}}getHeightAtTileCoord(e,t){const n=this.getNodesInfo(),r=[];for(let i=0;ia.aabb.max[0]||t>a.aabb.max[1])continue;const s=(e-a.aabb.min[0])/(a.aabb.max[0]-a.aabb.min[0])*64|0,l=64*Math.min(63,(t-a.aabb.min[1])/(a.aabb.max[1]-a.aabb.min[1])*64|0)+Math.min(63,s);if(!(a.heightmap[l]<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return{height:a.heightmap[l],maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new v(e,t),new v(e,t),r),r.length>0)return{height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function Xx(e,t){return!e.isLightConstant&&t}function Yx(e,t,n,r,i,o,a,s){let l=(61440&t|(61440&t)>>4)>>8,u=(3840&t|(3840&t)>>4)>>4,c=240&t|(240&t)>>4;n[3]>0&&(l=Yr(l,255*n[0],n[3]),u=Yr(u,255*n[1],n[3]),c=Yr(c,255*n[2],n[3]));const h=l<<8|u,d=c<<8|Math.floor(255*r[3]),f=function(e){const t=O(e,0,2);return Math.min(Math.round(.5*t*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],p=O(i[0],0,1),m=O(i[1],0,1),_=O(i[2],0,1),g=O(i[3],0,1);let y,v,x,b;if(p!==m&&a!==o&&m!==p){const e=a-o;v=1/(e*(m-p)),x=-(o+e*p)/(e*(m-p));const t=O(i[4],-1,1);b=Math.pow(10,t),y=255*_<<8|255*g}else y=65535,v=0,x=1,b=1;if(e.emplaceBack(h,d,f,y,v,x,b),s){const e=s.length;s.clear();for(let t=0;t>16&65535,u=e.evaluatedRMEA[s],c=e.evaluatedColor[s],h=e.emissionHeightBasedParams[s];if(o&&2===s&&n.lights&&(r=new Fl,r.resize(10*n.lights.length)),Yx(i.featureArray,l,c,u,h,i.aabb.min[2],i.aabb.max[2],r),r&&o){o=!1;const e=n.meshes[n.lightMeshIndex];e.featureArray=r,e.featureArray._trim()}}i.featureArray._trim(),r++}}xa($x,"Tiled3dModelBucket",{omit:["layers"]}),xa(Hx,"Tiled3dModelFeature");class Jx{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[]}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e){const t=nb(new v(0,0),new v(hr,hr),e),n=[];for(const r of this._activeRegions){if(r.hiddenByOverlap)continue;if(!tb(t,r))continue;const i=rb(r.min,r.max,e);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[r.priority],footprint:r.footprint,footprintTileId:r.tileId})}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const n of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(n).buckets[e.layer];if(r)for(const e of r.getNodesInfo()){const r=e.node;r.footprint&&t.push({footprint:r.footprint,id:n.toUnwrapped()})}}return t}})))}_addSource(e){const t=e.getFootprints();if(0!==t.length){for(const e of t){if(!e.footprint)continue;const t=nb(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint})}this._sourceIds.push(e.getSourceId())}}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Qx(e.min,t.min)||Qx(e.max,t.max));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0,n=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],i=this._prevRegions[n];e=r.priority!==i.priority||!eb(r,i),++t,++n}}if(e){++this._updateTime;const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const n=t[e].priority;for(;e1){let t=0,n=e(t);for(;t!==n;){let r=t;const i=t;for(;r!==n;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement()}}function Qx(e,t){return e.x-t.x||e.y-t.y}function eb(e,t){return 0===Qx(e.min,t.min)&&0===Qx(e.max,t.max)}function tb(e,t){return!(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew v(e.x*o.x*hr*s-a.x*hr,e.y*o.y*hr*s-a.y*hr))}return ib(n,i,e.indices,0,e.indices.length,0,0)}const ab=km.types,sb=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius"],lb=["fill-extrusion-flood-light-ground-radius"],ub=Math.pow(2,13),cb=Math.pow(2,15)-1,hb=new v(0,1),db=2147483648;function fb(e,t,n,r,i,o,a,s){e.emplaceBack((t<<1)+a,(n<<1)+o,(Math.floor(r*ub)<<1)+i,Math.round(s))}function pb(e,t,n,r,i,o){e.emplaceBack(t.x,t.y,(n.x<<1)+r,(n.y<<1)+i,o)}function mb(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class _b{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class gb{constructor(){this.centroidXY=new v(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new v(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new v(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0}span(){return new v(this.max.x-this.min.x,this.max.y-this.min.y)}}class yb{constructor(){this.acc=new v(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y)}appendEdge(e,t,n){this.accCount++,this.acc._add(t);let r=!!this.borders;t.xe.max.x&&(e.max.x=t.x,r=!0),t.ye.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===hr)&&t.x===n.x)!=((0===t.y||t.y===hr)&&t.y===n.y)&&this.processBorderOverlap(t,n),r&&this.checkBorderIntersection(t,n)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Yr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>hr!=e.x>hr&&this.addBorderIntersection(1,Yr(t.y,e.y,(hr-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Yr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>hr!=e.y>hr&&this.addBorderIntersection(3,Yr(t.x,e.x,(hr-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(){return 0===this.accCount?new v(0,0):new v(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0):0}}function vb(e,t){const n=e.add(t)._unit(),r=O(e.x*n.x+e.y*n.y,-1,1);var i,o,a;return i=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(i)))/4*cb*((o=e).x*(a=t).y-o.y*a.x<0?-1:1)}const xb=[e=>e.x<0,e=>e.x>hr,e=>e.y<0,e=>e.y>hr];function bb(e,t,n,r){const i=[4];if(0===r)return i;n._mult(r);const o=e.sub(n),a=t.sub(n),s=[e,t,o,a];for(let e=0;e<4;e++)for(const t of s)if(xb[e](t)){i.push(e);break}return i}class wb{constructor(e){this.vertexArray=new fl,this.indexArray=new Al,this.programConfigurations=new Ru(e.layers,e.zoom,e=>lb.includes(e)),this._segments=new Ql,this.hiddenByLandmarkVertexArray=new jl,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Ql}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,n,r=!1){const i=e.length;if(i>2){let o=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let s;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],n=e[1];s=vb(t.sub(e[i-1])._perp()._unit(),n.sub(t)._perp()._unit())}for(let l=0;le.region-t.region);for(let n=0;ne+t,0);let o=0;for(let e=0;e<=4;e++){const t=i[e];if(0!==t){let n=this.regionSegments[e];n||(n=this.regionSegments[e]=new Ql);const i={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};n.get().push(i)}o+=t}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,pm.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy()}}}}class Tb{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.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Al,this.footprintVertices=new cl,this.footprintSegments=[],this.layoutVertexArray=new dl,this.centroidVertexArray=new Yl,this.indexArray=new Al,this.programConfigurations=new Ru(e.layers,e.zoom,e=>sb.includes(e)),this.segments=new Ql,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new wb(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}populate(e,t,n,r){this.features=[],this.hasPattern=am("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=If(n),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:i,id:o,index:a,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ff(i,e);if(!this.layers[0]._featureFilter.filter(new Ns(this.zoom),l,n))continue;const u={id:o,sourceLayerIndex:s,index:a,geometry:e?l.geometry:Bf(i,n,r),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length;this.hasPattern?this.features.push(sm("fill-extrusion",this.layers,u,this.zoom,t)):this.addFeature(u,u.geometry,a,n,{},t.availableImages,r,t.brightness),t.featureIndex.insert(i,u.geometry,a,s,this.index,c)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,n,r,i,o){for(const e of this.features){const{geometry:a}=e;this.addFeature(e,a,e.index,t,n,r,i,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,n,r,i){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const a=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,t,a,n,r,i),this.groundEffect.update(e,t,a,n,r,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,_m),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,mm.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,fm.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,n,r,i,o,a,s){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,u=[new v(0,0),new v(hr,hr)],c=a.projection,h="globe"===c.name,d="Polygon"===ab[e.type],f=new yb;f.centroidDataIndex=this.centroidData.length;const p=new gb,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},r);p.height=_,p.vertexArrayOffset=this.layoutVertexArray.length,p.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new yl);const g=im(t,500);for(let e=g.length-1;e>=0;e--){const t=g[e];(0===t.length||(y=t[0]).every(e=>e.x<=0)||y.every(e=>e.x>=hr)||y.every(e=>e.y<=0)||y.every(e=>e.y>=hr))&&g.splice(e,1)}var y;let x;if(h)x=Pb(g,u,r);else{x=[];for(const e of g)x.push({polygon:e,bounds:u})}const b=d?this.edgeRadius:0,w=b>0&&this.zoom<17,T=(e,t)=>{if(0===e.length)return!1;const n=e[e.length-1];return t.x===n.x&&t.y===n.y};for(const{polygon:e,bounds:t}of x){let n=0,i=0;for(const t of e)d&&!t[0].equals(t[t.length-1])&&t.push(t[0]),i+=d?t.length-1:t.length;const o=this.segments.prepareSegment((d?5:4)*i,this.layoutVertexArray,this.indexArray);p.footprintSegIdx<0&&(p.footprintSegIdx=this.footprintSegments.length),p.polygonSegIdx<0&&(p.polygonSegIdx=this.polygonSegments.length);const a={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},s=new _b;if(s.vertexOffset=this.footprintVertices.length,s.indexOffset=3*this.footprintIndices.length,s.ringIndices=[],d){const i=[],a=[];n=o.vertexLength;for(let n=0;n4&&Cb(a[a.length-2],a[0],a[1]),u=b?Eb(a[a.length-2],a[0],a[1],b):0;const _=[];let g,y,v;y=a[1].sub(a[0])._perp()._unit();let x=!0;for(let e=1,i=0;e0?1:0,A=l.dist(d);if(i+A>32768&&(i=0),b){v=w.sub(d)._perp()._unit();let e=Mb(l,d,w,Sb(y,v),b);isNaN(e)&&(e=0);const t=d.sub(l)._unit();l=l.add(t.mult(u))._round(),d=d.add(t.mult(-e))._round(),u=e,y=v,m&&this.zoom>=17&&(T(_,l)||_.push(l),T(_,d)||_.push(d))}const I=o.vertexLength,C=a.length>4&&Cb(l,d,w);let k=kb(i,s,x);if(fb(this.layoutVertexArray,l.x,l.y,E,M,0,0,k),fb(this.layoutVertexArray,l.x,l.y,E,M,0,1,k),i+=A,k=kb(i,C,!x),s=C,fb(this.layoutVertexArray,d.x,d.y,E,M,0,0,k),fb(this.layoutVertexArray,d.x,d.y,E,M,0,1,k),o.vertexLength+=4,this.indexArray.emplaceBack(I+0,I+1,I+2),this.indexArray.emplaceBack(I+1,I+3,I+2),o.primitiveLength+=2,b){const r=n+(1===e?a.length-2:e-2),i=1===e?n:r+1;if(this.indexArray.emplaceBack(I+1,r,I+3),this.indexArray.emplaceBack(r,i,I+3),o.primitiveLength+=2,void 0===g&&(g=I),!Ab(w,a[e],t)){const t=e===a.length-1?g:o.vertexLength;this.indexArray.emplaceBack(I+2,I+3,t),this.indexArray.emplaceBack(I+3,t+1,t),this.indexArray.emplaceBack(I+3,i,t+1),o.primitiveLength+=3}x=!x}if(h){const e=this.layoutVertexExtArray,t=c.projectTilePoint(l.x,l.y,r),n=c.projectTilePoint(d.x,d.y,r),i=c.upVector(r,l.x,l.y),o=c.upVector(r,d.x,d.y);mb(e,t,i),mb(e,t,i),mb(e,n,o),mb(e,n,o)}}d&&(n+=a.length-1),m&&b&&this.zoom>=17&&(0!==_.length&&T(_,_[0])&&_.pop(),this.groundEffect.addData(_,t,l,b>0))}this.footprintSegments.push(s),a.triangleCount=this.indexArray.length-a.triangleArrayOffset,this.polygonSegments.push(a),++p.footprintSegLen,++p.polygonSegLen}if(p.vertexCount=this.layoutVertexArray.length-p.vertexArrayOffset,p.groundVertexCount=this.groundEffect.vertexArray.length-p.groundVertexArrayOffset,0!==p.vertexCount){if(p.centroidXY=f.borders?hb:this.encodeCentroid(f,p),this.centroidData.push(p),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}splitToSubtiles(){const e=[];for(let t=0;thr),i=2*r+(+(n.min.x+n.max.x>hr)^r);for(let r=0;re.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let n=0,r=0,i=0;for(const t of e){if(t.triangleSegmentIdx!==n)break;i++}const o=e.length;for(;r!==e.length;){n=e[r].triangleSegmentIdx;let a=0,s=r,l=r;for(let t=s;t0&&this.triangleSubSegments.push({segment:c,min:o,max:u}),s=l;for(let t=s;t[e[0]*(1-n[0])+t[0]*n[0],e[1]*(1-n[1])+t[1]*n[1]],d=[],f=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/hr,d[1]=e.min.y/hr,f[0]=e.max.x/hr,f[1]=e.max.y/hr;const t=h(l,u,d),o=h(l,u,f);if(0===new Md([t[0],t[1],r],[o[0],o[1],i]).intersectsPrecise(n)){s&&(c.segments.push(s),s=void 0);continue}const a=e.segment;s&&s.vertexOffset!==a.vertexOffset&&(c.segments.push(s),s=void 0),s?(s.vertexLength+=a.vertexLength,s.primitiveLength+=a.primitiveLength):s={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return s&&c.segments.push(s),c}encodeCentroid(e,t){const n=e.centroid(),r=t.span(),i=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new v(O(n.x,1,8191)<<3|i,O(n.y,1,8191)<<3|o)}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=db,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,n=e.vertexCount+e.vertexArrayOffset,r=e.flags&db?hb:e.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||i!==r.x){for(let e=t;ei.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(s+o.vertexOffset)+0]-n)*(t-a)/(l-a)+n&&(r=!r)}a=n}}return r}getHeightAtTileCoord(e,t){let n=Number.NEGATIVE_INFINITY,r=!0;const i=4*(e+hr)*hr+(t+hr);if(this.partLookup.hasOwnProperty(i)){const e=this.partLookup[i];return e?{height:e.height,hidden:!!(e.flags&db)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||this.footprintContainsPoint(e,t,o)&&o&&o.height>n&&(n=o.height,this.partLookup[i]=o,r=!!(o.flags&db));if(n!==Number.NEGATIVE_INFINITY)return{height:n,hidden:r};this.partLookup[i]=void 0}}function Sb(e,t){const n=e.add(t)._unit();return e.x*n.x+e.y*n.y}function Eb(e,t,n,r){const i=t.sub(e)._perp()._unit(),o=n.sub(t)._perp()._unit();return Mb(e,t,n,Sb(i,o),r)}function Mb(e,t,n,r,i){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(n)/3,i*o/r)}function Ab(e,t,n){return e.xn[1].x&&t.x>n[1].x||e.yn[1].y&&t.y>n[1].y}function Ib(e,t){return e.xt[1].x||e.yt[1].y}function Cb(e,t,n){if(e.x<0||e.x>=hr||t.x<0||t.x>=hr||n.x<0||n.x>=hr)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 kb(e,t,n){const r=t?2|e:-3&e;return n?1|r:-2&r}function Ob(){const e=Math.PI/32,t=Math.tan(e),n=ff;return n*Math.sqrt(1+2*t*t)-n}function Pb(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=wf((n.y+t/hr)/r);return(vf(.5*(wf((n.y+i/hr)/r)+e))*r-n.y)*hr}})}function Rb(e,t,n,r,i,o){const a=Math.pow(2,r.z-i.z);for(let s=0;s{const s=e.transform,l=s.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Wb(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:Hb(n)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:qb(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:a,u_emissive_strength:n.paint.get("line-emissive-strength")}},Gb=(e,t,n,r,i)=>{const o=e.transform;return{u_matrix:Wb(e,t,n,r),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:qb(t,o),u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function qb(e,t){return 1/ox(e,1,t.tileZoom)}function Wb(e,t,n,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Zb=e=>{const t=[];Hb(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const n=e.paint.get("line-trim-offset");return 0===n[0]&&0===n[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER"),t};function Hb(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const $b=new class extends Ys{possiblyEvaluate(e,t){return t=new Ns(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)}}(Ub.paint.properties["line-width"].specification);function Xb(e,t){return t>0?t+2*e:e}$b.useIntegerZoom=!0;const Yb=new Js({visibility:new Xs(Pt.layout_background.visibility)});var Kb={paint:new Js({"background-color":new Xs(Pt.paint_background["background-color"]),"background-pattern":new Xs(Pt.paint_background["background-pattern"]),"background-opacity":new Xs(Pt.paint_background["background-opacity"]),"background-emissive-strength":new Xs(Pt.paint_background["background-emissive-strength"])}),layout:Yb};const Jb=new Js({visibility:new Xs(Pt.layout_raster.visibility)});var Qb={paint:new Js({"raster-opacity":new Xs(Pt.paint_raster["raster-opacity"]),"raster-color":new Ks(Pt.paint_raster["raster-color"]),"raster-color-mix":new Xs(Pt.paint_raster["raster-color-mix"]),"raster-color-range":new Xs(Pt.paint_raster["raster-color-range"]),"raster-hue-rotate":new Xs(Pt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Xs(Pt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Xs(Pt.paint_raster["raster-brightness-max"]),"raster-saturation":new Xs(Pt.paint_raster["raster-saturation"]),"raster-contrast":new Xs(Pt.paint_raster["raster-contrast"]),"raster-resampling":new Xs(Pt.paint_raster["raster-resampling"]),"raster-fade-duration":new Xs(Pt.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new Xs(Pt.paint_raster["raster-emissive-strength"]),"raster-array-band":new Xs(Pt.paint_raster["raster-array-band"]),"raster-elevation":new Xs(Pt.paint_raster["raster-elevation"])}),layout:Jb};function ew(e,t,n,r,i,o,a,s){const l=[e,n,i,t,r,o,1,1,1],u=[a,s,1],c=Yh.adjoint([],l),[h,d,f]=id.transformMat3(u,u,Yh.transpose(c,c));return Yh.multiply(l,[h,0,0,0,d,0,0,0,f],l)}class tw extends Ot{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.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new Ct("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ce(this.map._requestManager.transformRequest(this.url,ve.Image),(t,r)=>{if(this._imageRequest=null,this._loaded=!0,t)this.fire(new kt(t));else if(r){const{HTMLImageElement:t}=n;this.image=r instanceof t?ft.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading()}})}loaded(){return this._loaded}updateImage(e){return 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}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Dy(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Ct("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 instanceof Dy||this.texture.destroy()}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],n=e[0][1];for(const r of e)r[1]>n&&(n=r[1]),r[1]Sf?this.onNorthPole=!0:r<-Sf&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(Cf.fromLngLat);this.tileID=function(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x),i=Math.max(i,o.y);const o=Math.max(r-t,i-n),a=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),s=Math.pow(2,a);return new pd(a,Math.floor((t+r)/2*s),Math.floor((n+i)/2*s))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){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 t=jg(this.tileID,this.map.transform.projection),[n,r,i,o]=this.coordinates.map(e=>{const n=t.projection.project(e[0],e[1]);return Ug(t,n)._round()});this.perspectiveTransform=function(e,t,n,r,i,o,a,s,l,u){const c=ew(0,0,e,0,0,t,e,t),h=ew(n,r,i,o,a,s,l,u);return Yh.multiply(h,Yh.adjoint(c,c),h),[h[6]/h[8]*e/hr,h[7]/h[8]*t/hr]}(this.width,this.height,n.x,n.y,r.x,r.y,o.x,o.y,i.x,i.y);const a=this._boundsArray=new dl;a.emplaceBack(n.x,n.y,0,0),a.emplaceBack(r.x,r.y,hr,0),a.emplaceBack(o.x,o.y,0,hr),a.emplaceBack(i.x,i.y,hr,hr),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,Ny.members),this.boundsSegments=Ql.simpleSegment(0,0,4,2)}prepare(){const e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;const t=this.map.painter.context,n=t.gl;!this._dirty||this.texture instanceof Dy||(this.texture?this.texture.update(this.image):(this.texture=new Ry(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this._dirty=!1),e&&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}}class nw extends rl{constructor(e){super(e,{}),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(e){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)}}const rw=new Js({visibility:new Xs(Pt.layout_sky.visibility)});var iw={paint:new Js({"sky-type":new Xs(Pt.paint_sky["sky-type"]),"sky-atmosphere-sun":new Xs(Pt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Xs(Pt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Xs(Pt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Xs(Pt.paint_sky["sky-gradient-radius"]),"sky-gradient":new Ks(Pt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Xs(Pt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Xs(Pt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Xs(Pt.paint_sky["sky-opacity"])}),layout:rw};function ow(e,t,n){const r=[0,0,1],i=ed.identity([]);return ed.rotateY(i,i,n?-T(e)+Math.PI:T(e)),ed.rotateX(i,i,-T(t)),id.transformQuat(r,r,i),id.normalize(r,r)}var aw={paint:new Js({})};const sw={circle:class extends rl{constructor(e,t){super(e,sp,t)}createBucket(e){return new Uf(e)}queryRadius(e){const t=e;return np("circle-radius",this,t)+np("circle-stroke-width",this,t)+rp(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=op(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 hp(e,r,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return["circle"]}getDefaultProgramParams(e,t){const n=cp(this);return{config:new Pu(this,t),defines:n,overrideFog:!1}}},heatmap:class extends rl{createBucket(e){return new _p(e)}constructor(e,t){super(e,Sp,t),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Ep({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 np("heatmap-radius",this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=this.paint.get("heatmap-radius").evaluate(t,n);return hp(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"]}getDefaultProgramParams(e,t){return"heatmap"===e?{config:new Pu(this,t),overrideFog:!1}:{}}},hillshade:class extends rl{constructor(e,t){super(e,Ap,t)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t){return{overrideFog:!1}}},fill:class extends rl{constructor(e,t){super(e,cm,t)}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}getDefaultProgramParams(e,t){return{config:new Pu(this,t),overrideFog:!1}}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 lm(e)}queryRadius(){return rp(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,n,r,i,o){return!e.queryGeometry.isAboveHorizon&&qf(ip(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 rl{constructor(e,t){super(e,Lb,t),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new Tb(e)}queryRadius(){return rp(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}hasShadowPass(){return!0}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,n,r,i,o,a,s,l){const u=op(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 Tb){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=Ob();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=jb(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),id.transformMat4(p,p,o),id.transformMat4(m,m,o),t.push(new zb(p[0],p[1],p[2])),y.push(new zb(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=jb(c,d,t,n,o,a,s,l);h[0]=c,h[1]=d,h[2]=p.base,h[3]=1,qh.transformMat4(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new zb(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,qh.transformMat4(h,h,i),h[3]=Math.max(h[3],1e-5);const _=new zb(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),T=m+h,S=_+d,E=g+f,M=Math.max(y+p,1e-5);e.push(new zb(v/w,x/w,b/w)),n.push(new zb(T/M,S/M,E/M))}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;qf(n,t)&&(r=Fb(n,t[0]));for(let i=0;i=3)for(let t=0;t=0)r=t;else{const i=e.points[n-4];r=Kr(i,t,i[2]/(i[2]-t[2]))}if(yw(this.state,r[0],r[1],0,this._transform)>=mw)return!0}return!1}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,n){return(!n||!1!==n.validate)&&ma(this,e.call(ra,z({value:t,style:{glyphs:!0,sprite:!0},styleSpec:Pt})))}}class ww{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Tw{constructor(){this.tasks={},this.taskQueue=[],G(["process"],this),this.invoker=new ww(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){ee();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(){ee();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{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||ee()){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(Sa(t.error)):n(null,Sa(t.data)))}else{const n=new Set,r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Ta(t):null,data:Ta(r,n)},n)}:e=>{},i=Sa(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,i.scope)[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)}}class Ew{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=j();const n=this.workerPool.acquire(this.id);for(let e=0;e{this.ready=!0})}broadcast(e,t,n){D(this.actors,(n,r)=>{n.send(e,t,r)},n=n||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)}}Ew.Actor=Sw;class Mw extends Ot{constructor(e,t,n,r){super(),this.scope=n,this._options=e,this.properties=new $s(t),this._transitionable=new Gs(t,new Map(r)),this._transitionable.setTransitionOrValue(e.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}const Aw=new Js({color:new Xs(Pt.properties_light_ambient.color),intensity:new Xs(Pt.properties_light_ambient.intensity)}),Iw=new Js({direction:new class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const n=J([1,e,t]);return{x:n.x,y:n.y,z:n.z}}(e.expression.evaluate(t))}interpolate(e,t,n){return{x:Yr(e.x,t.x,n),y:Yr(e.y,t.y,n),z:Yr(e.z,t.z,n)}}}(Pt.properties_light_directional.direction),color:new Xs(Pt.properties_light_directional.color),intensity:new Xs(Pt.properties_light_directional.intensity),"cast-shadows":new Xs(Pt.properties_light_directional["cast-shadows"]),"shadow-intensity":new Xs(Pt.properties_light_directional["shadow-intensity"])});class Cw{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(e,t){let n,r;if(e instanceof v||"number"==typeof e[0]){const i=v.convert(e);n=[i],r=t.isPointAboveHorizon(i)}else{const i=v.convert(e[0]),o=v.convert(e[1]);n=[i,o],r=I(i,o).every(e=>t.isPointAboveHorizon(e))}return new Cw(n,t.getCameraPoint(),r,t)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return I(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const t=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new v(1,1)):this.screenBounds[1],r=I(t,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>t.x&&this.cameraPoint.x=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=t.x&&(r[3]=this.cameraPoint)),function(e,t){const n=[];for(let r=0;rt.y)+(i.y>n.y))+((i.x>t.x)+(i.x>n.x))){case 0:r[0]=i,r[4]=i.clone();break;case 1:r.splice(1,0,i);break;case 2:r[1]=i;break;case 3:r.splice(4,0,i);break;case 5:r.splice(2,0,i);break;case 6:r[3]=i;break;case 7:r.splice(3,0,i);break;case 8:r[2]=i}return r}containsTile(e,t,n,r=0){const i=e.queryPadding/t._pixelsPerMercatorPixel+1,o=n?this._bufferedCameraMercator(i,t):this._bufferedScreenMercator(i,t);let a=e.tileID.wrap+(o.unwrapped?r:0);const s=o.polygon.map(t=>Ug(e.tileTransform,t,a));if(!Jf(s,0,0,hr,hr))return;a=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const l=this.screenGeometryMercator.polygon.map(t=>Vg(e.tileTransform,t,a)),u=l.map(e=>new v(e[0],e[1])),c=t.getFreeCameraOptions().position||new Cf(0,0,0),h=Vg(e.tileTransform,c,a),d=l.map(e=>{const t=id.sub(e,e,h);return id.normalize(t,t),new vd(h,t)}),f=ox(e,1,t.zoom)*t._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:d,bufferedTilespaceGeometry:s,bufferedTilespaceBounds:(p=A(s),p.min.x=O(p.min.x,0,hr),p.min.y=O(p.min.y,0,hr),p.max.x=O(p.max.x,0,hr),p.max.y=O(p.max.y,0,hr),p),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:f};var p}_bufferedScreenMercator(e,t){const n=Pw(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=Pw(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(e,t){const n=function(e,t){const n=Jh.multiply([],t.pixelMatrix,t.globeMatrix),r=[0,-Ad,0,1],i=[0,Ad,0,1],o=[0,0,0,1];qh.transformMat4(r,r,n),qh.transformMat4(i,i,n),qh.transformMat4(o,o,n);const a=new v(r[0]/r[3],r[1]/r[3]),s=new v(i[0]/i[3],i[1]/i[3]),l=Kf(e,a)&&r[3]1?kw(e.slice(0,h),t):[],p=hnew v(Ow(e.x),e.y)),p=p.map(e=>new v(Ow(e.x),e.y));const m=[...f];0===m.length&&m.push(p[p.length-1]);const _=Yr(m[m.length-1].y,(0===p.length?f[0]:p[0]).y,d);let g;return g=l?[new v(0,_),new v(0,0),new v(1,0),new v(1,_)]:[new v(1,_),new v(1,1),new v(0,1),new v(0,_)],m.push(...g),0===p.length?m.push(f[0]):m.push(...p),{polygon:m.map(e=>new Cf(e.x,e.y)),unwrapped:!1}}(e,t);if(n)return n;const r=function(e,t){let n=!1,r=-1/0,i=0;for(let t=0;tr&&(r=e[t].x,i=t);for(let t=0;t.5&&(o.x{e.x-=1}),{polygon:e,unwrapped:n}}(kw(e,t).map(e=>new v(Ow(e.x),e.y)),t);return{polygon:r.polygon.map(e=>new Cf(e.x,e.y)),unwrapped:r.unwrapped}}}function kw(e,t){return Of(e,e=>{const n=t.pointCoordinate3D(e);e.x=n.x,e.y=n.y},1/256)}function Ow(e){return e<0?1+e%1:e%1}function Pw(e){return 100*e|0}function Rw(e,t,n,r,i){const o=function(n,r){if(n)return i(n);if(r){e.url&&r.tiles&&e.tiles&&delete e.tiles;const n=B(z(r,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(n.vectorLayers=r.vector_layers,n.vectorLayerIds=n.vectorLayers.map(e=>e.id)),n.tiles=t.canonicalizeTileset(n,e.url),i(null,n)}};return e.url?Te(t.transformRequest(t.normalizeSourceURL(e.url,null,n,r),ve.Source),o):ft.frame(()=>o(null,e))}class Dw{constructor(e,t,n){this.bounds=ju.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=n||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(e){const t=Math.pow(2,e.z),n=Math.floor(yf(this.bounds.getWest())*t),r=Math.floor(vf(this.bounds.getNorth())*t),i=Math.ceil(yf(this.bounds.getEast())*t),o=Math.ceil(vf(this.bounds.getSouth())*t);return e.x>=n&&e.x=r&&e.y1&&(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 X("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t=t.maxzoom||"none"!==t.visibility&&(Fw(e,this.zoom,u.brightness,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:d,sourceID:this.source,projection:this.projection.spec})).populate(f,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 this.status="done",i(h);if(this.extraShadowCaster)this.status="done",i(null,{buckets:L(s).filter(e=>!e.isEmpty()),featureIndex:a,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:u.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(d&&f&&p){const e=new zw(d),t=new hg(f,p);for(const r in s){const i=s[r];i instanceof Ey?(Fw(i.layers,this.zoom,u.brightness,n),Ig(i,d,e.positions,f,t.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):i.hasPattern&&(i instanceof Py||i instanceof lm||i instanceof Tb)&&(Fw(i.layers,this.zoom,u.brightness,n),i.addFeatures(u,this.tileID.canonical,t.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",i(null,{buckets:L(s).filter(e=>!e.isEmpty()),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,brightness:u.brightness})}};if(!this.extraShadowCaster){const e=W(u.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},(e,t)=>{h||(h=e,d=t,_())},void 0,!1,m):d={};const t=Object.keys(u.iconDependencies);t.length?r.send("getImages",{icons:t,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(e,t)=>{h||(h=e,f=t,_())},void 0,!1,m):f={};const n=Object.keys(u.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(e,t)=>{h||(h=e,p=t,_())},void 0,!1,m):p={}}_()}}function Fw(e,t,n,r){const i=new Ns(t,{brightness:n});for(const t of e)t.recalculate(i,r)}class jw{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 Nw(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=Se(e.request,(e,r,i,o)=>{e?t(e):r&&t(null,{vectorTile:n?void 0:new Cm(new e_(r)),rawData:r,cacheControl:i,expires:o})});return()=>{r.cancel(),t()}},t)}class Uw extends Ot{constructor(e,t,n,r){if(super(),this.id=e,this.dispatcher=n,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,z(this,B(t,["url","scheme","tileSize","promoteId"])),this._options=z({type:"vector"},t),this._collectResourceTiming=!!t.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new jw}load(e){this._loaded=!1,this.fire(new Ct("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map._worldview;this._tileJSONRequest=Rw(this._options,this.map._requestManager,t,n,(r,i)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: "+t),n&&2!==n.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: "+n),this.fire(new kt(r))):i&&(z(this,i),i.bounds&&(this.tileBounds=new Dw(i.bounds,this.minzoom,this.maxzoom)),qe(i.tiles,this.map._requestManager._customAccessToken),this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=el(this.id,this.scope);this.load(()=>this.map.style.clearSource(e))}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 z({},this._options)}loadTile(e,t){const n=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,ve.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:ft.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:e.isExtraShadowCaster};if(r.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=t:e.request=e.actor.send("reloadTile",r,i.bind(this));else if(e.actor=this._tileWorkers[n]=this._tileWorkers[n]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",r,i.bind(this),void 0,!0);else{const t=Nw.call({deduped:this._deduped},r,(t,n)=>{t||!n?i.call(this,t):(r.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},e.actor&&e.actor.send("loadTile",r,i.bind(this),void 0,!0))},!0);e.request={cancel:t}}function i(n,r){return delete e.request,e.aborted?t(null):n&&404!==n.status?t(n):(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),ye(this.dispatcher),t(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.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,scope:this.scope})}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Vw extends Ot{constructor(e,t,n,r){super(),this.id=e,this.dispatcher=n,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=z({type:"raster"},t),z(this,B(t,["url","scheme","tileSize"]))}load(e){this._loaded=!1,this.fire(new Ct("dataloading",{dataType:"source"})),this._tileJSONRequest=Rw(this._options,this.map._requestManager,null,null,(t,n)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new kt(t)):n&&(z(this,n),n.bounds&&(this.tileBounds=new Dw(n.bounds,this.minzoom,this.maxzoom)),qe(n.tiles),this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))),e&&e(t)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=el(this.id,this.scope);this.load(()=>this.map.style.clearSource(e))}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 z({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const n=ft.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);e.request=Ce(this.map._requestManager.transformRequest(r,ve.Tile),(n,r,i,o)=>(delete e.request,e.aborted?(e.state="unloaded",t(null)):n?(e.state="errored",t(n)):r?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:i,expires:o}),e.setTexture(r,this.map.painter),e.state="loaded",ye(this.dispatcher),void t(null)):t(null)))}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&e.texture instanceof Ry?(e.destroy(!0),e.texture&&e.texture instanceof Ry&&this.map.painter.saveTileTexture(e.texture)):e.destroy(),t()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Gw(){return null!=xI.workerClass?new xI.workerClass:new n.Worker(xI.workerUrl)}const qw="mapboxgl_preloaded_worker_pool";class Ww{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[qw]}numActive(){return Object.keys(this.active).length}}let Zw;function Hw(){return Zw||(Zw=new Ww),Zw}Ww.workerCount=2;let $w,Xw,Yw,Kw=null;function Jw(){return ee()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:Xw||o.DRACO_URL}const Qw={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},eT={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},tT={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function nT(e,t,n){const r=n.json.bufferViews.length,i=n.buffers.length;t.bufferView=r,n.json.bufferViews[r]={buffer:i,byteLength:e.byteLength},n.buffers[i]=e}const rT="KHR_draco_mesh_compression";function iT(e,t){const n=e.extensions&&e.extensions[rT];if(!n)return;const r=new Yw.Decoder,i=uT(t,n.bufferView),o=new Yw.Mesh;if(!r.DecodeArrayToMesh(i,i.byteLength,o))throw new Error("Failed to decode Draco mesh");const a=t.json.accessors[e.indices],s=Qw[a.componentType],l=a.count*s.BYTES_PER_ELEMENT,u=Yw._malloc(l);s===Uint16Array?r.GetTrianglesUInt16Array(o,l,u):r.GetTrianglesUInt32Array(o,l,u),nT(Yw.memory.buffer.slice(u,u+l),a,t),Yw._free(u);for(const i of Object.keys(n.attributes)){const a=r.GetAttributeByUniqueId(o,n.attributes[i]),s=t.json.accessors[e.attributes[i]],l=eT[s.componentType],u=s.count*tT[s.type]*Qw[s.componentType].BYTES_PER_ELEMENT,c=Yw._malloc(u);r.GetAttributeDataArrayForAllPoints(o,a,Yw[l],u,c),nT(Yw.memory.buffer.slice(c,c+u),s,t),Yw._free(c)}r.destroy(),o.destroy(),delete e.extensions[rT]}const oT=1179937895,aT=new TextDecoder("utf8");function sT(e,t){return new URL(e,t).href}function lT(e,t,n,r){return fetch(sT(e.uri,r)).then(e=>e.arrayBuffer()).then(e=>{t.buffers[n]=e})}function uT(e,t){const n=e.json.bufferViews[t];return new Uint8Array(e.buffers[n.buffer],n.byteOffset||0,n.byteLength)}function cT(e,t,r,i){if(e.uri){const o=sT(e.uri,i);return fetch(o).then(e=>e.blob()).then(e=>n.createImageBitmap(e)).then(e=>{t.images[r]=e})}if(void 0!==e.bufferView){const i=uT(t,e.bufferView),o=new n.Blob([i],{type:e.mimeType});return n.createImageBitmap(o).then(e=>{t.images[r]=e})}}function hT(e,t=0,n){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===oT){const n=new Uint32Array(e,t);let i=2;const o=(n[i++]>>2)-3,a=n[i++]>>2;if(i++,r.json=JSON.parse(aT.decode(n.subarray(i,i+a))),i+=a,i{const e=[],t=s&&s.includes(rT);if(t&&e.push(function(){if(!Yw)return $w||($w=function(e){let t,n=null;function r(){t=new Uint8Array(n.buffer)}function i(){throw new Error("Unexpected Draco error.")}const o={a:{a:i,d:function(e,n,r){return t.copyWithin(e,n,n+r)},c:function(e){const i=t.length,o=Math.max(e>>>0,Math.ceil(1.2*i)),a=Math.ceil((o-i)/65536);try{return n.grow(a),r(),!0}catch(e){return!1}},b:i}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,o))).then(e=>{const{Rb:i,Qb:o,P:a,T:s,X:l,Ja:u,La:c,Qa:h,Va:d,Wa:f,eb:p,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=e.instance.exports;n=g;const S=(()=>{let e=0,n=0,r=0,a=0;return s=>{r&&(i(a),i(e),n+=r,r=e=0),e||(n+=128,e=o(n));const l=s.length+7&-8;let u=e;l>=n&&(r=l,u=a=o(l));for(let e=0;e{Yw=e,$w=void 0}))}()),o)for(let t=0;t{if(t&&a)for(const{primitives:e}of a)for(const t of e)iT(t,r);return r})})}function dT(e){return fetch(e).then(e=>e.arrayBuffer()).then(t=>hT(t,0,e))}class fT{constructor(e,t,n){if(this.triangleCount=t.length/3,this.min=new v(0,0),this.max=new v(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length||0===n)return;const r=e.map(e=>e.x),i=e.map(e=>e.y);this.min=new v(Math.min(...r),Math.min(...i)),this.max=new v(Math.max(...r),Math.max(...i));const o=this.max.sub(this.min);o.x=Math.max(o.x,1),o.y=Math.max(o.y,1);const a=Math.max(o.x,o.y)/n;this.cellsX=Math.max(1,Math.ceil(o.x/a)),this.cellsY=Math.max(1,Math.ceil(o.y/a)),this.xScale=1/a,this.yScale=1/a;const s=[];for(let n=0;ne.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let l=0;for(;lthis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let e=0;e0){for(let i=0;i0){o.texcoordArray=new zl;const e=t.json.accessors[i.TEXCOORD_0];o.texcoordArray.reserve(e.count);const n=mT(t,e);for(let t=0;t1&&r[r.length-1].equals(r[0])&&r.pop();let i=0;for(let e=0;e0&&r.reverse();const o=rm(r.flatMap(e=>[e.x,e.y]),[]);return 0===o.length?null:{vertices:r,indices:o}}function xT(e){const t=[],n=[];let r=0;for(const i of e){r=t.length;const e=i.vertexArray.float32,o=i.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]])}return{vertices:t,indices:n}}function bT(e){const t=function(e,t){const n=[];for(const r of e.json.meshes){const i=[];for(const n of r.primitives)i.push(_T(n,e,t));n.push(i)}return n}(e,function(e,t){const r=[],i=n.WebGL2RenderingContext;if(e.json.textures)for(const n of e.json.textures){const o={magFilter:i.LINEAR,minFilter:i.NEAREST,wrapS:i.REPEAT,wrapT:i.REPEAT};void 0!==n.sampler&&Object.assign(o,e.json.samplers[n.sampler]),r.push({image:t[n.source],sampler:o,uploaded:!1})}return r}(e,e.images)),{scenes:r,scene:i,nodes:o}=e.json,a=r?r[i||0].nodes:o,s=[];for(const n of a)s.push(gT(o[n],e,t));return function(e,t,n){const r={},i=new Set;for(let o=0;o0){const t=Array.from(i.values()).sort((e,t)=>e-t);for(let n=t.length-1;n>=0;n--)e.splice(t[n],1)}}(s,a,e.json.nodes),s}function wT(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,n=e.aabb.min[0]-1,r=e.aabb.min[1]-1,i=64/(e.aabb.max[0]-n+2),o=64/(e.aabb.max[1]-r+2);for(let a=0;ae.heightmap[64*u+l]&&(e.heightmap[64*u+l]=s)}}function TT(e,t){const n={};n.indexArray=new Al,n.indexArray.reserve(4*e.length),n.vertexArray=new Ll,n.vertexArray.reserve(10*e.length),n.colorArray=new ml,n.vertexArray.reserve(10*e.length);let r=0;for(const i of e){const e=Math.min(10,Math.max(4,1.3*i.height))*t,o=[-i.normal[1],i.normal[0],0],a=Math.min(.29,.1*i.width/i.depth),s=i.width-2*i.depth*t*(a+.01),l=id.scaleAndAdd([],i.pos,o,s/2),u=id.scaleAndAdd([],i.pos,o,-s/2),c=[l[0],l[1],l[2]+i.height],h=[u[0],u[1],u[2]+i.height],d=id.scaleAndAdd([],i.normal,o,a);id.scale(d,d,e);const f=id.scaleAndAdd([],i.normal,o,-a);id.scale(f,f,e),id.add(d,l,d),id.add(f,u,f),l[2]+=.1,u[2]+=.1,n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(l[0],l[1],l[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(l[0],l[1],l[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const p=s/e/2;n.colorArray.emplaceBack(-p-a,-1,p,.8),n.colorArray.emplaceBack(p+a,-1,p,.8),n.colorArray.emplaceBack(-p,0,p,1.3),n.colorArray.emplaceBack(p,0,p,1.3),n.colorArray.emplaceBack(p+a,-.8,p,.7),n.colorArray.emplaceBack(p+a,-.8,p,.7),n.colorArray.emplaceBack(0,0,p,1.3),n.colorArray.emplaceBack(0,0,p,1.3),n.colorArray.emplaceBack(p+a,-1.2,p,.8),n.colorArray.emplaceBack(p+a,-1.2,p,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const i={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=dn.white,i.pbrMetallicRoughness=o,n.material=i,n.aabb=new Md([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}xa(fT,"TriangleGridIndex");const ST={vector:Uw,raster:Vw,"raster-dem":class extends Vw{constructor(e,t,n,r){super(e,t,n,r),this.type="raster-dem",this.maxzoom=22,this._options=z({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTile(e,t){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(n,r){n&&(e.state="errored",t(n)),r&&(e.dem=r,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",t(null))}e.request=Ce(this.map._requestManager.transformRequest(r,ve.Tile),function(r,o,a,s){if(delete e.request,e.aborted)e.state="unloaded",t(null);else if(r)e.state="errored",t(r);else if(o){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:a,expires:s});const t=n.ImageBitmap&&o instanceof n.ImageBitmap&&dt(),r=1-(o.width-((l=o.width)<=1?1:Math.pow(2,Math.floor(Math.log(l)/Math.LN2))))/2;r<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const u=t?o:ft.getImageData(o,r),c={uid:e.uid,coord:e.tileID,source:this.id,scope:this.scope,rawImageData:u,encoding:this.encoding,padding:r};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",c,i.bind(this),void 0,!0))}var l}.bind(this))}_getNeighboringTiles(e){const t=e.canonical,n=Math.pow(2,t.z),r=(t.x-1+n)%n,i=0===t.x?e.wrap-1:e.wrap,o=(t.x+1+n)%n,a=t.x+1===n?e.wrap+1:e.wrap,s={};return s[new _d(e.overscaledZ,i,t.z,r,t.y).key]={backfilled:!1},s[new _d(e.overscaledZ,a,t.z,o,t.y).key]={backfilled:!1},t.y>0&&(s[new _d(e.overscaledZ,i,t.z,r,t.y-1).key]={backfilled:!1},s[new _d(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},s[new _d(e.overscaledZ,a,t.z,o,t.y-1).key]={backfilled:!1}),t.y+1{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new kt(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&t&&t.resourceTiming&&t.resourceTiming[this.id]&&(e.resourceTiming=t.resourceTiming[this.id]),this.fire(new Ct("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(e,t){const n=e.actor?"reloadTile":"loadTile";e.actor=this.actor;const r={type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:ft.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};e.request=this.actor.send(n,r,(r,i)=>(delete e.request,e.destroy(),e.aborted?t(null):r?t(r):(e.loadVectorData(i,this.map.painter,"reloadTile"===n),t(null))),void 0,"loadTile"===n)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return z({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends tw{constructor(e,t,n,r){super(e,t,n,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,ve.Source).url);!function(e,t){const r=n.document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(let t=0;t{this._loaded=!0,e?this.fire(new kt(e)):t&&(this.video=t,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const t=this.video.seekable;et.end(0)?this.fire(new kt(new Rt("sources."+this.id,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}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 e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new Ry(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:tw,model:class extends Ot{constructor(e,t,n,r){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t}load(){const e=[];for(const t in this._options.models){const n=this._options.models[t],r=dT(this.map._requestManager.transformRequest(n.uri,ve.Model).url).then(e=>{if(!e)return;const r=bT(e),i=new Px(t,n.position,n.orientation,r);i.computeBoundsAndApplyParent(),this.models.push(i)}).catch(e=>{this.fire(new kt(new Error(`Could not load model ${t} from ${n.uri}: ${e.message}`)))});e.push(r)}return Promise.allSettled(e).then(()=>{this._loaded=!0,this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(e=>{this.fire(new kt(new Error("Could not load models: "+e.message)))})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return{type:"model"}}},"batched-model":class extends Ot{constructor(e,t,n,r){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=n,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(r)}onAdd(e){this.map=e,this.load()}load(e){this._loaded=!1,this.fire(new Ct("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map._worldview;this._tileJSONRequest=Rw(this._options,this.map._requestManager,t,n,(r,i)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: "+t),n&&2!==n.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: "+n),this.fire(new kt(r))):i&&(z(this,i),i.bounds&&(this.tileBounds=new Dw(i.bounds,this.minzoom,this.maxzoom)),qe(i.tiles,this.map._requestManager._customAccessToken),this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)})}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(e,t){const n=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,ve.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(e.actor&&"expired"!==e.state)if("loading"===e.state)e.reloadCallback=t;else{if(e.buckets){const t=Object.values(e.buckets);for(const e of t)e.dirty=!0;return void(e.state="loaded")}e.request=e.actor.send("reloadTile",r,i.bind(this))}else e.actor=this.dispatcher.getActor(),e.request=e.actor.send("loadTile",r,i.bind(this),void 0,!0);function i(n,r){return e.aborted?t(null):n&&404!==n.status?t(n):(r&&(r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&e.setExpiryData(r),e.buckets={...e.buckets,...r.buckets}),e.state="loaded",void t(null))}}serialize(){return z({},this._options)}},canvas:class extends tw{constructor(e,t,r,i){super(e,t,r,i),t.coordinates?Array.isArray(t.coordinates)&&4===t.coordinates.length&&!t.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new kt(new Rt("sources."+e,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new kt(new Rt("sources."+e,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new kt(new Rt("sources."+e,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"==typeof t.canvas||t.canvas instanceof n.HTMLCanvasElement||this.fire(new kt(new Rt("sources."+e,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new kt(new Rt("sources."+e,null,'missing required property "canvas"'))),this.options=t,this.animate=void 0===t.animate||t.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof n.HTMLCanvasElement?this.options.canvas:n.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new kt(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 e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const t=this.map.painter.context;this.texture?!e&&!this._playing||this.texture instanceof Dy||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Ry(t,this.canvas,t.gl.RGBA,{premultiply:!0}),this._prepareData(t)}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 Ot{constructor(e,t,n,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=n,this._implementation=t,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new kt(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new kt(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Dw(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.clearTiles=this._clearTiles.bind(this),t.coveringTiles=this._coveringTiles.bind(this),z(this,B(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return B(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new Ct("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),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(e,t){const{x:r,y:i,z:o}=e.tileID.canonical,a=new n.AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:o},{signal:a.signal})).then(function(r){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===r?(e.state="errored",t(null)):null===r?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof n.ImageData||e instanceof n.HTMLCanvasElement||e instanceof n.ImageBitmap||e instanceof n.HTMLImageElement}(r)?(this.loadTileData(e,r),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(n=>{20!==n.code&&(e.state="errored",t(n))}),e.request.cancel=()=>a.abort()}loadTileData(e,t){e.setTexture(t,this._map.painter)}unloadTile(e,t){if(e.texture&&e.texture instanceof Ry?(e.destroy(!0),e.texture&&e.texture instanceof Ry&&this._map.painter.saveTileTexture(e.texture)):e.destroy(),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(){const e=el(this.id,this.scope);this._map.style.clearSource(e)}_update(){this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))}}},ET=function(e,t,n,r){const i=new ST[t.type](e,t,n,r);if(i.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${i.id}`);return G(["load","abort","unload","serialize","prepare"],i),i};function MT(e,t){const n=Jh.identity([]);return Jh.scale(n,n,[.5*e.width,.5*-e.height,1]),Jh.translate(n,n,[1,-1,0]),Jh.multiply(n,n,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(n)}function AT(e,t,n,r,i,o,a,s=!1){const l=e.tilesIn(r,a,s);l.sort(CT);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,MT(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&&"slot"!==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 IT(e,t){const n=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],i={};for(let e=0;e0?n.paint.get("fill-extrusion-vertical-scale"):0);let o=r?r.getTile(t):null;if(!o&&r&&t.canonical.z>r.getSource().minzoom){let e=t.scaledTo(Math.min(r.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=r.getSource().minzoom&&(o=r.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:o?o.getBucket(n):null,tileID:o?o.tileID:t,verticalScale:i})}e.hasAnyZOffset=!1;let n=!1;for(let r=0;r{e in t&&(n[e]=t[e])}),n}function RT(e){e=e.slice();const t=Object.create(null);for(let n=0;n0?(r-o)/a:0;return this.points[i].mult(1-s).add(this.points[t].mult(s))}}class GT{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 qT=100;class WT{constructor(e,t,n=new GT(e.width+200,e.height+200,25),r=new GT(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+qT,this.screenBottomBoundary=e.height+qT,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(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=[],_=this.transform.elevation,g=e.getProjection(),y=_?_.getAtTileOffsetFunc(p,this.transform.center.lat,this.transform.worldSize,g):null,x=new v(n.tileAnchorX,n.tileAnchorY);let{x:b,y:w,z:T}=g.projectTilePoint(x.x,x.y,p.canonical);if(y){const[e,t,n]=y(x);b+=e,w+=t,T+=n}const S="globe"===g.name,E=this.projectAndGetPerspectiveRatio(a,b,w,T,p,S||!!_||this.transform.pitch>0,g),{perspectiveRatio:M}=E,A=(c?o/M:o*M)/24,I=fx(b,w,T,s),C=E.signedDistanceFromCamera>0?gx(A,i,n.lineOffsetX*A,n.lineOffsetY*A,!1,I,x,n,r,s,{},_&&!c?y:null,c&&!!_,g,p,c):null;let k=!1,O=!1,P=!0;if(C&&!E.occluded){const e=.5*d*M+f,n=new v(-100,-100),r=new v(this.screenRightBoundary,this.screenBottomBoundary),i=new VT,{first:o,last:a}=C,s=o.path.length;let c=[];for(let e=s-1;e>=1;e--)c.push(o.path[e]);for(let e=1;e(y&&!S&&(n=y(re[3]<=0)&&(c=[]));let _=[];if(c.length>0){let e=1/0,t=-1/0,i=1/0,o=-1/0;for(const n of c)e=Math.min(e,n[0]),i=Math.min(i,n[1]),t=Math.max(t,n[0]),o=Math.max(o,n[1]);t>=n.x&&e<=r.x&&o>=n.y&&i<=r.y&&(_=[c.map(e=>new v(e[0],e[1]))],(er.x||ir.y)&&(_=lg(_,n.x,n.y,r.x,r.y)))}for(const n of _){i.reset(n,.25*e);let r=0;r=i.length<=.5*e?1:Math.ceil(i.paddedLength/p)+1;for(let n=0;n0?(qh.transformMat4(s,s,e),this.fogState&&i&&"globe"!==a.name&&(l=function(e,t,n,r,i,o){const a=o.calculateFogTileMatrix(i),s=[t,n,r];return id.transformMat4(s,s,a),_w(e,id.length(s),o.pitch,o._fov)}(this.fogState,t,n,r,i.toUnwrapped(),this.transform)>.9)):Sx(s,s,e);const u=s[3];return{point:new v((s[0]/u+1)/2*this.transform.width+qT,(-s[1]/u+1)/2*this.transform.height+qT),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:o&&s[2]>u||l}}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 tS(e,t,n,r,i){const{horizontalAlign:o,verticalAlign:a}=K_(e),s=-(o-.5)*t,l=-(a-.5)*n,u=Ag(e,r);return new v(s+u[0]*i,l+u[1]*i)}function nS(e,t,n,r,i){const o=new v(e,t);return n&&o._rotate(r?i:-i),o}class rS{constructor(e,t,n,r,i,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new WT(this.transform,i),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new eS(n),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,t,n,r){const i=n.getBucket(t),o=n.latestFeatureIndex;if(!i||!o||t.fqid!==i.layerIds[0])return;const a=i.layers[0].layout,s=n.collisionBoxArray,l=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),u=n.tileSize/hr,c=n.tileID.toUnwrapped();this.transform.setProjection(i.projection);const h=(d=n.tileID,f=i.getProjection(),p=this.transform,f.name===this.projection?p.calculateProjMatrix(d.toUnwrapped()):ZT(p,f,d));var d,f,p;const m="map"===a.get("text-pitch-alignment"),_="map"===a.get("text-rotation-alignment");t.compileFilter();const g=t.dynamicFilter(),y=t.dynamicFilterNeedsFeature(),v=this.transform.calculatePixelsToTileUnitsMatrix(n),x=hx(h,n.tileID.canonical,m,_,this.transform,i.getProjection(),v);let b=null;if(m){const e=dx(h,n.tileID.canonical,m,_,this.transform,i.getProjection(),v);b=Jh.multiply([],this.transform.labelPlaneMatrix,e)}let w=null;g&&n.latestFeatureIndex&&(w={unwrappedTileID:c,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:n.latestFeatureIndex}),this.retainedQueryData[i.bucketInstanceId]=new QT(i.bucketInstanceId,o,i.sourceLayerIndex,i.index,n.tileID);const T={bucket:i,layout:a,posMatrix:h,textLabelPlaneMatrix:x,labelToScreenMatrix:b,clippingData:w,scale:l,textPixelRatio:u,holdingForFade:n.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:P_(i.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:P_(i.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(i.sourceID)};if(r)for(const t of i.sortKeyRanges){const{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=t;e.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:T})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:i.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=tS(e,n,r,b,i),T=this.collisionIndex.placeCollisionBox(f,i,t,nS(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,nS(w.x,w.y,o,a,this.transform.angle),c,s,l,u.predicate).box.length)return}if(T.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:T}}}placeLayerBucketPart(e,t,n,r){const{bucket:i,layout:o,posMatrix:a,textLabelPlaneMatrix:s,labelToScreenMatrix:l,clippingData:u,textPixelRatio:c,holdingForFade:h,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:p,collisionGroup:m}=e.parameters,_=o.get("text-optional"),g=o.get("icon-optional"),y=o.get("text-allow-overlap"),x=o.get("icon-allow-overlap"),b="map"===o.get("text-rotation-alignment"),w="map"===o.get("text-pitch-alignment"),T="viewport-y"===o.get("symbol-z-order"),S=o.get("symbol-z-elevate");this.transform.setProjection(i.projection);let E=y&&(x||!i.hasIconData()||g),M=x&&(y||!i.hasTextData()||_);!i.collisionArrays&&d&&i.deserializeCollisionBoxes(d),n&&r&&i.updateCollisionDebugBuffers(this.transform.zoom,d);const A=(e,r,d)=>{const{crossTileID:T,numVerticalGlyphVertices:S}=e;if(u){const n={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(u.dynamicFilterNeedsFeature){const t=this.retainedQueryData[i.bucketInstanceId];r=u.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(n,r,this.retainedQueryData[i.bucketInstanceId].tileID.canonical,new v(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[T]=new KT(!1,!1,!1,!0),void t.add(T)}if(t.has(T))return;if(h)return void(this.placements[T]=new KT(!1,!1,!1));let A=!1,I=!1,C=!0,k=!1,O=!1,P=null,R={box:null,offscreen:null,occluded:null},D={box:null,offscreen:null,occluded:null},L=null,z=null,B=null,F=0,j=0,N=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(j=d.verticalTextFeatureIndex);const U=t=>{t.tileID=this.retainedQueryData[i.bucketInstanceId].tileID;const n=this.transform.elevation;t.elevation=e.zOffset+(n?n.getAtTileOffset(t.tileID,t.tileAnchorX,t.tileAnchorY):0)},V=d.textBox;if(V){U(V);const t=t=>{let n=U_.horizontal;if(i.allowVerticalPlacement&&!t&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[T];t&&(this.placedOrientations[T]=t,n=t,this.markUsedOrientation(i,n,e))}return n},n=(e,t)=>{if(i.allowVerticalPlacement&&S>0&&d.verticalTextBox){for(const n of i.writingModes)if(n===U_.vertical?(R=t(),D=R):R=e(),R&&R.box&&R.box.length)break}else R=e()};if(o.get("text-variable-anchor")){let s=o.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];s.indexOf(e.anchor)>0&&(s=s.filter(t=>t!==e.anchor),s.unshift(e.anchor))}const l=(t,n,o)=>{const l=i.getSymbolInstanceTextSize(f,e,this.transform.zoom,r),u=(t.x2-t.x1)*l+2*t.padding,h=(t.y2-t.y1)*l+2*t.padding,d=e.hasIconTextFit&&!x?n:null;d&&U(d);let _={box:[],offscreen:!1,occluded:!1};const g=y?2*s.length:s.length;for(let n=0;n=s.length,e,r,i,o,d,f,p);if(g&&(_=g.placedGlyphBoxes,_&&_.box&&_.box.length)){A=!0,P=g.shift;break}}return _};n(()=>l(V,d.iconBox,U_.horizontal),()=>{const e=d.verticalTextBox;return e&&U(e),i.allowVerticalPlacement&&!(R&&R.box&&R.box.length)&&S>0&&e?l(e,d.verticalIconBox,U_.vertical):{box:null,offscreen:null,occluded:null}}),R&&(A=R.box,C=R.offscreen,k=R.occluded);const u=t(!(!R||!R.box));if(!A&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[T];t&&(this.variableOffsets[T]=t,this.markUsedJustification(i,t.anchor,e,u))}}else{const o=(t,n)=>{const o=i.getSymbolInstanceTextSize(f,e,this.transform.zoom,r),s=this.collisionIndex.placeCollisionBox(i,o,t,new v(0,0),y,c,a,m.predicate);return s&&s.box&&s.box.length&&(this.markUsedOrientation(i,n,e),this.placedOrientations[T]=n),s};n(()=>o(V,U_.horizontal),()=>{const e=d.verticalTextBox;return i.allowVerticalPlacement&&S>0&&e?(U(e),o(e,U_.vertical)):{box:null,offscreen:null,occluded:null}}),t(!!(R&&R.box&&R.box.length))}}if(L=R,A=L&&L.box&&L.box.length>0,C=L&&L.offscreen,k=L&&L.occluded,e.useRuntimeCollisionCircles){const t=i.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),r=O_(i.textSizeData,f,t),u=o.get("text-padding");z=this.collisionIndex.placeCollisionCircles(i,y,t,i.lineVertexArray,i.glyphOffsetArray,r,a,s,l,n,w,m.predicate,e.collisionCircleDiameter*r/24,u,this.retainedQueryData[i.bucketInstanceId].tileID),A=y||z.circles.length>0&&!z.collisionDetected,C=C&&z.offscreen,k=z.occluded}if(d.iconFeatureIndex&&(N=d.iconFeatureIndex),d.iconBox){const t=t=>{U(t);const n=e.hasIconTextFit&&P?nS(P.x,P.y,b,w,this.transform.angle):new v(0,0),r=i.getSymbolInstanceIconSize(p,this.transform.zoom,e.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(i,r,t,n,x,c,a,m.predicate)};D&&D.box&&D.box.length&&d.verticalIconBox?(B=t(d.verticalIconBox),I=B.box.length>0):(B=t(d.iconBox),I=B.box.length>0),C=C&&B.offscreen,O=B.occluded}const G=_||0===e.numHorizontalGlyphVertices&&0===S,q=g||0===e.numIconVertices;if(G||q?q?G||(I=I&&A):A=I&&A:I=A=I&&A,A&&L&&L.box&&this.collisionIndex.insertCollisionBox(L.box,o.get("text-ignore-placement"),i.bucketInstanceId,D&&D.box&&j?j:F,m.ID),I&&B&&this.collisionIndex.insertCollisionBox(B.box,o.get("icon-ignore-placement"),i.bucketInstanceId,N,m.ID),z&&(A&&this.collisionIndex.insertCollisionCircles(z.circles,o.get("text-ignore-placement"),i.bucketInstanceId,F,m.ID),n)){const e=i.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new JT);for(let e=0;e=0;--t){const n=e[t];A(i.symbolInstances.get(n),n,i.collisionArrays[n])}i.hasAnyZOffset&&X(i.layerIds[0]+" layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y")}else if(i.hasAnyZOffset){const e=i.getSortedIndexesByZOffset();for(let t=0;t=0&&(e.text.placedSymbolArray.get(i).crossTileID=c>=0&&i!==c?0:l),o>=0&&(e.text.placedSymbolArray.get(o).crossTileID=c>=0&&o!==c?0:l),a>=0&&(e.text.placedSymbolArray.get(a).crossTileID=c>=0&&a!==c?0:l),s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=c>=0&&s!==c?0:l)}markUsedOrientation(e,t,n){const r=t===U_.horizontal||t===U_.horizontalOnly?t:0,i=t===U_.vertical?t:0,{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:l}=n,u=e.text.placedSymbolArray;o>=0&&(u.get(o).placedOrientation=r),a>=0&&(u.get(a).placedOrientation=r),s>=0&&(u.get(s).placedOrientation=r),l>=0&&(u.get(l).placedOrientation=i)}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 YT(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 YT(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 YT(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.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,n,r.collisionBoxArray),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,r.tileID),t.updateZOffset()))}}updateBucketOpacities(e,t,n){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const r=e.layers[0].layout,i=!!e.layers[0].dynamicFilter(),o=new YT(null,0,!1,!1,!0),a=r.get("text-allow-overlap"),s=r.get("icon-allow-overlap"),l=r.get("text-variable-anchor"),u="map"===r.get("text-rotation-alignment"),c="map"===r.get("text-pitch-alignment"),h=new YT(null,0,a&&(s||!e.hasIconData()||r.get("icon-optional")),s&&(a||!e.hasTextData()||r.get("text-optional")),!0);!e.collisionArrays&&n&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(n);const d=(e,t,n)=>{for(let r=0;r0||s>0,x=m>0,b=this.placedOrientations[p],w=b===U_.vertical,T=b===U_.horizontal||b===U_.horizontalOnly;if(!y&&!x||g.isHidden()||f++,y){const t=dS(g.text);d(e.text,a,w?fS:t),d(e.text,s,T?fS:t);const n=g.text.isHidden(),{leftJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:u}=r,c=e.text.placedSymbolArray,h=n||w?1:0;i>=0&&(c.get(i).hidden=h),o>=0&&(c.get(o).hidden=h),l>=0&&(c.get(l).hidden=h),u>=0&&(c.get(u).hidden=n||T?1:0);const f=this.variableOffsets[p];f&&this.markUsedJustification(e,f.anchor,r,b);const m=this.placedOrientations[p];m&&(this.markUsedJustification(e,"left",r,m),this.markUsedOrientation(e,m,r))}if(x){const t=dS(g.icon),{placedIconSymbolIndex:n,verticalPlacedIconSymbolIndex:i}=r,o=e.icon.placedSymbolArray,a=g.icon.isHidden()?1:0;n>=0&&(d(e.icon,m,w?fS:t),o.get(n).hidden=a),i>=0&&(d(e.icon,r.numVerticalIconVertices,T?fS:t),o.get(i).hidden=a)}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const t=e.collisionArrays[n];if(t){let n=new v(0,0),o=!0;if(t.textBox||t.verticalTextBox){if(l){const e=this.variableOffsets[p];e?(n=tS(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&n._rotate(c?this.transform.angle:-this.transform.angle)):o=!1}i&&(o=!g.clipped),t.textBox&&iS(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||w,n.x,n.y),t.verticalTextBox&&iS(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||T,n.x,n.y)}const a=o&&Boolean(!T&&t.verticalIconBox);t.iconBox&&iS(e.iconCollisionBox.collisionVertexArray,g.icon.placed,a,r.hasIconTextFit?n.x:0,r.hasIconTextFit?n.y:0),t.verticalIconBox&&iS(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!a,r.hasIconTextFit?n.x:0,r.hasIconTextFit?n.y:0)}}}if(e.fullyClipped=0===f,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(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 iS(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 oS=Math.pow(2,25),aS=Math.pow(2,24),sS=Math.pow(2,17),lS=Math.pow(2,16),uS=Math.pow(2,9),cS=Math.pow(2,8),hS=Math.pow(2,1);function dS(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*oS+t*aS+n*sS+t*lS+n*uS+t*cS+n*hS+t}const fS=0;class pS{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 e=ft.now()-i;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const i=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===i.type&&(!i.minzoom||i.minzoom<=a)&&(!i.maxzoom||i.maxzoom>a)){const e=i,t=e.layout.get("symbol-z-elevate"),a=this._inProgressLayer=this._inProgressLayer||new pS(e),s=el(i.source,i.scope);if(a.continuePlacement(t?r[s]:n[s],this.placement,this._showCollisionBoxes,i,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const _S=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class gS{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=_S[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 gS(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=_S.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(yS(t,n,i,r),n[2*o+a]>s&&yS(t,n,i,o);ls;)u--}n[2*i+a]===s?yS(t,n,i,u):(u++,yS(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++)xS(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];xS(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 yS(e,t,n,r){vS(e,n,r),vS(t,2*n,2*r),vS(t,2*n+1,2*r+1)}function vS(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function xS(e,t,n,r){const i=e-n,o=t-r;return i*i+o*o}const bS=.03125;class wS{constructor(e,t,n){this.tileID=e,this.bucketInstanceId=n,this.index=new gS(t.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=e.canonical.x*hr,i=e.canonical.y*hr;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]}}var MS="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w-0.0001;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",AS="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out 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;}",IS="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;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 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*texture(u_dem,pos).r;\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=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;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*texture(u_dem_prev,pos).r;\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=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;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(texture(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(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(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) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return 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",CS="#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;out 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",kS="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in 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 opacity_limit) {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,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}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;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",OS="#ifdef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);vec4 _raTexLinearCoord(vec2 texCoord,vec2 texResolution,out vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return (texCoord.xxyy+vec2(1.5,0.5).xyxy)/texResolution.xxyy;}vec2 _raTexLinearMix(vec2 fxy,vec4 colorMix,float colorOffset,vec4 t00,vec4 t10,vec4 t01,vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec2 fxy;vec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texture(u_image0,c.yz),texture(u_image0,c.xz),texture(u_image0,c.yw),texture(u_image0,c.xw)\n);}vec2 raTexture2D_image1_linear(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec2 fxy;vec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texture(u_image1,c.yz),texture(u_image1,c.xz),texture(u_image1,c.yw),texture(u_image1,c.xw)\n);}vec2 raTexture2D_image0_nearest(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec4 t=texture(u_image0,texCoord);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec4 t=texture(u_image1,texCoord);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",PS="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",RS="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const DS=[];NS(MS,DS);const LS={"_prelude_fog.vertex.glsl":CS,"_prelude_terrain.vertex.glsl":IS,"_prelude_shadow.vertex.glsl":PS,"_prelude_fog.fragment.glsl":kS,"_prelude_shadow.fragment.glsl":RS,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":OS},zS={};US("",IS),US(kS,CS),US(RS,PS),US(OS,"");const BS=US("\nout vec4 glFragColor;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#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif","\n#define EXTENT 8192.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\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;}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+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);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const 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);}"),FS=MS;var jS={background:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin 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\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in 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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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;in vec2 a_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in 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\nuniform float u_emissive_strength;void 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_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\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;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nout vec3 v_data;out 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:US("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:US('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in 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);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nout 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:US("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:US("in float v_placed;in 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);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in float a_size_scale;in vec2 a_padding;in float a_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+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:US("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in 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);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out 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:US("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void 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_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 v_pos;uniform float u_emissive_strength;\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_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in vec2 v_pos;in 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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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;in vec2 a_pos;out vec2 v_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in vec2 v_pos;uniform float u_emissive_strength;\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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nuniform float u_emissive_strength;in float v_height;void main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_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);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,v_depth);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,u_emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef RENDER_CUTOFF\ncolor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#ifdef RENDER_CUTOFF\ninvariant gl_Position;\n#endif\nuniform 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;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 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) || defined(LIGHTING_3D_MODE)\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);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\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);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\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=vec2(mix(concave,-concave,start),y_ground);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\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\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=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),fillExtrusionDepth:US("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=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\nvec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\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);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp 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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*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\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nout vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp 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_normal=normal;\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}'),groundShadow:US('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,v_depth));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0)).r);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);v_depth=gl_Position.w;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:US("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;HANDLE_WIREFRAME_DEBUG;\n#endif\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;\n#ifdef FORCE_ABS_FL_GROUND_RADIUS\nfl_ground_radius=abs(flood_light_ground_radius);\n#endif\nfloat flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(1.0,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:US("precision highp float;uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}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));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(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);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\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 lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\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\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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=texture(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=texture(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\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(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);if (border_color.a==0.0) { \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);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trimmed,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin 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;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out 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\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\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\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in 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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in 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;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;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;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.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_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform vec4 u_tl_br;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#elif defined(PROJECTION_GLOBE_VIEW)\nin vec2 a_pos;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;void main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec2 globe_tl=vec2(u_tl_br.x,u_tl_br.y);vec2 globe_br=vec2(u_tl_br.z,u_tl_br.w);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=1.0-((mercatorY-globe_br.y)/(globe_tl.y-globe_br.y));float mercatorX=mercatorXfromLng(latLng[1]);float uvX=(mercatorX-globe_br.x)/(globe_tl.x-globe_br.x);vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);uv=vec2(uvX,uvY);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 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,u_raster_elevation,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);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\nuv=a_texture_pos/8192.0;\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),symbolIcon:US('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nuniform mediump float u_icon_saturation;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b)*alpha;\n#else\nout_color=texture(u_texture,v_tex_a)*alpha;\n#endif\n#ifdef SATURATION\nvec3 luma=vec3(dot(out_color.rgb,vec3(0.2126,0.7152,0.0722)));out_color.rgb=mix(luma,out_color.rgb,u_icon_saturation);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\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\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\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;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;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;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 out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:US('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in 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\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\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;bool draw_halo=v_draw_halo > 0.0;if (draw_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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in 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 bool u_is_halo;\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\nout float v_draw_halo;out vec2 v_data0;out 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\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\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;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;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;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));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:US('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;in float v_draw_halo;in vec4 v_data0;in 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\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=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;bool draw_halo=v_draw_halo > 0.0;if (draw_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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in 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;uniform bool u_is_halo;\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\nout float v_draw_halo;out vec4 v_data0;out 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\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\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;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;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;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\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,v_depth,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\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\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_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:US("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\nin 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=texture(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);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',AS),skyboxGradient:US('#include "_prelude_fog.fragment.glsl"\nin 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=texture(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);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',AS),skyboxCapture:US("\nin 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;precision highp float;\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;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in 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=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform 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\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;\n#endif\nout vec2 v_pos0;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);globe_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:US('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;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) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp 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;\n#ifdef ALPHA_PASS\nfloat 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);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 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=c2;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\nglFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in 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;out highp vec3 v_ray_dir;out 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);}"),model:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\ntexColor.rgb=sRGBToLinear(texColor.rgb);if(u_baseTextureIsAlpha) {if (texColor.w < 0.5) {discard;}albedo*=mix(vec4(texColor.rgb,texColor.a),vec4(texColor.a),float(u_baseTextureIsAlpha));} else {albedo*=texColor;}\n#endif\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 diffuse=getDiffuseShadedColor(getBaseColor().rgb,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(diffuse,1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nao=(texture(u_occlusionTexture,uv_2f).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);color=mix(color,v_color_mix.rgb,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=u_matrix*pos;pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=local_pos;\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normalize(normal_3f));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1);v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:US("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:US("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}")};function NS(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 US(e,t){const n=/#include\s+"([^"]+)"/g,r=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let i=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);i&&(i=i.map(e=>{const t=e.split(" ");return t[t.length-1]}),i=[...new Set(i)]);const o={},a=[],s=[];e=e.replace(n,(e,t)=>(s.push(t),"")),t=t.replace(n,(e,t)=>(a.push(t),""));let l=[...DS];NS(e,l),NS(t,l);for(const e of[...a,...s])LS[e]||console.error("Undefined include: "+e),zS[e]||(zS[e]=[],NS(LS[e],zS[e])),l=[...l,...zS[e]];return{fragmentSource:e=e.replace(r,(e,t,n,r,i)=>(o[i]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${i}\nin ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = u_${i};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\n in ${n} ${r} ${i};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(r,(e,t,n,r,i)=>{const a="float"===r?"vec2":r,s=i.match(/color/)?"color":a;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\nin ${n} ${r} a_${i};\n#endif\n`:o[i]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\nout ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:"initialize"===t?"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = unpack_mix_${s}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\n in ${n} ${r} a_${i};\n out ${n} ${r} ${i};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\n ${i} = a_${i};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:"define-instanced"===t?"mat4"===s?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${i}0;\nin vec4 a_${i}1;\nin vec4 a_${i}2;\nin vec4 a_${i}3;\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${n} ${a} a_${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\n ${n} ${r} ${i} = a_${i};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = unpack_mix_${s}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`}),staticAttributes:i,usedDefines:l,vertexIncludes:a,fragmentIncludes:s}}class VS{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,s){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e{const i=n.paint.get("hillshade-shadow-color"),o=n.paint.get("hillshade-highlight-color"),a=n.paint.get("hillshade-accent-color"),s=n.paint.get("hillshade-emissive-strength");let l=T(n.paint.get("hillshade-illumination-direction"));if("viewport"===n.paint.get("hillshade-illumination-anchor"))l-=e.transform.angle;else if(e.style&&e.style.enable3dLights()&&e.style.directionalLight){const t=e.style.directionalLight.properties.get("direction");l=T(Q(t.x,t.y,t.z)[1])}const u=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),u),u_image:0,u_latrange:GS(0,t.tileID),u_light:[n.paint.get("hillshade-exaggeration"),l],u_shadow:i,u_highlight:o,u_emissive_strength:s,u_accent:a}})(e,n,r,e.terrain?t.projMatrix:null);e.uploadCommonUniforms(s,h,t.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:p,tileBoundsSegments:m}=e.getTileBoundsBuffers(n);h.draw(e,l.TRIANGLES,i,o,a,Dv.disabled,d,r.id,f,p,m)}function WS(e,t,n){if(!t.needsDEMTextureUpload)return;const r=e.context,i=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||e.getTileTexture(n.stride);const o=n.getPixels();t.demTexture?t.demTexture.update(o,{premultiply:!1}):t.demTexture=new Ry(r,o,i.R32F,{premultiply:!1}),t.needsDEMTextureUpload=!1}function ZS(e,t,n){const r=e.context,i=r.gl;if(!t.dem)return;const o=t.dem;if(r.activeTexture.set(i.TEXTURE1),WS(e,t,o),!t.demTexture)return;t.demTexture.bind(i.NEAREST,i.CLAMP_TO_EDGE);const a=o.dim;r.activeTexture.set(i.TEXTURE0);let s=t.hillshadeFBO;if(!s){const e=new Ry(r,{width:a,height:a,data:null},i.RGBA);e.bind(i.LINEAR,i.CLAMP_TO_EDGE),s=t.hillshadeFBO=r.createFramebuffer(a,a,!0,"renderbuffer"),s.colorAttachment.set(e.texture)}r.bindFramebuffer.set(s.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:l,tileBoundsIndexBuffer:u,tileBoundsSegments:c}=e.getMercatorTileBoundsBuffers(),h=[];e.linearFloatFilteringSupported()&&h.push("TERRAIN_DEM_FLOAT_FORMAT"),e.getOrCreateProgram("hillshadePrepare",{defines:h}).draw(e,i.TRIANGLES,Ov.disabled,Pv.disabled,Rv.unblended,Dv.disabled,((e,t)=>{const n=t.stride,r=Jh.create();return Jh.ortho(r,0,hr,-hr,0,0,1),Jh.translate(r,r,[0,-hr,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:e.overscaledZ}})(t.tileID,o),n.id,l,u,c),t.needsHillshadePrepare=!1}const HS=e=>({u_matrix:new bu(e),u_image0:new pu(e),u_skirt_height:new mu(e),u_ground_shadow_factor:new gu(e)}),$S=(e,t,n)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:n}),XS=(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}),YS=(e,t)=>{if(t>0&&e.terrain&&X("Cutoff is currently disabled on terrain"),t<=0||e.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,0]}};const n=e.transform,r=Math.max(Math.abs(n._zoom-(e.minCutoffZoom-1)),1),i=n.isLODDisabled(!1)?P(60,45,n.pitch):P(30,15,n.pitch),o=n._farZ-n._nearZ,a=t*n.height,s=((1-(l=i))*(.75*n.cameraToCenterDistance)+l*(n._farZ+a))*r;var l;return{shouldRenderCutoff:i<1,uniformValues:{u_cutoff_params:[n._nearZ,n._farZ,(s-n._nearZ)/o,(s-a-n._nearZ)/o]}}};function KS(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const JS=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()}},QS={0:null,1:"TERRAIN_VERTEX_MORPHING"};function eE(e,t,n){if(0===t)return 0;const r=t<1&&514===n?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function tE(e,t){const n=1<({u_matrix:e});function rE(e,t,n,r,i){if(i>0){const o=ft.now(),a=(o-e.timeAdded)/i,s=t?(o-t.timeAdded)/i:-1,l=n.getSource(),u=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),c=!t||Math.abs(t.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),h=c&&e.refreshedUponExpiration?1:O(c?a:1-s,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),t?{opacity:1,mix:1-h}:{opacity:h,mix:0}}return{opacity:1,mix:0}}class iE extends zv{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},n=new Ew(Hw(),null),r=ET("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 oE extends zv{constructor(e){const t=ET("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new Ew(Hw(),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(e,t,n){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((t,n)=>{if(t[n.key]="",!this._tiles[n.key]){const t=new Vy(n,this._source.tileSize*n.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[n.key]=t}return t},{});for(const e in this._tiles)e in r||(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 aE extends _d{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 sE extends 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),s=r.upVectorScale(e.canonical,t,n).metersToTile;return id.scale(a,a,o*s),a}}getForTilePoints(e,t,n,r){if(this.isUsingMockSource())return!1;const i=__.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<o||e<0||e>o?24575:0,i=O(Math.round(n),0,hr),a=O(Math.round(e),0,hr);t.emplaceBack(i+r,a)}const a=(e,t)=>{const i=t*r+e;n.emplaceBack(i+1,i,i+r),n.emplaceBack(i+r,i+r+1,i+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return[0,129].forEach(e=>{for(let t=0;t<130;t++)a(t,e),a(e,t)}),[t,n,32768]}(),o=e.context;this.gridBuffer=o.createVertexBuffer(n,hd.members),this.gridIndexBuffer=o.createIndexBuffer(r),this.gridSegments=Ql.simpleSegment(0,0,n.length,r.length),this.gridNoSkirtSegments=Ql.simpleSegment(0,0,n.length,i),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new oE(t.map),this.orthoMatrix=Jh.create(),Jh.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,hr,0,hr,0,1);const a=o.gl;this._overlapStencilMode=new Pv({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=t,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new iE(t.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(e,t,n){if(e&&e.terrain){this._style!==e&&(this.style=e,this._evaluationZoom=void 0);const r=e.terrain.properties,i=0===e.terrain.drapeRenderMode,o=e.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=ft.now();const a=e.terrain&&e.terrain.scope,s=r.get("source"),l=i?this._mockSourceCache:e.getSourceCache(s,a);if(!l)return void X(`Couldn't find terrain source "${s}".`);if(this.sourceCache=l,this._exaggeration=o?this.calculateExaggeration(t):r.get("exaggeration"),!t.projection.requiresDraping&&o&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{this.sourceCache.used&&X(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.getScaledDemTileSize();this.sourceCache.update(t,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),t.updateElevation(!0,n),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(t),this._emptyDEMTextureDirty=!0,this._previousZoom=t.zoom}else this._disable()}calculateExaggeration(e){const t=this._previousCameraAltitude,n=e.getFreeCameraOptions().position.z/e.pixelsPerMeter*e.worldSize;this._previousCameraAltitude=n;const r=null!=t?n-t:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const i=e.zoom,o=this._style.terrain;if(!this._previousUpdateTimestamp)return o.getExaggeration(i);let a=i-this._previousZoom;const s=this._previousUpdateTimestamp;let l=i;null!=this._evaluationZoom&&(l=this._evaluationZoom,Math.abs(i-l)>.5&&(a=.5*(i-l+a)),a*r<0&&(l+=a)),this._evaluationZoom=l;const u=o.getExaggeration(l),c=u===o.getExaggeration(Math.max(0,l-.1));if(c&&Math.abs(u-this._exaggeration)<.01)return u;let h=Math.min(.1,.00375*(this._updateTimestamp-s));return(c||u<.1||Math.abs(a)<1e-4)&&(h=Math.min(.2,4*h)),Yr(this._exaggeration,u,h)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[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),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_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(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const t=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(Cf.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=t.getIds().map(e=>{const r=t.getTileByID(e).tileID;return r.projMatrix=n.calculateProjMatrix(r.toUnwrapped()),r});!function(e,t){const n=t.transform.pointCoordinate(t.transform.getCameraPoint()),r=new v(n.x,n.y);e.sort((e,t)=>{if(t.overscaledZ-e.overscaledZ)return t.overscaledZ-e.overscaledZ;const n=new v(e.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const o=this._style._mergedSourceCaches;for(const t in o){const n=o[t];if(!n.used)continue;if(n!==this.sourceCache&&this.resetTileLookupCache(n.id),this._setupProxiedCoordsForOrtho(n,e[t],i),n.usedForTerrain)continue;const r=e[t];n.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[t.id]=r.map(e=>new aE(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(i),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const n=t.tileID.key;n in a||(this._visibleDemTiles.push(t),a[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),WS(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 e=this.painter.context,t=e.gl;if(!this._emptyDepthBufferTexture){const n=new bp({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new Ry(e,n,t.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 e=this.painter.context,t=e.gl;e.activeTexture.set(t.TEXTURE2);const n=this._getLoadedAreaMinimum(),[r,i]=(()=>{const e=new wp({width:1,height:1},new Float32Array([n]));return[t.R32F,e]})();this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(i,{premultiply:!1}):o=this._emptyDEMTexture=new Ry(e,i,r,{premultiply:!1}),o}setupElevationDraw(e,t,n){const r=this.painter.context,i=r.gl,o={u_dem:2,u_dem_prev:4,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};o.u_exaggeration=this.exaggeration();let a=null,s=null,l=1;if(n&&n.morphing&&this._useVertexMorphing){const t=n.morphing.srcDemTile,r=n.morphing.dstDemTile;l=n.morphing.phase,t&&r&&(this._prepareDemTileUniforms(e,t,o,"_prev")&&(s=t),this._prepareDemTileUniforms(e,r,o)&&(a=r))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?i.LINEAR:i.NEAREST,c=e=>{o.u_dem_size=1===e.size[0]?1:e.size[0]-2};if(s&&a)r.activeTexture.set(i.TEXTURE2),a.demTexture.bind(u(a),i.CLAMP_TO_EDGE),r.activeTexture.set(i.TEXTURE4),s.demTexture.bind(u(s),i.CLAMP_TO_EDGE),a.demTexture&&c(a.demTexture),o.u_dem_lerp=l;else{a=this.terrainTileForTile[e.tileID.key],r.activeTexture.set(i.TEXTURE2);const t=this._prepareDemTileUniforms(e,a,o)?a.demTexture:this.emptyDEMTexture;t.bind(u(a),i.CLAMP_TO_EDGE),c(t)}if(r.activeTexture.set(i.TEXTURE3),n&&n.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(i.NEAREST,i.CLAMP_TO_EDGE),this._depthFBO&&(o.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(i.NEAREST,i.CLAMP_TO_EDGE),o.u_depth_size_inv=[1,1]),n&&n.useMeterToDem&&a){const e=(1<{if(l===n)return;const r=[QS[n],"PROJECTION_GLOBE_VIEW"];c&&r.push("CUSTOM_ANTIALIASING");const i=e.isTileAffectedByFog(t);s=e.getOrCreateProgram("globeRaster",{defines:r,overrideFog:i}),l=n},d=e.colorModeForRenderPass(),f=new Ov(a.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D);JS.update(i);const p=Qd(u),m=[yf(u.center.lng),vf(u.center.lat)],_=e.globeSharedBuffers,g=[u.width*ft.devicePixelRatio,u.height*ft.devicePixelRatio],y=Float32Array.from(u.globeMatrix),v={useDenormalizedUpVectorScale:!0};{const u=e.transform,c=eE(u.zoom,t.exaggeration(),t.sourceCache._source.tileSize);l=-1;const x=a.TRIANGLES;for(const l of r){const r=n.getTile(l),b=Pv.disabled,w=t.prevTerrainTileForTile[l.key],T=t.terrainTileForTile[l.key];KS(w,T)&&JS.newMorphing(l.key,w,T,i,250),o.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=JS.getMorphValuesForProxy(l.key),E=S?1:0;S&&Lt(v,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:M(S.phase)}});const A=Ud(l.canonical),I=of(A.getCenter().lat),C=rf(l.canonical,A,I,u.worldSize/u._pixelsPerMercatorPixel),k=$d(zd(l.canonical)),O=XS(u.expandedFarZProjMatrix,y,p,k,ef(u.zoom),m,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,g,c,C);if(h(l,E),s&&(t.setupElevationDraw(r,s,v),e.uploadCommonUniforms(o,s,l.toUnwrapped()),_)){const[t,n,r]=_.getGridBuffers(I,0!==c);s.draw(e,x,f,b,d,Dv.backCCW,O,"globe_raster",t,n,r)}}}if(_&&(e.renderDefaultNorthPole||e.renderDefaultSouthPole)){const i=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];c&&i.push("CUSTOM_ANTIALIASING"),s=e.getOrCreateProgram("globeRaster",{defines:i});for(const i of r){const{x:r,y:l,z:c}=i.canonical,h=0===l,p=l===(1<t.draw(e,a.TRIANGLES,f,Pv.disabled,d,Dv.disabled,XS(u.expandedFarZProjMatrix,_,_,T,0,m,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,g,0),"globe_pole_raster",n,b,w);t.setupElevationDraw(l,s,v),e.uploadCommonUniforms(o,s,i.toUnwrapped()),h&&e.renderDefaultNorthPole&&S(s,y),p&&e.renderDefaultSouthPole&&(_=Jh.scale(Jh.create(),_,[1,-1,1]),S(s,x))}}}}(e,t,n,r,i);else{const o=e.context,a=o.gl;let s,l;const u=e.shadowRenderer,c=YS(e,e.longestCutoffRange),h=t=>{if(l===t)return;const n=[];n.push(QS[t]),c.shouldRenderCutoff&&n.push("RENDER_CUTOFF"),s=e.getOrCreateProgram("terrainRaster",{defines:n}),l=t},d=e.colorModeForRenderPass(),f=new Ov(a.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D);JS.update(i);const p=e.transform,m=eE(p.zoom,t.exaggeration(),t.sourceCache._source.tileSize);let _=[0,0,0];if(u){const t=e.style.directionalLight,n=e.style.ambientLight;t&&n&&(_=$M(t,n))}{l=-1;const g=a.TRIANGLES,[y,v]=[t.gridIndexBuffer,t.gridSegments];for(const l of r){const r=n.getTile(l),x=Pv.disabled,b=t.prevTerrainTileForTile[l.key],w=t.terrainTileForTile[l.key];KS(b,w)&&JS.newMorphing(l.key,b,w,i,250),o.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=JS.getMorphValuesForProxy(l.key),S=T?1:0;let E;T&&(E={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:M(T.phase)}});const A=$S(l.projMatrix,tE(l.canonical,p.renderWorldCopies)?m/10:m,_);if(h(S),!s)continue;t.setupElevationDraw(r,s,E);const I=l.toUnwrapped();u&&u.setupShadows(I,s),e.uploadCommonUniforms(o,s,I,null,c),s.draw(e,g,f,x,d,Dv.backCCW,A,"terrain_raster",t.gridBuffer,y,v)}}}}(t,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,t.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const t=this.painter,n=this.painter.context,r=this.proxySourceCache,i=this.proxiedCoords[r.id],o=this._drapedRenderBatches.shift(),a=t.style.order,s=[];let l=0;for(const u of i){const i=r.getTileByID(u.proxyTileKey),c=r.proxyCachedFBO[u.key]?r.proxyCachedFBO[u.key][e]:void 0,h=void 0!==c?r.renderCache[c]:this.pool[l++],d=void 0!==c;if(i.texture=h.tex,d&&!h.dirty){s.push(i.tileID);continue}let f;n.bindFramebuffer.set(h.fb.framebuffer),this.renderedToTile=!1,h.dirty&&(n.clear({color:dn.transparent,stencil:0}),h.dirty=!1);for(let e=o.start;e<=o.end;++e){const r=t.style._mergedLayers[a[e]];if(r.isHidden(t.transform.zoom))continue;const i=t.style.getLayerSourceCache(r),o=i?this.proxyToSource[u.key][i.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,h.fb.width,h.fb.height]),f!==(i?i.id:null)&&(this._setupStencil(h,o,r,i),f=i?i.id:null),t.renderLayer(t,i,r,s)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const r=t.style._mergedLayers[a[e]];if(r.isHidden(t.transform.zoom))continue;const i=t.style.getLayerSourceCache(r),o=i?this.proxyToSource[u.key][i.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,h.fb.width,h.fb.height]),f!==(i?i.id:null)&&(this._setupStencil(h,o,r,i),f=i?i.id:null),t.renderLayer(t,i,r,s)}this.renderedToTile?(h.dirty=!0,s.push(i.tileID)):d||--l,5===l&&(l=0,this.renderToBackBuffer(s))}return this.renderToBackBuffer(s),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height]),o.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let n=-1,r=t;for(let i=0;in}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter(e=>e.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 e=this.painter.context,t=e.gl,n=this.drapeBufferSize;e.activeTexture.set(t.TEXTURE0);const r=new Ry(e,{width:n[0],height:n[1],data:null},t.RGBA);r.bind(t.LINEAR,t.CLAMP_TO_EDGE);const i=e.createFramebuffer(n[0],n[1],!0,null);return i.colorAttachment.set(r.texture),i.depthAttachment=new Cv(e,i.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,n[0],n[1]),this._stencilRef=0,i.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):i.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:i,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],n=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!n&&t.shouldRedrape():!n&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let e=!1;for(const t of this._style.getSources())if(t instanceof Uw){e=!0;break}if(!e)return;const t={};for(let e=0;et>e.end)||X("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=n}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.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(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):Pv.disabled}_renderTileClippingMasks(e,t){const n=this.painter,r=this.painter.context,i=r.gl;n._tileClippingMaskIDs={},r.setColorMode(Rv.disabled),r.setDepthMode(Ov.disabled);const o=n.getOrCreateProgram("clippingMask");for(const r of e){const e=n._tileClippingMaskIDs[r.key]=--t;o.draw(n,i.TRIANGLES,Ov.disabled,new Pv({func:i.ALWAYS,mask:0},e,255,i.KEEP,i.KEEP,i.REPLACE),Rv.disabled,Dv.disabled,nE(r.projMatrix),"$clipping",n.tileExtentBuffer,n.quadTriangleIndexBuffer,n.tileExtentSegments)}}pointCoordinate(e){const t=this.painter.transform;if(e.x<0||e.x>t.width||e.y<0||e.y>t.height)return null;const n=[e.x,e.y,1,1];qh.transformMat4(n,n,t.pixelMatrixInverse),qh.scale(n,n,1/n[3]),n[0]/=t.worldSize,n[1]/=t.worldSize;const r=t._camera.position,i=xf(1,t.center.lat),o=[r[0],r[1],r[2]/i,0],a=id.subtract([],n.slice(0,3),o);id.normalize(a,a);const s=this.raycast(o,a,this._exaggeration);return null!==s&&s?(id.scaleAndAdd(o,o,a,s),o[3]=o[2],o[2]*=i,o):null}drawDepth(){const e=this.painter,t=e.context,n=this.proxySourceCache,r=Math.ceil(e.width),i=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===i||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=t.gl,n=t.createFramebuffer(r,i,!0,"renderbuffer");t.activeTexture.set(e.TEXTURE0);const o=new Ry(t,{width:r,height:i,data:null},e.RGBA);o.bind(e.NEAREST,e.CLAMP_TO_EDGE),n.colorAttachment.set(o.texture);const a=t.createRenderbuffer(t.gl.DEPTH_COMPONENT16,r,i);n.depthAttachment.set(a),this._depthFBO=n,this._depthTexture=o}t.bindFramebuffer.set(this._depthFBO.framebuffer),t.viewport.set([0,0,r,i]),function(e,t,n,r){if("globe"===e.transform.projection.name)return;const i=e.context,o=i.gl;i.clear({depth:1});const a=e.getOrCreateProgram("terrainDepth"),s=new Ov(o.LESS,Ov.ReadWrite,e.depthRangeFor3D);for(const i of r){const r=n.getTile(i),l=$S(i.projMatrix,0,[0,0,0]);t.setupElevationDraw(r,a),a.draw(e,o.TRIANGLES,s,Pv.disabled,Rv.unblended,Dv.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments)}}(e,this,n,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,n){if(e.getSource()instanceof tw)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 v(Number.MAX_VALUE,Number.MAX_VALUE),max:new v(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(e,t)=>{const n=e.wrap+e.canonical.x/(1<o+l.max.x||r+ia+l.max.y};for(let o=0;oe.key===t.tileID.key);if(e)return e}if(t.tileID.key!==e.key){const n=e.canonical.z-t.tileID.canonical.z;let i,o,a;r=Jh.create();const s=t.tileID.wrap-e.wrap<0?(i=hr>>n,o=i*((t.tileID.canonical.x<=r){const n=e.canonical.z-r;t.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,t.transform.tileZoom),o=new _d(a,e.wrap,r,e.canonical.x>>n,e.canonical.y>>n)):0!==n&&(a=r,o=new _d(a,e.wrap,r,e.canonical.x>>n,e.canonical.y>>n))}o.key!==e.key&&(l.push(o.key),n=t.getTile(o))}const u=e=>{l.forEach(t=>{r[t]=e}),l.length=0};for(a-=1;a>=s&&(!n||!n.hasData());a--){n&&u(n.tileID.key);const e=o.calculateScaledKey(a);if(n=t.getTileByID(e),n&&n.hasData())break;const i=r[e];if(null===i)break;void 0===i?l.push(e):n=t.getTileByID(i)}return u(n?n.tileID.key:null),n&&n.hasData()?n: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}}function lE(e,t,n){const r=function(e,t,n){const r=id.dot(t,e),i=id.dot(n,[.2126,.7152,.0722]),o=(e,t,n)=>(1-n)*e+n*t,a=o(1-.3*Math.min(i,1),1,Math.min(r+1,1));return o(.92,1,Math.asin(O(t[2],-1,1))/Math.PI+.5)*a}(e,[0,0,1],t),i=[0,0,0];id.scale(i,n.slice(0,3),r);const o=[0,0,0];id.scale(o,t.slice(0,3),e[2]);const a=[0,0,0];return id.add(a,i,o),le(a)}const uE=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],cE=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class hE{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(e,t,n,r,i,o){const a=e.gl;this.program=a.createProgram(),this.configuration=r,this.name=t,this.fixedDefines=[...o];const s=r?r.getBinderAttributes():[],l=(n.staticAttributes||[]).concat(s);let u=r?r.defines():[];u=u.concat(o.map(e=>"#define "+e));const c="#version 300 es\n";let h=c+u.concat("precision mediump float;",FS,BS.fragmentSource).join("\n");for(const e of n.fragmentIncludes)h+="\n"+LS[e];h+="\n"+n.fragmentSource;let d=c+u.concat("precision highp float;",FS,BS.vertexSource).join("\n");for(const e of n.vertexIncludes)d+="\n"+LS[e];d+="\n"+n.vertexSource;const f=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(f,h),a.compileShader(f),a.attachShader(this.program,f);const p=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(p,d),a.compileShader(p),a.attachShader(this.program,p),this.attributes={},this.numAttributes=l.length;for(let e=0;e({u_dem:new pu(e),u_dem_prev:new pu(e),u_dem_tl:new _u(e),u_dem_scale:new mu(e),u_dem_tl_prev:new _u(e),u_dem_scale_prev:new mu(e),u_dem_size:new mu(e),u_dem_lerp:new mu(e),u_exaggeration:new mu(e),u_depth:new pu(e),u_depth_size_inv:new _u(e),u_meter_to_dem:new mu(e),u_label_plane_matrix_inv:new bu(e)}))(e)),o.includes("GLOBE")&&(this.globeUniforms=(e=>({u_tile_tl_up:new gu(e),u_tile_tr_up:new gu(e),u_tile_br_up:new gu(e),u_tile_bl_up:new gu(e),u_tile_up_scale:new mu(e)}))(e)),o.includes("FOG")&&(this.fogUniforms=(e=>({u_fog_matrix:new bu(e),u_fog_range:new _u(e),u_fog_color:new yu(e),u_fog_horizon_blend:new mu(e),u_fog_vertical_limit:new _u(e),u_fog_temporal_offset:new mu(e),u_frustum_tl:new gu(e),u_frustum_tr:new gu(e),u_frustum_br:new gu(e),u_frustum_bl:new gu(e),u_globe_pos:new gu(e),u_globe_radius:new mu(e),u_globe_transition:new mu(e),u_is_globe:new pu(e),u_viewport:new _u(e)}))(e)),o.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(e=>({u_cutoff_params:new yu(e)}))(e)),o.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(e=>({u_lighting_ambient_color:new gu(e),u_lighting_directional_dir:new gu(e),u_lighting_directional_color:new gu(e),u_ground_radiance:new gu(e)}))(e)),o.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(e=>({u_light_matrix_0:new bu(e),u_light_matrix_1:new bu(e),u_fade_range:new _u(e),u_shadow_normal_offset:new gu(e),u_shadow_intensity:new mu(e),u_shadow_texel_size:new mu(e),u_shadow_map_resolution:new mu(e),u_shadow_direction:new gu(e),u_shadow_bias:new gu(e),u_shadowmap_0:new pu(e),u_shadowmap_1:new pu(e)}))(e))}}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])}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const n=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const n=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const n=this.shadowUniforms;e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}_drawDebugWireframe(e,t,n,r,i,o,a,s,l,u){const c=e.options.wireframe;if(!1===c.terrain&&!1===c.layers2D&&!1===c.layers3D)return;const h=e.context;if(!(()=>!(!c.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!c.layers2D||e._terrain&&e._terrain.renderingToTexture||!uE.includes(this.name))||!(!c.layers3D||!cE.includes(this.name)))())return;const d=h.gl,f=e.wireframeDebugCache.getLinesFromTrianglesBuffer(e.frameCounter,i,h);if(!f)return;const p=[...this.fixedDefines];p.push("DEBUG_WIREFRAME");const m=e.getOrCreateProgram(this.name,{config:this.configuration,defines:p});h.program.set(m.program);const _=(e,t,n)=>{if(t[e]&&n[e])for(const r in t[e])n[e][r]&&n[e][r].set(n.program,r,t[e][r].current)};l&&l.setUniforms(m.program,h,m.binderUniforms,a,{zoom:s}),_("fixedUniforms",this,m),_("terrainUniforms",this,m),_("globeUniforms",this,m),_("fogUniforms",this,m),_("lightsUniforms",this,m),_("shadowUniforms",this,m),f.bind(),h.setColorMode(new Rv([d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ZERO,d.ONE],dn.transparent,[!0,!0,!0,!1])),h.setDepthMode(new Ov(t.func===d.LESS?d.LEQUAL:t.func,Ov.ReadOnly,t.range)),h.setStencilMode(Pv.disabled);const g=3*o.primitiveLength*2,y=3*o.primitiveOffset*2*2;u&&u>1?d.drawElementsInstanced(d.LINES,g,d.UNSIGNED_SHORT,y,u):d.drawElements(d.LINES,g,d.UNSIGNED_SHORT,y),i.bind(),h.program.set(this.program),h.setDepthMode(t),h.setStencilMode(n),h.setColorMode(r)}draw(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m){const _=e.context,g=_.gl;if(this.failedToCreate)return;_.program.set(this.program),_.setDepthMode(n),_.setStencilMode(r),_.setColorMode(i),_.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);f&&f.setUniforms(this.program,_,this.binderUniforms,h,{zoom:d});const y={[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],v=m&&m>0?1:void 0;for(const o of c.get()){const a=o.vaos||(o.vaos={});(a[s]||(a[s]=new VS)).bind(_,this,l,f?f.getPaintVertexBuffers():[],u,o.vertexOffset,p||[],v),m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2,m):g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2),t===g.TRIANGLES&&this._drawDebugWireframe(e,n,r,i,u,o,h,d,f,m)}}}function dE(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?t.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/ox(t,1,e.transform.tileZoom),u_pixel_coord_upper:[i>>16,o>>16],u_pixel_coord_lower:[65535&i,65535&o]}}const fE=Jh.create(),pE=(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m)=>{const _=t.style.light,g=_.properties.get("position"),y=[g.x,g.y,g.z],v=Yh.create();"viewport"===_.properties.get("anchor")&&(Yh.fromRotation(v,-t.transform.angle),id.transformMat3(y,y,v));const x=_.properties.get("color"),b=t.transform,w={u_matrix:e,u_lightpos:y,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[x.r,x.g,x.b],u_vertical_gradient:+n,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:fE,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:i,u_edge_radius:o,u_flood_light_color:h,u_vertical_scale:d,u_flood_light_intensity:f,u_ground_shadow_factor:p,u_emissive_strength:m};return"globe"===b.projection.name&&(w.u_tile_id=[a.canonical.x,a.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_vertical_scale:n}),_E=(e,t,n,r,i,o,a,s,l,u,c,h,d,f)=>{const p=pE(e,t,n,r,i,o,a,l,u,c,h,d,f,1,[0,0,0],0),m={u_height_factor:-Math.pow(2,a.overscaledZ)/s.tileSize/8};return z(p,dE(t,s),m)},gE=(e,t)=>({u_matrix:e,u_emissive_strength:t}),yE=(e,t,n,r)=>z(gE(e,t),dE(n,r)),vE=(e,t,n)=>({u_matrix:e,u_world:n,u_emissive_strength:t}),xE=(e,t,n,r,i)=>z(yE(e,t,n,r),{u_world:i}),bE=(e,t,n,r)=>{const i=hr/n.tileSize;return{u_matrix:e,u_camera_to_center_distance:t.getCameraToCenterDistance(r),u_extrude_scale:[t.pixelsToGLUnits[0]/i,t.pixelsToGLUnits[1]/i]}},wE=(e,t,n=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:n}),TE=Jh.create(),SE=(e,t,n,r,i,o,a)=>{const s=e.transform,l="globe"===s.projection.name,u=l?Kd(s.zoom,t.canonical)*s._pixelsPerMercatorPixel:ox(n,1,o),c={u_matrix:t.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:TE,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=r,c.u_merc_center=i,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{return{u_matrix:e,u_normalize_matrix:t,u_globe_matrix:n,u_merc_matrix:r,u_grid_matrix:i,u_tl_parent:o,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:(T=d.paint.get("raster-saturation"),T>0?1-1/(1.001-T):-T),u_contrast_factor:(w=d.paint.get("raster-contrast"),w>0?1/(1-w):1+w),u_spin_weights:ME(d.paint.get("raster-hue-rotate")),u_perspective_transform:f,u_raster_elevation:p,u_tl_br:a,u_zoom_transition:s,u_merc_center:l,u_cutoff_params:u,u_colorization_mix:AE(_,y),u_colorization_offset:IE(g,y),u_color_ramp:m,u_texture_offset:[x/(v+2*x),v/(v+2*x)],u_texture_res:[v+2*x,v+2*x],u_emissive_strength:b};var w,T};function ME(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]}function AE([e,t,n,r],[i,o]){if(i===o)return[0,0,0,0];const a=259/257/(o-i);return[e*a,t*a,n*a,r*a]}function IE(e,[t,n]){return t===n?0:((e-t)/(n-t)*259-1)/257}const CE=Jh.create(),kE=(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g)=>{const y=i.transform,v={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:y.getCameraToCenterDistance(m),u_rotate_symbol:+n,u_aspect_ratio:y.width/y.height,u_fade_change:i.options.fadeDuration?i.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:a,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:CE,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:CE,u_up_vector:[0,-1,0],u_icon_transition:g||0,u_icon_saturation:_};return"globe"===m.name&&(v.u_tile_id=[c.canonical.x,c.canonical.y,1<z(kE(e,t,n,r,i,o,a,s,l,u,h,d,f,p,m,_,1),{u_gamma_scale:r?i.transform.getCameraToCenterDistance(_)*Math.cos(i.terrain?0:i.transform._pitch):1,u_device_pixel_ratio:ft.devicePixelRatio,u_is_halo:+c,undefined:void 0}),PE=(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m)=>z(OE(e,t,n,r,i,o,a,s,!0,l,!0,c,h,d,f,p,m),{u_texsize_icon:u,u_texture_icon:1}),RE=(e,t,n,r)=>({u_matrix:e,u_emissive_strength:t,u_opacity:n,u_color:r}),DE=(e,t,n,r,i,o,a)=>z(function(e,t,n,r){const i=n.imageManager.getPattern(e.toString(),t),{width:o,height:a}=n.imageManager.getPixelSize(t),s=Math.pow(2,r.tileID.overscaledZ),l=r.tileSize*Math.pow(2,n.transform.tileZoom)/s,u=l*(r.tileID.canonical.x+r.tileID.wrap*s),c=l*r.tileID.canonical.y;return{u_image:0,u_pattern_tl:i.tl,u_pattern_br:i.br,u_texsize:[o,a],u_pattern_size:i.displaySize,u_tile_units_to_pixels:1/ox(r,1,n.transform.tileZoom),u_pixel_coord_upper:[u>>16,c>>16],u_pixel_coord_lower:[65535&u,65535&c]}}(i,o,r,a),{u_matrix:e,u_emissive_strength:t,u_opacity:n}),LE=5,zE=6,BE=7,FE=8,jE=9,NE=10,UE=(e,t,n,r,i,o,a,s,l,u,c,h,d=[0,0,0])=>{const f=r.style.light,p=f.properties.get("position"),m=[-p.x,-p.y,p.z],_=Yh.create();"viewport"===f.properties.get("anchor")&&(Yh.fromRotation(_,-r.transform.angle),id.transformMat3(m,m,_));const g="MASK"===u.alphaMode,y=f.properties.get("color"),v=h.paint.get("model-ambient-occlusion-intensity"),x=h.paint.get("model-color").constantOr(dn.white),b=h.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:e,u_lighting_matrix:t,u_normal_matrix:n,u_lightpos:m,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_camera_pos:d,u_opacity:i,u_baseTextureIsAlpha:0,u_alphaMask:+g,u_alphaCutoff:u.alphaCutoff,u_baseColorFactor:[o.r,o.g,o.b,o.a],u_emissiveFactor:[a[0],a[1],a[2],1],u_metallicFactor:s,u_roughnessFactor:l,u_baseColorTexture:LE,u_metallicRoughnessTexture:zE,u_normalTexture:BE,u_occlusionTexture:FE,u_emissionTexture:jE,u_color_mix:[x.r,x.g,x.b,b],u_aoIntensity:v,u_emissive_strength:c}},VE=new Float32Array(16),GE=(e,t=VE,n=VE)=>({u_matrix:e,u_instance:t,u_node_matrix:n}),qE={fillExtrusion:e=>({u_matrix:new bu(e),u_lightpos:new gu(e),u_lightintensity:new mu(e),u_lightcolor:new gu(e),u_vertical_gradient:new mu(e),u_opacity:new mu(e),u_edge_radius:new mu(e),u_ao:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_up_dir:new gu(e),u_height_lift:new mu(e),u_flood_light_color:new gu(e),u_vertical_scale:new mu(e),u_flood_light_intensity:new mu(e),u_ground_shadow_factor:new gu(e),u_emissive_strength:new mu(e)}),fillExtrusionDepth:e=>({u_matrix:new bu(e),u_edge_radius:new mu(e),u_vertical_scale:new mu(e)}),fillExtrusionPattern:e=>({u_matrix:new bu(e),u_lightpos:new gu(e),u_lightintensity:new mu(e),u_lightcolor:new gu(e),u_vertical_gradient:new mu(e),u_height_factor:new mu(e),u_edge_radius:new mu(e),u_ao:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_up_dir:new gu(e),u_height_lift:new mu(e),u_image:new pu(e),u_texsize:new _u(e),u_pixel_coord_upper:new _u(e),u_pixel_coord_lower:new _u(e),u_tile_units_to_pixels:new mu(e),u_opacity:new mu(e)}),fillExtrusionGroundEffect:e=>({u_matrix:new bu(e),u_opacity:new mu(e),u_ao_pass:new mu(e),u_meter_to_tile:new mu(e),u_ao:new _u(e),u_flood_light_intensity:new mu(e),u_flood_light_color:new gu(e),u_attenuation:new mu(e),u_edge_radius:new mu(e),u_fb:new pu(e),u_fb_size:new mu(e)}),fill:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e)}),fillPattern:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_image:new pu(e),u_texsize:new _u(e),u_pixel_coord_upper:new _u(e),u_pixel_coord_lower:new _u(e),u_tile_units_to_pixels:new mu(e)}),fillOutline:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_world:new _u(e)}),fillOutlinePattern:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_world:new _u(e),u_image:new pu(e),u_texsize:new _u(e),u_pixel_coord_upper:new _u(e),u_pixel_coord_lower:new _u(e),u_tile_units_to_pixels:new mu(e)}),circle:e=>({u_camera_to_center_distance:new mu(e),u_extrude_scale:new Eu(e),u_device_pixel_ratio:new mu(e),u_matrix:new bu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_up_dir:new gu(e),u_emissive_strength:new mu(e)}),collisionBox:e=>({u_matrix:new bu(e),u_camera_to_center_distance:new mu(e),u_extrude_scale:new _u(e)}),collisionCircle:e=>({u_matrix:new bu(e),u_inv_matrix:new bu(e),u_camera_to_center_distance:new mu(e),u_viewport_size:new _u(e)}),debug:e=>({u_color:new vu(e),u_matrix:new bu(e),u_overlay:new pu(e),u_overlay_scale:new mu(e)}),clippingMask:e=>({u_matrix:new bu(e)}),heatmap:e=>({u_extrude_scale:new mu(e),u_intensity:new mu(e),u_matrix:new bu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_up_dir:new gu(e)}),heatmapTexture:e=>({u_image:new pu(e),u_color_ramp:new pu(e),u_opacity:new mu(e)}),hillshade:e=>({u_matrix:new bu(e),u_image:new pu(e),u_latrange:new _u(e),u_light:new _u(e),u_shadow:new vu(e),u_highlight:new vu(e),u_emissive_strength:new mu(e),u_accent:new vu(e)}),hillshadePrepare:e=>({u_matrix:new bu(e),u_image:new pu(e),u_dimension:new _u(e),u_zoom:new mu(e)}),line:e=>({u_matrix:new bu(e),u_pixels_to_tile_units:new Eu(e),u_device_pixel_ratio:new mu(e),u_units_to_pixels:new _u(e),u_dash_image:new pu(e),u_gradient_image:new pu(e),u_image_height:new mu(e),u_texsize:new _u(e),u_tile_units_to_pixels:new mu(e),u_alpha_discard_threshold:new mu(e),u_trim_offset:new _u(e),u_emissive_strength:new mu(e)}),linePattern:e=>({u_matrix:new bu(e),u_texsize:new _u(e),u_pixels_to_tile_units:new Eu(e),u_device_pixel_ratio:new mu(e),u_image:new pu(e),u_units_to_pixels:new _u(e),u_tile_units_to_pixels:new mu(e),u_alpha_discard_threshold:new mu(e)}),raster:e=>({u_matrix:new bu(e),u_normalize_matrix:new bu(e),u_globe_matrix:new bu(e),u_merc_matrix:new bu(e),u_grid_matrix:new Tu(e),u_tl_parent:new _u(e),u_scale_parent:new mu(e),u_fade_t:new mu(e),u_opacity:new mu(e),u_image0:new pu(e),u_image1:new pu(e),u_brightness_low:new mu(e),u_brightness_high:new mu(e),u_saturation_factor:new mu(e),u_contrast_factor:new mu(e),u_spin_weights:new gu(e),u_perspective_transform:new _u(e),u_raster_elevation:new mu(e),u_tl_br:new yu(e),u_zoom_transition:new mu(e),u_merc_center:new _u(e),u_cutoff_params:new yu(e),u_colorization_mix:new yu(e),u_colorization_offset:new mu(e),u_color_ramp:new pu(e),u_texture_offset:new _u(e),u_texture_res:new _u(e),u_emissive_strength:new mu(e)}),symbolIcon:e=>({u_is_size_zoom_constant:new pu(e),u_is_size_feature_constant:new pu(e),u_size_t:new mu(e),u_size:new mu(e),u_camera_to_center_distance:new mu(e),u_rotate_symbol:new pu(e),u_aspect_ratio:new mu(e),u_fade_change:new mu(e),u_matrix:new bu(e),u_label_plane_matrix:new bu(e),u_coord_matrix:new bu(e),u_is_text:new pu(e),u_pitch_with_map:new pu(e),u_texsize:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_camera_forward:new gu(e),u_tile_matrix:new bu(e),u_up_vector:new gu(e),u_ecef_origin:new gu(e),u_texture:new pu(e),u_icon_transition:new mu(e),u_icon_saturation:new mu(e)}),symbolSDF:e=>({u_is_size_zoom_constant:new pu(e),u_is_size_feature_constant:new pu(e),u_size_t:new mu(e),u_size:new mu(e),u_camera_to_center_distance:new mu(e),u_rotate_symbol:new pu(e),u_aspect_ratio:new mu(e),u_fade_change:new mu(e),u_matrix:new bu(e),u_label_plane_matrix:new bu(e),u_coord_matrix:new bu(e),u_is_text:new pu(e),u_pitch_with_map:new pu(e),u_texsize:new _u(e),u_texture:new pu(e),u_gamma_scale:new mu(e),u_device_pixel_ratio:new mu(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_camera_forward:new gu(e),u_tile_matrix:new bu(e),u_up_vector:new gu(e),u_ecef_origin:new gu(e),u_is_halo:new pu(e)}),symbolTextAndIcon:e=>({u_is_size_zoom_constant:new pu(e),u_is_size_feature_constant:new pu(e),u_size_t:new mu(e),u_size:new mu(e),u_camera_to_center_distance:new mu(e),u_rotate_symbol:new pu(e),u_aspect_ratio:new mu(e),u_fade_change:new mu(e),u_matrix:new bu(e),u_label_plane_matrix:new bu(e),u_coord_matrix:new bu(e),u_is_text:new pu(e),u_pitch_with_map:new pu(e),u_texsize:new _u(e),u_texsize_icon:new _u(e),u_texture:new pu(e),u_texture_icon:new pu(e),u_gamma_scale:new mu(e),u_device_pixel_ratio:new mu(e),u_is_halo:new pu(e)}),background:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_opacity:new mu(e),u_color:new vu(e)}),backgroundPattern:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_opacity:new mu(e),u_image:new pu(e),u_pattern_tl:new _u(e),u_pattern_br:new _u(e),u_texsize:new _u(e),u_pattern_size:new _u(e),u_pixel_coord_upper:new _u(e),u_pixel_coord_lower:new _u(e),u_tile_units_to_pixels:new mu(e)}),terrainRaster:HS,terrainDepth:HS,skybox:e=>({u_matrix:new bu(e),u_sun_direction:new gu(e),u_cubemap:new pu(e),u_opacity:new mu(e),u_temporal_offset:new mu(e)}),skyboxGradient:e=>({u_matrix:new bu(e),u_color_ramp:new pu(e),u_center_direction:new gu(e),u_radius:new mu(e),u_opacity:new mu(e),u_temporal_offset:new mu(e)}),skyboxCapture:e=>({u_matrix_3f:new Tu(e),u_sun_direction:new gu(e),u_sun_intensity:new mu(e),u_color_tint_r:new yu(e),u_color_tint_m:new yu(e),u_luminance:new mu(e)}),globeRaster:e=>({u_proj_matrix:new bu(e),u_globe_matrix:new bu(e),u_normalize_matrix:new bu(e),u_merc_matrix:new bu(e),u_zoom_transition:new mu(e),u_merc_center:new _u(e),u_image0:new pu(e),u_grid_matrix:new Tu(e),u_skirt_height:new mu(e),u_frustum_tl:new gu(e),u_frustum_tr:new gu(e),u_frustum_br:new gu(e),u_frustum_bl:new gu(e),u_globe_pos:new gu(e),u_globe_radius:new mu(e),u_viewport:new _u(e)}),globeAtmosphere:e=>({u_frustum_tl:new gu(e),u_frustum_tr:new gu(e),u_frustum_br:new gu(e),u_frustum_bl:new gu(e),u_horizon:new mu(e),u_transition:new mu(e),u_fadeout_range:new mu(e),u_color:new yu(e),u_high_color:new yu(e),u_space_color:new yu(e),u_temporal_offset:new mu(e),u_horizon_angle:new mu(e)}),model:e=>({u_matrix:new bu(e),u_lighting_matrix:new bu(e),u_normal_matrix:new bu(e),u_lightpos:new gu(e),u_lightintensity:new mu(e),u_lightcolor:new gu(e),u_camera_pos:new gu(e),u_opacity:new mu(e),u_baseColorFactor:new yu(e),u_emissiveFactor:new yu(e),u_metallicFactor:new mu(e),u_roughnessFactor:new mu(e),u_baseTextureIsAlpha:new pu(e),u_alphaMask:new pu(e),u_alphaCutoff:new mu(e),u_baseColorTexture:new pu(e),u_metallicRoughnessTexture:new pu(e),u_normalTexture:new pu(e),u_occlusionTexture:new pu(e),u_emissionTexture:new pu(e),u_color_mix:new yu(e),u_aoIntensity:new mu(e),u_emissive_strength:new mu(e)}),modelDepth:e=>({u_matrix:new bu(e),u_instance:new bu(e),u_node_matrix:new bu(e)}),groundShadow:e=>({u_matrix:new bu(e),u_ground_shadow_factor:new gu(e)}),stars:e=>({u_matrix:new bu(e),u_up:new gu(e),u_right:new gu(e),u_intensity_multiplier:new mu(e)})};let WE;function ZE(e,t,n,r,i,o,a){const s=e.context,l=s.gl,u=e.transform,c=e.getOrCreateProgram("collisionBox"),h=[];let d=0,f=0;for(let s=0;s0){const e=Jh.create(),t=y;Jh.mul(e,_.placementInvProjMatrix,u.glCoordMatrix),Jh.mul(e,e,_.placementViewportMatrix),h.push({circleArray:x,circleOffset:f,transform:t,invTransform:e,projection:_.getProjection()}),d+=x.length/4,f=d}v&&(e.terrain&&e.terrain.setupElevationDraw(m,c),c.draw(e,l.LINES,Ov.disabled,Pv.disabled,e.colorModeForRenderPass(),Dv.disabled,bE(y,u,m,_.getProjection()),n.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,u.zoom,null,[v.collisionVertexBuffer,v.collisionVertexBufferExt]))}if(!a||!h.length)return;const p=e.getOrCreateProgram("collisionCircle"),m=new El;m.resize(4*d),m._trim();let _=0;for(const e of h)for(let t=0;t=0&&(p[v.associatedIconIndex]={x:S,y:E,z:M,angle:O})}else Tx(w,d)}if(c){f.clear();const t=e.icon.placedSymbolArray;for(let e=0;e0&&Q.push("ICON_TRANSITION"),h.zOffsetVertexBuffer&&Q.push("Z_OFFSET");const ee=f&&0!==n.paint.get(i?"text-halo-width":"icon-halo-width").constantOr(1);let te;f?te=l.iconsInText?PE(w.kind,k,v,g,e,$,X,Y,O,L,s,j,T,K,F,l.getProjection()):OE(w.kind,k,v,g,e,$,X,Y,i,O,!0,s,j,T,K,F,l.getProjection()):(c<1&&Q.push("SATURATION"),te=kE(w.kind,k,v,g,e,$,X,Y,i,O,s,j,T,K,F,l.getProjection(),c,J));const ne={program:e.getOrCreateProgram(YE(f,i,l),{config:d,defines:Q}),buffers:h,uniformValues:te,atlasTexture:P,atlasTextureIcon:z,atlasInterpolation:R,atlasInterpolationIcon:D,isSDF:f,hasHalo:ee,tile:r,labelPlaneMatrixInv:G};if(x&&l.canOverlap){b=!0;const e=h.segments.get();for(const t of e)M.push({segments:new Ql([t]),sortKey:t.sortKey,state:ne})}else M.push({segments:h.segments,sortKey:0,state:ne})}b&&M.sort((e,t)=>e.sortKey-t.sortKey);for(const t of M){const r=t.state;if(e.terrain&&e.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:m.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:r.labelPlaneMatrixInv}),f.activeTexture.set(p.TEXTURE0),r.atlasTexture&&r.atlasTexture.bind(r.atlasInterpolation,p.CLAMP_TO_EDGE),r.atlasTextureIcon&&(f.activeTexture.set(p.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),e.uploadCommonLightUniforms(e.context,r.program),r.hasHalo){const i=r.uniformValues;i.u_is_halo=1,JE(r.buffers,t.segments,n,e,r.program,w,h,d,i,2),i.u_is_halo=0}else{if(r.isSDF){const i=r.uniformValues;r.hasHalo&&(i.u_is_halo=1,JE(r.buffers,t.segments,n,e,r.program,w,h,d,i,1)),i.u_is_halo=0}JE(r.buffers,t.segments,n,e,r.program,w,h,d,r.uniformValues,1)}}}function JE(e,t,n,r,i,o,a,s,l,u){const c=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];i.draw(r,r.context.gl.TRIANGLES,o,a,s,Dv.disabled,l,n.id,e.layoutVertexBuffer,e.indexBuffer,t,n.paint,r.transform.zoom,e.programConfigurations.get(n.id),c,u)}function QE(e,t,n,r,i,o,a){const s=e.context.gl,l=n.paint.get("fill-pattern"),u=l&&l.constantOr(1);let c,h,d,f,p;a?(h=u&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",c=s.LINES):(h=u?"fillPattern":"fill",c=s.TRIANGLES);for(const m of r){const r=t.getTile(m);if(u&&!r.patternsLoaded())continue;const _=r.getBucket(n);if(!_)continue;e.prepareDrawTile();const g=_.programConfigurations.get(n.id),y=e.isTileAffectedByFog(m),v=e.getOrCreateProgram(h,{config:g,overrideFog:y});u&&(e.context.activeTexture.set(s.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),g.updatePaintBuffers());const x=l.constantOr(null);if(x&&r.imageAtlas){const e=r.imageAtlas.patternPositions[x.toString()];e&&g.setConstantPatternPositions(e)}const b=e.translatePosMatrix(m.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor")),w=n.paint.get("fill-emissive-strength");if(a){f=_.indexBuffer2,p=_.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[s.drawingBufferWidth,s.drawingBufferHeight];d="fillOutlinePattern"===h&&u?xE(b,w,e,r,t):vE(b,w,t)}else f=_.indexBuffer,p=_.segments,d=u?yE(b,w,e,r):gE(b,w);e.uploadCommonUniforms(e.context,v,m.toUnwrapped()),v.draw(e,c,i,e.stencilModeForClipping(m),o,Dv.disabled,d,n.id,_.layoutVertexBuffer,f,p,n.paint,e.transform.zoom,g,void 0)}}function eM(e,t,n,r,i,o,a,s){n.resetLayerRenderingStats();const l=e.context,u=l.gl,c=e.transform,h=n.paint.get("fill-extrusion-pattern"),d=h.constantOr(1),f=n.paint.get("fill-extrusion-opacity"),p=e.style.enable3dLights(),m=n.paint.get(p&&!d?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),_=[n.paint.get("fill-extrusion-ambient-occlusion-intensity"),m],g=n.layout.get("fill-extrusion-edge-radius"),y=g>0&&!n.paint.get("fill-extrusion-rounded-roof"),v=y?0:g,x="globe"===c.projection.name?Ob():0,b="globe"===c.projection.name,w=b?ef(c.zoom):0,T=[yf(c.center.lng),vf(c.center.lat)],S=n.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),E=n.paint.get("fill-extrusion-flood-light-intensity"),M=n.paint.get("fill-extrusion-vertical-scale"),A=YS(e,n.paint.get("fill-extrusion-cutoff-fade-range")),I=n.paint.get("fill-extrusion-emissive-strength"),C=[];let k;b&&C.push("PROJECTION_GLOBE_VIEW"),_[0]>0&&C.push("FAUX_AO"),y&&C.push("ZERO_ROOF_RADIUS"),s&&C.push("HAS_CENTROID"),E>0&&C.push("FLOOD_LIGHT"),A.shouldRenderCutoff&&C.push("RENDER_CUTOFF");const O="shadow"===e.renderPass,P=e.shadowRenderer,R=O&&!!P;e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0);let D=[0,0,0];if(P){const t=e.style.directionalLight,n=e.style.ambientLight;t&&n&&(D=$M(t,n)),k=C.concat(["SHADOWS_SINGLE_CASCADE"])}const L=R?"fillExtrusionDepth":d?"fillExtrusionPattern":"fillExtrusion",z=n.getLayerRenderingStats();for(const p of r){const r=t.getTile(p),m=r.getBucket(n);if(!m||m.projection.name!==c.projection.name)continue;let g=!1;P&&(g=0===P.getMaxCascadeForTile(p.toUnwrapped()));const y=e.isTileAffectedByFog(p),R=m.programConfigurations.get(n.id),B=e.getOrCreateProgram(L,{config:R,defines:g?k:C,overrideFog:y});if(e.terrain&&e.terrain.setupElevationDraw(r,B,{useMeterToDem:!0}),!m.centroidVertexBuffer){const e=B.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}!O&&P&&P.setupShadows(r.tileID.toUnwrapped(),B,"vector-tile",r.tileID.overscaledZ),d&&(e.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),R.updatePaintBuffers());const F=h.constantOr(null);if(F&&r.imageAtlas){const e=r.imageAtlas.patternPositions[F.toString()];e&&R.setConstantPatternPositions(e)}const j=n.paint.get("fill-extrusion-vertical-gradient");let N;if(O&&P){if(aM(r.tileID,m,e))continue;const t=P.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());N=mE(t,v,M)}else{const t=e.translatePosMatrix(p.expandedProjMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),i=c.projection.createInversionMatrix(c,p.canonical);N=d?_E(t,e,j,f,_,v,p,r,x,w,T,i,S,M):pE(t,e,j,f,_,v,p,x,w,T,i,S,M,E,D,I)}e.uploadCommonUniforms(l,B,p.toUnwrapped(),null,A);let U=m.segments;if("mercator"===c.projection.name&&!O&&(U=m.getVisibleSegments(r.tileID,e.terrain,e.transform.getFrustum(0)),!U.get().length))continue;if(z)if(O)for(const e of U.get())z.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of U.get())z.numRenderedVerticesInTransparentPass+=e.primitiveLength;const V=[];(e.terrain||s)&&V.push(m.centroidVertexBuffer),b&&V.push(m.layoutVertexExtBuffer),B.draw(e,l.gl.TRIANGLES,i,o,a,Dv.backCCW,N,n.id,m.layoutVertexBuffer,m.indexBuffer,U,n.paint,e.transform.zoom,R,V)}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1)}function tM(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y){const v=e.context,x=v.gl,b=e.transform,w=e.transform.zoom,T=[],S=YS(e,n.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===u?(T.push("CLEAR_SUBPASS"),y&&(T.push("CLEAR_FROM_TEXTURE"),v.activeTexture.set(x.TEXTURE0),y.bind(x.LINEAR,x.CLAMP_TO_EDGE))):"sdf"===u&&T.push("SDF_SUBPASS"),_&&T.push("HAS_CENTROID"),S.shouldRenderCutoff&&T.push("RENDER_CUTOFF");const E=n.layout.get("fill-extrusion-edge-radius"),M=(t,r,u,g,x)=>{const b=r.programConfigurations.get(n.id),M=e.isTileAffectedByFog(t),A=e.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:T,overrideFog:M}),I=((e,t,n,r,i,o,a,s,l,u,c)=>({u_matrix:t,u_opacity:n,u_ao_pass:r?1:0,u_meter_to_tile:i,u_ao:o,u_flood_light_intensity:a,u_flood_light_color:s,u_attenuation:l,u_edge_radius:u,u_fb:0,u_fb_size:c}))(0,g,c,l,x,[h,d*x],f,p,m,w>=17?0:E*x,y?y.size[0]:0),C=[];_&&C.push(r.hiddenByLandmarkVertexBuffer),e.uploadCommonUniforms(v,A,t.toUnwrapped(),null,S),A.draw(e,v.gl.TRIANGLES,i,o,a,s,I,n.id,r.vertexBuffer,r.indexBuffer,u,n.paint,w,b,C)};for(const i of r){const r=t.getTile(i),o=r.getBucket(n);if(!o||o.projection.name!==b.projection.name||!o.groundEffect||o.groundEffect&&!o.groundEffect.hasData())continue;const a=o.groundEffect,s=1/o.tileToMeter;{const t=e.translatePosMatrix(i.projMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),o=a.getDefaultSegment();M(i,a,o,t,s)}if(g)for(let o=0;o<4;o++){const a=yd[o](i),l=t.getTile(a);if(!l)continue;const u=l.getBucket(n);if(!u||u.projection.name!==b.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const c=u.groundEffect;let h,d;0===o?(h=[-hr,0,0],d=1):1===o?(h=[hr,0,0],d=0):2===o?(h=[0,-hr,0],d=3):(h=[0,hr,0],d=2);const f=c.regionSegments[d];if(!f)continue;const p=new Float32Array(16);Jh.translate(p,i.projMatrix,h),M(i,c,f,e.translatePosMatrix(p,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),s)}}}function nM(e,t,n,r,i,o,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const s=o?o.findDEMTileFor(n):null;if(!(s&&s.dem||a))return;const l=e=>{const n=t.getSource().minzoom,r=e=>{const n=t.getTileByID(e);if(n&&n.hasData())return n.getBucket(i)},o=[0,-1,1];for(const t of o){if(e.overscaledZ+t(u[0]=Math.min(e.min.y,t.min.y),u[1]=Math.max(e.max.y,t.max.y),u[2]=hr-t.min.x>e.max.x?t.min.x-hr:e.max.x,u),h=(e,t)=>(u[0]=Math.min(e.min.x,t.min.x),u[1]=Math.max(e.max.x,t.max.x),u[2]=hr-t.min.y>e.max.y?t.min.y-hr:e.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=(e,t,r,i,a,l,u)=>{if(!o)return 0;const c=[[l?r:e,l?e:r,0],[l?r:t,l?t:r,0]],h=u<0?hr+u:u,d=[l?h:(e+t)/2,l?(e+t)/2:h,0];return 0===r&&u<0||0!==r&&u>0?o.getForTilePoints(a,[d],!0,i):c.push(d),o.getForTilePoints(n,c,!0,s),Math.max(c[0][2],c[1][2],d[2])/o.exaggeration()};for(let e=0;e<4;e++){const t=r.borderFeatureIndices[e];if(0===t.length)continue;const i=yd[e](n),s=l(i);if(!(s&&s instanceof Tb))continue;if(r.borderDoneWithNeighborZ[e]===s.canonical.z)continue;0===s.centroidVertexArray.length&&s.createCentroidsBuffer();const u=o?o.findDEMTileFor(i):null;if(!(u&&u.dem||a))continue;const c=(e<2?1:5)-e,h=s.borderDoneWithNeighborZ[c]!==r.canonical.z,g=s.borderFeatureIndices[c];let y=0;if(r.canonical.z!==s.canonical.z){for(const e of t)r.showCentroid(r.featuresOnBorder[e]);if(h)for(const e of g)s.showCentroid(s.featuresOnBorder[e]);r.borderDoneWithNeighborZ[e]=s.canonical.z,s.borderDoneWithNeighborZ[c]=r.canonical.z}for(const n of t){const t=r.featuresOnBorder[n],o=r.centroidData[t.centroidDataIndex],l=t.borders[e];let h;for(;yl[0]+3||e[0]>l[0]-3)break;s.showCentroid(h),y++}if(h&&yl[1]-3)&&(x++,++y!==g.length);)h=s.featuresOnBorder[g[y]];if(h=s.featuresOnBorder[g[n]],x>1){const e=h.borders[c];Math.abs(l[0]-e[0])<3&&Math.abs(l[1]-e[1])<3&&(x=1,y=n+1)}else if(0===x){r.showCentroid(t);continue}const b=s.centroidData[h.centroidDataIndex];a&&1===x&&(((m=o).flags|(_=b).flags)&db?(m.flags|=db,_.flags|=db):(m.flags&=2147483647,_.flags&=2147483647));let w=new v(0,0);if(x>1)y=n;else if(u&&u.dem&&!(t.intersectsCount()>1||h.intersectsCount()>1)){const t=d[e](o,b),n=e%2?8191:0;p=f(t[0],Math.min(8191,t[1]),n,u,i,e<2,t[2]),w=new v(Math.ceil(7*(p+450)),0)}o.centroidXY=b.centroidXY=w,r.writeCentroidToBuffer(o),s.writeCentroidToBuffer(b)}else r.showCentroid(t)}r.borderDoneWithNeighborZ[e]=s.canonical.z,s.borderDoneWithNeighborZ[c]=r.canonical.z}var p,m,_;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(e)}const rM=[1,0,0],iM=[0,1,0],oM=[0,0,1];function aM(e,t,n){const r=n.transform,i=n.shadowRenderer;if(!i)return!0;const o=e.toUnwrapped(),a=r.tileSize*i._cascades[n.currentShadowCascade].scale;let s=t.maxHeight;if(r.elevation){const t=r.elevation.getMinMaxForTile(e);t&&(s+=t.max)}const l=[...i.shadowDirection];l[2]=-l[2];const u=i.computeSimplifiedTileShadowVolume(o,s,a,l);if(!u)return!1;const c=[rM,iM,oM,l,[l[0],0,l[2]],[0,l[1],l[2]]],h="globe"===r.projection.name,d=r.scaleZoom(a),f=Ed.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,d,!h),p=i.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(u.vertices,u.planes,c)||0===p.intersectsPrecise(u.vertices,u.planes,c)}function sM(e){const t=e._nearZ,n=e.projection.farthestPixelDistance(e),r=n-t,i=.2*e.height,o=t+i;return[t,n,(o-i-t)/r,(o-t)/r]}const lM=new dn(1,0,0,1),uM=new dn(0,1,0,1),cM=new dn(0,0,1,1),hM=new dn(1,0,1,1),dM=new dn(0,1,1,1);function fM(e,t,n){const r=e.context,i=e.transform,o=r.gl,a="globe"===i.projection.name,s=a?["PROJECTION_GLOBE_VIEW"]:[];let l=n.projMatrix;if(a&&ef(i.zoom)>0){const e=Xd(Fd(n.canonical,i));l=Jh.multiply(new Float32Array(16),i.globeMatrix,e),Jh.multiply(l,i.projMatrix,l)}const u=e.getOrCreateProgram("debug",{defines:s}),c=t.getTileByID(n.key);e.terrain&&e.terrain.setupElevationDraw(c,u);const h=Ov.disabled,d=Pv.disabled,f=e.colorModeForRenderPass(),p="$debug";r.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),a?c._makeGlobeTileDebugBuffers(e.context,i):c._makeDebugTileBoundsBuffers(e.context,i.projection);const m=c._tileDebugBuffer||e.debugBuffer,_=c._tileDebugIndexBuffer||e.debugIndexBuffer,g=c._tileDebugSegments||e.debugSegments;u.draw(e,o.LINE_STRIP,h,d,f,Dv.disabled,wE(l,dn.red),p,m,_,g,null,null,null,[c._globeTileDebugBorderBuffer]);const y=c.latestRawTileData,v=Math.floor((y&&y.byteLength||0)/1024),x=t.getTile(n).tileSize,b=512/Math.min(x,512)*(n.overscaledZ/i.zoom)*.5;let w=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(w+=" => "+n.overscaledZ),w+=` ${v}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)}(e,w);const T=c._tileDebugTextBuffer||e.debugBuffer,S=c._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,E=c._tileDebugTextSegments||e.debugSegments;u.draw(e,o.TRIANGLES,h,d,Rv.alphaBlended,Dv.disabled,wE(l,dn.transparent,b),p,T,S,E,null,null,null,[c._globeTileDebugTextBuffer])}function pM(e,t,n,r){_M(e,0,t+n/2,e.transform.width,n,r)}function mM(e,t,n,r){_M(e,t-n/2,0,n,e.transform.height,r)}function _M(e,t,n,r,i,o){const a=e.context,s=a.gl;s.enable(s.SCISSOR_TEST),s.scissor(t*ft.devicePixelRatio,n*ft.devicePixelRatio,r*ft.devicePixelRatio,i*ft.devicePixelRatio),a.clear({color:o}),s.disable(s.SCISSOR_TEST)}const gM=ll([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:yM}=gM;function vM(e,t,n,r){e.emplaceBack(t,n,r)}class xM{constructor(e){this.vertexArray=new Ll,this.indices=new Al,vM(this.vertexArray,-1,-1,1),vM(this.vertexArray,1,-1,1),vM(this.vertexArray,-1,1,1),vM(this.vertexArray,1,1,1),vM(this.vertexArray,-1,-1,-1),vM(this.vertexArray,1,-1,-1),vM(this.vertexArray,-1,1,-1),vM(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=e.createVertexBuffer(this.vertexArray,yM),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=Ql.simpleSegment(0,0,36,12)}}function bM(e,t,n,r,i,o){const a=e.context.gl,s=t.paint.get("sky-atmosphere-color"),l=t.paint.get("sky-atmosphere-halo-color"),u=t.paint.get("sky-atmosphere-sun-intensity"),c=((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}))(Yh.fromMat4(Yh.create(),r),i,u,s,l);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+o,t.skyboxTexture,0),n.draw(e,a.TRIANGLES,Ov.disabled,Pv.disabled,Rv.unblended,Dv.frontCW,c,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}const wM=ll([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class TM{constructor(e){const t=new Ol;t.emplaceBack(-1,1,1,0,0),t.emplaceBack(1,1,1,1,0),t.emplaceBack(1,-1,1,1,1),t.emplaceBack(-1,-1,1,0,1);const n=new Al;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(t,wM.members),this.indexBuffer=e.createIndexBuffer(n),this.segments=Ql.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const SM=ll([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class EM{constructor(){this.colorModeAlphaBlendedWriteRGB=new Rv([1,771,1,771],dn.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Rv([1,0,1,0],dn.transparent,[!1,!1,!1,!0])}update(e){const t=e.context;if(!this.atmosphereBuffer){this.atmosphereBuffer=new TM(t);const e=100,n=200,r=function(e){const t=Gi(30),n=[];for(let e=0;e<16e3;++e){const e=2*Math.PI*t(),r=Math.acos(1-2*t())-.5*Math.PI;n.push(id.fromValues(Math.cos(r)*Math.cos(e),Math.cos(r)*Math.sin(e),Math.sin(r)))}return n}(),i=Gi(300),o=new Pl,a=new Al;let s=0;for(let t=0;t{const c="globe"===i.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];t&&c.push("ALPHA_PASS");const d=e.getOrCreateProgram("globeAtmosphere",{defines:c}),p=((e,t,n,r,i,o,a,s,l,u,c,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:n,u_frustum_bl:r,u_horizon:i,u_transition:o,u_fadeout_range:a,u_color:s,u_high_color:l,u_space_color:u,u_temporal_offset:c,u_horizon_angle:h}))(i.frustumCorners.TL,i.frustumCorners.TR,i.frustumCorners.BR,i.frustumCorners.BL,i.frustumCorners.horizon,a,h,s,l,u,f,_);e.uploadCommonUniforms(n,d);const m=this.atmosphereBuffer;m&&d.draw(e,r.TRIANGLES,o,Pv.disabled,t?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Dv.backCW,p,t?"atmosphere_glow_alpha":"atmosphere_glow",m.vertexBuffer,m.indexBuffer,m.segments)};g(!1),g(!0)}drawStars(e,t){const n=O(t.properties.get("star-intensity"),0,1);if(0===n)return;const r=e.context,i=r.gl,o=e.transform,a=e.getOrCreateProgram("stars"),s=ed.identity([]);ed.rotateX(s,s,-o._pitch),ed.rotateZ(s,s,-o.angle),ed.rotateX(s,s,T(o._center.lat)),ed.rotateY(s,s,-T(o._center.lng));const l=Jh.fromQuat(new Float32Array(16),s),u=Jh.multiply([],o.starsProjMatrix,l),c=Yh.fromMat4([],l),h=Yh.invert([],c),d=[0,1,0];id.transformMat3(d,d,h),id.scale(d,d,.15);const f=[1,0,0];id.transformMat3(f,f,h),id.scale(f,f,.15);const p=((e,t,n,r)=>({u_matrix:Float32Array.from(e),u_up:t,u_right:n,u_intensity_multiplier:r}))(u,d,f,n);e.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(e,i.TRIANGLES,Ov.disabled,Pv.disabled,this.colorModeAlphaBlendedWriteRGB,Dv.disabled,p,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function MM(e,t){const n=[...e],r=t.cameraWorldSizeForFog/t.worldSize,i=Jh.identity([]);return Jh.scale(i,i,[r,r,1]),Jh.multiply(n,i,n),Jh.multiply(n,t.worldToFogMatrix,n),n}function AM(e,t,n,r){const i=n.material,o=r.context,{baseColorTexture:a,metallicRoughnessTexture:s}=i.pbrMetallicRoughness,{normalTexture:l,occlusionTexture:u,emissionTexture:c}=i;function h(t,n,r){if(t&&(e.push(n),o.activeTexture.set(o.gl.TEXTURE0+r),t.gfxTexture)){const{minFilter:e,magFilter:n,wrapS:r,wrapT:i}=t.sampler;t.gfxTexture.bindExtraParam(e,n,r,i)}}h(a,"HAS_TEXTURE_u_baseColorTexture",LE),h(s,"HAS_TEXTURE_u_metallicRoughnessTexture",zE),h(l,"HAS_TEXTURE_u_normalTexture",BE),h(u,"HAS_TEXTURE_u_occlusionTexture",FE),h(c,"HAS_TEXTURE_u_emissionTexture",jE),n.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(n.texcoordBuffer)),n.colorBuffer&&(e.push(12===n.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(n.colorBuffer)),n.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(n.normalBuffer)),n.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(n.pbrBuffer)),"OPAQUE"!==i.alphaMode&&"MASK"!==i.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),i.defined||e.push("DIFFUSE_SHADED"),e.push("USE_STANDARD_DERIVATIVES")}function IM(e,t,n,r,i,o){const a=n.paint.get("model-opacity"),s=t.context,l=new Ov(t.context.gl.LEQUAL,Ov.ReadWrite,t.depthRangeFor3D),u=t.transform,c=e.mesh,h=c.material,d=h.pbrMetallicRoughness,f=t.style.fog;let p;p="pixels"===t.transform.projection.zAxisUnit?[...e.nodeModelMatrix]:Jh.multiply([],r.zScaleMatrix,e.nodeModelMatrix),Jh.multiply(p,r.negCameraPosMatrix,p);const m=Jh.invert([],p);Jh.transpose(m,m);const _=n.paint.get("model-emissive-strength").constantOr(0),g=UE(new Float32Array(e.worldViewProjection),new Float32Array(p),new Float32Array(m),t,a,d.baseColorFactor,h.emissiveFactor,d.metallicFactor,d.roughnessFactor,h,_,n),y={defines:[]},v=[];AM(y.defines,v,c,t);const x=t.shadowRenderer;x&&(x.useNormalOffset=!1);let b=null;if(f){const n=MM(e.nodeModelMatrix,t.transform);if(b=new Float32Array(n),"globe"!==u.projection.name){const e=c.aabb.min,t=c.aabb.max,[r,i]=f.getOpacityForBounds(n,e[0],e[1],t[0],t[1]);y.overrideFog=r>=mw||i>=mw}}const w=YS(t,n.paint.get("model-cutoff-fade-range"));w.shouldRenderCutoff&&y.defines.push("RENDER_CUTOFF");const T=t.getOrCreateProgram("model",y);t.uploadCommonUniforms(s,T,null,b,w),"shadow"!==t.renderPass&&x&&x.setupShadowsFromMatrix(e.nodeModelMatrix,T),T.draw(t,s.gl.TRIANGLES,l,i,o,c.material.doubleSided?Dv.disabled:Dv.backCCW,g,n.id,c.vertexBuffer,c.indexBuffer,c.segments,n.paint,t.transform.zoom,void 0,v)}function CM(e,t,n,r,i,o,a){let s;s="globe"===e.projection.name?kx(n,e):[...n],Jh.multiply(s,s,t.matrix);const l=Jh.multiply([],r,s);if(t.meshes)for(const e of t.meshes){if("BLEND"!==e.material.alphaMode){a.push({mesh:e,depth:0,modelIndex:i,worldViewProjection:l,nodeModelMatrix:s});continue}const t=id.transformMat4([],e.centroid,l);t[2]>0&&o.push({mesh:e,depth:t[2],modelIndex:i,worldViewProjection:l,nodeModelMatrix:s})}if(t.children)for(const s of t.children)CM(e,s,n,r,i,o,a)}function kM(e,t,n,r){const i=n.shadowRenderer;if(!i)return;const o=i.getShadowPassDepthMode(),a=i.getShadowPassColorMode(),s=i.calculateShadowPassMatrixFromMatrix(t),l=GE(s);n.getOrCreateProgram("modelDepth",{defines:["DEPTH_TEXTURE"]}).draw(n,n.context.gl.TRIANGLES,o,Pv.disabled,a,Dv.backCCW,l,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,n.transform.zoom,void 0,void 0)}function OM(e,t,n){const r=t.updateZoomBasedPaintProperties(),i=function(e,t,n){let r,i,o,a=e.terrain?e.terrain.exaggeration():0;if(e.terrain&&a>0){const t=e.terrain,i=t.findDEMTileFor(n);i&&i.dem?r=__.create(t,n,i):a=0}if(0===a&&(t.terrainElevationMin=0,t.terrainElevationMax=0),a===t.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===t.validForDEMTile.id&&r._dem._timestamp===t.validForDEMTile.timestamp))return!1;for(const e in t.instancesPerModel){const n=t.instancesPerModel[e];for(let e=0;eu&&(u=t.max)}const c=O(r.x,o,a)-r.x,h=O(r.y,s,l)-r.y,d=xf(u,t.center.lat)-r.z;return t._zoomFromMercatorZ(Math.sqrt(c*c+h*h+d*d))}function DM(e,t,n,r,i,o,a){const s=e.context,l="shadow"===e.renderPass,u=e.shadowRenderer,c=l&&u?u.getShadowPassDepthMode():new Ov(s.gl.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o);if(n.meshes)for(const d of n.meshes){const f=["MODEL_POSITION_ON_GPU"],p=[];let m,_,g;r.instancedDataArray.length>20&&f.push("INSTANCED_ARRAYS");const y=YS(e,t.paint.get("model-cutoff-fade-range"));if(y.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&u)m=e.getOrCreateProgram("modelDepth",{defines:f}),_=GE(a.shadowTileMatrix,a.shadowTileMatrix,Float32Array.from(n.matrix)),g=u.getShadowPassColorMode();else{AM(f,p,d,e),m=e.getOrCreateProgram("model",{defines:f,overrideFog:h});const r=d.material,l=r.pbrMetallicRoughness,c=t.paint.get("model-opacity"),v=t.paint.get("model-emissive-strength").constantOr(0);_=UE(o.expandedProjMatrix,Float32Array.from(n.matrix),new Float32Array(16),e,c,l.baseColorFactor,r.emissiveFactor,l.metallicFactor,l.roughnessFactor,r,v,t,i),u&&(a.shadowUniformsInitialized?m.setShadowUniformValues(s,u.getShadowUniformValues()):(u.setupShadows(o.toUnwrapped(),m,"model-tile",o.overscaledZ),a.shadowUniformsInitialized=!0)),g=y.shouldRenderCutoff||c<1||"OPAQUE"!==r.alphaMode?Rv.alphaBlended:Rv.unblended}e.uploadCommonUniforms(s,m,o.toUnwrapped(),null,y);const v=d.material.doubleSided?Dv.disabled:Dv.backCCW;if(r.instancedDataArray.length>20)p.push(r.instancedDataBuffer),m.draw(e,s.gl.TRIANGLES,c,Pv.disabled,g,v,_,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,p,r.instancedDataArray.length);else{const n=l?"u_instance":"u_normal_matrix";for(let i=0;i30&&(n.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}const jM={symbol:function(e,t,n,r,i){if("translucent"!==e.renderPass)return;const o=Pv.disabled,a=e.colorModeForRenderPass();n.layout.get("text-variable-anchor")&&function(e,t,n,r,i,o,a){const s=t.transform,l="map"===i,u="map"===o;for(const t of e){const e=r.getTile(t),i=e.getBucket(n);if(!i||!i.text||!i.text.segments.get().length)continue;const o=P_(i.textSizeData,s.zoom),c=$T(t,i.getProjection(),s),h=s.calculatePixelsToTileUnitsMatrix(e),d=cx(c,e.tileID.canonical,u,l,s,i.getProjection(),h),f=i.hasIconTextFit()&&i.hasIconData();if(o){const n=Math.pow(2,s.zoom-e.tileID.overscaledZ);XE(i,l,u,a,R_,s,d,t,n,o,f)}}}(r,e,n,t,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),i),0!==n.paint.get("icon-opacity").constantOr(1)&&KE(e,t,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),n.paint.get("icon-color-saturation"),o,a),0!==n.paint.get("text-opacity").constantOr(1)&&KE(e,t,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),n.paint.get("icon-color-saturation"),o,a),t.map.showCollisionBoxes&&(ZE(e,t,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),ZE(e,t,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(e,t,n,r){if("translucent"!==e.renderPass)return;const i=n.paint.get("circle-opacity"),o=n.paint.get("circle-stroke-width"),a=n.paint.get("circle-stroke-opacity"),s=void 0!==n.layout.get("circle-sort-key").constantOr(1),l=n.paint.get("circle-emissive-strength");if(0===i.constantOr(1)&&(0===o.constantOr(1)||0===a.constantOr(1)))return;const u=e.context,c=u.gl,h=e.transform,d=e.depthModeForSublayer(0,Ov.ReadOnly),f=Pv.disabled,p=e.colorModeForDrapableLayerRenderPass(l),m="globe"===h.projection.name,_=[yf(h.center.lng),vf(h.center.lat)],g=[];for(let i=0;ie.sortKey-t.sortKey);const y={useDepthForOcclusion:h.depthOcclusionForSymbolsAndCircles};for(const t of g){const{programConfiguration:r,program:i,layoutVertexBuffer:o,globeExtVertexBuffer:a,indexBuffer:s,uniformValues:l,tile:m}=t.state,_=t.segments;e.terrain&&e.terrain.setupElevationDraw(m,i,y),e.uploadCommonUniforms(u,i,m.tileID.toUnwrapped()),i.draw(e,c.TRIANGLES,d,f,p,Dv.disabled,l,n.id,o,s,_,n.paint,h.zoom,r,[a])}},heatmap:function(e,t,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const i=e.context,o=i.gl,a=Pv.disabled,s=new Rv([o.ONE,o.ONE,o.ONE,o.ONE],dn.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,!0,null),function(e,t,n,r,i,o){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?a.RGBA16F:a.RGBA,i,o,0,a.RGBA,e.extRenderToTextureHalfFloat?a.HALF_FLOAT: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)}(i,e,n,"globe"===e.transform.projection.name?.5:.25),i.clear({color:dn.transparent});const l=e.transform,u="globe"===l.projection.name,c=u?["PROJECTION_GLOBE_VIEW"]:[],h=u?Dv.frontCCW:Dv.disabled,d=[yf(l.center.lng),vf(l.center.lat)];for(let f=0;f({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,t),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom)}(e,n))},line:function(e,t,n,r){if("translucent"!==e.renderPass)return;const i=n.paint.get("line-opacity"),o=n.paint.get("line-width");if(0===i.constantOr(1)||0===o.constantOr(1))return;const a=n.paint.get("line-emissive-strength"),s=e.depthModeForSublayer(0,Ov.ReadOnly),l=e.colorModeForDrapableLayerRenderPass(a),u=e.terrain&&e.terrain.renderingToTexture?1:ft.devicePixelRatio,c=n.paint.get("line-dasharray"),h=c.constantOr(1),d=n.layout.get("line-cap"),f=n.paint.get("line-pattern"),p=f.constantOr(1),m=n.paint.get("line-pattern").constantOr(1),_=1!==n.paint.get("line-opacity").constantOr(1);let g=!m&&_;const y=n.paint.get("line-gradient"),v=p?"linePattern":"line",x=e.context,b=x.gl,w=Zb(n);e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(g=!1);for(const i of r){const r=t.getTile(i);if(p&&!r.patternsLoaded())continue;const o=r.getBucket(n);if(!o)continue;e.prepareDrawTile();const a=o.programConfigurations.get(n.id),m=e.isTileAffectedByFog(i),_=e.getOrCreateProgram(v,{config:a,defines:w,overrideFog:m}),T=f.constantOr(null);if(T&&r.imageAtlas){const e=r.imageAtlas.patternPositions[T.toString()];e&&a.setConstantPatternPositions(e)}const S=c.constantOr(null),E=d.constantOr(null);if(!p&&S&&E&&r.lineAtlas){const e=r.lineAtlas.getDash(S,E);e&&a.setConstantPatternPositions(e)}let[M,A]=n.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;M!==A&&(0===M&&(M-=e),1===A&&(A+=e))}const I=e.terrain?i.projMatrix:null,C=p?Gb(e,r,n,I,u):Vb(e,r,n,I,o.lineClipsArray.length,u,[M,A]);if(y){const r=o.gradients[n.id];let a=r.texture;if(n.gradientVersion!==r.version){let s=256;if(n.stepInterpolant){const n=t.getSource().maxzoom,r=i.canonical.z===n?Math.ceil(1<{_.draw(e,b.TRIANGLES,s,t,l,Dv.disabled,C,n.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,n.paint,e.transform.zoom,a,[o.layoutVertexBuffer2])};if(g){const t=e.stencilModeForClipping(i).ref;0===t&&e.terrain&&x.clear({stencil:0});const n={func:b.EQUAL,mask:255};C.u_alpha_discard_threshold=.8,k(new Pv(n,t,255,b.KEEP,b.KEEP,b.INVERT)),C.u_alpha_discard_threshold=0,k(new Pv(n,t,255,b.KEEP,b.KEEP,b.KEEP))}else k(e.stencilModeForClipping(i))}g&&(e.resetStencilClippingMasks(),e.terrain&&x.clear({stencil:0}))},fill:function(e,t,n,r){const i=n.paint.get("fill-color"),o=n.paint.get("fill-opacity");if(0===o.constantOr(1))return;const a=n.paint.get("fill-emissive-strength"),s=e.colorModeForDrapableLayerRenderPass(a),l=n.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===i.constantOr(dn.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";if(e.renderPass===u){const i=e.depthModeForSublayer(1,"opaque"===e.renderPass?Ov.ReadWrite:Ov.ReadOnly);QE(e,t,n,r,i,s,!1)}if("translucent"===e.renderPass&&n.paint.get("fill-antialias")){const i=e.depthModeForSublayer(n.getPaintProperty("fill-outline-color")?2:0,Ov.ReadOnly);QE(e,t,n,r,i,s,!0)}},"fill-extrusion":function(e,t,n,r){const i=n.paint.get("fill-extrusion-opacity"),o=e.context,a=o.gl,s=e.terrain,l=s&&s.renderingToTexture,u=n.paint.get("fill-extrusion-cutoff-fade-range");if(0===i)return;const c=e.conflationActive&&e.layerUsedInConflation(n,t.getSource());if(c&&function(e,t,n,r){for(const i of r){const r=t.getTile(i).getBucket(n);r&&(r.updateReplacement(i,e.replacementSource),r.uploadCentroid(e.context))}}(e,t,n,r),s||c)for(const i of r){const r=t.getTile(i).getBucket(n);r&&nM(e.context,t,i,r,n,s,c)}if("shadow"===e.renderPass&&e.shadowRenderer){const o=e.shadowRenderer;if(s&&i<.65&&n._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof vo)return;const a=o.getShadowPassDepthMode(),l=o.getShadowPassColorMode();eM(e,t,n,r,a,Pv.disabled,l,c)}else if("translucent"===e.renderPass){const h=!n.paint.get("fill-extrusion-pattern").constantOr(1);if(!l){const o=new Ov(e.context.gl.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D);0===u&&1===i&&h?eM(e,t,n,r,o,Pv.disabled,Rv.unblended,c):(eM(e,t,n,r,o,Pv.disabled,Rv.disabled,c),eM(e,t,n,r,o,e.stencilModeFor3D(),e.colorModeForRenderPass(),c),e.resetStencilClippingMasks())}if(e.style.enable3dLights()&&h&&(!s&&"globe"!==e.transform.projection.name||l)){const i=n.paint.get("fill-extrusion-opacity"),u=n.paint.get("fill-extrusion-ambient-occlusion-intensity"),h=n.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),d=n.paint.get("fill-extrusion-flood-light-intensity"),f=n.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),p=u>0&&h>0,m=d>0,_=(e,t,n)=>(1-n)*e+n*t,g=o=>{const s=e.depthModeForSublayer(1,Ov.ReadOnly,a.LEQUAL,!0),l=n.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),p=_(.1,3,l),m=e._showOverdrawInspector;if(!m){const l=new Pv({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),m=new Rv([a.ONE,a.ONE,a.ONE,a.ONE],dn.transparent,[!1,!1,!1,!0],a.MIN);tM(e,t,n,r,s,l,m,Dv.disabled,o,"sdf",i,u,h,d,f,p,c,!1)}{const l=m?Pv.disabled:new Pv({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),_=m?e.colorModeForRenderPass():new Rv([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],dn.transparent,[!0,!0,!0,!0]);tM(e,t,n,r,s,l,_,Dv.disabled,o,"color",i,u,h,d,f,p,c,!1)}};if(l){const l=(o,s,l)=>{const p=e.depthModeForSublayer(1,Ov.ReadOnly,a.LEQUAL,!1),m=n.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),g=_(.1,3,m);{const l=new Rv([a.ONE,a.ONE,a.ONE,a.ONE],dn.transparent,[!1,!1,!1,!0]);tM(e,t,n,r,p,Pv.disabled,l,Dv.disabled,o,"clear",i,u,h,d,f,g,c,s)}{const l=new Pv({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),m=new Rv([a.ONE,a.ONE,a.ONE,a.ONE],dn.transparent,[!1,!1,!1,!0],a.MIN);tM(e,t,n,r,p,l,m,Dv.disabled,o,"sdf",i,u,h,d,f,g,c,s)}{const l=o?a.ZERO:a.ONE_MINUS_DST_ALPHA,m=new Pv({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),_=new Rv([l,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],dn.transparent,[!0,!0,!0,!0]);tM(e,t,n,r,p,m,_,Dv.disabled,o,"color",i,u,h,d,f,g,c,s)}{const m=new Rv([a.ONE,a.ONE,a.ONE,o?a.ZERO:a.ONE],dn.transparent,[!1,!1,!1,!0],o?a.FUNC_ADD:a.MAX);tM(e,t,n,r,p,Pv.disabled,m,Dv.disabled,o,"clear",i,u,h,d,f,g,c,s,l)}};if(p||m){let t;if(e.prepareDrawTile(),s){const e=s.drapeBufferSize[0],n=s.drapeBufferSize[1];t=s.framebufferCopyTexture,t&&(!t||t.size[0]===e&&t.size[1]===n)||(t&&t.destroy(),t=s.framebufferCopyTexture=new Ry(o,new bp({width:e,height:n}),a.RGBA)),t.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,e,n,0)}p&&l(!0,!1,t),m&&l(!1,!0,t)}}else p&&g(!0),m&&g(!1)}}},hillshade:function(e,t,n,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const i=e.context,o=e.terrain&&e.terrain.renderingToTexture,[a,s]="translucent"!==e.renderPass||o?[{},r]:e.stencilConfigForOverlap(r);for(const r of s){const i=t.getTile(r);if(i.needsHillshadePrepare&&"offscreen"===e.renderPass)ZS(e,i,n);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Ov.ReadOnly),s=n.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(s),u=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):a[r.overscaledZ];qS(e,r,i,n,t,u,l)}}i.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,t,n,r,i,o){if("translucent"!==e.renderPass)return;if(0===n.paint.get("raster-opacity"))return;const a=e.context,s=a.gl,l=t.getSource(),u=function(e,t,n){const r=e.paint.get("raster-color"),i=[],o=e.paint.get("raster-resampling"),a=e.paint.get("raster-color-mix"),s=e.paint.get("raster-color-range"),l=[a[0],a[1],a[2],0],u=a[3],c="nearest"===o?n.NEAREST:n.LINEAR;if(r&&i.push("RASTER_COLOR"),r){t.activeTexture.set(n.TEXTURE2);let r=e.colorRampTexture;r||(r=e.colorRampTexture=new Ry(t,e.colorRamp,n.RGBA)),r.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:l,range:s,offset:u,defines:i,resampling:c}}(n,a,s),c=u.defines,h="globe"===e.transform.projection.name;let d=!1;if(l instanceof tw&&!r.length){if(!h)return;if(l.onNorthPole)d=!0,c.push("GLOBE_POLES");else{if(!l.onSouthPole)return;d=!0,c.push("GLOBE_POLES")}}const f=n.paint.get("raster-emissive-strength"),p=e.colorModeForDrapableLayerRenderPass(f),m=e.terrain&&e.terrain.renderingToTexture,_=l instanceof tw&&0!==n.paint.get("raster-elevation"),g=!e.options.moving,y="nearest"===n.paint.get("raster-resampling")?s.NEAREST:s.LINEAR;if(d){const r=t.getSource();if(!(r instanceof tw))return;const i=r.texture;if(!i)return;const o=e.globeSharedBuffers;if(!o)return;const l=new Ov(s.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D),c=Float32Array.from(e.transform.expandedFarZProjMatrix);let h=tf(0,0,e.transform);const d=Float32Array.from($d(zd(new pd(0,0,0)))),m={opacity:1,mix:0};e.terrain&&e.terrain.prepareDrawTile(),a.activeTexture.set(s.TEXTURE0),i.bind(y,s.CLAMP_TO_EDGE),a.activeTexture.set(s.TEXTURE1),i.bind(y,s.CLAMP_TO_EDGE),i.useMipmap&&a.extTextureFilterAnisotropic&&e.transform.pitch>20&&s.texParameterf(s.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax);const[_,g,v,x]=o.getPoleBuffers(0,!0);let b;r.onNorthPole?(b=_,e.renderDefaultNorthPole=!1):(h=Jh.scale(Jh.create(),h,[1,-1,1]),b=g,e.renderDefaultSouthPole=!1);const w=((e,t,n,r,i,o,a,s,l,u,c,h)=>EE(e,t,n,new Float32Array(16),new Float32Array(9),[0,0],[0,0,0,0],0,[0,0],[0,0,0,0],1,r,i,o||[0,0],a,2,l,u,c,1,0,h))(c,d,h,m,n,r.perspectiveTransform||[0,0],n.paint.get("raster-elevation"),0,u.mix,u.offset,u.range,f),T=e.getOrCreateProgram("raster",{defines:u.defines});return e.uploadCommonUniforms(a,T,null),void T.draw(e,s.TRIANGLES,l,Pv.disabled,p,Dv.disabled,w,n.id,b,v,x)}if(!r.length)return;const[v,x]=l instanceof tw||m?[{},r]:e.stencilConfigForOverlap(r),b=x[x.length-1].overscaledZ,w=_&&h;w&&u.defines.push("PROJECTION_GLOBE_VIEW"),_&&u.defines.push("RENDER_CUTOFF");for(const r of x){const i=r.toUnwrapped(),c=t.getTile(r);if(m&&(!c||!c.hasData()))continue;if(!c.texture)continue;let d,x;m?(d=Ov.disabled,x=r.projMatrix):_?(d=new Ov(s.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D),x=h?Float32Array.from(e.transform.expandedFarZProjMatrix):e.transform.calculateProjMatrix(i,g)):(d=e.depthModeForSublayer(r.overscaledZ-b,1===n.paint.get("raster-opacity")?Ov.ReadWrite:Ov.ReadOnly,s.LESS),x=e.transform.calculateProjMatrix(i,g));const T=e.terrain&&m?e.terrain.stencilModeForRTTOverlap(r):v[r.overscaledZ],S=o?0:n.paint.get("raster-fade-duration");c.registerFadeDuration(S);const E=t.findLoadedParent(r,0),M=rE(c,E,t,e.transform,S);let A,I;e.terrain&&e.terrain.prepareDrawTile(),a.activeTexture.set(s.TEXTURE0),c.texture&&c.texture.bind(y,s.CLAMP_TO_EDGE),a.activeTexture.set(s.TEXTURE1),E?(E.texture&&E.texture.bind(y,s.CLAMP_TO_EDGE),A=Math.pow(2,E.tileID.overscaledZ-c.tileID.overscaledZ),I=[c.tileID.canonical.x*A%1,c.tileID.canonical.y*A%1]):c.texture&&c.texture.bind(y,s.CLAMP_TO_EDGE),c.texture&&c.texture.useMipmap&&a.extTextureFilterAnisotropic&&e.transform.pitch>20&&s.texParameterf(s.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax);const C=e.transform,k=l instanceof tw?l.perspectiveTransform:[0,0],O=_?sM(C):[0,0,0,0];let P,R,D,L,z,B;if(w&&l instanceof tw&&l.coordinates.length>3){P=Float32Array.from($d(zd(new pd(0,0,0)))),R=Float32Array.from(C.globeMatrix),D=Float32Array.from(Qd(C)),L=[yf(C.center.lng),vf(C.center.lat)],B=[yf(l.coordinates[1][0]),vf(l.coordinates[1][1]),yf(l.coordinates[3][0]),vf(l.coordinates[3][1])];const t=new ju(l.coordinates[1],l.coordinates[3]);z=Float32Array.from(rf(new pd(0,0,0),t,0,C.worldSize/e.transform._pixelsPerMercatorPixel))}else P=new Float32Array(16),R=new Float32Array(9),D=new Float32Array(16),L=[0,0],z=new Float32Array(16),B=[0,0,0,0];const F=EE(x,P,R,D,z,I||[0,0],B,ef(e.transform.zoom),L,O,A||1,M,n,k,_?n.paint.get("raster-elevation"):0,2,u.mix,u.offset,u.range,1,0,f),j=e.isTileAffectedByFog(r),N=e.getOrCreateProgram("raster",{defines:u.defines,overrideFog:j});if(e.uploadCommonUniforms(a,N,i),l instanceof tw){if(m||!h)l.boundsBuffer&&l.boundsSegments&&N.draw(e,s.TRIANGLES,d,Pv.disabled,p,Dv.disabled,F,n.id,l.boundsBuffer,e.quadTriangleIndexBuffer,l.boundsSegments);else if(e.globeSharedBuffers){const[t,r,i]=e.globeSharedBuffers.getGridBuffers(0,!1);N.draw(e,s.TRIANGLES,d,Pv.disabled,p,Dv.frontCCW,F,n.id,t,r,i),N.draw(e,s.TRIANGLES,d,Pv.disabled,p,Dv.backCCW,F,n.id,t,r,i)}}else{const{tileBoundsBuffer:t,tileBoundsIndexBuffer:r,tileBoundsSegments:i}=e.getTileBoundsBuffers(c);N.draw(e,s.TRIANGLES,d,T,p,Dv.disabled,F,n.id,t,r,i)}}e.resetStencilClippingMasks()},background:function(e,t,n,r){const i=n.paint.get("background-color"),o=n.paint.get("background-opacity"),a=n.paint.get("background-emissive-strength");if(0===o)return;const s=e.context,l=s.gl,u=e.transform,c=u.tileSize,h=n.paint.get("background-pattern");if(e.isPatternMissing(h,n.scope))return;const d=!h&&1===i.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==d)return;const f=Pv.disabled,p=e.depthModeForSublayer(0,"opaque"===d?Ov.ReadWrite:Ov.ReadOnly),m=e.colorModeForDrapableLayerRenderPass(a),_=h?"backgroundPattern":"background";let g,y=r;y||(g=e.getBackgroundTiles(),y=Object.values(g).map(e=>e.tileID)),h&&(s.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context,n.scope));for(const d of y){const y=e.isTileAffectedByFog(d),v=e.getOrCreateProgram(_,{overrideFog:y}),x=d.toUnwrapped(),b=r?d.projMatrix:e.transform.calculateProjMatrix(x);e.prepareDrawTile();const w=t?t.getTile(d):g?g[d.key]:new Vy(d,c,u.zoom,e),T=h?DE(b,a,o,e,h,n.scope,{tileID:d,tileSize:c}):RE(b,a,o,i);e.uploadCommonUniforms(s,v,x);const{tileBoundsBuffer:S,tileBoundsIndexBuffer:E,tileBoundsSegments:M}=e.getTileBoundsBuffers(w);v.draw(e,l.TRIANGLES,p,f,m,Dv.disabled,T,n.id,S,E,M)}},sky:function(e,t,n){const r=e._atmosphere?ef(e.transform.zoom):1,i=n.paint.get("sky-opacity")*r;if(0===i)return;const o=e.context,a=n.paint.get("sky-type"),s=new Ov(o.gl.LEQUAL,Ov.ReadOnly,[0,1]),l=e.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===e.renderPass?n.needsSkyboxCapture(e)&&(function(e,t,n,r){const i=e.context,o=i.gl;let a=t.skyboxFbo;if(!a){a=t.skyboxFbo=i.createFramebuffer(32,32,!0,null),t.skyboxGeometry=new xM(i),t.skyboxTexture=i.gl.createTexture(),o.bindTexture(o.TEXTURE_CUBE_MAP,t.skyboxTexture),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR);for(let e=0;e<6;++e)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,o.RGBA,32,32,0,o.RGBA,o.UNSIGNED_BYTE,null)}i.bindFramebuffer.set(a.framebuffer),i.viewport.set([0,0,32,32]);const s=t.getCenter(e,!0),l=e.getOrCreateProgram("skyboxCapture"),u=new Float64Array(16);Jh.identity(u),Jh.rotateY(u,u,.5*-Math.PI),bM(e,t,l,u,s,0),Jh.identity(u),Jh.rotateY(u,u,.5*Math.PI),bM(e,t,l,u,s,1),Jh.identity(u),Jh.rotateX(u,u,.5*-Math.PI),bM(e,t,l,u,s,2),Jh.identity(u),Jh.rotateX(u,u,.5*Math.PI),bM(e,t,l,u,s,3),Jh.identity(u),bM(e,t,l,u,s,4),Jh.identity(u),Jh.rotateY(u,u,Math.PI),bM(e,t,l,u,s,5),i.viewport.set([0,0,e.width,e.height])}(e,n),n.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,t,n,r,i){const o=e.context,a=o.gl,s=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,t.skyboxTexture);const u=((e,t,n,r,i)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:i}))(s.skyboxMatrix,t.getCenter(e,!1),0,r,i);e.uploadCommonUniforms(o,l),l.draw(e,a.TRIANGLES,n,Pv.disabled,e.colorModeForRenderPass(),Dv.backCW,u,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,n,s,i,l):"gradient"===a&&"sky"===e.renderPass&&function(e,t,n,r,i){const o=e.context,a=o.gl,s=e.transform,l=e.getOrCreateProgram("skyboxGradient");t.skyboxGeometry||(t.skyboxGeometry=new xM(o)),o.activeTexture.set(a.TEXTURE0);let u=t.colorRampTexture;u||(u=t.colorRampTexture=new Ry(o,t.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const c=((e,t,n,r,i)=>({u_matrix:e,u_color_ramp:0,u_center_direction:t,u_radius:T(n),u_opacity:r,u_temporal_offset:i}))(s.skyboxMatrix,t.getCenter(e,!1),t.paint.get("sky-gradient-radius"),r,i);e.uploadCommonUniforms(o,l),l.draw(e,a.TRIANGLES,n,Pv.disabled,e.colorModeForRenderPass(),Dv.backCW,c,"skyboxGradient",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,n,s,i,l)},debug:function(e,t,n){for(let r=0;r{a&&(a.useNormalOffset=!0,s||(a.enabled=!0))},u=t.getSource();if("light-beam"===e.renderPass&&"batched-model"!==u.type)return;if("vector"===u.type||"geojson"===u.type)return function(e,t,n,r){const i=e.transform;if("mercator"!==i.projection.name)return void X(`Drawing 3D models for ${i.projection.name} projection is not yet implemented`);const o=i.getFreeCameraOptions().position;if(!e.modelManager)return;const a=e.modelManager,s=e.shadowRenderer;if(!n._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const l=n._unevaluatedLayout._values["model-id"],u={...n.layout.get("model-id").parameters};for(const c of r){const r=t.getTile(c).getBucket(n);if(!r||r.projection.name!==i.projection.name)continue;const h=RM(c,i);u.zoom=h;const d=l.possiblyEvaluate(u);if(OM(e,r,c),PM.shadowUniformsInitialized=!1,PM.useSingleShadowCascade=!!s&&0===s.getMaxCascadeForTile(c.toUnwrapped()),"shadow"===e.renderPass&&s){if(1===e.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const t=i.calculatePosMatrix(c.toUnwrapped(),i.worldSize);if(PM.tileMatrix.set(t),PM.shadowTileMatrix=Float32Array.from(s.calculateShadowPassMatrixFromMatrix(t)),PM.aabb.min.fill(0),PM.aabb.max[0]=PM.aabb.max[1]=hr,PM.aabb.max[2]=0,zM(r,PM,e,n.scope))continue}const f=1<0&&(t=d.evaluate(i.features[0].feature,{}));const o=a.getModel(t,n.scope);if(o&&o.uploaded)for(const t of o.nodes)DM(e,n,t,i,p,c,PM)}}}(e,t,n,r),void l();if(!u.loaded())return;if("batched-model"===u.type)return function(e,t,n,r){const i=e.context,o=e.transform,a=e.style.fog,s=e.shadowRenderer;if("mercator"!==o.projection.name)return void X(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`);const l=e.transform.getFreeCameraOptions().position,u=id.scale([],[l.x,l.y,l.z],e.transform.worldSize);id.negate(u,u);const c=Jh.identity([]),h=Mf(o.center.lat,o.zoom),d=Jh.fromScaling([],[1,1,1/h]);Jh.translate(c,c,u);const f=n.paint.get("model-opacity"),p=new Ov(i.gl.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D),m=new Ov(i.gl.LEQUAL,Ov.ReadOnly,e.depthRangeFor3D),_=function(l,u){for(const h of r){const r=t.getTile(h).getBucket(n);if(!r||!r.uploaded)continue;let _=!1;s&&(_=0===s.getMaxCascadeForTile(h.toUnwrapped()));const g=o.calculatePosMatrix(h.toUnwrapped(),o.worldSize),y=r.modelTraits;for(const t of r.getNodesInfo()){if(t.hiddenByReplacement)continue;if(!t.node.meshes)continue;const r=t.node,v="light-beam"===e.renderPass,x=[...g],b=t.evaluatedScale;let w=0;e.terrain&&r.elevation&&(w=r.elevation*e.terrain.exaggeration()),Jh.translate(x,x,[(r.anchor?r.anchor[0]:0)*(b[0]-1),(r.anchor?r.anchor[1]:0)*(b[1]-1),w]),b!==Ox&&Jh.scale(x,x,b),Jh.multiply(x,x,r.matrix);const T=Jh.multiply([],d,x);Jh.multiply(T,c,T);const S=Jh.invert([],T);Jh.transpose(S,S),Jh.scale(S,S,LM);const E=Jh.multiply([],o.expandedFarZProjMatrix,x);for(let c=0;c=mw||i>=mw}}const I=e.getOrCreateProgram("model",b);!M&&s&&(s.useNormalOffset=!!d.normalBuffer,s.setupShadowsFromMatrix(x,I,s.useNormalOffset)),e.uploadCommonUniforms(i,I,h.toUnwrapped(),A);const C=d.material,k=C.pbrMetallicRoughness;k.metallicFactor=.9,k.roughnessFactor=.5;const O=0,P=UE(new Float32Array(E),new Float32Array(T),new Float32Array(S),e,f,k.baseColorFactor,C.emissiveFactor,k.metallicFactor,k.roughnessFactor,C,O,n);I.draw(e,i.gl.TRIANGLES,u&&!g?p:m,Pv.disabled,l?g||f<1||t.hasTranslucentParts?Rv.alphaBlended:Rv.unblended:Rv.disabled,Dv.backCCW,P,n.id,d.vertexBuffer,d.indexBuffer,d.segments,n.paint,e.transform.zoom,void 0,w)}}}};(function(e,t,n,r){const i=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const a of r){const r=t.getTile(a).getBucket(n);r&&(e.conflationActive&&r.updateReplacement(a,e.replacementSource),r.evaluateScale(e,n),e.terrain&&i>0&&r.elevationUpdate(e.terrain,i,a,n.source),r.needsReEvaluation(e,o,n)&&r.evaluate(n))}})(e,t,n,r),1===f?_(!0,!0):(_(!1,!0),_(!0,!1))}(e,t,n,r),void l();const c=u.getModels(),h=[],d=e.transform.getFreeCameraOptions().position,f=id.scale([],[d.x,d.y,d.z],e.transform.worldSize);id.negate(f,f);const p=[],m=[];let _=0;for(const t of c){const r=n.paint.get("model-rotation").constantOr(null),i=n.paint.get("model-scale").constantOr(null),o=n.paint.get("model-translation").constantOr(null);t.computeModelMatrix(e,r,i,o,!0,!0,!1);const a=Jh.identity([]),s=Mf(t.position.lat,e.transform.zoom),l=Jh.fromScaling([],[1,1,1/s]);Jh.translate(a,a,f),h.push({zScaleMatrix:l,negCameraPosMatrix:a});for(const n of t.nodes)CM(e.transform,n,t.matrix,e.transform.expandedFarZProjMatrix,_,p,m);_++}if(p.sort((e,t)=>t.depth-e.depth),"shadow"!==e.renderPass){if(1===i)for(const t of m)IM(t,e,n,h[t.modelIndex],Pv.disabled,e.colorModeForRenderPass());else{for(const t of m)IM(t,e,n,h[t.modelIndex],Pv.disabled,Rv.disabled);for(const t of m)IM(t,e,n,h[t.modelIndex],e.stencilModeFor3D(),e.colorModeForRenderPass());e.resetStencilClippingMasks()}for(const t of p)IM(t,e,n,h[t.modelIndex],Pv.disabled,e.colorModeForRenderPass());l()}else{for(const t of m)kM(t.mesh,t.nodeModelMatrix,e,n);for(const t of p)kM(t.mesh,t.nodeModelMatrix,e,n);l()}}},NM={modelUpload:function(e,t,n){const r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(e.modelManager&&e.modelManager.upload(e,n));if("batched-model"===r.type)return;const i=r.getModels();for(const t of i)t.upload(e.context)}};class UM{constructor(e,t,n){this.context=new Lv(e,t),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=zv.maxUnderzooming+zv.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new Jx,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new WM(this),this._wireframeDebugCache=new FM,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0}updateTerrain(e,t){const n=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(n||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new sE(this,e));const r=this._terrain;this.transform.elevation=n?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.enabled&&(this.transform.elevation=null)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[n,r]=t.getFovAdjustedRange(this.transform._fov);if(n>r)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}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(e,t){if(this.width=e*ft.devicePixelRatio,this.height=t*ft.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize()}setup(){const e=this.context,t=new cl;t.emplaceBack(0,0),t.emplaceBack(hr,0),t.emplaceBack(0,hr),t.emplaceBack(hr,hr),this.tileExtentBuffer=e.createVertexBuffer(t,hd.members),this.tileExtentSegments=Ql.simpleSegment(0,0,4,2);const r=new cl;r.emplaceBack(0,0),r.emplaceBack(hr,0),r.emplaceBack(0,hr),r.emplaceBack(hr,hr),this.debugBuffer=e.createVertexBuffer(r,hd.members),this.debugSegments=Ql.simpleSegment(0,0,4,5);const i=new cl;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(-1,1),i.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(i,hd.members),this.viewportSegments=Ql.simpleSegment(0,0,4,2);const o=new dl;o.emplaceBack(0,0,0,0),o.emplaceBack(hr,0,hr,0),o.emplaceBack(0,hr,0,hr),o.emplaceBack(hr,hr,hr,hr),this.mercatorBoundsBuffer=e.createVertexBuffer(o,Ny.members),this.mercatorBoundsSegments=Ql.simpleSegment(0,0,4,2);const a=new Al;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(a);const s=new Dl;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=e.createIndexBuffer(s),this.emptyTexture=new Ry(e,new bp({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=Jh.create();const l=this.context.gl;this.stencilClearMode=new Pv({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(n.performance.now())}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 e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,Ov.disabled,this.stencilClearMode,Rv.disabled,Dv.disabled,nE(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,n){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!n||0===n.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of n)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,i=r.gl;this.nextStencilID+n.length>256&&this.clearStencil(),r.setColorMode(Rv.disabled),r.setDepthMode(Ov.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of n){const n=t.getTile(e),r=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:a,tileBoundsIndexBuffer:s,tileBoundsSegments:l}=this.getTileBoundsBuffers(n);o.draw(this,i.TRIANGLES,Ov.disabled,new Pv({func:i.ALWAYS,mask:0},r,255,i.KEEP,i.KEEP,i.REPLACE),Rv.disabled,Dv.disabled,nE(e.projMatrix),"$clipping",a,s,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Pv({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new Pv({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,n=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();const e={};for(let n=0;nthis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Rv([t.ONE,t.ONE_MINUS_SRC_ALPHA,t.CONSTANT_ALPHA,t.ONE_MINUS_SRC_ALPHA],new dn(0,0,0,void 0===e?0:e),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,n,r=!1){if(!this.opaquePassEnabledForLayer()&&!r)return Ov.disabled;const i=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Ov(n||this.context.gl.LEQUAL,t,[i,i])}opaquePassEnabledForLayer(){return this.currentLayerr[e]),a=this.style._mergedSourceCaches;this.imageManager=e.imageManager,this.modelManager=e.modelManager,this.symbolFadeChange=e.placement.symbolFadeChange(ft.now()),this.imageManager.beginFrame();let s=0,l=!1;for(const e in a){const t=a[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++s)}const u={},c={},h={},d={},f={};for(const e in a){const t=a[e];u[e]=t.getVisibleCoordinates(),c[e]=u[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse(),d[e]=t.getShadowCasterCoordinates(),f[e]=t.sortCoordinatesByDistance(u[e])}const p=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(s){const e=[];for(const t of o)this.layerUsedInConflation(t,p(t))&&e.push(t);if(e&&e.length>1){const t=[];for(const n of e){const e=this.style.getLayerSourceCache(n);e&&e.used&&e.getSource().usedInConflation&&t.push({layer:n.fqid,cache:e})}this.replacementSource.setSources(t),l=!0}}l||this.replacementSource.clear(),this.conflationActive=l,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const e of o){const t=e.cutoffRange();if(this.longestCutoffRange=Math.max(t,this.longestCutoffRange),t>0){const t=p(e);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),e.minzoom&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom))}}this.opaquePassCutoff=1/0;for(let e=0;e{if(t.showOverdrawInspector)return dn.black;if(this.style.fog&&this.transform.projection.supportsFog&&!y){const e=this.style.fog.properties.get("color").toArray01();return new dn(...e)}if(this.style.fog&&this.transform.projection.supportsFog&&y){const e=this.style.fog.properties.get("space-color").toArray01();return new dn(...e)}return dn.transparent})();if(this.context.clear({color:v,depth:1}),this.clearStencil(),this._showOverdrawInspector=t.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){const t=o[this.currentLayer],n=e.getLayerSourceCache(t);if(t.isSky())continue;const r=n?(t.is3D()?f:c)[n.id]:void 0;this._renderTileClippingMasks(t,n,r),this.renderLayer(this,n,t,r)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||ef(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&t.hasShadowPass()&&0==--x&&(_.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const t=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=t;this.currentLayer++){const t=o[this.currentLayer];if(!t.hasLightBeamPass())continue;const n=e.getLayerSourceCache(t);this.renderLayer(this,n,t,n?c[n.id]:void 0)}this.currentLayer=t,this.renderPass="translucent"}++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let t=null;o.forEach(n=>{const r=e.getLayerSourceCache(n);r&&!n.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!t||t.getSource().maxzoom0?t.pop():null}isPatternMissing(e,t){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString(),t)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,n){const r=void 0===n?this.terrain&&this.terrain.renderingToTexture:n,i=this.terrain&&0===this.terrain.exaggeration(),o=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(o.push("LIGHTING_3D_MODE"),o.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||o.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||o.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?o.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):o.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(o.push("TERRAIN"),this.linearFloatFilteringSupported()&&o.push("TERRAIN_DEM_FLOAT_FORMAT"),i&&o.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&o.push("GLOBE"),!this._fogVisible||r||void 0!==t&&!t||o.push("FOG","FOG_DITHERING"),r&&o.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&o.push("OVERDRAW_INSPECTOR"),o}getOrCreateProgram(e,t){this.cache=this.cache||{};const n=t&&t.defines||[],r=t&&t.config,i=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(n),o=hE.cacheKey(jS[e],e,i,r);return this.cache[o]||(this.cache[o]=new hE(this.context,e,jS[e],r,qE[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=n.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Ry(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(e,t){if(this.style.enable3dLights()){const n=this.style.directionalLight,r=this.style.ambientLight;if(n&&r){const i=((e,t)=>{const n=e.properties.get("direction"),r=e.properties.get("color").toArray01(),i=e.properties.get("intensity"),o=t.properties.get("color").toArray01(),a=t.properties.get("intensity"),s=[n.x,n.y,n.z],l=se(o,a),u=se(r,i);return{u_lighting_ambient_color:l,u_lighting_directional_dir:s,u_lighting_directional_color:u,u_ground_radiance:lE(s,u,l)}})(n,r);t.setLightsUniformValues(e,i)}}}uploadCommonUniforms(e,t,n,r,i){if(this.uploadCommonLightUniforms(e,t),this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const i=o.getOpacity(this.transform.pitch),a=((e,t,n,r,i,o,a,s,l,u,c,h)=>{const d=e.transform,f=t.properties.get("color").toArray01();f[3]=r;const p=e.frameCounter/1e3%1,[m,_]=t.properties.get("vertical-range");return{u_fog_matrix:n?d.calculateFogTileMatrix(n):h||e.identityMat,u_fog_range:t.getFovAdjustedRange(d._fov),u_fog_color:f,u_fog_horizon_blend:t.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(m,_),_],u_fog_temporal_offset:p,u_frustum_tl:i,u_frustum_tr:o,u_frustum_br:a,u_frustum_bl:s,u_globe_pos:l,u_globe_radius:u,u_viewport:c,u_globe_transition:ef(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,o,n,i,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*ft.devicePixelRatio,this.transform.height*ft.devicePixelRatio],r);t.setFogUniformValues(e,a)}i&&t.setCutoffUniformValues(e,i.uniformValues)}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 e=this._backgroundTiles,t=this._backgroundTiles={},n=this.transform.coveringTiles({tileSize:512});for(const r of n)t[r.key]=e[r.key]||new Vy(r,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={}}layerUsedInConflation(e,t){return!(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||"building"!==e.sourceLayer&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=mw||t[1]>=mw}}const VM=2048;class GM{constructor(e,t){this.aabb=e,this.lastCascade=t}}class qM{add(e,t){const n=this.receivers[e.key];void 0!==n?(n.aabb.min[0]=Math.min(n.aabb.min[0],t.min[0]),n.aabb.min[1]=Math.min(n.aabb.min[1],t.min[1]),n.aabb.min[2]=Math.min(n.aabb.min[2],t.min[2]),n.aabb.max[0]=Math.max(n.aabb.max[0],t.max[0]),n.aabb.max[1]=Math.max(n.aabb.max[1],t.max[1]),n.aabb.max[2]=Math.max(n.aabb.max[2],t.max[2])):this.receivers[e.key]=new GM(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(e,t,n){const r=Md.fromPoints(e.points);let i=0;for(const e in this.receivers){const o=this.receivers[e];if(!o)continue;if(!r.intersectsAabb(o.aabb))continue;o.aabb.min=r.closestPoint(o.aabb.min),o.aabb.max=r.closestPoint(o.aabb.max);const a=o.aabb.getCorners();for(let e=0;e1||o[1]<-1||o[1]>1){r=!1;break}}if(o.lastCascade=e,i=Math.max(i,e),r)break}}return i+1}}class WM{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new qM,this._depthMode=new Ov(e.context.gl.LEQUAL,Ov.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this.useNormalOffset=!1}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(e,t){const n=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!t||!t.properties)return;const r=t.properties.get("shadow-intensity");if(!t.shadowsEnabled()||r<=0)return;if(this._shadowLayerCount=n.style.order.reduce((t,r)=>{const i=n.style._mergedLayers[r];return t+(i.hasShadowPass()&&!i.isHidden(e.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this._enabled)return;const i=n.context,o=VM,a=VM;if(0===this._cascades.length)for(let e=0;e<2;++e){const e=n._shadowMapDebug,t=i.gl,r=i.createFramebuffer(o,a,e,"texture"),s=new Ry(i,{width:o,height:a,data:null},t.DEPTH_COMPONENT);if(r.depthAttachment.set(s.texture),e){const e=new Ry(i,{width:o,height:a,data:null},t.RGBA);r.colorAttachment.set(e.texture)}this._cascades.push({framebuffer:r,texture:s,matrix:[],far:0,boundingSphereRadius:0,frustum:new Ed,scale:0})}this.shadowDirection=HM(t);let s=0;if(e.elevation){const t=e.elevation,n=[1e4,-1e4];t.visibleDemTiles.filter(e=>e.dem).forEach(e=>{const t=e.dem.tree;n[0]=Math.min(n[0],t.minimums[0]),n[1]=Math.max(n[1],t.maximums[0])}),1e4!==n[0]&&(s=(n[1]-n[0])*t.exaggeration())}const l=1.5*e.cameraToCenterDistance,u=3*l,c=new Float64Array(16);for(let t=0;t<2;++t){const n=this._cascades[t];let r=e.height/50,i=1;0===t?i=l:(r=l,i=u);const[o,a]=XM(e,this.shadowDirection,r,i,VM,s);n.scale=e.scale,n.matrix=o,n.boundingSphereRadius=a,Jh.invert(c,n.matrix),n.frustum=Ed.fromInvProjectionMatrix(c,1,0,!0),n.far=i}this._uniformValues.u_fade_range=[.75*this._cascades[1].far,this._cascades[1].far],this._uniformValues.u_shadow_intensity=r,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=.00048828125,this._uniformValues.u_shadow_map_resolution=VM,this._uniformValues.u_shadowmap_0=NE,this._uniformValues.u_shadowmap_1=NE+1,this._groundShadowTiles=n.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const h=n.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(h){const n=h.getMinMaxForTile(e);n&&(t=n)}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max)}}get enabled(){return this._enabled}set enabled(e){this._enabled=e}drawShadowPass(e,t){if(!this._enabled)return;const n=this.painter,r=n.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(n.transform.getFrustum(0),n.transform.worldSize,this._cascades),r.viewport.set([0,0,VM,VM]);for(let i=0;i=0)return{};const i=function(e,t,n){const r=n/(1<0&&(id.add(i[1],i[1],[r[0]*o,0,0]),id.add(i[2],i[2],[r[0]*o,0,0])),r[1]<0?(id.add(i[0],i[0],[0,r[1]*o,0]),id.add(i[1],i[1],[0,r[1]*o,0])):r[1]>0&&(id.add(i[2],i[2],[0,r[1]*o,0]),id.add(i[3],i[3],[0,r[1]*o,0]));const a={};return a.vertices=i,a.planes=[ZM(i[1],i[0],i[4]),ZM(i[2],i[1],i[5]),ZM(i[3],i[2],i[6]),ZM(i[0],i[3],i[7])],a}addShadowReceiver(e,t,n){this._receivers.add(e,Md.fromTileIdAndHeight(e,t,n))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function ZM(e,t,n){const r=id.sub([],n,t),i=id.sub([],e,t),o=id.cross([],r,i),a=id.length(o);return 0===a?[0,0,1,0]:(id.scale(o,o,1/a),[o[0],o[1],o[2],-id.dot(o,t)])}function HM(e){const t=e.properties.get("direction"),n=Q(t.x,t.y,t.z);n[2]=O(n[2],0,75);const r=J([n[0],n[1],n[2]]);return id.fromValues(r.x,r.y,r.z)}function $M(e,t){const n=e.properties.get("color"),r=e.properties.get("intensity"),i=e.properties.get("direction"),o=[i.x,i.y,i.z],a=t.properties.get("color"),s=t.properties.get("intensity"),l=Math.max(id.dot([0,0,1],o),0),u=[0,0,0];id.scale(u,a.toArray01Linear().slice(0,3),s);const c=[0,0,0];return id.scale(c,n.toArray01Linear().slice(0,3),l*r),le([u[0]>0?u[0]/(u[0]+c[0]):0,u[1]>0?u[1]/(u[1]+c[1]):0,u[2]>0?u[2]/(u[2]+c[2]):0])}function XM(e,t,n,r,i,o){const a=e.zoom,s=e.scale,l=e.worldSize,u=1/l,c=e.aspect,h=Math.sqrt(1+c*c)*Math.tan(.5*e.fovX),d=h*h,f=r-n,p=r+n;let m,_;d>f/p?(m=r,_=r*h):(m=.5*p*(1+d),_=.5*Math.sqrt(f*f+2*(r*r+n*n)*d+p*p*d*d));const g=e.projection.pixelsPerMeter(e.center.lat,l),y=e._camera.getCameraToWorldMercator(),v=[0,0,-m*u];id.transformMat4(v,v,y);let x=_*u;const b=e._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const t=e._camera.getWorldToCamera(e.worldSize,"meters"===e.projection.zAxisUnit?g:1),i=e._camera.getCameraToClipPerspective(e._fov,e.width/e.height,n,r);i[8]=2*-e.centerOffset.x/e.width,i[9]=2*e.centerOffset.y/e.height;const o=new Float64Array(16);Jh.mul(o,i,t);const u=new Float64Array(16);Jh.invert(u,o);const c=Ed.fromInvProjectionMatrix(u,l,a,!0);for(const t of c.points){const n=((w=t)[0]/=s,w[1]/=s,w[2]=xf(w[2],e._center.lat),w);x=Math.max(x,id.len(id.subtract([],v,n)))}}var w;x*=i/(i-1);const T=Math.acos(t[2]),S=Math.atan2(-t[0],-t[1]),E=new Jv;E.position=v,E.setPitchBearing(T,S);const M=E.getWorldToCamera(l,g),A=x*l,I=Math.min(e._mercatorZfromZoom(17)*l*-2,-2*A),C=E.getCameraToClipOrthographic(-A,A,-A,A,I,(A+o*g)/t[2]),k=new Float64Array(16);Jh.multiply(k,C,M);const O=id.fromValues(Math.floor(1e6*v[0])/1e6*l,Math.floor(1e6*v[1])/1e6*l,0),P=.5*i,R=[0,0,0];id.transformMat4(R,O,k),id.scale(R,R,P);const D=[Math.floor(R[0]),Math.floor(R[1]),Math.floor(R[2])],L=[0,0,0];id.sub(L,R,D),id.scale(L,L,-1/P);const z=new Float64Array(16);return Jh.identity(z),Jh.translate(z,z,L),Jh.multiply(k,z,k),[k,A]}class YM extends Ot{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={}}loadModel(e,t){return dT(this.requestManager.transformRequest(t,ve.Model).url).then(t=>{if(!t)return;const n=bT(t),r=new Px(e,void 0,void 0,n);return r.computeBoundsAndApplyParent(),r}).catch(n=>{this.fire(new kt(new Error(`Could not load model ${e} from ${t}: ${n.message}`)))})}load(e,t){this.models[t]||(this.models[t]={});const n=Object.keys(e);this.numModelsLoading[t]=(this.numModelsLoading[t]||0)+n.length;const r=[];for(const t of n)r.push(this.loadModel(t,e[t]));Promise.allSettled(r).then(e=>{for(let r=0;r{this.fire(new kt(new Error("Could not load models: "+e.message)))})}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t){return!!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]}addModel(e,t,n){this.models[n]||(this.models[n]={}),this.hasModel(e,n)&&this.removeModel(e,n),this.load({[e]:this.requestManager.normalizeModelURL(t)},n)}addModels(e,t){const n={};for(const t in e)n[t]=this.requestManager.normalizeModelURL(e[t]);this.load(n,t)}removeModel(e,t){this.models[t]||(this.models[t]={});const n=this.models[t][e];delete this.models[t][e],n.destroy()}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const n in this.models[t])this.models[t][n].upload(e.context)}}const KM=(e,t)=>ma(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),JM=B(DT,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","setImportUrl","setImportData","setImportConfig"]),QM=B(DT,["setCenter","setZoom","setBearing","setPitch"]),eA={version:8,layers:[],sources:{}},tA={duration:300,delay:0},nA=new Set(["fill","line","background","hillshade","raster"]);class rA extends Ot{constructor(e,t={}){super(),this.map=e,this.scope=t.scope||"",this.fragments=[],this.importDepth=t.importDepth||0,this.importsCache=t.importsCache||new Map,this.resolvedImports=t.resolvedImports||new Set,this.transition=z({},tA),this._buildingIndex=new kT(this),this.crossTileSymbolIndex=new ES,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=t.styleChanges||new il,this.dispatcher=t.dispatcher?t.dispatcher:new Ew(Hw(),this),t.imageManager?this.imageManager=t.imageManager:(this.imageManager=new cw,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=t.glyphManager?t.glyphManager:new mg(e._requestManager,t.localFontFamily?2:t.localIdeographFontFamily?1:0,t.localFontFamily||t.localIdeographFontFamily),t.modelManager?this.modelManager=t.modelManager:(this.modelManager=new YM(e._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this.options=new Map,this._configDependentLayers=new Set,this._config=t.config,this.dispatcher.broadcast("setReferrer",be());const n=this;this._rtlTextPluginCallback=rA.registerForPluginStateChange(e=>{n.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},(e,t)=>{if(Ds(e),t&&t.every(e=>e))for(const e in n._sourceCaches){const t=n._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||t.reload()}})}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(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(e,t={}){this.fire(new Ct("dataloading",{dataType:"style"}));const n="boolean"==typeof t.validate?t.validate:!Pe(e);e=this.map._requestManager.normalizeStyleURL(e,t.accessToken),this.resolvedImports.add(e);const r=this.importsCache.get(e);if(r)return this._load(r,n);const i=this.map._requestManager.transformRequest(e,ve.Style);this._request=Te(i,(t,r)=>{if(this._request=null,t)this.fire(new kt(t));else if(r)return this.importsCache.set(e,r),this._load(r,n)})}loadJSON(e,t={}){this.fire(new Ct("dataloading",{dataType:"style"})),this._request=ft.frame(()=>{this._request=null,this._load(e,!1!==t.validate)})}loadEmpty(){this.fire(new Ct("dataloading",{dataType:"style"})),this._load(eA,!1)}_loadImports(e,t){if(this.importDepth>=4)return X("Style doesn't support nesting deeper than 5"),Promise.resolve();const n=[];for(const r of e){const e=this._createFragmentStyle(r),i=new Promise(t=>{e.once("style.import.load",t),e.once("error",t)}).then(()=>this.mergeAll());if(n.push(i),this.resolvedImports.has(r.url)){e.loadEmpty();continue}const o=r.data||this.importsCache.get(r.url);o?e.loadJSON(o,{validate:t}):r.url?e.loadURL(r.url,{validate:t}):e.loadEmpty(),this.fragments.push({style:e,id:r.id,config:r.config})}return Promise.allSettled(n)}_createFragmentStyle(e){const t=this.scope?el(e.id,this.scope):e.id,n=new rA(this.map,{scope:t,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:e.config});return n.setEventedParent(this.map,{style:n}),n}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options});const e=this.isRootStyle();this._shouldPrecompile=e,this.fire(new Ct(e?"style.load":"style.import.load"))}_load(e,t){const n=e.schema;if(this.isRootStyle()&&(e.fragment||n&&!1!==e.fragment)){const n=z({},eA,{imports:[{id:"basemap",data:e,url:""}]});return void this._load(n,t)}if(this.setConfig(this._config,n),t&&KM(this,ra(e)))return;this._loaded=!0,this.stylesheet=H(e);for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1,isInitialLoad:!0});e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(e.glyphs,this.scope);const r=RT(this.stylesheet.layers);if(this._order=r.map(e=>e.id),this.stylesheet.light&&X("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new dw(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new dw(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const e of r){const t=lw(e,this.options);t.setScope(this.scope),t.isConfigDependent&&this._configDependentLayers.add(t.fqid),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize();const n=this.getOwnLayerSourceCache(t),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();n&&t.canCastShadows()&&r&&(n.castsShadows=!0)}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const i=this.stylesheet.terrain;i&&(void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=ft.hasCanvasFingerprintNoise()),this.disableElevatedTerrain?X("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."):this.terrainSetForDrapingOnly()||this._createTerrain(i,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new Ct("data",{dataType:"style"})),e.imports?this._loadImports(e.imports,t).then(()=>this._reloadImports()):this._reloadImports()}isRootStyle(){return 0===this.importDepth}mergeAll(){let e,t,n,r,i,o,a,s;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(l=>{if(l.stylesheet){if(null!=l.light&&(e=l.light),l.stylesheet.lights)for(const e of l.stylesheet.lights)"ambient"===e.type&&null!=l.ambientLight&&(t=l.ambientLight),"directional"===e.type&&null!=l.directionalLight&&(n=l.directionalLight);r=this._prioritizeTerrain(r,l.terrain,l.stylesheet.terrain),l.stylesheet.fog&&null!=l.fog&&(i=l.fog),null!=l.stylesheet.camera&&(s=l.stylesheet.camera),null!=l.stylesheet.projection&&(o=l.stylesheet.projection),null!=l.stylesheet.transition&&(a=l.stylesheet.transition)}}),this.light=e,this.ambientLight=t,this.directionalLight=n,this.fog=i,null===r?delete this.terrain:this.terrain=r,this.camera=s||{"camera-projection":"perspective"},this.projection=o||{name:"mercator"},this.transition=z({},tA,a),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(e){const t=n=>{for(const e of n.fragments)t(e.style);e(n)};t(this)}_prioritizeTerrain(e,t,n){const r=e&&0===e.drapeRenderMode;return null===n?t&&0===t.drapeRenderMode?t:r?e:null:null!=t&&(!e||r||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain)}),null===e?delete this.terrain:this.terrain=e}mergeProjection(){let e;this.forEachFragmentStyle(t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)}),this.projection=e||{name:"mercator"}}mergeSources(){const e={},t={},n={};this.forEachFragmentStyle(r=>{for(const t in r._sourceCaches){const n=el(t,r.scope);e[n]=r._sourceCaches[t]}for(const e in r._otherSourceCaches){const n=el(e,r.scope);t[n]=r._otherSourceCaches[e]}for(const e in r._symbolSourceCaches){const t=el(e,r.scope);n[t]=r._symbolSourceCaches[e]}}),this._mergedSourceCaches=e,this._mergedOtherSourceCaches=t,this._mergedSymbolSourceCaches=n}mergeLayers(){const e={},t=[],n={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(n=>{for(const r of n._order){const i=n._layers[r];if("slot"===i.type){const t=tl(r);if(e[t])continue;e[t]=[]}i.slot&&e[i.slot]?e[i.slot].push(i):t.push(i)}}),this._mergedOrder=[];const r=(t=[])=>{for(const i of t)if("slot"===i.type){const t=tl(i.id);e[t]&&r(e[t])}else{const e=el(i.id,i.scope);this._mergedOrder.push(e),n[e]=i,i.is3D()&&(this._has3DLayers=!0),"circle"===i.type&&(this._hasCircleLayers=!0),"symbol"===i.type&&(this._hasSymbolLayers=!0)}};r(t),this._mergedLayers=n,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=z({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),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.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(e){this._spriteRequest=function(e,t,n){let r,i,o;const a=ft.devicePixelRatio>1?"@2x":"";let s=Te(t.transformRequest(t.normalizeSpriteURL(e,a,".json"),ve.SpriteJSON),(e,t)=>{s=null,o||(o=e,r=t,u())}),l=Ce(t.transformRequest(t.normalizeSpriteURL(e,a,".png"),ve.SpriteImage),(e,t)=>{l=null,o||(o=e,i=t,u())});function u(){if(o)n(o);else if(r&&i){const e=ft.getImageData(i),t={};for(const n in r){const{width:i,height:o,x:a,y:s,sdf:l,pixelRatio:u,stretchX:c,stretchY:h,content:d}=r[n],f=new bp({width:i,height:o});bp.copy(e,f,{x:a,y:s},{x:0,y:0},{width:i,height:o}),t[n]={data:f,pixelRatio:u,sdf:l,stretchX:c,stretchY:h,content:d}}n(null,t)}}return{cancel(){s&&(s.cancel(),s=null),l&&(l.cancel(),l=null)}}}(e,this.map._requestManager,(e,t)=>{if(this._spriteRequest=null,e)this.fire(new kt(e));else if(t)for(const e in t)this.imageManager.addImage(e,this.scope,t[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new Ct("data",{dataType:"style"}))})}_validateLayer(e){const t=this.getOwnSource(e.source);if(!t)return;const n=e.sourceLayer;n&&("geojson"===t.type||t.vectorLayerIds&&-1===t.vectorLayerIds.indexOf(n))&&this.fire(new kt(new Error(`Source layer "${n}" does not exist on source "${t.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded())return!1;if(!this.modelManager.isLoaded())return!1;for(const{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((e,t)=>{const n=this.fragments[t];return n&&n.style&&(e.data=n.style.serialize()),e})}_serializeSources(){const e={};for(const t in this._sourceCaches){const n=this._sourceCaches[t].getSource();e[n.id]||(e[n.id]=n.serialize())}return e}_serializeLayers(e){const t=[];for(const n of e){const e=this._layers[n];e&&"custom"!==e.type&&t.push(e.serialize())}return t}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())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.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&("function"==typeof e.isLayerDraped?e.isLayerDraped(this.getLayerSourceCache(e)):nA.has(e.type))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(e){const t=this.getOwnLayer(e);if(t)return t;this.fire(new kt(new Error(`The layer '${e}' does not exist in the map's style.`)))}_checkSource(e){const t=this.getOwnSource(e);if(t)return t;this.fire(new kt(new Error(`The source '${e}' does not exist in the map's style.`)))}update(e){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(e),this.directionalLight&&this.directionalLight.recalculate(e);const t=this.calculateLightsBrightness();e.brightness=t||0,t!==this._brightness&&(this._brightness=t,this.dispatcher.broadcast("setBrightness",t));const n=this._changes.isDirty();if(this._changes.isDirty()){const t=this._changes.getLayerUpdatesByScope();for(const e in t){const{updatedIds:n,removedIds:r}=t[e];(n||r)&&this._updateWorkerLayers(e,n,r)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(e),this.light&&this.light.updateTransitions(e),this.ambientLight&&this.ambientLight.updateTransitions(e),this.directionalLight&&this.directionalLight.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._changes.reset()}const r={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];r[e]=t.used,t.used=!1}for(const t of this._mergedOrder){const n=this._mergedLayers[t];if(n.recalculate(e,this._availableImages),!n.isHidden(e.zoom)){const e=this.getLayerSourceCache(n);e&&(e.used=!0)}if(!this._precompileDone&&this._shouldPrecompile)for(let t=n.minzoom||0;t<(n.maxzoom||25.5);t++){const t=this.map.painter;if(t){const r=n.getProgramIds();if(!r)continue;for(const i of r){const r=n.getDefaultProgramParams(i,e.zoom);r&&(t.style=this,this.fog&&(t._fogVisible=!0,r.overrideFog=!0,t.getOrCreateProgram(i,r)),t._fogVisible=!1,r.overrideFog=!1,t.getOrCreateProgram(i,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,t.getOrCreateProgram(i,r)))}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const e in r){const t=this._mergedSourceCaches[e];r[e]!==t.used&&t.getSource().fire(new Ct("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}))}this.light&&this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new Ct("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages()}}_updateWorkerLayers(e,t,n){const r=this.getFragmentStyle(e);r&&this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:n||[],options:r.options})}setState(e){if(this._checkLoaded(),KM(this,ra(e)))return!1;(e=H(e)).layers=RT(e.layers);const t=function(e,t){if(!e)return[{command:DT.setStyle,args:[t]}];let n=[];try{if(!x(e.version,t.version))return[{command:DT.setStyle,args:[t]}];x(e.center,t.center)||n.push({command:DT.setCenter,args:[t.center]}),x(e.zoom,t.zoom)||n.push({command:DT.setZoom,args:[t.zoom]}),x(e.bearing,t.bearing)||n.push({command:DT.setBearing,args:[t.bearing]}),x(e.pitch,t.pitch)||n.push({command:DT.setPitch,args:[t.pitch]}),x(e.sprite,t.sprite)||n.push({command:DT.setSprite,args:[t.sprite]}),x(e.glyphs,t.glyphs)||n.push({command:DT.setGlyphs,args:[t.glyphs]}),x(e.imports,t.imports)||function(e=[],t=[],n){t=t||[];const r=(e=e||[]).map(NT),i=t.map(NT),o=e.reduce(UT,{}),a=t.reduce(UT,{}),s=r.slice();let l,u,c,h;for(l=0,u=0;l{e.source&&r[e.source]?n.push({command:DT.removeLayer,args:[e.id]}):o.push(e)});let a=e.terrain;a&&r[a.source]&&(n.push({command:DT.setTerrain,args:[void 0]}),a=void 0),n=n.concat(i),x(a,t.terrain)||n.push({command:DT.setTerrain,args:[t.terrain]}),function(e,t,n){t=t||[];const r=(e=e||[]).map(NT),i=t.map(NT),o=e.reduce(UT,{}),a=t.reduce(UT,{}),s=r.slice(),l=Object.create(null);let u,c,h,d,f,p,m;for(u=0,c=0;u!(e.command in QM));if(0===t.length)return!1;const n=t.filter(e=>!(e.command in JM));if(n.length>0)throw new Error(`Unimplemented: ${n.map(e=>e.command).join(", ")}.`);return t.forEach(e=>{this[e.command].apply(this,e.args)}),this.stylesheet=e,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(e,t){return this.getImage(e)?this.fire(new kt(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,this.scope,t),this._afterImageUpdated(e),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t)}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e,this.scope),this._afterImageUpdated(e),this):this.fire(new kt(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(e),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new Ct("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,n={}){return this._checkLoaded(),this._validate(fa,"models."+e,t,null,n)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(e){return this.hasModel(e)?(this.modelManager.removeModel(e,this.scope),this):this.fire(new kt(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(e,t,n={}){if(this._checkLoaded(),void 0!==this.getOwnSource(e))throw new Error(`There is already a source with ID "${e}".`);if(!t.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(t.type)>=0&&this._validate(ia,"sources."+e,t,null,n))return;this.map&&this.map._collectResourceTiming&&(t.collectResourceTiming=!0);const r=ET(e,t,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id}));const i=e=>{const t=(e?"symbol:":"other:")+r.id,n=el(t,this.scope),i=this._sourceCaches[t]=new zv(n,r,e);(e?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=i,i.onAdd(this.map)};i(!1),"vector"!==t.type&&"geojson"!==t.type||i(!0),r.onAdd&&r.onAdd(this.map),n.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(e){this._checkLoaded();const t=this.getOwnSource(e);if(!t)throw new Error("There is no source with this ID");for(const t in this._layers)if(this._layers[t].source===e)return this.fire(new kt(new Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===e)return this.fire(new kt(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const n=this.getOwnSourceCaches(e);for(const e of n){const t=tl(e.id);delete this._sourceCaches[t],this._changes.discardSourceCacheUpdate(e.id),e.fire(new Ct("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles()}return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],this.mergeSources(),t.setEventedParent(null),t.onRemove&&t.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const n=this.getOwnSourceCache(t);n&&e.push(n.getSource())}return e}setLights(e){if(this._checkLoaded(),!e)return delete this.ambientLight,void delete this.directionalLight;const t=this._getTransitionParameters();for(const n of e){if(this._validate(aa,"lights",n))return;switch(n.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(n),e.updateTransitions(t)}else this.ambientLight=new Mw(n,Aw,this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(n),e.updateTransitions(t)}else this.directionalLight=new Mw(n,Iw,this.scope,this.options)}}const n=new Ns(this.z||0,t);this.ambientLight&&this.ambientLight.recalculate(n),this.directionalLight&&this.directionalLight.recalculate(n),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const e=this.directionalLight,t=this.ambientLight;if(!e||!t)return;const n=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=e.properties.get("color").toArray01(),i=e.properties.get("intensity"),o=e.properties.get("direction"),a=1-Q(o.x,o.y,o.z)[2]/90,s=n(r)*i*a,l=t.properties.get("color").toArray01(),u=t.properties.get("intensity");return(s+n(l)*u)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(e){if(!e)return this;if(Qs(e)){const t=function(e){const t=e.indexOf("");return t>=0?e.slice(t+1):""}(e),n=this.fragments.find(({id:e})=>e===t);if(!n)throw new Error("Style import not found: "+e);const r=tl(e);return n.style.getFragmentStyle(r)}{const t=this.fragments.find(({id:t})=>t===e);if(!t)throw new Error("Style import not found: "+e);return t.style}}getConfigProperty(e,t){const n=this.getFragmentStyle(e);if(!n)return null;const r=n.options.get(t),i=r?r.value||r.default:null;return i?i.serialize():null}setConfigProperty(e,t,n){const r=go(n);if("success"!==r.result)return void KM(this,r.value);const i=r.value.expression,o=this.getFragmentStyle(e);if(!o)return;const a=o.options.get(t);a&&(o.options.set(t,{...a,value:i}),o.updateConfigDependencies())}setConfig(e,t){if(this._config=e,e||t)if(t){this.options.clear();for(const n in t){let r,i;const o=go(t[n].default);if("success"===o.result&&(r=o.value.expression),e&&void 0!==e[n]){const t=go(e[n]);"success"===t.result&&(i=t.value.expression)}const{minValue:a,maxValue:s,stepValue:l,type:u,values:c}=t[n];r?this.options.set(n,{default:r,value:i,minValue:a,maxValue:s,stepValue:l,type:u,values:c}):this.fire(new kt(new Error(`No schema defined for config option "${n}".`)))}}else this.fire(new kt(new Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t))}this.ambientLight&&this.ambientLight.scope===this.scope&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.scope===this.scope&&this.directionalLight.updateConfig(this.options),this._changes.setDirty()}addLayer(e,t,n={}){this._checkLoaded();const r=e.id;if(this._layers[r])return void this.fire(new kt(new Error(`Layer with id "${r}" already exists on this map`)));let i;if("custom"===e.type){if(KM(this,function(e){const t=[],n=e.id;return void 0===n&&t.push({message:`layers.${n}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${n}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${n}: property "renderingMode" must be either "2d" or "3d"`}),t}(e)))return;i=lw(e,this.options)}else{if("object"==typeof e.source&&(this.addSource(r,e.source),e=z(e=H(e),{source:r})),this._validate(ua,"layers."+r,e,{arrayIndex:-1},n))return;i=lw(e,this.options),this._validateLayer(i),i.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[i.id]=i.serialize()}i.isConfigDependent&&this._configDependentLayers.add(i.fqid),i.setScope(this.scope);let o=this._order.length;if(t){const e=this._order.indexOf(t);if(-1===e)return void this.fire(new kt(new Error(`Layer with id "${t}" does not exist on this map.`)));i.slot===this._layers[t].slot?o=e:X(`Layer with id "${t}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,r),this._layerOrderChanged=!0,this._layers[r]=i;const a=this.getOwnLayerSourceCache(i),s=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&i.canCastShadows()&&s&&(a.castsShadows=!0);const l=this._changes.getRemovedLayer(i);if(l&&i.source&&a&&"custom"!==i.type){this._changes.discardLayerRemoval(i);const e=el(i.source,i.scope);l.type!==i.type?this._changes.updateSourceCache(e,"clear"):(this._changes.updateSourceCache(e,"reload"),a.pause())}this._updateLayer(i),i.onAdd&&i.onAdd(this.map),i.scope=this.scope,this.mergeLayers()}moveLayer(e,t){this._checkLoaded();const n=this._checkLayer(e);if(!n)return;if(e===t)return;const r=this._order.indexOf(e);this._order.splice(r,1);let i=this._order.length;if(t){const e=this._order.indexOf(t);if(-1===e)return void this.fire(new kt(new Error(`Layer with id "${t}" does not exist on this map.`)));n.slot===this._layers[t].slot?i=e:X(`Layer with id "${t}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(i,0,e),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const n=this._order.indexOf(e);this._order.splice(n,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const n in this._layers)if(this._layers[n].source===t.source&&this._layers[n].canCastShadows()){e=!0;break}r.castsShadows=e}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,n){this._checkLoaded();const r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===n||(null!=t&&(r.minzoom=t),null!=n&&(r.maxzoom=n),this._updateLayer(r)))}setSlot(e,t){this._checkLoaded();const n=this._checkLayer(e);n&&n.slot!==t&&(n.slot=t,this._updateLayer(n))}setFilter(e,t,n={}){this._checkLoaded();const r=this._checkLayer(e);if(r&&!x(r.filter,t))return null==t?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(ca,`layers.${r.id}.filter`,t,{layerType:r.type},n)||(r.filter=H(t),this._updateLayer(r)))}getFilter(e){const t=this._checkLayer(e);if(t)return H(t.filter)}setLayoutProperty(e,t,n,r={}){this._checkLoaded();const i=this._checkLayer(e);i&&(x(i.getLayoutProperty(t),n)||(i.setLayoutProperty(t,n,r),i.isConfigDependent&&this._configDependentLayers.add(i.fqid),this._updateLayer(i)))}getLayoutProperty(e,t){const n=this._checkLayer(e);if(n)return n.getLayoutProperty(t)}setPaintProperty(e,t,n,r={}){this._checkLoaded();const i=this._checkLayer(e);if(!i)return;if(x(i.getPaintProperty(t),n))return;const o=i.setPaintProperty(t,n,r);i.isConfigDependent&&this._configDependentLayers.add(i.fqid),o&&this._updateLayer(i),this._changes.updatePaintProperties(i)}getPaintProperty(e,t){const n=this._checkLayer(e);if(n)return n.getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();const n=e.source,r=e.sourceLayer,i=this._checkSource(n);if(!i)return;const o=i.type;if("geojson"===o&&r)return void this.fire(new kt(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!r)return void this.fire(new kt(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new kt(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(n);for(const n of a)n.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();const n=e.source,r=this._checkSource(n);if(!r)return;const i=r.type,o="vector"===i?e.sourceLayer:void 0;if("vector"===i&&!o)return void this.fire(new kt(new Error("The sourceLayer parameter must be provided for vector source types.")));if(t&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new kt(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(n);for(const n of a)n.removeFeatureState(o,e.id,t)}getFeatureState(e){this._checkLoaded();const t=e.source,n=e.sourceLayer,r=this._checkSource(t);if(r){if("vector"!==r.type||n)return void 0===e.id&&this.fire(new kt(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(t)[0].getFeatureState(n,e.id);this.fire(new kt(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(e){return this.stylesheet.transition=z({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return z({},this.stylesheet.transition)}serialize(){this._checkLoaded();const e=this.getTerrain(),t=e&&this.terrain&&this.terrain.scope===this.scope?e:this.stylesheet.terrain;return Z({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:t,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:this._serializeSources(),layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateLayer(e){this._changes.updateLayer(e);const t=this.getLayerSourceCache(e),n=el(e.source,e.scope),r=this._changes.getUpdatedSourceCaches();e.source&&!r[n]&&t&&"raster"!==t.getSource().type&&(this._changes.updateSourceCache(n,"reload"),t.pause()),e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type,n=this.order,r={},i=[];for(let o=n.length-1;o>=0;o--){const a=n[o];if(t(a)){r[a]=o;for(const t of e){const e=t[a];if(e)for(const t of e)i.push(t)}}}i.sort((e,t)=>t.intersectionZ-e.intersectionZ);const o=[];for(let a=n.length-1;a>=0;a--){const s=n[a];if(t(s))for(let e=i.length-1;e>=0;e--){const t=i[e].feature;if(r[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()}):this.has3DLayers(),s=Cw.createFromScreenPoints(e,n);for(const e in this._mergedSourceCaches){const l=this._mergedSourceCaches[e].getSource();if(!l||l.scope!==t.scope)continue;const u=this._mergedSourceCaches[e].getSource().id;t.layers&&!r[u]||i.push(AT(this._mergedSourceCaches[e],this._mergedLayers,o,s,t,n,a,!!this.map._showQueryGeometry))}return this.placement&&i.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(CT);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._mergedLayers,o,this.getLayerSourceCache.bind(this),s.screenGeometry,t,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(i)}querySourceFeatures(e,t){t&&t.filter&&this._validate(ca,"querySourceFeatures.filter",t.filter,null,t);const n=this.getOwnSourceCaches(e);let r=[];for(const e of n)r=r.concat(IT(e,t));return r}addSourceType(e,t,n){return rA.getSourceType(e)?n(new Error(`A source type called "${e}" already exists.`)):(rA.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},n):n(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,t,n={}){this._checkLoaded();const r=this.light.getLight();let i=!1;for(const t in e)if(!x(e[t],r[t])){i=!0;break}if(!i)return;const o=this._getTransitionParameters();this.light.setLight(e,t,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(e,t=1){if(this._checkLoaded(),!e)return delete this.terrain,null===e?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let n=e;const r=null==e.source;if(1===t){if("object"==typeof n.source){const e="terrain-dem-src";this.addSource(e,n.source),n=H(n),n=z(n,{source:e})}const e=z({},n),t={};if(this.terrain&&r){e.source=this.terrain.get().source;const n=this.terrain?this.getFragmentStyle(this.terrain.scope):null;n&&(t.style=n.serialize())}if(this._validate(sa,"terrain",e,t))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&t!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,t),this.fire(new Ct("data",{dataType:"style"}))}else{const t=this.terrain,r=t.get();for(const e of Object.keys(Pt.terrain))!n.hasOwnProperty(e)&&Pt.terrain[e].default&&(n[e]=Pt.terrain[e].default);for(const n in e)if(!x(e[n],r[n])){t.set(e,this.options),this.stylesheet.terrain=e;const n=this._getTransitionParameters({duration:0});t.updateTransitions(n),this.fire(new Ct("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new bw(e,this.map.transform);this.stylesheet.fog=t.get();const n=this._getTransitionParameters({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 t=this.fog;if(!x(t.get(),e)){t.set(e),this.stylesheet.fog=t.get();const n=this._getTransitionParameters({duration:0});t.updateTransitions(n)}}else this._createFog(e);this._markersNeedUpdate=!0}_getTransitionParameters(e){return{now:ft.now(),transition:z(this.transition,e)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const n in this._mergedLayers)this.isLayerDraped(this._mergedLayers[n])?e.push(n):t.push(n);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const n=this.terrain=new pw(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({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(e,t,n,r,i={}){if(i&&!1===i.validate)return!1;const o=z({},this.serialize());return KM(this,e.call(ra,z({key:t,style:o,value:n,styleSpec:Pt},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),zs.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove())}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles()}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[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){let t;this.directionalLight&&(t=HM(this.directionalLight));for(const n in this._mergedSourceCaches)this._mergedSourceCaches[n].update(e,void 0,void 0,t)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(e,t,n,r,i=!1){let o=!1,a=!1;const s={},l={};for(const t of this._mergedOrder){const n=this._mergedLayers[t];if("symbol"!==n.type)continue;const r=el(n.source,n.scope);let i=s[r];if(!i){const e=this.getLayerSourceCache(n);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));l[r]=t.slice(),i=s[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const a=this.crossTileSymbolIndex.addLayer(n,i,e.center.lng,e.projection);o=o||a}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),i=i||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new Ct("neworder")),(i||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(ft.now(),e.zoom))&&(this.pauseablePlacement=new mS(e,this._mergedOrder,i,t,n,r,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,s,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ft.now()),a=!0),o&&this.pauseablePlacement.placement.setStale()),a||o)for(const e of this._mergedOrder){const t=this._mergedLayers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,s[el(t.source,t.scope)])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(ft.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(e){this._checkLoaded();const t=this.stylesheet.imports=this.stylesheet.imports||[];return-1!==t.findIndex(({id:t})=>t===e.id)?this.fire(new kt(new Error(`Import with id '${e.id}' already exists in the map's style.`))):(t.push(e),this._loadImports([e],!0),this)}setImportUrl(e,t){this._checkLoaded();const n=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;n[r].url=t;const i=this.fragments[r];return i.style=this._createFragmentStyle(n[r]),i.style.on("style.import.load",()=>this.mergeAll()),i.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];return-1===n?this:t?(this.fragments[n].style.setState(t),this._reloadImports(),this):(delete r[n].data,this.setImportUrl(e,r[n].url))}setImportConfig(e,t){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===n)return this;t?r[n].config=t:delete r[n].config;const i=this.fragments[n],o=i.style.stylesheet&&i.style.stylesheet.schema;return i.config=t,i.style.setConfig(t,o),i.style.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],n=this.getImportIndex(e);return-1===n||(t.splice(n,1),this.fragments[n].style._remove(),this.fragments.splice(n,1),this._reloadImports()),this}getImportIndex(e){const t=(this.stylesheet.imports||[]).findIndex(t=>t.id===e);return-1===t&&this.fire(new kt(new Error(`Import '${e}' does not exist in the map's style and cannot be updated.`))),t}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const n=this._mergedOtherSourceCaches[t];n&&e.push(n.getSource())}return e}getSource(e,t){const n=this.getSourceCache(e,t);return n&&n.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(e,t){const n=el(e,t);return this._mergedOtherSourceCaches[n]}getLayerSourceCache(e){const t=el(e.source,e.scope);return"symbol"===e.type?this._mergedSymbolSourceCaches[t]:this._mergedOtherSourceCaches[t]}getSourceCaches(e){const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const n=e[t];"reload"===n?this.reloadSource(t):"clear"===n&&this.clearSource(t)}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const n of t){const t=this.getLayer(n);t&&t.updateTransitions(e)}}getImages(e,t,n){this.imageManager.getImages(t.icons,t.scope,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,t.scope,n)}getResource(e,t,n){return we(t,n)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(e){const t=this.getOwnSourceCaches(e);return 0===t.length?(this.fire(new kt(new Error(`There is no source with ID '${e}'`))),!1):t.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}function iA(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)}rA.getSourceType=function(e){return ST[e]},rA.setSourceType=function(e,t){ST[e]=t},rA.registerForPluginStateChange=function(e){return e({pluginStatus:Ps,pluginURL:Rs}),zs.on("pluginStateChange",e),e};class oA{constructor(e){this._hashName=e&&encodeURIComponent(e),G(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=iA(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,n.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),n.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const t=aA(e);if(this._hashName){const e=this._hashName;let r=!1;const i=n.location.hash.slice(1).split("&").map(n=>{const i=n.split("=")[0];return i===e?(r=!0,`${i}=${t}`):n}).filter(e=>e);return r||i.push(`${e}=${t}`),"#"+i.join("&")}return"#"+t}_getCurrentHash(){const e=n.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map(e=>e.split("=")).forEach(e=>{e[0]===this._hashName&&(t=e)}),(t&&t[1]||"").split("/")}return e.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 e=n.location.href.replace(/(#.+)?$/,this.getHashString());n.history.replaceState(n.history.state,null,e)}}function aA(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 sA={linearity:.3,easing:C(0,0,.3,1)},lA=z({deceleration:2500,maxSpeed:1400},sA),uA=z({deceleration:20,maxSpeed:1400},sA),cA=z({deceleration:1e3,maxSpeed:360},sA),hA=z({deceleration:1e3,maxSpeed:90},sA);class dA{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ft.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=ft.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const t={zoom:0,bearing:0,pitch:0,pan:new v(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)t.zoom+=e.zoomDelta||0,t.bearing+=e.bearingDelta||0,t.pitch+=e.pitchDelta||0,e.panDelta&&t.pan._add(e.panDelta),e.around&&(t.around=e.around),e.pinchAround&&(t.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(t.pan.mag()){const i=pA(t.pan.mag(),n,z({},lA,e||{}));r.offset=t.pan.mult(i.amount/t.pan.mag()),r.center=this._map.transform.center,fA(r,i)}if(t.zoom){const e=pA(t.zoom,n,uA);r.zoom=this._map.transform.zoom+e.amount,fA(r,e)}if(t.bearing){const e=pA(t.bearing,n,cA);r.bearing=this._map.transform.bearing+O(e.amount,-179,179),fA(r,e)}if(t.pitch){const e=pA(t.pitch,n,hA);r.pitch=this._map.transform.pitch+e.amount,fA(r,e)}if(r.zoom||r.bearing){const e=void 0===t.pinchAround?t.around:t.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function fA(e,t){(!e.duration||e.durationt.unproject(e)),a=i.reduce((e,t,n,r)=>e.add(t.div(r.length)),new v(0,0));super(e,{points:i,point:a,lngLats:o,lngLat:t.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class gA extends Ct{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class yA{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new gA(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new mA(e.type,this._map,e))}mouseup(e){this._map.fire(new mA(e.type,this._map,e))}preclick(e){const t=z({},e);t.type="preclick",this._map.fire(new mA(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new mA(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new mA(e.type,this._map,e))}mouseover(e){this._map.fire(new mA(e.type,this._map,e))}mouseout(e){this._map.fire(new mA(e.type,this._map,e))}touchstart(e){return this._firePreventable(new _A(e.type,this._map,e))}touchmove(e){this._map.fire(new _A(e.type,this._map,e))}touchend(e){this._map.fire(new _A(e.type,this._map,e))}touchcancel(e){this._map.fire(new _A(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class vA{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new mA(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new mA("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new mA(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class xA{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&&(vt(),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(${o}px,${s}px)`,this._box.style.width=a-o+"px",this._box.style.height=l-s+"px")})}mouseupWindow(e,t){if(!this._active)return;const n=this._startPos,r=t;if(n&&0===e.button){if(this.reset(),wt(),n.x!==r.x||n.y!==r.y)return this._map.fire(new Ct("boxzoomend",{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(n,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}}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),xt(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new Ct(e,{originalEvent:t}))}}function bA(e,t){const n={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=function(e){const t=new v(0,0);for(const n of e)t._add(n);return t.div(e.length)}(t),this.touches=bA(n,t)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;const r=bA(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 TA{constructor(e){this.singleTap=new wA(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 SA{constructor(){this._zoomIn=new TA({numTouches:1,numTaps:2}),this._zoomOut=new TA({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 EA={0:1,2:2};class MA{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=Et(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=EA[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 r=bA(n,t),i=new v(0,0),o=new v(0,0);let a=0;for(const e in r){const t=r[e],n=this._touches[e];n&&(i._add(t),o._add(t.sub(n)),a++,r[e]=t)}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class OA{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=PA(n,t,i),s=PA(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=PA(n,t,r),a=PA(n,t,i);o&&a||(this._active&&wt(),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 PA(e,t,n){for(let r=0;rMath.abs(e.x)}class FA extends OA{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,BA(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,n){const r=this._lastPoints;if(!r)return;const i=e[0].sub(r[0]),o=e[1].sub(r[1]);return this._map._cooperativeGestures&&!re()&&n.touches.length<3||(this._valid=this.gestureBeginsVertically(i,o,n.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(i.y+o.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 BA(e)&&BA(t)&&o}}const jA={panStep:100,bearingStep:15,pitchStep:10};class NA{constructor(){const e=jA;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:UA,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 UA(e){return e*(2-e)}const VA=4.000244140625;class GA{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._handler=t,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,G(["_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(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||re()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let t=e.deltaMode===n.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=ft.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==t&&t%VA==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.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=Tt(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 e=this._map.transform;"wheel"===this._type&&e.projection.wrap&&(e._center.lng>=180||e._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const t=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const n="wheel"===this._type&&Math.abs(this._delta)>VA?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&0!==r&&(r=1/r);const i=t(),o=Math.pow(2,i),a="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(a*r))),"wheel"===this._type&&(this._startZoom=i,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const n="number"==typeof this._targetZoom?this._targetZoom:t(),r=this._startZoom,i=this._easing;let o,a=!1;if("wheel"===this._type&&r&&i){const e=Math.min((ft.now()-this._lastWheelEventTime)/200,1);o=Yr(r,n,i(e)),e<1?this._frameId||(this._frameId=!0):a=!0}else o=n,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let s=o-t();return s*this._lastDelta<0&&(s=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=k;if(this._prevEase){const e=this._prevEase,n=(ft.now()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),i=.27/Math.sqrt(r*r+1e-4)*.01;t=C(i,Math.sqrt(.0729-i*i),.25,1)}return this._prevEase={start:ft.now(),duration:e,easing:t},t}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=pt("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(n.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 qA{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 WA{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 ZA{constructor(){this._tap=new TA({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 HA{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 $A{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 XA{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 YA=e=>e.zoom||e.drag||e.pitch||e.rotate;class KA extends Ct{}class JA{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,t){const n=id.sub([],t,e);this.radius=id.length(n[2]<0?id.div([],n,this.constants):[n[0],n[1],0])}projectRay(e){id.div(e,e,this.constants),id.normalize(e,e),id.mul(e,e,this.constants);const t=id.scale([],e,this.radius);if(t[2]>0){const e=id.scale([],[0,0,1],id.dot(t,[0,0,1])),n=id.scale([],id.normalize([],[t[0],t[1],0]),this.radius),r=id.add([],t,id.scale([],id.sub([],id.add([],n,e),t),2));t[0]=r[0],t[1]=r[1]}return t}}function QA(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class eI{constructor(e,t){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new dA(e),this._bearingSnap=t.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new JA,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(t),G(["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],[n.document,"mousemove",{capture:!0}],[n.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],[n,"blur",void 0]];for(const[e,t,r]of this._listeners)e.addEventListener(t,e===n.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[e,t,r]of this._listeners)e.removeEventListener(t,e===n.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){const t=this._map,n=t.getCanvasContainer();this._add("mapEvent",new yA(t,e));const r=t.boxZoom=new xA(t,e);this._add("boxZoom",r);const i=new SA,o=new WA;t.doubleClickZoom=new qA(o,i),this._add("tapZoom",i),this._add("clickZoom",o);const a=new ZA;this._add("tapDragZoom",a);const s=t.touchPitch=new FA(t);this._add("touchPitch",s);const l=new IA(e),u=new CA(e);t.dragRotate=new $A(e,l,u),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);const c=new AA(e),h=new kA(t,e);t.dragPan=new HA(n,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new zA,f=new DA;t.touchZoomRotate=new XA(n,f,d,a),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),this._add("blockableMapEvent",new vA(t));const p=t.scrollZoom=new GA(t,this);this._add("scrollZoom",p,["mousePan"]);const m=t.keyboard=new NA;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=[],this._originalZoom=void 0}}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!!YA(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?St(this._el,s):n?void 0:Tt(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||QA(i))&&(this._changes.push([i,o,u]),this._triggerRenderFrame()),(Object.keys(a).length||QA(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(e,t,n,r,i){if(!n)return;z(e,n);const o={handlerName:r,originalEvent:n.originalEvent||i};void 0!==n.zoomDelta&&(t.zoom=o),void 0!==n.panDelta&&(t.drag=o),void 0!==n.pitchDelta&&(t.pitch=o),void 0!==n.bearingDelta&&(t.rotate=o)}_applyChanges(){const e={},t={},n={};for(const[r,i,o]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new v(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.aroundCoord&&(e.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),z(t,i),z(n,o);this._updateMapTransform(e,t,n),this._changes=[]}_updateMapTransform(e,t,n){const r=this._map,i=r.transform,o=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!QA(e)){const e=i.zoom;i.cameraElevationReference="sea",null!=this._originalZoom&&i._orthographicProjectionAtLowPitch&&"globe"!==i.projection.name&&0===i.pitch?(i.cameraElevationReference="ground",i.zoom=this._originalZoom):(i.recenterOnTerrain(),i.cameraElevationReference="ground"),e!==i.zoom&&this._map._update(!0)}if(i._isCameraConstrained&&r._stop(!0),!QA(e))return void this._fireEvents(t,n,!0);let{panDelta:a,zoomDelta:s,bearingDelta:l,pitchDelta:u,around:c,aroundCoord:h,pinchAround:d}=e;i._isCameraConstrained&&(s>0&&(s=0),i._isCameraConstrained=!1),void 0!==d&&(c=d),(s||(e=>t[e]&&!this._eventsInProgress[e])("drag"))&&c&&(this._dragOrigin=o(i.pointCoordinate3D(c)),this._originalZoom=i.zoom,this._trackingEllipsoid.setup(i._camera.position,this._dragOrigin)),i.cameraElevationReference="sea",r._stop(!0),c=c||r.transform.centerPoint,l&&(i.bearing+=l),u&&(i.pitch+=u),i._updateCameraState();const f=[0,0,0];if(a)if("mercator"===i.projection.name){const e=this._trackingEllipsoid.projectRay(i.screenPointToMercatorRay(c).dir),t=this._trackingEllipsoid.projectRay(i.screenPointToMercatorRay(c.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const e=i.pointCoordinate(c);if("globe"===i.projection.name){a=a.rotate(-i.angle);const t=i._pixelsPerMercatorPixel/i.worldSize;f[0]=-a.x*Af(wf(e.y))*t,f[1]=-a.y*Af(i.center.lat)*t}else{const t=i.pointCoordinate(c.sub(a));e&&t&&(f[0]=t.x-e.x,f[1]=t.y-e.y)}}const p=i.zoom,m=[0,0,0];if(s){const e=o(h||i.pointCoordinate3D(c)),t={dir:id.normalize([],id.sub([],e,i._camera.position))};if(t.dir[2]<0){const n=i.zoomDeltaToMovement(e,s);id.scale(m,t.dir,n)}}const _=id.add(f,f,m);i._translateCameraConstrained(_),s&&Math.abs(i.zoom-p)>1e-4&&i.recenterOnTerrain(),i.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,n,!0)}_fireEvents(e,t,n){const r=YA(this._eventsInProgress),i=YA(e),o={};for(const t in e){const{originalEvent:n}=e[t];this._eventsInProgress[t]||(o[t+"start"]=n),this._eventsInProgress[t]=e[t]}!r&&i&&this._fireEvent("movestart",i.originalEvent);for(const e in o)this._fireEvent(e,o[e]);i&&this._fireEvent("move",i.originalEvent);for(const t in e){const{originalEvent:n}=e[t];this._fireEvent(t,n)}const a={};let s;for(const e in this._eventsInProgress){const{handlerName:n,originalEvent:r}=this._eventsInProgress[e];this._handlersById[n].isActive()||(delete this._eventsInProgress[e],s=t[n]||r,a[e+"end"]=s)}for(const e in a)this._fireEvent(e,a[e]);const l=YA(this._eventsInProgress);if(n&&(r||i)&&!l){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new KA("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const tI="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class nI extends Ot{constructor(e,t){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=t.bearingSnap,this._respectPrefersReducedMotion=!1!==t.respectPrefersReducedMotion,G(["_renderFrameCallback"],this)}getCenter(){return new _f(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(e,t,n){return e=v.convert(e).mult(-1),this.panTo(this.transform.center,z({offset:e},t),n)}panTo(e,t,n){return this.easeTo(z({center:e},t),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,n){return this.easeTo(z({zoom:e},t),n)}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(e,t,n){return this.easeTo(z({bearing:e},t),n)}resetNorth(e,t){return this.rotateTo(0,z({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(z({bearing:0,pitch:0,duration:1e3},e),t),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(e,t,n,r,i,o){const a=e.clone(),s=this._extendCameraOptions(o);a.bearing=r,a.pitch=i;const l=_f.convert(t),u=_f.convert(n),c=.5*(l.lat+u.lat),h=.5*(l.lng+u.lng),d=qd(c,h),f=id.normalize([],d),p=id.normalize([],id.cross([],f,[0,1,0])),m=id.cross([],p,f),_=[p[0],p[1],p[2],0,m[0],m[1],m[2],0,f[0],f[1],f[2],0,0,0,0,1],g=[d,qd(l.lat,l.lng),qd(u.lat,l.lng),qd(u.lat,u.lng),qd(l.lat,u.lng),qd(c,l.lng),qd(c,u.lng),qd(l.lat,h),qd(u.lat,h)];let y=Md.fromPoints(g.map(e=>[id.dot(p,e),id.dot(m,e),id.dot(f,e)]));const v=id.transformMat4([],y.center,_);0===id.squaredLength(v)&&id.set(v,0,0,1),id.normalize(v,v),id.scale(v,v,Ad),a.center=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 _f(S(i),S(o))}(v);const x=a.getWorldToCameraMatrix(),b=Jh.invert(new Float64Array(16),x);y=Md.applyTransform(y,Jh.multiply([],x,_)),id.transformMat4(v,v,x);const w=.5*(y.max[2]-y.min[2]),T=this._minimumAABBFrustumDistance(a,y),E=id.scale([],[0,0,1],w),M=id.add(E,v,E),A=T+(0===a.pitch?0:id.distance(v,M)),I=a.globeCenterInViewSpace,C=id.sub([],v,[I[0],I[1],I[2]]);id.normalize(C,C),id.scale(C,C,A);const k=id.add([],v,C);id.transformMat4(k,k,b);const O=ff/Ad,P=id.length(k),R=xf(Math.max(P*O-ff,Number.EPSILON),0),D=Math.min(a.zoomFromMercatorZAdjusted(R),s.maxZoom);return D>5.5?(a.setProjection({name:"mercator"}),a.zoom=D,this._cameraForBounds(a,t,n,r,i,o)):{center:a.center,zoom:D,bearing:r,pitch:i}}queryTerrainElevation(e,t){const n=this.transform.elevation;return n?(t=z({},{exaggerated:!0},t),n.getAtPoint(Cf.fromLngLat(e),null,t.exaggerated)):null}_cameraForBounds(e,t,n,r,i,o){if("globe"===e.projection.name)return this._cameraForBoundsOnGlobe(e,t,n,r,i,o);const a=e.clone(),s=this._extendCameraOptions(o),l=a.padding;a.bearing=r,a.pitch=i;const u=_f.convert(t),c=_f.convert(n),h=new _f(u.lng,c.lat),d=new _f(c.lng,u.lat),f=a.project(u),p=a.project(c),m=this.queryTerrainElevation(u),_=this.queryTerrainElevation(c),g=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),x=[[f.x,f.y,Math.min(m||0,_||0,g||0,y||0)],[p.x,p.y,Math.max(m||0,_||0,g||0,y||0)]];let b=Md.fromPoints(x);const w=a.getWorldToCameraMatrix(),S=Jh.invert(new Float64Array(16),w);b=Md.applyTransform(b,w);const E=id.sub([],b.max,b.min),M=l.left||0,A=l.right||0,I=l.bottom||0,C=l.top||0,{left:k,right:O,top:P,bottom:R}=s.padding,D=.5*(M+A),L=.5*(C+I),z=Math.min(a.scaleZoom(a.scale*Math.min((a.width-(M+A+k+O))/E[0],(a.height-(I+C+R+P))/E[1])),s.maxZoom),B=a.scale/a.zoomScale(z);b=new Md([b.min[0]-(k+D)*B,b.min[1]-(R+L)*B,b.min[2]],[b.max[0]+(O+D)*B,b.max[1]+(P+L)*B,b.max[2]]);const F=.5*E[2],j=this._minimumAABBFrustumDistance(a,b),N=[0,0,1,0];qh.transformMat4(N,N,w),qh.normalize(N,N);const U=id.scale([],N,j+F),V=id.add([],b.center,U),G=("number"==typeof s.offset.x&&"number"==typeof s.offset.y?new v(s.offset.x,s.offset.y):v.convert(s.offset)).rotate(-T(r));b.center[0]-=G.x*B,b.center[1]+=G.y*B,id.transformMat4(b.center,b.center,S),id.transformMat4(V,V,S);const q=[b.center[0],b.center[1],V[2]*a.pixelsPerMeter];id.scale(q,q,1/a.worldSize);const W=bf(q[0]),Z=wf(q[1]),H=Math.min(a._zoomFromMercatorZ(q[2]),s.maxZoom),$=new _f(W,Z);return a.mercatorFromTransition&&H<5.5?(a.setProjection({name:"globe"}),a.zoom=H,this._cameraForBounds(a,t,n,r,i,o)):{center:$,zoom:H,bearing:r,pitch:i}}fitBounds(e,t,n){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,n)}fitScreenCoordinates(e,t,n,r,i){const o=v.convert(e),a=v.convert(t),s=new v(Math.min(o.x,a.x),Math.min(o.y,a.y)),l=new v(Math.max(o.x,a.x),Math.max(o.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(o,a))return this;const u=this.transform.pointLocation3D(s),c=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(new v(s.x,l.y)),d=this.transform.pointLocation3D(new v(l.x,s.y)),f=[Math.min(u.lng,c.lng,h.lng,d.lng),Math.min(u.lat,c.lat,h.lat,d.lat)],p=[Math.max(u.lng,c.lng,h.lng,d.lng),Math.max(u.lat,c.lat,h.lat,d.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,f,p,n,m,r);return this._fitInternal(_,r,i)}_fitInternal(e,t,n){return e?(delete(t=z(e,t)).padding,t.linear?this.easeTo(t,n):this.flyTo(t,n)):this}jumpTo(e,t){this.stop();const n=e.preloadOnly?this.transform.clone():this.transform;let r=!1,i=!1,o=!1;return"zoom"in e&&n.zoom!==+e.zoom&&(r=!0,n.zoom=+e.zoom),void 0!==e.center&&(n.center=_f.convert(e.center)),"bearing"in e&&n.bearing!==+e.bearing&&(i=!0,n.bearing=+e.bearing),"pitch"in e&&n.pitch!==+e.pitch&&(o=!0,n.pitch=+e.pitch),null==e.padding||n.isPaddingEqual(e.padding)||(n.padding=e.padding),e.preloadOnly?(this._preloadTiles(n),this):(this.fire(new Ct("movestart",t)).fire(new Ct("move",t)),r&&this.fire(new Ct("zoomstart",t)).fire(new Ct("zoom",t)).fire(new Ct("zoomend",t)),i&&this.fire(new Ct("rotatestart",t)).fire(new Ct("rotate",t)).fire(new Ct("rotateend",t)),o&&this.fire(new Ct("pitchstart",t)).fire(new Ct("pitch",t)).fire(new Ct("pitchend",t)),this.fire(new Ct("moveend",t)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||X(tI),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,t){const n=this.transform;if(!n.projection.supportsFreeCamera)return X(tI),this;this.stop();const r=n.zoom,i=n.pitch,o=n.bearing;n.setFreeCameraOptions(e);const a=r!==n.zoom,s=i!==n.pitch,l=o!==n.bearing;return this.fire(new Ct("movestart",t)).fire(new Ct("move",t)),a&&this.fire(new Ct("zoomstart",t)).fire(new Ct("zoom",t)).fire(new Ct("zoomend",t)),l&&this.fire(new Ct("rotatestart",t)).fire(new Ct("rotate",t)).fire(new Ct("rotateend",t)),s&&this.fire(new Ct("pitchstart",t)).fire(new Ct("pitch",t)).fire(new Ct("pitchend",t)),this.fire(new Ct("moveend",t)),this}easeTo(e,t){this._stop(!1,e.easeId),(!1===(e=z({offset:[0,0],duration:500,easing:k},e)).animate||this._prefersReducedMotion(e))&&(e.duration=0);const n=this.transform,r=this.getZoom(),i=this.getBearing(),o=this.getPitch(),a=this.getPadding(),s="zoom"in e?+e.zoom:r,l="bearing"in e?this._normalizeBearing(e.bearing,i):i,u="pitch"in e?+e.pitch:o,c="padding"in e?e.padding:n.padding,h=v.convert(e.offset);let d,f,p;if("globe"===n.projection.name){const t=Cf.fromLngLat(n.center),r=h.rotate(-n.angle);t.x+=r.x/n.worldSize,t.y+=r.y/n.worldSize;const i=t.toLngLat(),o=_f.convert(e.center||i);this._normalizeCenter(o),d=n.centerPoint.add(r),f=new v(t.x,t.y).mult(n.worldSize),p=new v(yf(o.lng),vf(o.lat)).mult(n.worldSize).sub(f)}else{d=n.centerPoint.add(h);const t=n.pointLocation(d),r=_f.convert(e.center||t);this._normalizeCenter(r),f=n.project(t),p=n.project(r).sub(f)}const m=n.zoomScale(s-r);let _,g;e.around&&(_=_f.convert(e.around),g=n.locationPoint(_));const y=this._zooming||s!==r,x=this._rotating||i!==l,b=this._pitching||u!==o,w=!n.isPaddingEqual(c),T=n=>v=>{if(y&&(n.zoom=Yr(r,s,v)),x&&(n.bearing=Yr(i,l,v)),b&&(n.pitch=Yr(o,u,v)),w&&(n.interpolatePadding(a,c,v),d=n.centerPoint.add(h)),_)n.setLocationAtPoint(_,g);else{const e=n.zoomScale(n.zoom-r),t=s>r?Math.min(2,m):Math.max(.5,m),i=Math.pow(t,1-v),o=n.unproject(f.add(p.mult(v*i)).mult(e));n.setLocationAtPoint(n.renderWorldCopies?o.wrap():o,d)}return e.preloadOnly||this._fireMoveEvents(t),n};if(e.preloadOnly){const t=this._emulate(T,e.duration,n);return this._preloadTiles(t),this}const S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,S),this._ease(T(n),e=>{"sea"===n.cameraElevationReference&&n.recenterOnTerrain(),this._afterEase(t,e)},e),this}_prepareEase(e,t,n={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),t||n.moving||this.fire(new Ct("movestart",e)),this._zooming&&!n.zooming&&this.fire(new Ct("zoomstart",e)),this._rotating&&!n.rotating&&this.fire(new Ct("rotatestart",e)),this._pitching&&!n.pitching&&this.fire(new Ct("pitchstart",e))}_fireMoveEvents(e){this.fire(new Ct("move",e)),this._zooming&&this.fire(new Ct("zoom",e)),this._rotating&&this.fire(new Ct("rotate",e)),this._pitching&&this.fire(new Ct("pitch",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const n=this._zooming,r=this._rotating,i=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new Ct("zoomend",e)),r&&this.fire(new Ct("rotateend",e)),i&&this.fire(new Ct("pitchend",e)),this.fire(new Ct("moveend",e))}flyTo(e,t){if(this._prefersReducedMotion(e)){const n=B(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(n,t)}this.stop(),e=z({offset:[0,0],speed:1.2,curve:1.42,easing:k},e);const n=this.transform,r=this.getZoom(),i=this.getBearing(),o=this.getPitch(),a=this.getPadding(),s="zoom"in e?O(+e.zoom,n.minZoom,n.maxZoom):r,l="bearing"in e?this._normalizeBearing(e.bearing,i):i,u="pitch"in e?+e.pitch:o,c="padding"in e?e.padding:n.padding,h=n.zoomScale(s-r),d=v.convert(e.offset);let f=n.centerPoint.add(d);const p=n.pointLocation(f),m=_f.convert(e.center||p);this._normalizeCenter(m);const _=n.project(p),g=n.project(m).sub(_);let y=e.curve;const x=Math.max(n.width,n.height),b=x/h,w=g.mag();if("minZoom"in e){const t=O(Math.min(e.minZoom,r,s),n.minZoom,n.maxZoom),i=x/n.zoomScale(t-r);y=Math.sqrt(i/w*2)}const T=y*y;function S(e){const t=(b*b-x*x+(e?-1:1)*T*T*w*w)/(2*(e?b:x)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function M(e){return(Math.exp(e)+Math.exp(-e))/2}const A=S(0);let I=function(e){return M(A)/M(A+y*e)},C=function(e){return x*((M(A)*(E(t=A+y*e)/M(t))-E(A))/T)/w;var t},P=(S(1)-A)/y;if(Math.abs(w)<1e-6||!isFinite(P)){if(Math.abs(x-b)<1e-6)return this.easeTo(e,t);const n=be.maxDuration&&(e.duration=0);const R=i!==l,D=u!==o,L=!n.isPaddingEqual(c),F=n=>h=>{const p=h*P,y=1/I(p);n.zoom=1===h?s:r+n.scaleZoom(y),R&&(n.bearing=Yr(i,l,h)),D&&(n.pitch=Yr(o,u,h)),L&&(n.interpolatePadding(a,c,h),f=n.centerPoint.add(d));const v=1===h?m:n.unproject(_.add(g.mult(C(p))).mult(y));return n.setLocationAtPoint(n.renderWorldCopies?v.wrap():v,f),n._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(t),n};if(e.preloadOnly){const t=this._emulate(F,e.duration,n);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=R,this._pitching=D,this._padding=L,this._prepareEase(t,!1),this._ease(F(n),()=>this._afterEase(t),e),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(e,t,n){!1===n.animate||0===n.duration?(e(1),t()):(this._easeStart=ft.now(),this._easeOptions=n,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((ft.now()-this._easeStart)/this._easeOptions.duration,1),t=this._onEaseFrame;t&&t(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,t){e=R(e,-180,180);const n=Math.abs(e-t);return Math.abs(e-360-t)180?-360:n<-180?360:0}_prefersReducedMotion(e){return this._respectPrefersReducedMotion&&ft.prefersReducedMotion&&!(e&&e.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 rI{constructor(e={}){this.options=e,G(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=pt("button","mapboxgl-ctrl-attrib-button",this._container),pt("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=pt("div","mapboxgl-ctrl-attrib-inner",this._container),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.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 e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const t=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||o.ACCESS_TOKEN}];if(e){const n=t.reduce((e,n,r)=>(n.value&&(e+=`${n.key}=${n.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 iI{constructor(){G(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=pt("div","mapboxgl-ctrl");const t=pt("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 oI{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 aI(e,t,n){if(e=new _f(e.lng,e.lat),t){const r=new _f(e.lng-360,e.lat),i=new _f(e.lng+360,e.lat),o=360*Math.ceil(Math.abs(e.lng-n.center.lng)/360),a=n.locationPoint(e).distSqr(t),s=t.x<0||t.y<0||t.x>n.width||t.y>n.height;n.locationPoint(r).distSqr(t)180;){const t=n.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e}const sI={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 lI extends Ot{constructor(e,t){if(super(),(e instanceof n.HTMLElement||t)&&(e=z({element:e},t)),G(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=e&&e.occludedOpacity||.2,e&&e.element)this._element=e.element,this._offset=v.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=pt("div");const t=41,n=27,r=mt("svg",{display:"block",height:t*this._scale+"px",width:n*this._scale+"px",viewBox:`0 0 ${n} ${t}`},this._element),i=mt("radialGradient",{id:"shadowGradient"},mt("defs",{},r));mt("stop",{offset:"10%","stop-opacity":.4},i),mt("stop",{offset:"100%","stop-opacity":.05},i),mt("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),mt("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"},r),mt("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"},r),mt("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=v.convert(e&&e.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),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 sI)r.remove("mapboxgl-marker-anchor-"+e);r.add("mapboxgl-marker-anchor-"+this._anchor);const i=e&&e.className?e.className.trim().split(/\s+/):[];r.add(...i),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(e){return this._lngLat=_f.convert(e),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 e=this._map;if(!e)return;const t=this._pos;if(!t||t.x<0||t.x>e.transform.width||t.y<0||t.y>e.transform.height)return void this._clearFadeTimer();const n=e.unproject(t);let r;e._showingGlobe()&&lf(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(n),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=""+r,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),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 ${sI[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const e=this._pos,t=this._map,n=this.getPitchAlignment();if(!t||!e||"map"!==n)return"";if(!t._showingGlobe()){const e=t.getPitch();return e?`rotateX(${e}deg)`:""}const r=S(sf(t.transform,this._lngLat)),i=e.sub(af(t.transform)),o=Math.abs(i.x)+Math.abs(i.y);if(0===o)return"";const a=r/o;return`rotateX(${-i.y*a}deg) rotateY(${i.x*a}deg)`}_calculateZTransform(){const e=this._pos,t=this._map;if(!t||!e)return"";let n=0;const r=this.getRotationAlignment();if("map"===r)if(t._showingGlobe()){const e=t.project(new _f(this._lngLat.lng,this._lngLat.lat+.001)),r=t.project(new _f(this._lngLat.lng,this._lngLat.lat-.001)).sub(e);n=S(Math.atan2(r.y,r.x))-90}else n=-t.getBearing();else if("horizon"===r){const r=P(4,6,t.getZoom()),i=af(t.transform);i.y+=r*t.transform.height;const o=e.sub(i),a=S(Math.atan2(o.y,o.x));n=(a>90?a-270:a+90)*(1-r)}return n+=this._rotation,n?`rotateZ(${n}deg)`:""}_update(e){n.cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=aI(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=n.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(e){return this._offset=v.convert(e),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(e){const t=this._map;if(!t)return;const n=this._pointerdownPos,r=this._positionDelta;if(n&&r){if(!this._isDragging){const r=this._clickTolerance||t._clickTolerance;if(e.point.dist(n)=this._endTime)return this._end;const t=M((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-t)+this._end*t}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 fI={"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"},pI={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,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1},mI={showCompass:!0,showZoom:!0,visualizePitch:!1};class _I{constructor(e,t,n=!1){this._clickTolerance=10,this.element=t,this.mouseRotate=new IA({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,n&&(this.mousePitch=new CA({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),G(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),vt()}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(){xt(),n.removeEventListener("mousemove",this.mousemove),n.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(z({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),Tt(this.element,e)),n.addEventListener("mousemove",this.mousemove),n.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,Tt(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=St(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=St(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)e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==ne){const t=e.navigator?e.navigator.userAgent:null;ne=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return ne}(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/))}(n)&&(e.antialias=!1,X("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Ax(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._collectResourceTiming=e.collectResourceTiming,this._language=this._parseLanguage(e.language),this._worldview=e.worldview,this._renderTaskQueue=new oI,this._domRenderTaskQueue=new oI,this._controls=[],this._markers=[],this._popups=[],this._mapId=j(),this._locale=z({},fI,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._performanceMetricsCollection=e.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new dI(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new Oe(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,this._contextCreateOptions=e.contextCreateOptions?{...e.contextCreateOptions}:{},"string"==typeof e.container){if(this._container=n.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container.toString()}' not found.`)}else{if(!(e.container instanceof n.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(this._container.childNodes.length>0&&X("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),e.maxBounds&&this.setMaxBounds(e.maxBounds),G(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==n&&(this._fullscreenchangeEvent="onfullscreenchange"in n.document?"fullscreenchange":"webkitfullscreenchange",n.addEventListener("online",this._onWindowOnline,!1),n.addEventListener("resize",this._onWindowResize,!1),n.addEventListener("orientationchange",this._onWindowResize,!1),n.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),n.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new eI(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,(e.style||!e.testMode)&&this.setStyle(e.style||o.DEFAULT_STYLE,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),e.hash&&(this._hash=new oA("string"==typeof e.hash&&e.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==t.center&&null==t.zoom||(this.transform._unmodified=!1),this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch});const n=e.bounds;n&&(this.resize(),this.fitBounds(n,z({},e.fitBoundsOptions,{duration:0})))}this.resize(),e.attributionControl&&this.addControl(new rI({customAttribution:e.customAttribution})),this._logoControl=new iI,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new Ct(e.dataType+"data",e))}),this.on("dataloading",e=>{this.fire(new Ct(e.dataType+"dataloading",e))})}_getMapId(){return this._mapId}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new kt(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[t];return-1!==t.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new kt(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const t=!this._moving;return t&&this.fire(new Ct("movestart",e)).fire(new Ct("move",e)),this.fire(new Ct("resize",e)),t&&this.fire(new Ct("moveend",e)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(ju.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new Ct("zoomstart")).fire(new Ct("zoom")).fire(new Ct("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new Ct("pitchstart")).fire(new Ct("pitch")).fire(new Ct("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(e){return"auto"===e?n.navigator.language:Array.isArray(e)?0===e.length?void 0:e.map(e=>"auto"===e?n.navigator.language:e):e}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.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const e=this.transform,t=e.projection.name;let n;"globe"===t&&e.zoom>=6?(e.setMercatorFromTransition(),n=!0):"mercator"===t&&e.zoom<6&&(e.setProjection({name:"globe"}),n=!0),n&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(e){let t;return t="globe"===e.name&&this.transform.zoom>=6?this.transform.setMercatorFromTransition():this.transform.setProjection(e),this.style.applyProjectionUpdate(),t&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(e){return this.transform.locationPoint3D(_f.convert(e))}unproject(e){return this.transform.pointLocation3D(v.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_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 mA(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 mA(e,this,i.originalEvent)))},o=t=>{r&&(r=!1,n.call(this,new mA(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);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;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);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;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]);for(const e of t)if(!this._isValidId(e))return this;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{e?this.fire(new kt(e)):n&&this._updateDiff(n,t)})}else"object"==typeof e&&this._updateDiff(e,t)}_updateDiff(e,t){try{this.style.setState(e)&&this._update(!0)}catch(n){X(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(X("There is no style added to the map."),!1)}_isValidId(e){return null==e?(this.fire(new kt(new Error("IDs can't be empty."))),!1):!Qs(e)||(this.fire(new kt(new Error(`IDs can't contain special symbols: "${e}".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!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._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(e,t,{pixelRatio:r=1,sdf:i=!1,stretchX:o,stretchY:a,content:s}={}){if(this._lazyInitEmptyStyle(),t instanceof n.HTMLImageElement||n.ImageBitmap&&t instanceof n.ImageBitmap){const{width:n,height:l,data:u}=ft.getImageData(t);this.style.addImage(e,{data:new bp({width:n,height:l},u),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0})}else if(void 0===t.width||void 0===t.height)this.fire(new kt(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:n,height:l}=t,u=t;this.style.addImage(e,{data:new bp({width:n,height:l},new Uint8Array(u.data)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}updateImage(e,t){this._lazyInitEmptyStyle();const r=this.style.getImage(e);if(!r)return void this.fire(new kt(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=t instanceof n.HTMLImageElement||n.ImageBitmap&&t instanceof n.ImageBitmap?ft.getImageData(t):t,{width:o,height:a}=i;void 0!==o&&void 0!==a?o===r.data.width&&a===r.data.height?(r.data.replace(i.data,!(t instanceof n.HTMLImageElement||n.ImageBitmap&&t instanceof n.ImageBitmap)),this.style.updateImage(e,r)):this.fire(new kt(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 kt(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(e){return e?!!this.style&&!!this.style.getImage(e):(this.fire(new kt(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e,t){Ce(this._requestManager.transformRequest(e,ve.Image),(e,r)=>{t(e,r instanceof n.HTMLImageElement?ft.getImageData(r):r)})}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(e){return e?this.style.hasModel(e):(this.fire(new kt(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}setLayerZoomRange(e,t,n){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,n),this._update(!0)):this}setFilter(e,t,n={}){return this._isValidId(e)?(this.style.setFilter(e,t,n),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,n,r={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,n,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,n,r={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,n,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,n){return this.style.setConfigProperty(e,t,n),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}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}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(_f.convert(e),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let r,i,o,a=this._container;for(;a&&(!i||!o);){const e=n.getComputedStyle(a).transform;e&&"none"!==e&&(r=e.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(e/i):e,this._containerHeight=o?Math.abs(t/o):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==n.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&X("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=pt("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=pt("div","mapboxgl-canvas-container",e);this._canvas=pt("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),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=pt("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{r[e]=pt("div","mapboxgl-ctrl-"+e,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t){const n=ft.devicePixelRatio||1;this._canvas.width=n*Math.ceil(e),this._canvas.height=n*Math.ceil(t),this._canvas.style.width=e+"px",this._canvas.style.height=t+"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 e=z({},it.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl2",e);t?(Je(t,!0),this.painter=new UM(t,this._contextCreateOptions,this.transform),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),a.testSupport(t)):this.fire(new kt(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new Ct("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new Ct("webglcontextrestored",{originalEvent:e}))}_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(e){let t;this.fire(new Ct("renderstart"));const r=this.painter.context.extTimerQuery,i=ft.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(t=o.createQuery(),o.beginQuery(r.TIME_ELAPSED_EXT,t)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],n.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],n.performance.now())),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;this._updateProjectionTransition();const a=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,t=this.transform.pitch,n=ft.now(),r=new Ns(e,{now:n,fadeDuration:a,pitch:t,transition:this.style.transition});this.style.update(r)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(i),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):s=this._updateAverageElevation(i),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,a,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,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 Ct("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new Ct("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),t){const e=ft.now()-i;o.endQuery(r.TIME_ELAPSED_EXT),setTimeout(()=>{const r=o.getQueryParameter(t,o.QUERY_RESULT)/1e6;o.deleteQuery(t),this.fire(new Ct("gpu-timing-frame",{cpuTime:e,gpuTime:r})),n.performance.mark("frame-gpu",{startTime:i,detail:{gpuTime:r}})},50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout(()=>{const t=this.painter.queryGpuTimers(e);this.fire(new Ct("gpu-timing-layer",{layerTimes:t}))},50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const t=this.painter.queryGpuTimeDeferredRender(e);this.fire(new Ct("gpu-timing-deferred-render",{gpuTime:t}))},50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(l||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(s=this._updateAverageElevation(i,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new Ct("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new Ct("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,et.mark(Qe.fullLoad),this._performanceMetricsCollection&&$e(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);const r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let i=this.transform.sampleAverageElevation();this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(i)?i=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-i);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(i),n(i);this._averageElevation.easeTo(i,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(i),n(i)}return!!this._averageElevation.isEasing(e)&&n(this._averageElevation.getValue(e))}_authenticate(){Ye(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,e=>{if(e&&(e.message===ke||401===e.status)){const e=this.painter.context.gl;Je(e,!1),this._logoControl instanceof iI&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new kt(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/")))}}),Ze(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(e){return D(this.style?Object.values(this.style._sourceCaches):[],(t,n)=>t._preloadTiles(e,n),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===n.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 showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=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(e,t){!function(e,t){de=e,fe=t}(e,t)}get version(){return r}},NavigationControl:class{constructor(e){this.options=z({},mI,e),this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(G(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),pt("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})}),pt("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(G(["_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=pt("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 _I(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=pt("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 Ot{constructor(e){super(),this.options=z({geolocation:n.navigator.geolocation},gI,e),G(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=iA(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==n.navigator.permissions?n.navigator.permissions.query({name:"geolocation"}).then(e=>t("denied"!==e.state)).catch(()=>t()):t()}_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(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new Ct("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new Ct("geolocate",e)),this._finish()}}_updateCamera(e){const t=new _f(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r=z({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(n),r,{geolocateSource:!0})}_updateMarker(e){if(e){const t=new _f(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,t=xf(1,e._center.lat)*e.worldSize,n=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=n+"px",this._circleElement.style.height=n+"px"}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const 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===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new Ct("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=pt("button","mapboxgl-ctrl-geolocate",this._container),pt("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){X("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const 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=pt("div","mapboxgl-user-location"),this._dotElement.appendChild(pt("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(pt("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new lI({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=pt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new lI({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new Ct("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 X("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 Ct("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 Ct("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 Ct("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 e=()=>{n.addEventListener("ondeviceorientationabsolute"in n?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==n.DeviceMotionEvent&&"function"==typeof n.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e()}).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),n.removeEventListener("deviceorientation",this._onDeviceOrientation),n.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:rI,ScaleControl:class{constructor(e){this.options=z({},yI,e),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),G(["_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} ${vI[n]}`,this._container.style.width=e*i+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=pt("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(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof n.HTMLElement?this._container=e.container:X("Full screen control 'container' must be a DOM element.")),G(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in n.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in n.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=pt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",X("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,n.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!n.document.fullscreenEnabled&&!n.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=pt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);pt("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),n.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(){(n.document.fullscreenElement||n.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()?n.document.exitFullscreen?n.document.exitFullscreen():n.document.webkitCancelFullScreen&&n.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends Ot{constructor(e){super(),this.options=z(Object.create(uI),e),G(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),e._addPopup(this),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new Ct("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),e._canvasContainer&&e._canvasContainer.classList.remove("mapboxgl-track-pointer"),e._removePopup(this),this._map=void 0),this.fire(new Ct("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=_f.convert(e),this._pos=null,this._trackPointer=!1,this._update();const t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._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(e){return this.setDOMContent(n.document.createTextNode(e))}setHTML(e){const t=n.document.createDocumentFragment(),r=n.document.createElement("body");let i;for(r.innerHTML=e;i=r.firstChild,i;)t.appendChild(i);return this.setDOMContent(t)}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=pt("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=pt("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(e){const t=this._map,n=this._content;if(!t||!this._lngLat&&!this._trackPointer||!n)return;let r=this._container;if(r||(r=this._container=pt("div","mapboxgl-popup",t.getContainer()),this._tip=pt("div","mapboxgl-popup-tip",r),r.appendChild(n)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=aI(this._lngLat,this._pos,t.transform)),!this._trackPointer||e){const n=this._pos=this._trackPointer&&e?e:t.project(this._lngLat),r=hI(this.options.offset),i=this._anchor=this._getAnchor(r.y),o=hI(this.options.offset,i),a=n.add(o).round();t._requestDomTask(()=>{this._container&&i&&(this._container.style.transform=`${sI[i]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&t._showingGlobe()){const e=lf(t.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(cI);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:lI,Style:rA,LngLat:_f,LngLatBounds:ju,Point:v,MercatorCoordinate:Cf,FreeCameraOptions:Kv,Evented:Ot,config:o,prewarm:function(){Hw().acquire(qw)},clearPrewarmedResources:function(){const e=Zw;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(qw),Zw=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 o.ACCESS_TOKEN},set accessToken(e){o.ACCESS_TOKEN=e},get baseApiUrl(){return o.API_URL},set baseApiUrl(e){o.API_URL=e},get workerCount(){return Ww.workerCount},set workerCount(e){Ww.workerCount=e},get maxParallelImageRequests(){return o.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){o.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){!function(e){if(!pe())return;const t=n.caches.delete(ue);e&&t.catch(e).then(()=>e())}(e)},workerUrl:"",workerClass:null,get dracoUrl(){return Jw()},set dracoUrl(e){!function(e){Xw=ft.resolveURL(e),Kw||(Kw=new Ew(Hw(),new Ot)),Kw.broadcast("setDracoUrl",Xw)}(e)},setNow:ft.setNow,restoreNow:ft.restoreNow};e.A=Sw,e.D=m_,e.E=hr,e.F=g_,e.K=gS,e.O=_d,e.P=v,e.T=$x,e.V=km,e.a=gm,e.b=Rm,e.c=lw,e.d=class extends Ot{constructor(e,t,n,r,i,o){super(),this.actor=e,this.layerIndex=t,this.availableImages=n,this.loadVectorData=i||Nw,this.loading={},this.loaded={},this.deduped=new jw(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=o}loadTile(e,t){const n=e.uid,r=e&&e.request,i=r&&r.collectResourceTiming,o=this.loading[n]=new Bw(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 Cm(new e_(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=rt(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.projection=e.projection,o.brightness=e.brightness,o.tileTransform=jg(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster;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())}else t(null,void 0)}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.e=go,e.f=rt,e.g=f,e.h=Te,e.i=Se,e.j=function(e,t){const n=bT(e);for(const e of n){for(const t of e.meshes)wT(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(TT(e.lights,t)))}return n},e.k=Ns,e.l=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==oT){const n=new Uint32Array(e,0,7),[,,r,i,o,a]=n;t=n.byteLength+i+o+a+o,(r!==e.byteLength||t>=e.byteLength)&&X("Invalid b3dm header information.")}return hT(e,t)},e.m=uy,e.n=js,e.o=Ct,e.p=g,e.q=function(e){me(),ce&&ce.then(t=>{t.keys().then(n=>{for(let r=0;rthis._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}=t,s=e.w.ImageBitmap&&o instanceof e.w.ImageBitmap?this.getImageData(o,a):o;n(null,new e.D(r,s,i,a<1))}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.g((function e(t,n){var r,i=t&&t.type;if("FeatureCollection"===i)for(r=0;r>31}function T(e,t){for(var n=e.loadGeometry(),r=e.type,i=0,o=0,a=n.length,s=0;se},A=Math.fround||(I=new Float32Array(1),e=>(I[0]=+e,I[0]));var I;class C{constructor(e){this.options=Object.assign(Object.create(M),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(P(n),R(o),P(i),R(r)),l=a.data,u=[];for(const e of s){const t=this.stride*e;u.push(l[t+5]>1?k(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?k(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=O(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=P(r),c=R(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 k(e,t,n){return{type:"Feature",id:e[t+3],properties:O(e,t,n),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),D(e[t+1])]}};var r}function O(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 P(e){return e/360+.5}function R(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 D(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var L={exports:{}};L.exports=function(){function e(n,r,i,o){for(var a,s=o,l=i-r>>1,u=i-r,c=n[r],h=n[r+1],d=n[i],f=n[i+1],p=r+3;ps)a=p,s=m;else if(m===s){var _=Math.abs(p-l);_o&&(a-r>3&&e(n,r,a,o),n[a+2]=s,i-a>3&&e(n,a,i,o))}function t(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 n(e,t,n,i){var o={id:void 0===e?null:e,type:t,geometry:n,tags:i,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)r(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var i=0;i0&&(s+=i?(o*d-h*a)/2:Math.sqrt(Math.pow(h-o,2)+Math.pow(d-a,2))),o=h,a=d}var f=n.length-3;n[2]=1,e(n,0,f,r),n[f+2]=1,n.size=Math.abs(s),n.start=0,n.end=n.size}function s(e,t,n,r){for(var i=0;i1?1:n}function c(e,t,r,i,o,a,s,l){if(i/=t,a>=(r/=t)&&s=i)return null;for(var u=[],c=0;c=r&&y=i)){var v=[];if("Point"===_||"MultiPoint"===_)h(m,v,r,i,o);else if("LineString"===_)d(m,v,r,i,o,!1,l.lineMetrics);else if("MultiLineString"===_)p(m,v,r,i,o,!1);else if("Polygon"===_)p(m,v,r,i,o,!0);else if("MultiPolygon"===_)for(var x=0;x=n&&a<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function d(e,t,n,r,i,o,a){for(var s,l,u=f(e),c=0===i?_:g,h=e.start,d=0;dn&&(l=c(u,p,y,x,b,n),a&&(u.start=h+s*l)):w>r?T=n&&(l=c(u,p,y,x,b,n),S=!0),T>r&&w<=r&&(l=c(u,p,y,x,b,r),S=!0),!o&&S&&(a&&(u.end=h+s*l),t.push(u),u=f(e)),a&&(h+=s)}var E=e.length-3;p=e[E],y=e[E+1],v=e[E+2],(w=0===i?p:y)>=n&&w<=r&&m(u,p,y,v),E=u.length-3,o&&E>=3&&(u[E]!==u[0]||u[E+1]!==u[1])&&m(u,u[0],u[1],u[2]),u.length&&t.push(u)}function f(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function p(e,t,n,r,i,o){for(var a=0;aa.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function T(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"),f=this.tiles[d]=w(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,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var p="z"+t;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(f.source=e,i){if(t===l.maxZoom||t===i)continue;var m=1<1&&console.time("clipping");var _,g,y,v,x,b,T=.5*l.buffer/l.extent,S=.5-T,E=.5+T,A=1+T;_=g=y=v=null,x=c(e,h,n-T,n+E,0,f.minX,f.maxX,l),b=c(e,h,n+S,n+A,0,f.minX,f.maxX,l),e=null,x&&(_=c(x,h,r-T,r+E,1,f.minY,f.maxY,l),g=c(x,h,r+S,r+A,1,f.minY,f.maxY,l),x=null),b&&(y=c(b,h,r-T,r+E,1,f.minY,f.maxY,l),v=c(b,h,r+S,r+A,1,f.minY,f.maxY,l),b=null),u>1&&console.timeEnd("clipping"),s.push(_||[],t+1,2*n,2*r),s.push(g||[],t+1,2*n,2*r+1),s.push(y||[],t+1,2*n+1,2*r),s.push(v||[],t+1,2*n+1,2*r+1)}}},E.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[M(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]?x(this.tiles[s],i):null):null},function(e,t){return new E(e,t)}}();var z=e.g(L.exports);function B(t,n){const r=t.tileID.canonical;if(!this._geoJSONIndex)return n(null,null);const i=this._geoJSONIndex.getTile(r.z,r.x,r.y);if(!i)return n(null,null);const o=new class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.E,this.length=t.length,this._features=t}feature(t){return new class{constructor(t){this._feature=t,this.extent=e.E,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const n of this._feature.geometry)t.push([new e.P(n[0],n[1])]);return t}{const t=[];for(const n of this._feature.geometry){const r=[];for(const t of n)r.push(new e.P(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,n){return l.call(this,e,t,n)}}(this._features[t])}}(i.features);let a=E(o);0===a.byteOffset&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),n(null,{vectorTile:o,rawData:a.buffer})}class F extends e.d{constructor(e,t,n,r,i,o){super(e,t,n,r,B,o),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.e(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.e(a),l=e.e("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):z(a,t.geojsonVtOptions)}catch(o){return n(o)}this.loaded={};const l={};if(i){const n=e.f(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.h(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 j{constructor(t,n){this.tileID=new e.O(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=n}parse(t,n,r,i){this.status="parsing";const o=new e.O(r.tileID.overscaledZ,r.tileID.wrap,r.tileID.canonical.z,r.tileID.canonical.x,r.tileID.canonical.y),a={},s=n.familiesBySource[r.source],l=new e.F(o,r.promoteId);return l.bucketLayerIDs=[],e.l(t).then(t=>{if(!t)return i(new Error("Could not parse tile"));const n=e.j(t,1/e.t(r.tileID.canonical)),u=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features"),c=new e.k(this.zoom,{brightness:this.brightness});for(const r in s)for(const i of s[r]){const r=i[0],s=t.json.extensionsUsed;r.recalculate(c,[]);const l=new e.T(n,o,s&&s.includes("MAPBOX_mesh_features"),this.brightness);u||(l.needsUpload=!0),a[r.fqid]=l,l.evaluate(r)}this.status="done",i(null,{buckets:a,featureIndex:l})}).catch(e=>i(new Error(e.message)))}}class N{constructor(e,t,n,r,i,o){this.actor=e,this.layerIndex=t,this.brightness=o,this.loading={},this.loaded={}}loadTile(t,n){const r=t.uid,i=this.loading[r]=new j(t,this.brightness);e.i(t.request,(e,o)=>{const a=!this.loading[r];return delete this.loading[r],a||e?(i.status="done",a||(this.loaded[r]=i),n(e)):o&&0!==o.byteLength?void i.parse(o,this.layerIndex,t,(e,t)=>{i.status="done",this.loaded=this.loaded||{},this.loaded[r]=i,e||!t?n(e):n(null,t)}):(i.status="done",this.loaded[r]=i,n())})}reloadTile(e,t){const n=this.loaded,r=e.uid;if(n&&n[r]){const i=n[r];i.projection=e.projection,i.brightness=e.brightness;const o=(n,r)=>{i.reloadCallback&&(delete i.reloadCallback,this.loadTile(e,t)),t(n,r)};"parsing"===i.status?i.reloadCallback=o:"done"===i.status&&this.loadTile(e,t)}}abortTile(e,t){const n=e.uid;this.loading[n]&&delete this.loading[n],t()}removeTile(e,t){const n=this.loaded,r=e.uid;n&&n[r]&&delete n[r],t()}}class U{constructor(t){this.self=t,this.actor=new e.A(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.m({name:"mercator"}),this.workerSourceTypes={vector:e.d,geojson:F,"batched-model":N},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.n.isParsed())throw new Error("RTL text plugin already registered.");e.n.applyArabicShaping=t.applyArabicShaping,e.n.processBidirectionalText=t.processBidirectionalText,e.n.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,{scope:n,isLoaded:r}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][n]=r,this.workerSources[t]&&this.workerSources[t][n])for(const i in this.workerSources[t][n]){const o=this.workerSources[t][n][i];for(const t in o)o[t]instanceof e.d&&(o[t].isSpriteLoaded=r,o[t].fire(new e.o("isSpriteLoaded")))}}setImages(e,{scope:t,images:n},r){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=n,this.workerSources[e]&&this.workerSources[e][t]){for(const r in this.workerSources[e][t]){const i=this.workerSources[e][t][r];for(const e in i)i[e].availableImages=n}r()}else r()}setProjection(t,n){this.projections[t]=e.m(n)}setBrightness(e,t,n){this.brightness=t,n()}setLayers(e,t,n){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),n()}updateLayers(e,t,n){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),n()}loadTile(e,t,n){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,n)}loadDEMTile(e,t,n){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,n)}reloadTile(e,t,n){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,n)}abortTile(e,t,n){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,n)}removeTile(e,t,n){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,n)}removeSource(e,t,n){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const r=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][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.n.setState(n);const t=e.n.getPluginURL();if(e.n.isLoaded()&&!e.n.isParsed()&&null!=t){this.self.importScripts(t);const n=e.n.isParsed();r(n?void 0:new Error("RTL Text Plugin failed to import scripts from "+t),n)}}catch(e){r(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let n=this.availableImages[e][t];return n||(n=[]),n}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let n=this.layerIndexes[e][t];return n||(n=this.layerIndexes[e][t]=new r,n.scope=t),n}getWorkerSource(e,t,n,r){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][r]||(this.workerSources[e][r]={}),this.workerSources[e][r][t]||(this.workerSources[e][r][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!this.workerSources[e][r][t][n]){const i={send:(t,n,r,i,o,a)=>{this.actor.send(t,n,r,e,o,a)},scheduler:this.actor.scheduler};this.workerSources[e][r][t][n]=new this.workerSourceTypes[t](i,this.getLayerIndex(e,r),this.getAvailableImages(e,r),this.isSpriteLoaded[e][r],void 0,this.brightness)}return this.workerSources[e][r][t][n]}getDEMWorkerSource(e,t,n){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][n]||(this.demWorkerSources[e][n]={}),this.demWorkerSources[e][n][t]||(this.demWorkerSources[e][n][t]=new i),this.demWorkerSources[e][n][t]}enforceCacheSizeLimit(t,n){e.q(n)}getWorkerPerformanceMetrics(e,t,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new U(self)),U})),i(0,(function(e){return e.s})),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||g,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 _(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 g(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+"[]",_(e))})),!1;return!!a(e)||(n.append(l(i,t,f),_(e)),!1)}const y=[],v=Object.assign(u,{defaultVisitor:g,convertValue:_,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},_=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(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),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(C)>3?"":" "}function V(e,t){for(;--t&&R()&&!(C<48||C>102||C>57&&C<65||C>70&&C<97););return z(e,L()+(t<6&&32==D()&&32==R()))}function G(e,t){for(;R()&&e+C!==57&&(e+C!==84||47!==D()););return"/*"+z(t,I-1)+"*"+d(47===e?e:R())}function q(e){for(;!B(D());)R();return z(e,I)}function W(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,S=1,A=0,O="",P=o,z=a,B=i,F=O;for(;w;)switch(_=A,A=R()){case 40:if(108!=_&&58==v(F,f-1)){-1!=y(F+=g(N(A),"&","&\f"),"&\f")&&(S=-1);break}case 34:case 39:case 91:F+=N(A);break;case 9:case 10:case 13:case 32:F+=U(_);break;case 92:F+=V(L()-1,7);continue;case 47:switch(D()){case 42:case 47:T(H(G(R(),L()),n,r),u);break;default:F+="/"}break;case 123*x:l[c++]=b(F)*S;case 125*x:case 59:case 0:switch(A){case 0:case 125:w=0;case 59+h:-1==S&&(F=g(F,/\f/g,"")),m>0&&b(F)-f&&T(m>32?$(F+";",i,r,f-1):$(g(F," ","")+";",i,r,f-2),u);break;case 59:F+=";";default:if(T(B=Z(F,n,r,c,h,o,l,O,P=[],z=[],f),a),123===A)if(0===h)e(F,n,B,B,P,a,f,l,z);else switch(99===p&&110===v(F,3)?100:p){case 100:case 108:case 109:case 115:e(t,B,B,i&&T(Z(t,B,B,0,0,o,l,O,o,P=[],f),z),o,z,f,l,i?P:z);break;default:e(F,B,B,B,[""],z,0,l,z)}}c=h=m=0,x=S=1,O=F="",f=s;break;case 58:f=1+b(F),m=_;default:if(x<1)if(123==A)--x;else if(125==A&&0==x++&&125==(C=I>0?v(k,--I):0,M--,10===C&&(M=1,E--),C))continue;switch(F+=d(A),A*x){case 38:S=h>0?1:(F+="\f",-1);break;case 44:l[c++]=(b(F)-1)*S,S=1;break;case 64:45===D()&&(F+=N(R())),p=D(),h=f=b(O=F+=q(L())),A++;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[T]+" "+S:g(S,/&\f/g,p[T])))&&(u[b++]=E);return O(e,t,n,0===i?l:s,u,c,d)}function H(e,t,n){return O(e,t,n,s,d(C),x(e,2,-2),0)}function $(e,t,n,r){return O(e,t,n,u,x(e,0,r),x(e,r+1,-1),r)}function X(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 X([P(e,{value:g(e.value,"@","@"+a)})],r);case l:if(e.length)return S(e.props,(function(t){switch(_(t,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return X([P(e,{props:[g(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return X([P(e,{props:[g(t,/:(plac\w+)/,":"+a+"input-$1")]}),P(e,{props:[g(t,/:(plac\w+)/,":-moz-$1")]}),P(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){if(G(n))return e.decorate_20223_(t,n);V(t,n,e)}),e)}function V(e,t,n){k(e,N)||w(e,N,D({},e[N])),function(e){return"override"===e.annotationType_}(n)||(e[N][t]=n)}function G(e){return"object"==typeof e&&"string"==typeof e.kind}var q=Symbol("mobx administration"),W=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_=Ze.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 gt(this)},t.reportChanged=function(){mt(),yt(this),_t()},t.toString=function(){return this.name_},e}(),Z=S("Atom",W);function H(e,t,n){void 0===t&&(t=_),void 0===n&&(n=_);var r,i=new W(e);return t!==_&&zt("onBO",i,t,r),n!==_&&Lt(i,n),i}var $={identity:function(e,t){return e===t},structural:function(e,t){return Yn(e,t)},default:function(e,t){return Object.is?Object.is(e,t):e===t?0!==e||1/e==1/t:e!=e&&t!=t},shallow:function(e,t){return Yn(e,t,1)}};function X(e,t,n){return Zt(e)?e:Array.isArray(e)?Oe.array(e,{name:n}):x(e)?Oe.object(e,void 0,{name:n}):E(e)?Oe.map(e,{name:n}):M(e)?Oe.set(e,{name:n}):"function"!=typeof e||Ot(e)||qt(e)?e:b(e)?Vt(e):kt(n,e)}function Y(e){return e}function K(e,t){return{annotationType_:e,options_:t,make_:J,extend_:Q,decorate_20223_:ee}}function J(e,t,n,r){var i;if(null!=(i=this.options_)&&i.bound)return null===this.extend_(e,t,n,!1)?0:1;if(r===e.target_)return null===this.extend_(e,t,n,!1)?0:2;if(Ot(n.value))return 1;var o=te(e,this,t,n,!1);return l(r,t,o),2}function Q(e,t,n,r){var i=te(e,this,t,n);return e.defineProperty_(t,i,r)}function ee(e,t){var n=t.kind,i=t.name,o=t.addInitializer,a=this;if("field"!=n){var s,l,u,c,h,d;if("method"==n)return Ot(e)||(l=e,e=Ne(null!=(u=null==(c=a.options_)?void 0:c.name)?u:i.toString(),l,null!=(h=null==(d=a.options_)?void 0:d.autoAction)&&h)),null!=(s=this.options_)&&s.bound&&o((function(){var e=this[i].bind(this);e.isMobxAction=!0,this[i]=e})),e;r("Cannot apply '"+a.annotationType_+"' to '"+String(i)+"' (kind: "+n+"):\n'"+a.annotationType_+"' can only be used on properties with a function value.")}else o((function(){V(this,i,a)}))}function te(e,t,n,r,i){var o,a,s,l,u,c,h,d;void 0===i&&(i=ht.safeDescriptors),d=r,t.annotationType_,d.value;var f,p=r.value;null!=(o=t.options_)&&o.bound&&(p=p.bind(null!=(f=e.proxy_)?f:e.target_));return{value:Ne(null!=(a=null==(s=t.options_)?void 0:s.name)?a:n.toString(),p,null!=(l=null==(u=t.options_)?void 0:u.autoAction)&&l,null!=(c=t.options_)&&c.bound?null!=(h=e.proxy_)?h:e.target_:void 0),configurable:!i||e.isPlainObject_,enumerable:!1,writable:!i}}function ne(e,t){return{annotationType_:e,options_:t,make_:re,extend_:ie,decorate_20223_:oe}}function re(e,t,n,r){var i;if(r===e.target_)return null===this.extend_(e,t,n,!1)?0:2;if(null!=(i=this.options_)&&i.bound&&(!k(e.target_,t)||!qt(e.target_[t]))&&null===this.extend_(e,t,n,!1))return 0;if(qt(n.value))return 1;var o=ae(e,this,t,n,!1,!1);return l(r,t,o),2}function ie(e,t,n,r){var i,o=ae(e,this,t,n,null==(i=this.options_)?void 0:i.bound);return e.defineProperty_(t,o,r)}function oe(e,t){var n;var r=t.name,i=t.addInitializer;return qt(e)||(e=Vt(e)),null!=(n=this.options_)&&n.bound&&i((function(){var e=this[r].bind(this);e.isMobXFlow=!0,this[r]=e})),e}function ae(e,t,n,r,i,o){var a;void 0===o&&(o=ht.safeDescriptors),a=r,t.annotationType_,a.value;var s,l=r.value;(qt(l)||(l=Vt(l)),i)&&((l=l.bind(null!=(s=e.proxy_)?s:e.target_)).isMobXFlow=!0);return{value:l,configurable:!o||e.isPlainObject_,enumerable:!1,writable:!o}}function se(e,t){return{annotationType_:e,options_:t,make_:le,extend_:ue,decorate_20223_:ce}}function le(e,t,n){return null===this.extend_(e,t,n,!1)?0:1}function ue(e,t,n,r){return function(e,t,n,r){t.annotationType_,r.get;0}(0,this,0,n),e.defineComputedProperty_(t,D({},this.options_,{get:n.get,set:n.set}),r)}function ce(e,t){var n=this,r=t.name;return(0,t.addInitializer)((function(){var t=In(this)[q],i=D({},n.options_,{get:e,context:this});i.name||(i.name="ObservableObject."+r.toString()),t.values_.set(r,new $e(i))})),function(){return this[q].getObservablePropValue_(r)}}function he(e,t){return{annotationType_:e,options_:t,make_:de,extend_:fe,decorate_20223_:pe}}function de(e,t,n){return null===this.extend_(e,t,n,!1)?0:1}function fe(e,t,n,r){var i,o;return function(e,t,n,r){t.annotationType_;0}(0,this),e.defineObservableProperty_(t,n.value,null!=(i=null==(o=this.options_)?void 0:o.enhancer)?i:X,r)}function pe(e,t){var n=this,r=t.kind,i=t.name,o=new WeakSet;function a(e,t){var r,a,s=In(e)[q],l=new We(t,null!=(r=null==(a=n.options_)?void 0:a.enhancer)?r:X,"ObservableObject."+i.toString(),!1);s.values_.set(i,l),o.add(e)}if("accessor"==r)return{get:function(){return o.has(this)||a(this,e.get.call(this)),this[q].getObservablePropValue_(i)},set:function(e){return o.has(this)||a(this,e),this[q].setObservablePropValue_(i,e)},init:function(e){return o.has(this)||a(this,e),e}}}var me=_e();function _e(e){return{annotationType_:"true",options_:e,make_:ge,extend_:ye,decorate_20223_:ve}}function ge(e,t,n,r){var i,o,a,s;if(n.get)return De.make_(e,t,n,r);if(n.set){var u=Ne(t.toString(),n.set);return r===e.target_?null===e.defineProperty_(t,{configurable:!ht.safeDescriptors||e.isPlainObject_,set:u})?0:2:(l(r,t,{configurable:!0,set:u}),2)}if(r!==e.target_&&"function"==typeof n.value)return b(n.value)?(null!=(s=this.options_)&&s.autoBind?Vt.bound:Vt).make_(e,t,n,r):(null!=(a=this.options_)&&a.autoBind?kt.bound:kt).make_(e,t,n,r);var c,h=!1===(null==(i=this.options_)?void 0:i.deep)?Oe.ref:Oe;"function"==typeof n.value&&null!=(o=this.options_)&&o.autoBind&&(n.value=n.value.bind(null!=(c=e.proxy_)?c:e.target_));return h.make_(e,t,n,r)}function ye(e,t,n,r){var i,o,a;if(n.get)return De.extend_(e,t,n,r);if(n.set)return e.defineProperty_(t,{configurable:!ht.safeDescriptors||e.isPlainObject_,set:Ne(t.toString(),n.set)},r);"function"==typeof n.value&&null!=(i=this.options_)&&i.autoBind&&(n.value=n.value.bind(null!=(a=e.proxy_)?a:e.target_));return(!1===(null==(o=this.options_)?void 0:o.deep)?Oe.ref:Oe).extend_(e,t,n,r)}function ve(e,t){r("'"+this.annotationType_+"' cannot be used as a decorator")}var xe={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};function be(e){return e||xe}Object.freeze(xe);var we=he("observable"),Te=he("observable.ref",{enhancer:Y}),Se=he("observable.shallow",{enhancer:function(e,t,n){return null==e||On(e)||_n(e)||wn(e)||En(e)?e:Array.isArray(e)?Oe.array(e,{name:n,deep:!1}):x(e)?Oe.object(e,void 0,{name:n,deep:!1}):E(e)?Oe.map(e,{name:n,deep:!1}):M(e)?Oe.set(e,{name:n,deep:!1}):void 0}}),Ee=he("observable.struct",{enhancer:function(e,t){return Yn(e,t)?t:e}}),Me=U(we);function Ae(e){return!0===e.deep?X:!1===e.deep?Y:(t=e.defaultDecorator)&&null!=(n=null==(r=t.options_)?void 0:r.enhancer)?n:X;var t,n,r}function Ie(e,t,n){return G(t)?we.decorate_20223_(e,t):y(t)?void V(e,t,we):Zt(e)?e:x(e)?Oe.object(e,t,n):Array.isArray(e)?Oe.array(e,t):E(e)?Oe.map(e,t):M(e)?Oe.set(e,t):"object"==typeof e&&null!==e?e:Oe.box(e,t)}a(Ie,Me);var Ce,ke,Oe=a(Ie,{box:function(e,t){var n=be(t);return new We(e,Ae(n),n.name,!0,n.equals)},array:function(e,t){var n=be(t);return(!1===ht.useProxies||!1===n.proxy?qn:sn)(e,Ae(n),n.name)},map:function(e,t){var n=be(t);return new bn(e,Ae(n),n.name)},set:function(e,t){var n=be(t);return new Sn(e,Ae(n),n.name)},object:function(e,t,n){return $n((function(){return Bt(!1===ht.useProxies||!1===(null==n?void 0:n.proxy)?In({},n):function(e,t){var n,r;return p(),e=In(e,t),null!=(r=(n=e[q]).proxy_)?r:n.proxy_=new Proxy(e,Xt)}({},n),e,t)}))},ref:U(Te),shallow:U(Se),deep:Me,struct:U(Ee)}),Pe=se("computed"),Re=se("computed.struct",{equals:$.structural}),De=function(e,t){if(G(t))return Pe.decorate_20223_(e,t);if(y(t))return V(e,t,Pe);if(x(e))return U(se("computed",e));var n=x(t)?t:{};return n.get=e,n.name||(n.name=e.name||""),new $e(n)};Object.assign(De,Pe),De.struct=U(Re);var Le,ze=0,Be=1,Fe=null!=(Ce=null==(ke=s((function(){}),"name"))?void 0:ke.configurable)&&Ce,je={value:"action",configurable:!0,writable:!1,enumerable:!1};function Ne(e,t,n,r){function i(){return Ue(e,n,t,r||this,arguments)}return void 0===n&&(n=!1),i.isMobxAction=!0,i.toString=function(){return t.toString()},Fe&&(je.value=e,l(i,"name",je)),i}function Ue(e,t,n,i,o){var a=function(e,t,n,r){0;var i=ht.trackingDerivation,o=!t||!i;mt();var a=ht.allowStateChanges;o&&(rt(),a=Ve(!0));var s=ot(!0),l={runAsAction_:o,prevDerivation_:i,prevAllowStateChanges_:a,prevAllowStateReads_:s,notifySpy_:!1,startTime_:0,actionId_:Be++,parentActionId_:ze};return ze=l.actionId_,l}(0,t);try{return n.apply(i,o)}catch(e){throw a.error_=e,e}finally{!function(e){ze!==e.actionId_&&r(30);ze=e.parentActionId_,void 0!==e.error_&&(ht.suppressReactionErrors=!0);Ge(e.prevAllowStateChanges_),at(e.prevAllowStateReads_),_t(),e.runAsAction_&&it(e.prevDerivation_);0;ht.suppressReactionErrors=!1}(a)}}function Ve(e){var t=ht.allowStateChanges;return ht.allowStateChanges=e,t}function Ge(e){ht.allowStateChanges=e}Le=Symbol.toPrimitive;var qe,We=function(e){function t(t,n,r,i,o){var a;return void 0===r&&(r="ObservableValue"),void 0===i&&(i=!0),void 0===o&&(o=$.default),(a=e.call(this,r)||this).enhancer=void 0,a.name_=void 0,a.equals=void 0,a.hasUnreportedChange_=!1,a.interceptors_=void 0,a.changeListeners_=void 0,a.value_=void 0,a.dehancer=void 0,a.enhancer=n,a.name_=r,a.equals=o,a.value_=n(t,void 0,r),a}L(t,e);var n=t.prototype;return n.dehanceValue=function(e){return void 0!==this.dehancer?this.dehancer(e):e},n.set=function(e){this.value_;if((e=this.prepareNewValue_(e))!==ht.UNCHANGED){0,this.setNewValue_(e)}},n.prepareNewValue_=function(e){if(Qe(this),Yt(this)){var t=Jt(this,{object:this,type:rn,newValue:e});if(!t)return ht.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.value_,this.name_),this.equals(this.value_,e)?ht.UNCHANGED:e},n.setNewValue_=function(e){var t=this.value_;this.value_=e,this.reportChanged(),Qt(this)&&tn(this,{type:rn,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},n.intercept_=function(e){return Kt(this,e)},n.observe_=function(e,t){return t&&e({observableKind:"value",debugObjectName:this.name_,object:this,type:rn,newValue:this.value_,oldValue:void 0}),en(this,e)},n.raw=function(){return this.value_},n.toJSON=function(){return this.get()},n.toString=function(){return this.name_+"["+this.value_+"]"},n.valueOf=function(){return C(this.get())},n[Le]=function(){return this.valueOf()},t}(W);qe=Symbol.toPrimitive;var Ze,He,$e=function(){function e(e){this.dependenciesState_=Ze.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.isBeingObserved_=!1,this.isPendingUnobservation_=!1,this.observers_=new Set,this.diffValue_=0,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Ze.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new Ye(null),this.name_=void 0,this.triggeredBy_=void 0,this.isComputing_=!1,this.isRunningSetter_=!1,this.derivation=void 0,this.setter_=void 0,this.isTracing_=He.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||r(31),this.derivation=e.get,this.name_=e.name||"ComputedValue",e.set&&(this.setter_=Ne("ComputedValue-setter",e.set)),this.equals_=e.equals||(e.compareStructural||e.struct?$.structural:$.default),this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}var t=e.prototype;return t.onBecomeStale_=function(){!function(e){if(e.lowestObserverState_!==Ze.UP_TO_DATE_)return;e.lowestObserverState_=Ze.POSSIBLY_STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ze.UP_TO_DATE_&&(e.dependenciesState_=Ze.POSSIBLY_STALE_,e.onBecomeStale_())}))}(this)},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.get=function(){if(this.isComputing_&&r(32,this.name_,this.derivation),0!==ht.inBatch||0!==this.observers_.size||this.keepAlive_){if(gt(this),Je(this)){var e=ht.trackingContext;this.keepAlive_&&!e&&(ht.trackingContext=this),this.trackAndCompute()&&function(e){if(e.lowestObserverState_===Ze.STALE_)return;e.lowestObserverState_=Ze.STALE_,e.observers_.forEach((function(t){t.dependenciesState_===Ze.POSSIBLY_STALE_?t.dependenciesState_=Ze.STALE_:t.dependenciesState_===Ze.UP_TO_DATE_&&(e.lowestObserverState_=Ze.UP_TO_DATE_)}))}(this),ht.trackingContext=e}}else Je(this)&&(this.warnAboutUntrackedRead_(),mt(),this.value_=this.computeValue_(!1),_t());var t=this.value_;if(Ke(t))throw t.cause;return t},t.set=function(e){if(this.setter_){this.isRunningSetter_&&r(33,this.name_),this.isRunningSetter_=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter_=!1}}else r(34,this.name_)},t.trackAndCompute=function(){var e=this.value_,t=this.dependenciesState_===Ze.NOT_TRACKING_,n=this.computeValue_(!0),r=t||Ke(e)||Ke(n)||!this.equals_(e,n);return r&&(this.value_=n),r},t.computeValue_=function(e){this.isComputing_=!0;var t,n=Ve(!1);if(e)t=et(this,this.derivation,this.scope_);else if(!0===ht.disableErrorBoundaries)t=this.derivation.call(this.scope_);else try{t=this.derivation.call(this.scope_)}catch(e){t=new Ye(e)}return Ge(n),this.isComputing_=!1,t},t.suspend_=function(){this.keepAlive_||(tt(this),this.value_=void 0)},t.observe_=function(e,t){var n=this,r=!0,i=void 0;return Pt((function(){var o=n.get();if(!r||t){var a=rt();e({observableKind:"computed",debugObjectName:n.name_,type:rn,object:n,newValue:o,oldValue:i}),it(a)}r=!1,i=o}))},t.warnAboutUntrackedRead_=function(){},t.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},t.valueOf=function(){return C(this.get())},t[qe]=function(){return this.valueOf()},e}(),Xe=S("ComputedValue",$e);!function(e){e[e.NOT_TRACKING_=-1]="NOT_TRACKING_",e[e.UP_TO_DATE_=0]="UP_TO_DATE_",e[e.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",e[e.STALE_=2]="STALE_"}(Ze||(Ze={})),function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"}(He||(He={}));var Ye=function(e){this.cause=void 0,this.cause=e};function Ke(e){return e instanceof Ye}function Je(e){switch(e.dependenciesState_){case Ze.UP_TO_DATE_:return!1;case Ze.NOT_TRACKING_:case Ze.STALE_:return!0;case Ze.POSSIBLY_STALE_:for(var t=ot(!0),n=rt(),r=e.observing_,i=r.length,o=0;or&&(r=s.dependenciesState_)}n.length=i,e.newObserving_=null,o=t.length;for(;o--;){var l=t[o];0===l.diffValue_&&ft(l,e),l.diffValue_=0}for(;i--;){var u=n[i];1===u.diffValue_&&(u.diffValue_=0,dt(u,e))}r!==Ze.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}(e),at(r),i}function tt(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)ft(t[n],e);e.dependenciesState_=Ze.NOT_TRACKING_}function nt(e){var t=rt();try{return e()}finally{it(t)}}function rt(){var e=ht.trackingDerivation;return ht.trackingDerivation=null,e}function it(e){ht.trackingDerivation=e}function ot(e){var t=ht.allowStateReads;return ht.allowStateReads=e,t}function at(e){ht.allowStateReads=e}function st(e){if(e.dependenciesState_!==Ze.UP_TO_DATE_){e.dependenciesState_=Ze.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=Ze.UP_TO_DATE_}}var lt=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},ut=!0,ct=!1,ht=function(){var e=o();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(ut=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==(new lt).version&&(ut=!1),ut?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new lt):(setTimeout((function(){ct||r(35)}),1),new lt)}();function dt(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function ft(e,t){e.observers_.delete(t),0===e.observers_.size&&pt(e)}function pt(e){!1===e.isPendingUnobservation_&&(e.isPendingUnobservation_=!0,ht.pendingUnobservations.push(e))}function mt(){ht.inBatch++}function _t(){if(0==--ht.inBatch){bt();for(var e=ht.pendingUnobservations,t=0;t0&&pt(e),!1)}function yt(e){e.lowestObserverState_!==Ze.STALE_&&(e.lowestObserverState_=Ze.STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ze.UP_TO_DATE_&&e.onBecomeStale_(),e.dependenciesState_=Ze.STALE_})))}var vt=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_=Ze.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_=He.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,ht.pendingReactions.push(this),bt())},t.isScheduled=function(){return this.isScheduled_},t.runReaction_=function(){if(!this.isDisposed_){mt(),this.isScheduled_=!1;var e=ht.trackingContext;if(ht.trackingContext=this,Je(this)){this.isTrackPending_=!0;try{this.onInvalidate_()}catch(e){this.reportExceptionInDerivation_(e)}}ht.trackingContext=e,_t()}},t.track=function(e){if(!this.isDisposed_){mt();0,this.isRunning_=!0;var t=ht.trackingContext;ht.trackingContext=this;var n=et(this,e,void 0);ht.trackingContext=t,this.isRunning_=!1,this.isTrackPending_=!1,this.isDisposed_&&tt(this),Ke(n)&&this.reportExceptionInDerivation_(n.cause),_t()}},t.reportExceptionInDerivation_=function(e){var t=this;if(this.errorHandler_)this.errorHandler_(e,this);else{if(ht.disableErrorBoundaries)throw e;var n="[mobx] uncaught error in '"+this+"'";ht.suppressReactionErrors||console.error(n,e),ht.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed_||(this.isDisposed_=!0,this.isRunning_||(mt(),tt(this),_t()))},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[q]=this,n},t.toString=function(){return"Reaction["+this.name_+"]"},t.trace=function(e){void 0===e&&(e=!1)},e}();var xt=function(e){return e()};function bt(){ht.inBatch>0||ht.isRunningReactions||xt(wt)}function wt(){ht.isRunningReactions=!0;for(var e=ht.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)?Ne(t,n,e):G(n)?(e?Mt:St).decorate_20223_(t,n):y(n)?V(t,n,e?Mt:St):y(t)?U(K(e?"autoAction":"action",{name:t,autoAction:e})):void 0}}var Ct=It(!1);Object.assign(Ct,St);var kt=It(!0);function Ot(e){return g(e)&&!0===e.isMobxAction}function Pt(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 vt(l,(function(){this.track(d)}),t.onError,t.requiresObservable);else{var u=Dt(t),c=!1;s=new vt(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(kt,Mt),Ct.bound=U(Et),kt.bound=U(At);var Rt=function(e){return e()};function Dt(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:Rt}function Lt(e,t,n){return zt("onBUO",e,t,n)}function zt(e,t,n,r){var i="function"==typeof r?Wn(t,n):Wn(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 Bt(e,t,n,r){var i=O(t);return $n((function(){var t=In(e,r)[q];I(i).forEach((function(e){t.extend_(e,i[e],!n||(!(e in n)||n[e]))}))})),e}var Ft=0;function jt(){this.message="FLOW_CANCELLED"}jt.prototype=Object.create(Error.prototype);var Nt=ne("flow"),Ut=ne("flow.bound",{bound:!0}),Vt=Object.assign((function(e,t){if(G(t))return Nt.decorate_20223_(e,t);if(y(t))return V(e,t,Nt);var n=e,r=n.name||"",i=function(){var e,t=this,i=arguments,o=++Ft,a=Ct(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=Ct(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=Ct(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=Ct(r+" - runid: "+o+" - cancel",(function(){try{s&&Gt(s);var t=a.return(void 0),n=Promise.resolve(t.value);n.then(_,_),Gt(n),e(new jt)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),Nt);function Gt(e){g(e.cancel)&&e.cancel()}function qt(e){return!0===(null==e?void 0:e.isMobXFlow)}function Wt(e,t){return!!e&&(void 0!==t?!!On(e)&&e[q].values_.has(t):On(e)||!!e[q]||Z(e)||Tt(e)||Xe(e))}function Zt(e){return Wt(e)}function Ht(e,t){void 0===t&&(t=void 0),mt();try{return e.apply(t)}finally{_t()}}function $t(e){return e[q]}Vt.bound=U(Ut);var Xt={has:function(e,t){return $t(e).has_(t)},get:function(e,t){return $t(e).get_(t)},set:function(e,t,n){var r;return!!y(t)&&(null==(r=$t(e).set_(t,n,!0))||r)},deleteProperty:function(e,t){var n;return!!y(t)&&(null==(n=$t(e).delete_(t,!0))||n)},defineProperty:function(e,t,n){var r;return null==(r=$t(e).defineProperty_(t,n))||r},ownKeys:function(e){return $t(e).ownKeys_()},preventExtensions:function(e){r(13)}};function Yt(e){return void 0!==e.interceptors_&&e.interceptors_.length>0}function Kt(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 Jt(e,t){var n=rt();try{for(var i=[].concat(e.interceptors_||[]),o=0,a=i.length;o0}function en(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 tn(e,t){var n=rt(),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 Kt(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}),en(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&&Gn(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),Yt(this)){var o=Jt(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 un(e,t){"function"==typeof Array.prototype[e]&&(ln[e]=t(e))}function cn(e){return function(){var t=this[q];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function hn(e){return function(t,n){var r=this,i=this[q];return i.atom_.reportObserved(),i.dehanceValues_(i.values_)[e]((function(e,i){return t.call(n,e,i,r)}))}}function dn(e){return function(){var t=this,n=this[q];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)}}un("at",cn),un("concat",cn),un("flat",cn),un("includes",cn),un("indexOf",cn),un("join",cn),un("lastIndexOf",cn),un("slice",cn),un("toString",cn),un("toLocaleString",cn),un("toSorted",cn),un("toSpliced",cn),un("with",cn),un("every",hn),un("filter",hn),un("find",hn),un("findIndex",hn),un("findLast",hn),un("findLastIndex",hn),un("flatMap",hn),un("forEach",hn),un("map",hn),un("some",hn),un("toReversed",hn),un("reduce",dn),un("reduceRight",dn);var fn,pn,mn=S("ObservableArrayAdministration",an);function _n(e){return v(e)&&mn(e[q])}var gn={},yn="add";fn=Symbol.iterator,pn=Symbol.toStringTag;var vn,xn,bn=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[q]=gn,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),$n((function(){i.keysAtom_=H("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(!ht.trackingDerivation)return this.has_(e);var n=this.hasMap_.get(e);if(!n){var r=n=new We(this.has_(e),Y,"ObservableMap.key?",!1);this.hasMap_.set(e,r),Lt(r,(function(){return t.hasMap_.delete(e)}))}return n.get()},t.set=function(e,t){var n=this.has_(e);if(Yt(this)){var r=Jt(this,{type:n?rn:yn,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_,Yt(this))&&!Jt(this,{type:"delete",object:this,name:e}))return!1;if(this.has_(e)){var n=Qt(this),r=n?{observableKind:"map",debugObjectName:this.name_,type:"delete",object:this,oldValue:this.data_.get(e).value_,name:e}:null;return Ht((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&&tn(this,r),!0}return!1},t.updateValue_=function(e,t){var n=this.data_.get(e);if((t=n.prepareNewValue_(t))!==ht.UNCHANGED){var r=Qt(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:rn,object:this,oldValue:n.value_,name:e,newValue:t}:null;0,n.setNewValue_(t),r&&tn(this,i)}},t.addValue_=function(e,t){var n=this;this.keysAtom_,Ht((function(){var r,i=new We(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=Qt(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:yn,object:this,name:e,newValue:t}:null;r&&tn(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 Jn({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 Jn({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},t[fn]=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 wn(e)&&(e=new Map(e)),Ht((function(){x(e)?function(e){var t=Object.keys(e);if(!A)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)})):E(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;Ht((function(){nt((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 Ht((function(){for(var n,i=function(e){if(E(e)||wn(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 en(this,e)},t.intercept_=function(e){return Kt(this,e)},R(e,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:pn,get:function(){return"Map"}}]),e}(),wn=S("ObservableMap",bn);var Tn={};vn=Symbol.iterator,xn=Symbol.toStringTag;var Sn=function(){function e(e,t,n){var i=this;void 0===t&&(t=X),void 0===n&&(n="ObservableSet"),this.name_=void 0,this[q]=Tn,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.enhancer_=function(e,r){return t(e,r,n)},$n((function(){i.atom_=H(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;Ht((function(){nt((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_,Yt(this))&&!Jt(this,{type:yn,object:this,newValue:e}))return this;if(!this.has(e)){Ht((function(){t.data_.add(t.enhancer_(e,void 0)),t.atom_.reportChanged()}));var n=Qt(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:yn,object:this,newValue:e}:null;0,n&&tn(this,r)}return this},t.delete=function(e){var t=this;if(Yt(this)&&!Jt(this,{type:"delete",object:this,oldValue:e}))return!1;if(this.has(e)){var n=Qt(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:"delete",object:this,oldValue:e}:null;return Ht((function(){t.atom_.reportChanged(),t.data_.delete(e)})),n&&tn(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 Jn({next:function(){var r=e;return e+=1,rFn){for(var t=Fn;t=0&&r++}t=Kn(t),n=Kn(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],!k(n,d)||!e(t[d],n[d],r-1,i,o))return!1}return i.pop(),o.pop(),!0}(e,t,n)}function Kn(e){return _n(e)?e.slice():E(e)||wn(e)||M(e)||En(e)?Array.from(e.entries()):e}function Jn(e){return e[Symbol.iterator]=Qn,e}function Qn(){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:Hn},$mobx:q})}).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,_="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 T?e(T,{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),_=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; +read: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)},write: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}};function Lm(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}Lm.Varint=0,Lm.Fixed64=1,Lm.Bytes=2,Lm.Fixed32=5;var zm=4294967296,Bm=1/zm,Fm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function jm(e){return e.type===Lm.Bytes?e.readVarint()+e.pos:e.pos+1}function Nm(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Um(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 Vm(e,t){for(var n=0;n>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Qm(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}Lm.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=Km(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Qm(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Km(this.buf,this.pos)+Km(this.buf,this.pos+4)*zm;return this.pos+=8,e},readSFixed64:function(){var e=Km(this.buf,this.pos)+Qm(this.buf,this.pos+4)*zm;return this.pos+=8,e},readFloat:function(){var e=Dm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Dm.read(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 Nm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return Nm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return Nm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return Nm(e,r,t);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return Nm(e,r,t);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return Nm(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&&Fm?function(e,t,n){return Fm.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!==Lm.Bytes)return e.push(this.readVarint(t));var n=jm(this);for(e=e||[];this.pos127;);else if(t===Lm.Bytes)this.pos=this.readVarint()+this.pos;else if(t===Lm.Fixed32)this.pos+=4;else{if(t!==Lm.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&&Um(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),Dm.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Dm.write(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&&Um(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,Lm.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,Vm,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Gm,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Zm,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,qm,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Wm,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Hm,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,$m,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Xm,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Ym,t)},writeBytesField:function(e,t){this.writeTag(e,Lm.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,Lm.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,Lm.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,Lm.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,Lm.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,Lm.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,Lm.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,Lm.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,Lm.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,Lm.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};var e_=f(Rm);const t_=["tile","layer","source","sourceLayer","state"];class n_{constructor(e,t,n,r,i){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=n,this._y=r,this.properties=e.properties,this.id=i}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};void 0!==this.id&&(e.id=this.id);for(const t of t_)void 0!==this[t]&&(e[t]=this[t]);return e}}class r_{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,n){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},z(this.stateChanges[e][r],n),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])n[t]||(this.deletedStates[e][r][t]=null)}else for(const t in n)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,n){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},n&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][n]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(n in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][n]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){const n=String(t),r=z({},(this.state[e]||{})[n],(this.stateChanges[e]||{})[n]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const n=this.deletedStates[e][t];if(null===n)return{};for(const e in n)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,t){const n={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const n in this.stateChanges[e])this.state[e][n]||(this.state[e][n]={}),z(this.state[e][n],this.stateChanges[e][n]),t[n]=this.state[e][n];n[e]=t}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const n in this.state[e])t[n]={},this.state[e][n]={};else for(const n in this.deletedStates[e]){if(null===this.deletedStates[e][n])this.state[e][n]={};else if(this.state[e][n])for(const t of Object.keys(this.deletedStates[e][n]))delete this.state[e][n][t];t[n]=this.state[e][n]}n[e]=n[e]||{},z(n[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(const r in e)e[r].setFeatureState(n,t)}}class i_{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const n=this.toIdx(e,t);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function o_(e,t,n,r){let i=0,o=Number.MAX_VALUE;for(let a=0;a<3;a++)if(Math.abs(r[a])<1e-15){if(n[a]t[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 a_(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,T=u[1]-t,S=u[2]-n,E=(w*g+T*y+S*v)*b;if(E<0||E>1)return null;const M=T*f-S*d,A=S*h-w*f,I=w*d-T*h,C=(c[0]*M+c[1]*A+c[2]*I)*b;return C<0||E+C>1?null:(p*M+m*A+_*I)*b}function s_(e,t,n){return(e-t)/(n-t)}function l_(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 i_(r);const s=[];for(let t=0;t=1;r/=2){const e=n[n.length-1];a=new i_(r);for(let t=0;t0;){const{idx:s,t:f,nodex:p,nodey:m,depth:_}=d.pop();if(this.leaves[s]){l_(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=h_(l,d,this.dem)*a,v=h_(u,d,this.dem)*a,x=h_(u,g,this.dem)*a,b=h_(l,g,this.dem)*a,w=a_(c[0],c[1],y,h[0],c[1],v,h[0],h[1],x,i,o),T=a_(h[0],h[1],x,c[0],h[1],b,c[0],c[1],y,i,o),S=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(S!==Number.MAX_VALUE)return S;{const e=id.scaleAndAdd([],i,o,f);if(c_(y,v,b,x,s_(e[0],c[0],h[0]),s_(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=m_.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 wp({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=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Cm(new e_(this.rawTileData)).layers,this.sourceLayerCoder=new Pm(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=Co(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)=>Jf(a.bufferedTilespaceGeometry,e,t,n,r));u.sort(v_);let c=null;s.elevation&&u.length>0&&(c=__.create(s.elevation,this.tileID));const h={};let d;for(let s=0;s(p||(p=Bf(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=Ff(m,!0);if(!n.filter(new Ns(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new Ns(this.tileID.overscaledZ),m))return;const _=this.getId(m,p);for(let t=0;t{const a=t instanceof $s?t.get(o):null;return a&&a.evaluate?a.evaluate(n,r,i):a})}function v_(e,t){return t-e}xa(g_,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const x_=ll([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),b_=ll([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),w_=ll([{name:"a_projected_pos",components:4,type:"Float32"}],4);ll([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const T_=ll([{name:"a_z_offset",components:1,type:"Float32"}],4),S_=ll([{name:"a_texb",components:2,type:"Uint16"}]),E_=ll([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),M_=ll([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_z_offset",components:1,type:"Float32"}]);ll([{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 A_=ll([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),I_=ll([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ll([{name:"triangle",components:3,type:"Uint16"}]),ll([{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"}]),ll([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{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"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),ll([{type:"Float32",name:"offsetX"}]),ll([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const C_=128;function k_(e,t){const{expression:n}=t;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new Ns(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()),js.applyArabicShaping&&(e=js.applyArabicShaping(e)),e}(e.text,t,n)}),e}const L_={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function z_(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function B_(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}function F_(e,t,n){t.glyphs=[],1===e&&n.readMessage(j_,t)}function j_(e,t,n){if(3===e){const{id:e,bitmap:r,width:i,height:o,left:a,top:s,advance:l}=n.readMessage(N_,{});t.glyphs.push({id:e,bitmap:new xp({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 N_(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())}const U_={horizontal:1,vertical:2,horizontalOnly:3};class V_{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const n=new V_;return n.scale=e||1,n.fontStack=t,n}static forImage(e){const t=new V_;return t.imageName=e,t}}class G_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const n=new G_;for(let r=0;r=0&&n>=e&&W_[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 G_;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(V_.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 q_(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=G_.fromFeature(e,i);h===U_.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]&&(S=e[m]);const r=t[s.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(v=o.metrics,M=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 rg(e){let t=0;for(let n=0;nu){const c=(u-l)/o,h=Yr(r.x,i.x,c),d=Yr(r.y,i.y,c),f=new tg(h,d,0,i.angleTo(r),n);return!a||ng(e,f,s,a,t)?f:void 0}l+=o}}function sg(e,t,n,r,i,o,a,s,l){const u=ig(r,o,a),c=og(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 tg(g,y,0,m,e);i&&!ng(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 lg(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}function ug(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,n)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,n);for(const r in e.getUpdatedImages(n))this.patchUpdatedImage(this.iconPositions[r],e.getImage(r,n),t),this.patchUpdatedImage(this.patternPositions[r],e.getImage(r,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})}}xa(cg,"ImagePosition"),xa(hg,"ImageAtlas");const dg=1e20;function fg(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]=dg}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 o=r.glyphs[t];if(void 0!==o)return void n(null,{stack:e,id:t,glyph:o});if(o=this._tinySDF(r,e,t),o)return r.glyphs[t]=o,void n(null,{stack:e,id:t,glyph:o});const a=Math.floor(t/256);if(256*a>65535)return void n(new Error("glyphs > 65535 not supported"));if(r.ranges[a])return void n(null,{stack:e,id:t,glyph:o});let s=r.requests[a];s||(s=r.requests[a]=[],mg.loadGlyphRange(e,a,i,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[a]=!0}for(const n of s)n(e,t);delete r.requests[a]})),s.push((r,i)=>{r?n(r):i&&n(null,{stack:e,id:t,glyph:i.glyphs[t]||null})})},(e,t)=>{if(e)n(e);else if(t){const e={};for(const{stack:n,id:r,glyph:i}of t)void 0===e[n]&&(e[n]={}),void 0===e[n].glyphs&&(e[n].glyphs={}),e[n].glyphs[r]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[n].ascender=this.entries[n].ascender,e[n].descender=this.entries[n].descender;n(null,e)}})}_doesCharSupportLocalGlyph(e){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&(os(e)||us(e)||Ha(e)||$a(e)||Za(e)||rs(e)||vs(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 mg.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.fromCodePoint(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 xp({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 _g(e,t,n,r){const i=[],o=e.imagePrimary,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,T=0,S=_,E=0,M=g;if(o.content&&r){const e=o.content;y=gg(h,0,e[0]),b=gg(d,0,e[1]),x=gg(h,e[0],e[2]),w=gg(d,e[1],e[3]),T=e[0]-y,E=e[1]-b,S=e[2]-e[0]-x,M=e[3]-e[1]-w}const A=(r,i,s,l)=>{const h=vg(r.stretch-y,x,u,e.left),d=xg(r.fixed-T,S,r.stretch,p),f=vg(i.stretch-b,w,c,e.top),_=xg(i.fixed-E,M,i.stretch,m),g=vg(s.stretch-y,x,u,e.left),A=xg(s.fixed-T,S,s.stretch,p),I=vg(l.stretch-b,w,c,e.top),C=xg(l.fixed-E,M,l.stretch,m),k=new v(h,f),O=new v(g,f),P=new v(g,I),R=new v(h,I),D=new v(d/a,_/a),L=new v(A/a,C/a),z=t*Math.PI/180;if(z){const e=Math.sin(z),t=Math.cos(z),n=[t,-e,e,t];k._matMult(n),O._matMult(n),R._matMult(n),P._matMult(n)}const B=r.stretch+r.fixed,F=s.stretch+s.fixed,j=i.stretch+i.fixed,N=l.stretch+l.fixed,U=e.imageSecondary;return{tl:k,tr:O,bl:R,br:P,texPrimary:{x:o.paddedRect.x+1+B,y:o.paddedRect.y+1+j,w:F-B,h:N-j},texSecondary:U?{x:U.paddedRect.x+1+B,y:U.paddedRect.y+1+j,w:F-B,h:N-j}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:L,minFontScaleX:S/a/u,minFontScaleY:M/a/c,isSDF:n}};if(r&&(o.stretchX||o.stretchY)){const e=yg(h,_,p),t=yg(d,g,m);for(let n=0;no)&&(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 cr([],Tg);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 Sg(r.p.x-u,r.p.y-u,u,e)),c.push(new Sg(r.p.x+u,r.p.y-u,u,e)),c.push(new Sg(r.p.x-u,r.p.y+u,u,e)),c.push(new Sg(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 Tg(e,t){return t.max-e.max}mg.loadGlyphRange=function(e,t,n,r,i){const o=256*t,a=o+255,s=r.transformRequest(r.normalizeGlyphsURL(n).replace("{fontstack}",e).replace("{range}",`${o}-${a}`),ve.Glyphs);Se(s,(e,t)=>{if(e)i(e);else if(t){const e={},n=function(e){return new e_(e).readFields(F_,{})}(t);for(const t of n.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:n.ascender,descender:n.descender})}})},mg.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(dg,0,h),_.fill(0,0,h);for(let e=0;e0?e*e:0,_[r]=e<0?e*e:0}}fg(g,0,0,u,c,u,this.f,this.v,this.z),fg(_,m,m,s,l,u,this.f,this.v,this.z);for(let e=0;ee.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,Xf(e,i,s))}}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}}const Eg=Number.POSITIVE_INFINITY,Mg=Math.sqrt(2);function Ag(e,[t,n]){let r=0,i=0;if(n===Eg){t<0&&(t=0);const n=t/Mg;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 Ig(e,t,n,r,i,o,a,s,l,u,c){e.createArrays(),e.tilePixelRatio=hr/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,f={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:n}=e.textSizeData;f.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ns(t),s),d["text-size"].possiblyEvaluate(new Ns(n),s)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:n}=e.iconSizeData;f.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ns(t),s),d["icon-size"].possiblyEvaluate(new Ns(n),s)]}f.layoutTextSize=d["text-size"].possiblyEvaluate(new Ns(l+1),s),f.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ns(l+1),s),f.textMaxSize=d["text-size"].possiblyEvaluate(new Ns(18),s);const p="map"===h.get("text-rotation-alignment")&&"point"!==h.get("symbol-placement"),m=h.get("text-size");let _=!1;for(const t of e.features)if(t.icon&&t.icon.nameSecondary){_=!0;break}for(const o of e.features){const l=h.get("text-font").evaluate(o,{},s).join(","),d=m.evaluate(o,{},s),g=f.layoutTextSize.evaluate(o,{},s),y=(f.layoutIconSize.evaluate(o,{},s),{horizontal:{},vertical:void 0}),v=o.text;let x,b=[0,0];if(v){const r=v.toString(),a=24*h.get("text-letter-spacing").evaluate(o,{},s),u=24*h.get("text-line-height").evaluate(o,{},s),c=bs(r)?a:0,f=h.get("text-anchor").evaluate(o,{},s),m=h.get("text-variable-anchor");if(!m){const e=h.get("text-radial-offset").evaluate(o,{},s);b=e?Ag(f,[24*e,Eg]):h.get("text-offset").evaluate(o,{},s).map(e=>24*e)}let _=p?"center":h.get("text-justify").evaluate(o,{},s);const x="point"===h.get("symbol-placement"),w=x?24*h.get("text-max-width").evaluate(o,{},s):1/0,T=o=>{e.allowVerticalPlacement&&xs(r)&&(y.vertical=q_(v,t,n,i,l,w,u,f,o,c,b,U_.vertical,!0,g,d))};if(!p&&m){const e="auto"===_?m.map(e=>Cg(e)):[_];let r=!1;for(let o=0;o=0||!xs(r)){const e=q_(v,t,n,i,l,w,u,f,_,c,b,U_.horizontal,!1,g,d);e&&(y.horizontal[_]=e)}T(x?"left":_)}}let w=!1;if(o.icon&&o.icon.namePrimary){const t=r[o.icon.namePrimary];t&&(x=Q_(i[o.icon.namePrimary],o.icon.nameSecondary?i[o.icon.nameSecondary]:void 0,h.get("icon-offset").evaluate(o,{},s),h.get("icon-anchor").evaluate(o,{},s)),w=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&X("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const T=Dg(y.horizontal)||y.vertical;e.iconsInText||(e.iconsInText=!!T&&T.iconsInText),(T||x)&&kg(e,o,y,x,r,f,g,0,b,w,a,s,u,c,_)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Cg(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 kg(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){let m=o.textMaxSize.evaluate(t,{},h);void 0===m&&(m=a);const _=e.layers[0].layout,g=_.get("icon-offset").evaluate(t,{},h),y=Dg(n.horizontal)||n.vertical,v="globe"===d.name,x=a/24,b=e.tilePixelRatio*m/24,w=(O=e.overscaling,e.zoom>18&&O>2&&(O>>=1),Math.max(hr/(512*O),1)*_.get("symbol-spacing")),S=_.get("text-padding")*e.tilePixelRatio,E=_.get("icon-padding")*e.tilePixelRatio,M=T(_.get("text-max-angle")),A="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),I="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),C=_.get("symbol-placement"),k=w/2;var O;const P=_.get("icon-text-fit").evaluate(t,{},h),R=_.get("icon-text-fit-padding").evaluate(t,{},h),D="none"!==P;let L;!1===e.hasAnyIconTextFit&&D&&(e.hasAnyIconTextFit=!0),r&&D&&(e.allowVerticalPlacement&&n.vertical&&(L=eg(r,n.vertical,P,R,g,x)),y&&(r=eg(r,y,P,R,g,x)));const z=(a,s,m)=>{if(s.x<0||s.x>=hr||s.y<0||s.y>=hr)return;let _=null;if(v){const{x:e,y:t,z:n}=d.projectTilePoint(s.x,s.y,m);_={anchor:new tg(e,t,n,0,void 0),up:d.upVector(m,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,T,S,E,M){const A=e.addToLineVertexArray(t,r);let I,C,k,O,P,R,D,L=0,z=0,B=0,F=0,j=-1,N=-1;const U={};let V=uu("");const G=n?n.anchor:t,q="none"!==l.layout.get("icon-text-fit").evaluate(x,{},S);let W=0,Z=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[W,Z]=l.layout.get("text-offset").evaluate(x,{},S).map(e=>24*e):(W=24*l.layout.get("text-radial-offset").evaluate(x,{},S),Z=Eg),e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(p)R=zg(e),s&&(D=zg(s));else{const n=l.layout.get("text-rotate").evaluate(x,{},S)+90;k=Lg(u,G,t,c,h,d,e,f,n,m),s&&(O=Lg(u,G,t,c,h,d,s,g,n))}}if(o){const r=l.layout.get("icon-rotate").evaluate(x,{},S),i=_g(o,r,w,q),a=s?_g(s,r,w,q):void 0;C=Lg(u,G,t,c,h,d,o,g,r),L=4*i.length;const f=e.iconSizeData;let p=null;"source"===f.kind?(p=[C_*l.layout.get("icon-size").evaluate(x,{},S)],p[0]>Pg&&X(`${e.layerIds[0]}: Value for "icon-size" is >= ${Og}. Reduce your "icon-size".`)):"composite"===f.kind&&(p=[C_*b.compositeIconSizes[0].evaluate(x,{},S),C_*b.compositeIconSizes[1].evaluate(x,{},S)],(p[0]>Pg||p[1]>Pg)&&X(`${e.layerIds[0]}: Value for "icon-size" is >= ${Og}. Reduce your "icon-size".`)),e.addSymbols(e.icon,i,p,v,y,x,!1,n,t,A.lineStartIndex,A.lineLength,-1,T,S,E,M),j=e.icon.placedSymbolArray.length-1,a&&(z=4*a.length,e.addSymbols(e.icon,a,p,v,y,x,U_.vertical,n,t,A.lineStartIndex,A.lineLength,-1,T,S,E,M),N=e.icon.placedSymbolArray.length-1)}for(const r in i.horizontal){const o=i.horizontal[r];I||(V=uu(o.text),p?P=zg(o):I=Lg(u,G,t,c,h,d,o,f,l.layout.get("text-rotate").evaluate(x,{},S),m));const s=1===o.positionedLines.length;if(B+=Rg(e,n,t,o,a,l,p,x,m,A,i.vertical?U_.horizontal:U_.horizontalOnly,s?Object.keys(i.horizontal):[r],U,j,b,T,S,E),s)break}i.vertical&&(F+=Rg(e,n,t,i.vertical,a,l,p,x,m,A,U_.vertical,["vertical"],U,N,b,T,S,E));let H=-1;const $=(e,t)=>e?Math.max(e,t):t;H=$(P,H),H=$(R,H),H=$(D,H);const Y=H>-1?1:0;e.glyphOffsetArray.length>=Ey.MAX_GLYPHS&&X("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(t.x,t.y,G.x,G.y,G.z,U.right>=0?U.right:-1,U.center>=0?U.center:-1,U.left>=0?U.left:-1,U.vertical>=0?U.vertical:-1,j,N,V,void 0!==I?I:e.collisionBoxArray.length,void 0!==I?I+1:e.collisionBoxArray.length,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,O||e.collisionBoxArray.length,O?O+1:e.collisionBoxArray.length,c,B,F,L,z,Y,0,W,Z,H,0,q?1:0)}(e,s,_,a,n,r,i,L,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,S,A,l,0,E,I,g,t,o,u,c,h,f,p)};if("line"===C)for(const i of lg(t.geometry,0,0,hr,hr)){const t=sg(i,w,M,n.vertical||y,r,24,b,e.overscaling,hr);for(const n of t)y&&Bg(e,y.text,k,n)||z(i,n,h)}else if("line-center"===C){for(const e of t.geometry)if(e.length>1){const t=ag(e,M,n.vertical||y,r,24,b);t&&z(e,t,h)}}else if("Polygon"===t.type)for(const e of im(t.geometry,0)){const t=wg(e,16);z(e[0],new tg(t.x,t.y,0,0,void 0),h)}else if("LineString"===t.type)for(const e of t.geometry)z(e,new tg(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)z([t],new tg(t.x,t.y,0,0,void 0),h)}const Og=255,Pg=Og*C_;function Rg(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g){const y=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;ePg&&X(`${e.layerIds[0]}: Value for "text-size" is >= ${Og}. Reduce your "text-size".`)):"composite"===x.kind&&(b=[C_*p.compositeTextSizes[0].evaluate(s,{},_),C_*p.compositeTextSizes[1].evaluate(s,{},_)],(b[0]>Pg||b[1]>Pg)&&X(`${e.layerIds[0]}: Value for "text-size" is >= ${Og}. Reduce your "text-size".`)),e.addSymbols(e.text,y,b,l,a,s,c,t,n,u.lineStartIndex,u.lineLength,f,m,_,g,!1);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function Dg(e){for(const t in e)return e[t];return null}function Lg(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=T(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 zg(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 Bg(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}}function Ng(e,t,n,r,i,o,a,s,l){if("globe"===l.name)return Nd(e,t,new pd(n,r,i),!1);const u=jg({z:n,x:r,y:i},l);return new Md([(o+u.x/u.scale)*t,t*(u.y/u.scale),a],[(o+u.x2/u.scale)*t,t*(u.y2/u.scale),s])}function Ug(e,{x:t,y:n},r=0){return new v(((t-r)*e.scale-e.x)*hr,(n*e.scale-e.y)*hr)}function Vg(e,t,n=0){return id.fromValues(((t.x-n)*e.scale-e.x)*hr,(t.y*e.scale-e.y)*hr,Tf(t.z,t.y))}const Gg=Jh.identity(new Float32Array(16));class qg{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 _f(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 xf(1,e)*t}pixelSpaceConversion(e,t,n){return 1}farthestPixelDistance(e){return Fg(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<-Qg+n&&(t=-Qg+n):t>Qg-n&&(t=Qg-n);const o=i/Math.pow(ey(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=O(S(s/n)+this.center[0],-180,180),u=O(S(2*Math.atan(Math.pow(r/a,1/n))-Qg),-Sf,Sf);return new _f(l,this.southernCenter?-u:u)}}class ny extends qg{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:yf(e),y:vf(t),z:0}}unproject(e,t){const n=bf(e),r=wf(t);return new _f(n,r)}}const ry=T(Sf);class iy extends qg{project(e,t){const n=(t=T(t))*t,r=n*n;return{x:.5*((e=T(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=O(n-i,-ry,ry)}while(Math.abs(i)>1e-6&&--r>0);o=n*n;const a=O(S(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=S(n);return new _f(a,s)}}const oy=T(Sf);class ay extends qg{project(e,t){t=T(t),e=T(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),T=.5*_*(u*h+g*p*i)+.5,S=b*w-T*x;a=(v*b-y*T)/S,s=(y*w-v*x)/S,n=O(n-a,-Math.PI,Math.PI),r=O(r-s,-oy,oy)}while((Math.abs(a)>o||Math.abs(s)>o)&&--i>0);return new _f(S(n),S(r))}}class sy extends qg{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(T(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:T(e)*r*n+.5,y:-Math.sin(T(t))/r*n+.5,z:0}}unproject(e,t){const{scale:n,cosPhi:r}=this,i=-(t-.5)/n,o=O(S((e-.5)/n)/r,-180,180),a=Math.asin(O(i*r,-1,1)),s=O(S(a),-Sf,Sf);return new _f(o,s)}}class ly extends ny{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=Wd(e,t,n),i=$d(zd(n));return id.transformMat4(r,r,i),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const n=qd(t.lat,t.lng),r=id.normalize([],n),i=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude,o=xf(1,0)*hr*i;id.scaleAndAdd(n,n,r,o);const a=Jh.identity(new Float64Array(16));return Jh.multiply(a,e.pixelMatrix,e.globeMatrix),id.transformMat4(n,n,a),new v(n[0],n[1])}pixelsPerMeter(e,t){return xf(1,0)*t}pixelSpaceConversion(e,t,n){const r=xf(1,e)*t,i=Yr(xf(1,45)*t,r,n);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,n){const r=Xd(zd(n.canonical));return Jh.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:n}=e,r=$d(zd(t));return Jh.rotateY(r,r,T(n.lng)),Jh.rotateX(r,r,T(n.lat)),Jh.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,n,r){return Rd(e,t,n,!0)||new Cf(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!Rd(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=id.add([],id.scale([],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=id.scale([],i.up(),c),d=id.scale([],i.right(),c*u),f=id.normalize([],id.add([],id.add([],o,h),d)),p=[];let m;if(new vd(a,f).closestPointOnSphere(l,s,p)){const t=id.add([],p,l),n=id.sub([],t,a);m=Math.cos(e.fovAboveCenter)*id.length(n)}else{const e=id.sub([],a,l),t=id.sub([],l,a);id.normalize(t,t);const n=id.length(e)-s;m=Math.sqrt(n*(n+2*s));const r=Math.acos(m/(s+n))-Math.acos(id.dot(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=ef(e.zoom);if(n>0){const r=Fg(e,xf(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Yr(t,r+i*(1-Math.cos(o)),Math.pow(n,10))}return t}upVector(e,t,n){return Wd(t,n,e,1)}upVectorScale(e){return{metersToTile:Pd(Zd(zd(e)))}}}function uy(e){const t=e.parallels,n=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new ny(e);case"equirectangular":return new Jg(e);case"naturalEarth":return new iy(e);case"equalEarth":return new Kg(e);case"winkelTripel":return new ay(e);case"albers":return n?new sy(e):new Wg(e);case"lambertConformalConic":return n?new sy(e):new ty(e);case"globe":return new ly(e)}throw new Error("Invalid projection name: "+e.name)}const cy=new Js({"symbol-placement":new Xs(Pt.layout_symbol["symbol-placement"]),"symbol-spacing":new Xs(Pt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Xs(Pt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Ys(Pt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Xs(Pt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Xs(Pt.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new Xs(Pt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Xs(Pt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Xs(Pt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Xs(Pt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Ys(Pt.layout_symbol["icon-size"]),"icon-text-fit":new Ys(Pt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Ys(Pt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Ys(Pt.layout_symbol["icon-image"]),"icon-rotate":new Ys(Pt.layout_symbol["icon-rotate"]),"icon-padding":new Xs(Pt.layout_symbol["icon-padding"]),"icon-keep-upright":new Xs(Pt.layout_symbol["icon-keep-upright"]),"icon-offset":new Ys(Pt.layout_symbol["icon-offset"]),"icon-anchor":new Ys(Pt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Xs(Pt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Xs(Pt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Xs(Pt.layout_symbol["text-rotation-alignment"]),"text-field":new Ys(Pt.layout_symbol["text-field"]),"text-font":new Ys(Pt.layout_symbol["text-font"]),"text-size":new Ys(Pt.layout_symbol["text-size"]),"text-max-width":new Ys(Pt.layout_symbol["text-max-width"]),"text-line-height":new Ys(Pt.layout_symbol["text-line-height"]),"text-letter-spacing":new Ys(Pt.layout_symbol["text-letter-spacing"]),"text-justify":new Ys(Pt.layout_symbol["text-justify"]),"text-radial-offset":new Ys(Pt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Xs(Pt.layout_symbol["text-variable-anchor"]),"text-anchor":new Ys(Pt.layout_symbol["text-anchor"]),"text-max-angle":new Xs(Pt.layout_symbol["text-max-angle"]),"text-writing-mode":new Xs(Pt.layout_symbol["text-writing-mode"]),"text-rotate":new Ys(Pt.layout_symbol["text-rotate"]),"text-padding":new Xs(Pt.layout_symbol["text-padding"]),"text-keep-upright":new Xs(Pt.layout_symbol["text-keep-upright"]),"text-transform":new Ys(Pt.layout_symbol["text-transform"]),"text-offset":new Ys(Pt.layout_symbol["text-offset"]),"text-allow-overlap":new Xs(Pt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Xs(Pt.layout_symbol["text-ignore-placement"]),"text-optional":new Xs(Pt.layout_symbol["text-optional"]),visibility:new Xs(Pt.layout_symbol.visibility)});var hy={paint:new Js({"icon-opacity":new Ys(Pt.paint_symbol["icon-opacity"]),"icon-emissive-strength":new Ys(Pt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new Ys(Pt.paint_symbol["text-emissive-strength"]),"icon-color":new Ys(Pt.paint_symbol["icon-color"]),"icon-halo-color":new Ys(Pt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Ys(Pt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Ys(Pt.paint_symbol["icon-halo-blur"]),"icon-translate":new Xs(Pt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Xs(Pt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Ys(Pt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new Ys(Pt.paint_symbol["text-opacity"]),"text-color":new Ys(Pt.paint_symbol["text-color"],{runtimeType:Zt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Ys(Pt.paint_symbol["text-halo-color"]),"text-halo-width":new Ys(Pt.paint_symbol["text-halo-width"]),"text-halo-blur":new Ys(Pt.paint_symbol["text-halo-blur"]),"text-translate":new Xs(Pt.paint_symbol["text-translate"]),"text-translate-anchor":new Xs(Pt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Xs(Pt.paint_symbol["icon-color-saturation"])}),layout:cy};class dy{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Vt,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}}xa(dy,"FormatSectionOverride",{omit:["defaultValue"]});class fy extends rl{constructor(e,t){super(e,hy,t)}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()||_o(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 Ey(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of hy.paint.overridableProperties){if(!fy.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),n=new dy(t),r=new mo(n,t.property.specification);let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new yo("source",r):new vo("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Hs(t.property,i,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&fy.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const n=e.get("text-field"),r=hy.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 mn)o(n.value.value.sections);else if("source"===n.value.kind){const e=t=>{i||(t instanceof wn&&vn(t.value)===Yt?o(t.value.sections):t instanceof An?o(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}getProgramIds(){const e=0!==this.paint.get("icon-opacity").constantOr(1),t=0!==this.paint.get("text-opacity").constantOr(1),n=[];return e&&n.push("symbolIcon"),t&&n.push("symbolSDF"),n}getDefaultProgramParams(e,t){return{config:new Pu(this,t),overrideFog:!1}}}const py=km.types,my=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function _y(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=s?Math.min(Pg,Math.round(s[0])):0,p=s?Math.min(Pg,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 gy(e,t,n){e.emplaceBack(t,n)}function yy(e,t,n,r,i,o,a){e.emplaceBack(t,n,r,i,o,a)}function vy(e,t,n,r,i){const o=5*t+2;e.float32[o+0]=n,e.float32[o+1]=r,e.float32[o+2]=i}function xy(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 by(e){for(const t of e.sections)if(As(t.text))return!0;return!1}class wy{constructor(e){this.layoutVertexArray=new vl,this.indexArray=new Al,this.programConfigurations=e,this.segments=new Ql,this.dynamicLayoutVertexArray=new ml,this.opacityVertexArray=new bl,this.placedSymbolArray=new Gl,this.iconTransitioningVertexArray=new wl,this.globeExtVertexArray=new xl,this.zOffsetVertexArray=new kl}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,t,n,r,i){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,x_.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,w_.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,my,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,S_.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,b_.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,T_.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.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy())}}xa(wy,"SymbolBuffers");class Ty{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new Ql,this.collisionVertexArray=new Ml,this.collisionVertexArrayExt=new ml}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,E_.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,M_.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}xa(Ty,"CollisionBuffers");class Sy{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.fqid),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Jh.identity([]),this.placementViewportMatrix=Jh.identity([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=k_(this.zoom,t["text-size"]),this.iconSizeData=k_(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=>U_[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get("symbol-z-elevate")}createArrays(){this.text=new wy(new Ru(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new wy(new Ru(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Zl,this.lineVertexArray=new Hl,this.symbolInstances=new Wl}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 Ns(this.zoom);for(const{feature:t,id:l,index:u,sourceLayerIndex:g}of e){const e=i._featureFilter.needGeometry,y=Ff(t,e);if(!i._featureFilter.filter(_,y,n))continue;if(e||(y.geometry=Bf(t,n,r)),a&&1!==t.type&&n.z<=5){const e=y.geometry,t=.98078528056,r=(e,r)=>{const i=Wd(e.x,e.y,n,1),o=Wd(r.x,r.y,n,1);return id.dot(i,o)=0;for(const n of v.sections)if(n.image)f[n.image.namePrimary]=!0;else{const r=xs(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,i){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const a=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,t,a,n,r,i),this.icon.programConfigurations.updatePaintArrays(e,t,a,n,r,i)}updateZOffset(){const e=(e,t,r)=>{n+=t,n>e.length&&e.resize(n);for(let i=-t;i<0;i++)e.emplace(i+n,r)},t=(e,t,n)=>{r+=t,r>e.length&&e.resize(r);for(let i=-t;i<0;i++)e.emplace(i+r,n)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let n=0,r=0;for(let n=0;n0;if((i>0||o>0)&&(e(this.text.zOffsetVertexArray,i,s),e(this.text.zOffsetVertexArray,o,s)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:n}=r;e>=0&&t(this.icon.zOffsetVertexArray,a,s),n>=0&&t(this.icon.zOffsetVertexArray,r.numVerticalIconVertices,s)}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray)}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.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=uy(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,p,m){const _=e.indexArray,g=e.layoutVertexArray,y=e.globeExtVertexArray,v=e.segments.prepareSegment(4*t.length,g,_,this.canOverlap?o.sortKey:void 0),x=this.glyphOffsetArray.length,b=v.vertexLength,w=this.allowVerticalPlacement&&a===U_.vertical?Math.PI/2:0,T=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=O_(this.textSizeData,e,i)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,n){const r=this.icon.placedSymbolArray.get(n),i=O_(this.iconSizeData,e,r);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,n,r){e.emplaceBack(t,-n,-n,r),e.emplaceBack(t,n,-n,r),e.emplaceBack(t,n,n,r),e.emplaceBack(t,-n,n,r)}_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}hasIconTextFit(){return this.hasAnyIconTextFit}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}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}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)}}}xa(Sy,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Sy.MAX_GLYPHS=65535,Sy.addDynamicAttributes=xy;var Ey=Sy;const My=ll([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Ay}=My,Iy=ll([{name:"a_packed",components:4,type:"Float32"}]),{members:Cy}=Iy,ky=km.types,Oy=Math.cos(Math.PI/180*37.5);class Py{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),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 pl,this.layoutVertexArray2=new ml,this.indexArray=new Al,this.programConfigurations=new Ru(e.layers,e.zoom),this.segments=new Ql,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){this.hasPattern=am("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=Ff(t,e);if(!this.layers[0]._featureFilter.filter(new Ns(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:Bf(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=sm("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,a.positions,t.availableImages,t.brightness);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,i){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,n,r,i)}addFeatures(e,t,n,r,i,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r,o)}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,Cy)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ay),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,a){const s=this.layers[0].layout,l=s.get("line-join").evaluate(e,{}),u=s.get("line-cap").evaluate(e,{}),c=s.get("line-miter-limit"),h=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const n of t)this.addLine(n,e,l,u,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r,a)}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 T=d&&f;let S=T?n:a?"butt":r;if(T&&"round"===S&&(vi&&(S="bevel"),"bevel"===S&&(v>2&&(S="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"===S||"fakeround"===S){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"===S){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()}}xa(Py,"LineBucket",{omit:["layers","patternFeatures"]});class Ry{constructor(e,t,n,r){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this.update(t,r)}update(e,t,r){const{width:i,height:o}=e,{context:a}=this,{gl:s}=a,{HTMLImageElement:l,HTMLCanvasElement:u,HTMLVideoElement:c,ImageData:h,ImageBitmap:d}=n;if(s.bindTexture(s.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1),a.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!t||!1!==t.premultiply)),r||this.size&&this.size[0]===i&&this.size[1]===o){const{x:t,y:n}=r||{x:0,y:0};if(e instanceof l||e instanceof u||e instanceof c||e instanceof h||d&&e instanceof d)s.texSubImage2D(s.TEXTURE_2D,0,t,n,s.RGBA,s.UNSIGNED_BYTE,e);else{let r=this.format,a=s.UNSIGNED_BYTE;this.format===s.R32F&&(r=s.RED,a=s.FLOAT),s.texSubImage2D(s.TEXTURE_2D,0,t,n,i,o,r,a,e.data)}}else if(this.size=[i,o],e instanceof l||e instanceof u||e instanceof c||e instanceof h||d&&e instanceof d){let t=this.format;this.format===s.R8&&(t=s.RED),s.texImage2D(s.TEXTURE_2D,0,this.format,t,s.UNSIGNED_BYTE,e)}else{let t=this.format,n=this.format,r=s.UNSIGNED_BYTE;this.format===s.DEPTH_COMPONENT&&(t=s.DEPTH_COMPONENT16,r=s.UNSIGNED_SHORT),this.format===s.R32F&&(r=s.FLOAT,n=s.RED),s.texImage2D(s.TEXTURE_2D,0,t,i,o,0,n,r,e.data)}this.useMipmap=Boolean(t&&t.useMipmap),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(e,t){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}bindExtraParam(e,t,n,r){const{context:i}=this,{gl:o}=i;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),n!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,n),this.wrapS=n),r!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapT=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Dy{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:n}=this,{gl:r}=n;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}}const Ly=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,n=0,r=0,i=0,o=0,a=0,s=0;for(1&t?i=o=a=32:n=r=s=32;(t>>=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;Ly[l+0]=n,Ly[l+1]=r,Ly[l+2]=i,Ly[l+3]=o}const zy=new Uint16Array(2178),By=new Uint8Array(1089),Fy=new Uint16Array(1089);function jy(e){return 0===e?-.03125:32===e?.03125:0}var Ny=ll([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Uy={type:2,extent:hr,loadGeometry:()=>[[new v(0,0),new v(8193,0),new v(8193,8193),new v(0,8193),new v(0,0)]]};class Vy{constructor(e,t,n,r,i){this.tileID=e,this.uid=j(),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,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),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.fqid]=r}}return n}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Ey){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 Ey&&t.hasRTLText){this.hasRTLText=!0,js.isLoading()||js.isLoaded()||"deferred"!==Bs()||Fs();break}}this.queryPadding=0;for(const e in this.buckets){const n=this.buckets[e],r=t.style.getOwnLayer(e);if(!r)continue;const i=r.queryRadius(n);this.queryPadding=Math.max(this.queryPadding,i)}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness}else this.collisionBoxArray=new Ul}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.fqid]}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 Ry(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ry(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Ry(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e,t,n){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,n),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const r=t.style.getBrightness();(this._lastUpdatedBrightness||r)&&(this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this._lastUpdatedBrightness=r,this.updateBuckets(void 0,t)))}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=Co(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=Ly[t+0],r=Ly[t+1],i=Ly[t+2],o=Ly[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((zy[2*c+0]+zy[2*h+0])/2-zy[2*d+0],(zy[2*c+1]+zy[2*h+1])/2-zy[2*d+1])>=16;By[d]=By[d]||(f?1:0),e<1022&&(By[d]=By[d]||By[33*(r+u>>1)+(n+l>>1)]||By[33*(o+u>>1)+(i+l>>1)])}const i=new dl,o=new Al;let a=0;function s(e,t){const n=33*t+e;return 0===Fy[n]&&(i.emplaceBack(zy[2*n+0],zy[2*n+1],e*hr/32,t*hr/32),Fy[n]=++a),Fy[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&&By[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 dl,i=new Al;for(const{x:e,y:t}of n)r.emplaceBack(e,t,0,0);const e=rm(r.int16,void 0,4);for(let t=0;t0&&(a=Jh.invert(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=Wd(e,t,n);if(o){const i=1<.5?h=-1:c<-.5&&(h=1);let d=(e/hr+n.x)/i+h,f=(t/hr+n.y)/i;d=(d-l)*r._pixelsPerMercatorPixel+l,f=(f-u)*r._pixelsPerMercatorPixel+u;const p=[d*r.worldSize,f*r.worldSize,0];id.transformMat4(p,p,o),s=Bd(s,p,a)}return id.transformMat4(s,s,i)}_makeGlobeTileDebugBorderBuffer(e,t,n,r,i,o){const a=new cl,s=new Dl,l=new hl,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;e{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 qy{constructor(e,t,n,r){this.id=qy.uniqueIdxCounter,qy.uniqueIdxCounter++,this.context=e;const i=e.gl;this.buffer=i.createBuffer(),this.dynamicDraw=Boolean(n),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||r||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=qy.uniqueIdxCounter,qy.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}qy.uniqueIdxCounter=0;const Wy={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Zy{constructor(e,t,n,r,i,o){this.length=t.length,this.attributes=n,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,this.context=e;const a=e.gl;this.buffer=a.createBuffer(),e.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||i||t.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let n=0;n0&&e.vertexAttribDivisor(i,n)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Hy{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class $y extends Hy{getDefault(){return dn.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Xy extends Hy{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class Yy extends Hy{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class Ky extends Hy{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class Jy extends Hy{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Qy extends Hy{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class ev extends Hy{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class tv extends Hy{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class nv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class rv extends Hy{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class iv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class ov extends Hy{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class av extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class sv extends Hy{getDefault(){const e=this.gl;return[e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class lv extends Hy{getDefault(){return dn.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class uv extends Hy{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1)}}class cv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class hv extends Hy{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class dv extends Hy{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let fv=class extends Hy{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class pv extends Hy{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class mv extends Hy{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class _v extends Hy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class gv extends Hy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class yv extends Hy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class vv extends Hy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class xv extends Hy{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class bv extends Hy{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class wv extends Hy{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Tv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class Sv extends Hy{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Ev extends Hy{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Mv extends Ev{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Av extends Ev{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Iv extends Ev{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Cv extends Av{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class kv{constructor(e,t,n,r,i){this.context=e,this.width=t,this.height=n;const o=this.framebuffer=e.gl.createFramebuffer();r&&(this.colorAttachment=new Mv(e,o)),i&&(this.depthAttachmentType=i,this.depthAttachment="renderbuffer"===i?new Av(e,o):new Iv(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t)}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}else{const t=this.depthAttachment.get();t&&e.deleteTexture(t)}e.deleteFramebuffer(this.framebuffer)}}class Ov{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}Ov.ReadOnly=!1,Ov.ReadWrite=!0,Ov.disabled=new Ov(519,Ov.ReadOnly,[0,1]);class Pv{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}}Pv.disabled=new Pv({func:519,mask:0},0,0,7680,7680,7680);class Rv{constructor(e,t,n,r){this.blendFunction=e,this.blendColor=t,this.mask=n,this.blendEquation=r}}Rv.Replace=[1,0,1,0],Rv.disabled=new Rv(Rv.Replace,dn.transparent,[!1,!1,!1,!1]),Rv.unblended=new Rv(Rv.Replace,dn.transparent,[!0,!0,!0,!0]),Rv.alphaBlended=new Rv([1,771,1,771],dn.transparent,[!0,!0,!0,!0]),Rv.multiply=new Rv([774,0,774,0],dn.transparent,[!0,!0,!0,!0]);class Dv{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}Dv.disabled=new Dv(!1,1029,2305),Dv.backCCW=new Dv(!0,1029,2305),Dv.backCW=new Dv(!0,1029,2304),Dv.frontCW=new Dv(!0,1028,2304),Dv.frontCCW=new Dv(!0,1028,2305);class Lv{constructor(e,t){this.gl=e,this.clearColor=new $y(this),this.clearDepth=new Xy(this),this.clearStencil=new Yy(this),this.colorMask=new Ky(this),this.depthMask=new Jy(this),this.stencilMask=new Qy(this),this.stencilFunc=new ev(this),this.stencilOp=new tv(this),this.stencilTest=new nv(this),this.depthRange=new rv(this),this.depthTest=new iv(this),this.depthFunc=new ov(this),this.blend=new av(this),this.blendFunc=new sv(this),this.blendColor=new lv(this),this.blendEquation=new uv(this),this.cullFace=new cv(this),this.cullFaceSide=new hv(this),this.frontFace=new dv(this),this.program=new fv(this),this.activeTexture=new pv(this),this.viewport=new mv(this),this.bindFramebuffer=new _v(this),this.bindRenderbuffer=new gv(this),this.bindTexture=new yv(this),this.bindVertexBuffer=new vv(this),this.bindElementBuffer=new xv(this),this.bindVertexArrayOES=new bv(this),this.pixelStoreUnpack=new wv(this),this.pixelStoreUnpackPremultiplyAlpha=new Tv(this),this.pixelStoreUnpackFlipY=new Sv(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(e,t,n){return new qy(this,e,t,n)}createVertexBuffer(e,t,n,r,i){return new Zy(this,e,t,n,r,i)}createRenderbuffer(e,t,n){const r=this.gl,i=r.createRenderbuffer();return this.bindRenderbuffer.set(i),r.renderbufferStorage(r.RENDERBUFFER,e,t,n),this.bindRenderbuffer.set(null),i}createFramebuffer(e,t,n,r){return new kv(this,e,t,n,r)}clear({color:e,depth:t,stencil:n,colorMask:r}){const i=this.gl;let o=0;e&&(o|=i.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(r||[!0,!0,!0,!0])),void 0!==t&&(o|=i.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==n&&(o|=i.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),i.clear(o)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){x(e.blendFunction,Rv.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}class zv extends Ot{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 Gy(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this._coveredTiles={},this._shadowCasterTiles={},this._state=new r_,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("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))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,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],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,this.map?this.map.painter:null,this._source.scope)}}getIds(){return L(this._tiles).map(e=>e.tileID).sort(Bv).map(e=>e.key)}getRenderableIds(e,t){const n=[];for(const r in this._tiles)this._isIdRenderable(+r,e,t)&&n.push(this._tiles[r]);return e?n.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):n.map(e=>e.tileID).sort(Bv).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,n){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(n||!this._shadowCasterTiles[e])}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 kt(r,{tile:e}));else{if(!(e.tileID.key in this._loadedParentTiles))return void this._source.fire(new Ct("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));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=ft.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 Ct("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,r){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;let i;if(this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?i=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new _d(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(i=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&&(i=i.filter(e=>this._source.hasTile(e)))):i=[],i.length>0&&this.castsShadows&&r&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Fv(this._source.type)){const o=e.coveringZoomLevel({tileSize:t||this._source.tileSize,roundZoom:this._source.roundZoom&&!n}),a=Math.min(o,this._source.maxzoom),s=e.extendTileCoverForShadows(i,r,a);for(const e of s)this._shadowCasterTiles[e.key]=!0,i.push(e)}const o=this._updateRetainedTiles(i);if(Fv(this._source.type)&&0!==i.length){const e={},t={},n=Object.keys(o);for(const r of n){const n=o[r],i=this._tiles[r];if(!i||i.fadeEndTime&&i.fadeEndTime<=ft.now())continue;const a=this.findLoadedParent(n,Math.max(n.overscaledZ-zv.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),t[r]=n}const r=i[i.length-1].overscaledZ;for(const e in this._tiles){const n=this._tiles[e];if(o[e]||!n.hasData())continue;let i=n.tileID;for(;i.overscaledZ>r;){i=i.scaledTo(i.overscaledZ-1);const r=this._tiles[i.key];if(r&&r.hasData()&&t[i.key]){o[e]=n.tileID;break}}}for(const t in e)o[t]||(this._coveredTiles[t]=!0,o[t]=e[t])}for(const e in o)this._tiles[e].clearFadeHold();const a=function(e,t){const n=[];for(const r in e)r in t||n.push(r);return n}(this._tiles,o);for(const e of a){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-zv.maxOverzooming,this._source.minzoom),a=Math.max(i+zv.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!0!==t.isExtraShadowCaster||!!this._shadowCasterTiles[e.key]||this._reloadTile(e.key,"reloading"),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 Vy(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 Ct("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=yf(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(O(a,...jv(e,-1))-a),Math.abs(O(a,...jv(e,1))-a)];u=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(O(a,...jv(e,-1))-a),Math.abs(O(a,...jv(e,0))-a),Math.abs(O(a,...jv(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}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const n=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),r="globe"===this.transform.projection.name;for(const e of n)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=r?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return n}sortCoordinatesByDistance(e){const t=e.slice(),n=this.transform._camera.position,r=this.transform._camera.forward(),i={};for(const e of t){const t=1/(1<i[e.key]-i[t.key]),t}hasTransition(){if(this._source.hasTransition())return!0;if(Fv(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=ft.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)}D(Array.from(n.values()),(e,t)=>{const n=new Vy(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 Bv(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 Fv(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function jv(e,t){const n=1<=1e-15){const e=id.normalize([],n);id.scale(r,e,id.dot(r,e)),t[0]=r[0],t[1]=r[1]}const i=id.cross([],t,e);if(id.len(i)<1e-15)return null;const o=Math.atan2(-i[1],i[0]);return Xv(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),o)}class Kv{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(e){if(e){const t=e instanceof Cf?e:new Cf(e[0],e[1],e[2]);this._renderWorldCopies&&(t.x=R(t.x,0,1)),this._position=t}else this._position=null}lookAtPoint(e,t){if(this.orientation=null,!this.position)return;const n=this.position,r=this._elevation?this._elevation.getAtPointOrZero(Cf.fromLngLat(e)):0,i=Cf.fromLngLat(e,r),o=[i.x-n.x,i.y-n.y,i.z-n.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=Yv(o,t)}setPitchBearing(e,t){this.orientation=Xv(T(e),T(-t))}}class Jv{constructor(e,t){this._transform=Jh.identity([]),this.orientation=t,this.position=e}get mercatorPosition(){const e=this.position;return new Cf(e[0],e[1],e[2])}get position(){const e=oe(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var t;e&&ae(this._transform,3,[(t=e)[0],t[1],t[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||ed.identity([]),e&&$v(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=Xv(e,t),$v(this._transform,this._orientation)}forward(){const e=oe(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=oe(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=oe(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,t){const n=new Float64Array(16);return Jh.invert(n,this.getWorldToCamera(e,t)),n}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(e,t,n){const r=this.position;id.scale(r,r,-e);const i=new Float64Array(16);return Jh.fromScaling(i,[n,n,n]),Jh.translate(i,i,r),i[10]*=t,i}getWorldToCamera(e,t){const n=new Float64Array(16),r=new Float64Array(4),i=this.position;return ed.conjugate(r,this._orientation),id.scale(i,i,-e),Jh.fromQuat(n,r),Jh.translate(n,n,i),n[1]*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=t,n[9]*=t,n[10]*=t,n[11]*=t,n}getCameraToClipPerspective(e,t,n,r){const i=new Float64Array(16);return Jh.perspective(i,e,t,n,r),i}getCameraToClipOrthographic(e,t,n,r,i,o){const a=new Float64Array(16);return Jh.ortho(a,e,t,n,r,i,o),a}getDistanceToElevation(e,t=!1){const n=0===e?0:xf(e,t?wf(this.position[1]):this.position[1]),r=this.forward();return(n-this.position[2])/r[2]}clone(){return new Jv([...this.position],[...this.orientation])}}function Qv(e,t){const n=tx(e.projection,e.zoom,e.width,e.height),r=function(e,t,n,r,i){const o=new _f(n.lng-180*nx,n.lat),a=new _f(n.lng+180*nx,n.lat),s=e.project(o.lng,o.lat),l=e.project(a.lng,a.lat),u=-Math.atan2(l.y-s.y,l.x-s.x),c=Cf.fromLngLat(n);c.y=O(c.y,-1+nx,1-nx);const h=c.toLngLat(),d=e.project(h.lng,h.lat),f=Cf.fromLngLat(h);f.x+=nx;const p=f.toLngLat(),m=e.project(p.lng,p.lat),_=ix(m.x-d.x,m.y-d.y,u),g=Cf.fromLngLat(h);g.y+=nx;const y=g.toLngLat(),v=e.project(y.lng,y.lat),x=ix(v.x-d.x,v.y-d.y,u),b=Math.abs(_.x)/Math.abs(x.y),w=Jh.identity([]);Jh.rotateZ(w,w,-u*(1-(i?0:r)));const T=Jh.identity([]);return Jh.scale(T,T,[1,1-(1-b)*r,1]),T[4]=-x.x/x.y*r,Jh.rotateZ(T,T,u),Jh.multiply(T,w,T),T}(e.projection,0,e.center,n,t),i=ex(e);return Jh.scale(r,r,[i,i,1]),r}function ex(e){const t=e.projection,n=tx(e.projection,e.zoom,e.width,e.height),r=rx(t,e.center),i=rx(t,_f.convert(t.center));return Math.pow(2,r*n+(1-n)*i)}function tx(e,t,n,r,i=1/0){const o=e.range;if(!o)return 0;const a=Math.min(i,Math.max(n,r)),s=Math.log(a/1024)/Math.LN2;return P(o[0]+s,o[1]+s,t)}const nx=1/4e4;function rx(e,t){const n=O(t.lat,-Sf,Sf),r=new _f(t.lng-180*nx,n),i=new _f(t.lng+180*nx,n),o=e.project(r.lng,n),a=e.project(i.lng,n),s=Cf.fromLngLat(r),l=Cf.fromLngLat(i),u=a.x-o.x,c=a.y-o.y,h=l.x-s.x,d=l.y-s.y,f=Math.sqrt((h*h+d*d)/(u*u+c*c));return Math.log(f)/Math.LN2}function ix(e,t,n){const r=Math.cos(n),i=Math.sin(n);return{x:e*r-t*i,y:e*i+t*r}}function ox(e,t,n){return t*(hr/(e.tileSize*Math.pow(2,n-e.tileID.overscaledZ)))}const ax=0,sx=1,lx=2,ux=Math.tan(85*Math.PI/180);function cx(e,t,n,r,i,o,a){const s=Jh.create();if(n)if("globe"===o.name){const e=function(e,t){const{x:n,y:r}=e.point,i=Jd(n,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return Jh.multiply(i,i,Xd(zd(t)))}(i,t);Jh.multiply(s,s,e)}else{const e=Hh.invert([],a);s[0]=e[0],s[1]=e[1],s[4]=e[2],s[5]=e[3],r||Jh.rotateZ(s,s,i.angle)}else Jh.multiply(s,i.labelPlaneMatrix,e);return s}function hx(e,t,n,r,i,o,a){const s=cx(e,t,n,r,i,o,a);return"globe"===o.name&&n||(s[2]=s[6]=s[10]=s[14]=0),s}function dx(e,t,n,r,i,o,a){if(n){if("globe"===o.name){const s=cx(e,t,n,r,i,o,a);return Jh.invert(s,s),Jh.multiply(s,e,s),s}{const t=Jh.clone(e),n=Jh.identity([]);return n[0]=a[0],n[1]=a[1],n[4]=a[2],n[5]=a[3],Jh.multiply(t,t,n),r||Jh.rotateZ(t,t,-i.angle),t}}return i.glCoordMatrix}function fx(e,t,n,r){const i=[e,t,n,1];n?qh.transformMat4(i,i,r):Sx(i,i,r);const o=i[3];return i[0]/=o,i[1]/=o,i[2]/=o,i}function px(e,t){return Math.min(.5+e/t*.5,1.5)}function mx(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 _x(e,t,n,r,i,o,a,s,l,u){const c=n.transform,h=r?e.textSizeData:e.iconSizeData,d=P_(h,n.transform.zoom),f="globe"===c.projection.name,p=[256/n.width*2+1,256/n.height*2+1],m=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;m.clear();let _=null;f&&(_=r?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const g=e.lineVertexArray,y=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,x=n.transform.width/n.transform.height;let b,w=!1;for(let r=0;rMath.abs(n)?{useVertical:!0}:e===U_.vertical?r>0?{needsFlipping:!0}:null:t!==ax&&function(e,t){return 0===e||Math.abs(t/e)>ux}(n,r)?t===sx?{needsFlipping:!0}:null:n<0?{needsFlipping:!0}:null}function vx(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y){const x=t/24,b=e.lineOffsetX*x,w=e.lineOffsetY*x,{lineStartIndex:T,glyphStartIndex:S,numGlyphs:E,segment:M,writingMode:A,flipState:I}=e,C=T+e.lineLength,k=e=>{if(c){const[t,n,r]=e.up,i=u.length;vy(c,i+0,t,n,r),vy(c,i+1,t,n,r),vy(c,i+2,t,n,r),vy(c,i+3,t,n,r)}const[t,n,r]=e.point;xy(u,t,n,r,e.angle)};if(E>1){const t=gx(x,s,b,w,n,h,d,e,l,o,f,m,!1,_,g,y);if(!t)return{notEnoughRoom:!0};if(r&&!n){let[n,r,i]=t.first.point,[o,s,l]=t.last.point;[n,r]=fx(n,r,i,a),[o,s]=fx(o,s,l,a);const u=yx(A,I,(o-n)*p,s-r);if(e.flipState=u&&u.needsFlipping?sx:lx,u)return u}k(t.first);for(let e=S+1;e0?o:bx(d,r,t,1,i,void 0,_,g.canonical),s=yx(A,I,(a[0]-t[0])*p,a[1]-t[1]);if(e.flipState=s&&s.needsFlipping?sx:lx,s)return s}const t=wx(x*s.getoffsetX(S),b,w,n,h,d,M,T,C,l,o,f,m,!1,!1,_,g,y);if(!t)return{notEnoughRoom:!0};k(t)}return{}}function xx(e,t,n,r,i){const{x:o,y:a,z:s}=r.projectTilePoint(e.x,e.y,t);if(!i)return fx(o,a,s,n);const[l,u,c]=i(e);return fx(o+l,a+u,s+c,n)}function bx(e,t,n,r,i,o,a,s){const l=xx(e.sub(t)._unit()._add(e),s,i,a,o);return id.sub(l,n,l),id.normalize(l,l),id.scaleAndAdd(l,n,l,r)}function wx(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g){const y=r?e-t:e+t;let x=y>0?1:-1,b=0;r&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=s+a+(x>0?0:1)|0,T=i,S=i,E=0,M=0;const A=Math.abs(y),I=[],C=[];let k=o,O=k;const P=()=>bx(O,k,S,A-E+1,c,d,m,_.canonical);for(;E+M<=A;){if(w+=x,w=l)return null;if(S=T,O=k,I.push(S),f&&C.push(O),k=new v(u.getx(w),u.gety(w)),T=h[w],!T){const e=xx(k,_.canonical,c,m,d);T=e[3]>0?h[w]=e:P()}E+=M,M=id.distance(S,T)}p&&d&&(h[w]&&(T=P(),M=id.distance(S,T)),h[w]=T);const R=(A-E)/M,D=k.sub(O)._mult(R)._add(O),L=id.sub([],T,S),z=id.scaleAndAdd([],S,L,R);let B=[0,0,1],F=L[0],j=L[1];if(g&&(B=m.upVector(_.canonical,D.x,D.y),0!==B[0]||0!==B[1]||1!==B[2])){const e=[B[2],0,-B[0]],t=id.cross([],B,e);id.normalize(e,e),id.normalize(t,t),F=id.dot(L,e),j=id.dot(L,t)}if(n){const e=id.cross([],B,L);id.normalize(e,e),id.scaleAndAdd(z,z,e,n*x)}const N=b+Math.atan2(j,F);return I.push(z),f&&C.push(D),{point:z,angle:N,path:I,tilePath:C,up:B}}function Tx(e,t){const n=t.length,r=n+4*e;t.resize(r),t.float32.fill(-1/0,4*n,4*r)}function Sx(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 Ex=(e,t,n)=>(1-n)*e+n*t,Mx=e=>e*e*e*e*e;class Ax{constructor(e,t,n,r,i,o,a){this.tileSize=512,this._renderWorldCopies=void 0===i||i,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=null==n?0:n,this._maxPitch=null==r?60:r,this.setProjection(o),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new _f(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 Hv,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Jv,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1}clone(){const e=new Ax(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._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,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 isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}get depthOcclusionForSymbolsAndCircles(){return"globe"!==this.projection.name&&!this.isOrthographic}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 B(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=uy(this.projectionOptions);const n=!x(t,this.getProjection());return n&&this._calcMatrices(),this.mercatorFromTransition=!1,n}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=uy({name:"mercator"});const t=e!==this.projection.name;return t&&this._calcMatrices(),t}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 xf(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new v(this.width,this.height)}get bearing(){return R(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;this.angle!==t&&(this._unmodified=!1,this.angle=t,this._calcMatrices(),this.rotationMatrix=Hh.create(),Hh.rotate(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=O(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,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(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=T(e),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(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const n=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&n.exaggeration()&&this._centerAltitudeValidForExaggeration!==n.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*n.exaggeration(),this._centerAltitudeValidForExaggeration=n.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=n.exaggeration()),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,t=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],n=this.horizonLineFromTop();let r=0,i=0;for(let o=0;o0,u=e.y+10,h=n.wrap-(l?0:1),d=n.wrap+(s?0:1),f=l?e.x-1:a-1,p=s?e.x+1:0;t[0]<0?(r.push(new _d(i,d,e.z,p,e.y)),t[1]<0&&u&&(r.push(new _d(i,o,e.z,e.x,e.y+1)),r.push(new _d(i,d,e.z,p,e.y+1))),t[1]>0&&c&&(r.push(new _d(i,o,e.z,e.x,e.y-1)),r.push(new _d(i,d,e.z,p,e.y-1)))):t[0]>0?(r.push(new _d(i,h,e.z,f,e.y)),t[1]<0&&u&&(r.push(new _d(i,o,e.z,e.x,e.y+1)),r.push(new _d(i,h,e.z,f,e.y+1))),t[1]>0&&c&&(r.push(new _d(i,o,e.z,e.x,e.y-1)),r.push(new _d(i,h,e.z,f,e.y-1)))):t[1]<0&&u?r.push(new _d(i,o,e.z,e.x,e.y+1)):c&&r.push(new _d(i,o,e.z,e.x,e.y-1))}if(r.length>1){r.sort((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y);let e=0,t=0;for(;te.isChildOf(t))||i.push(e);return r=i.filter(t=>!e.some(e=>!!(t.overscaledZe.maxzoom&&(t=e.maxzoom);const a=this.locationCoordinate(this.center),s=this.center.lat,l=1<{const t=1/4e4,n=new Cf(e.x+t,e.y,e.z),r=new Cf(e.x,e.y+t,e.z),i=e.toLngLat(),o=n.toLngLat(),a=r.toLngLat(),s=this.locationCoordinate(i),l=this.locationCoordinate(o),u=this.locationCoordinate(a),c=Math.hypot(l.x-s.x,l.y-s.y),h=Math.hypot(u.x-s.x,u.y-s.y);return Math.sqrt(c*h)*w/t},S=e=>{const t=x,n=b;return{aabb:Ng(this,l,0,0,0,e,n,t,this.projection),zoom:0,x:0,y:0,minZ:n,maxZ:t,wrap:e,fullyVisible:!1}},M=[];let A=[];const I=t,C=e.reparseOverscaled?n:t,k=e=>e*e,O=k((m-this._centerAltitude)*p),P=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=R(e),e.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},R=e=>{if(e.zoom=.9)return!0}else if(i&&(o=k(e.aabb.distanceZ(_)*p)),this.projection.isReprojectedInTileSpace&&n<=5){const t=Math.pow(2,e.zoom),n=T(new Cf((e.x+.5)/t,(e.y+.5)/t));a=n>.85?1:n}const l=t*t+r*r+o;return l{if(t*k(.707)0;){const n=M.pop(),r=n.x,a=n.y;let s=n.fullyVisible;const h=()=>"globe"===this.projection.name&&(0===n.y||n.y===(1<>1),h={aabb:o?n.aabb.quadrant(e):Ng(this,l,n.zoom+1,t,u,n.wrap,n.minZ,n.maxZ,this.projection),zoom:n.zoom+1,x:t,y:u,wrap:n.wrap,fullyVisible:s,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};i&&!c&&(h.tileID=new _d(n.zoom+1===I?C:n.zoom+1,n.wrap,n.zoom+1,t,u),P(h)),M.push(h)}else{const i=n.zoom===I?C:n.zoom;if(e.minzoom&&e.minzoom>i)continue;if(!s){let e=g?n.aabb.intersectsPrecise(d):n.aabb.intersectsPreciseFlat(d);if(0===e&&h()){const t=new pd(n.zoom,r,a);e=Nd(this,l,t,!0).intersectsPrecise(d)}if(0===e)continue}const o=u[0]-(.5+r+(n.wrap<{const i=[0,0,0,1],o=[hr,hr,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());qh.transformMat4(i,i,a),qh.transformMat4(o,o,a);const s=function(e,t,n){let r=0;for(let n=0;n<2;++n){const i=0;e[n]>i&&(r+=(e[n]-i)*(e[n]-i)),t[n]t&&0!==n){const t=this.calculateProjMatrix(r.tileID.toUnwrapped());let i;e.isTerrainDEM||(i=u.getMinMaxForTile(r.tileID)),i||(i={min:b,max:x});const o=function(e){const t=Math.round((e+45+360)%360/90)%4;return E[t]}(this.rotation),a=[o[0]*hr,o[1]*hr,i.max];id.transformMat4(a,a,t),l=(1-a[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(e){const t=O(e.lat,-Sf,Sf),n=this.projection.project(e.lng,t);return new v(n.x*this.worldSize,n.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/xf(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,t){let n,r;const i=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;n=(t.x-i.x)/e,r=(t.y-i.y)/e}else{const e=this.pointCoordinate(t),o=this.pointCoordinate(i);n=e.x-o.x,r=e.y-o.y}const o=this.locationCoordinate(e);this.setLocation(new Cf(o.x-n,o.y-r))}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(e,t){const n=t?xf(t,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new Cf(r.x,r.y,n)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const n=null!=t?t:this._centerAltitude,r=[e.x,e.y,0,1],i=[e.x,e.y,1,1];qh.transformMat4(r,r,this.pixelMatrixInverse),qh.transformMat4(i,i,this.pixelMatrixInverse);const o=i[3];qh.scale(r,r,1/r[3]),qh.scale(i,i,1/o);const a=r[2],s=i[2];return{p0:r,p1:i,t:a===s?0:(n-a)/(s-a)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],n=[e.x,e.y,1,1];return qh.transformMat4(t,t,this.pixelMatrixInverse),qh.transformMat4(n,n,this.pixelMatrixInverse),qh.scale(t,t,1/t[3]),qh.scale(n,n,1/n[3]),t[2]=xf(t[2],this._center.lat)*this.worldSize,n[2]=xf(n[2],this._center.lat)*this.worldSize,qh.scale(t,t,1/this.worldSize),qh.scale(n,n,1/this.worldSize),new vd([t[0],t[1],t[2]],id.normalize([],id.sub([],n,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:n,t:r}=e,i=xf(t[2],this._center.lat),o=xf(n[2],this._center.lat);return new Cf(Yr(t[0],n[0],r)/this.worldSize,Yr(t[1],n[1],r)/this.worldSize,Yr(i,o,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let t=this.projection.pointCoordinate3D(this,e.x,e.y);if(t)return new Cf(t[0],t[1],t[2]);let n=0,r=this.horizonLineFromTop();if(e.y>r)return this.pointCoordinate(e);const i=.02*r,o=e.clone();for(let e=0;e<10&&r-n>i;e++){o.y=Yr(n,r,.66);const e=this.projection.pointCoordinate3D(this,o.x,o.y);e?(r=o.y,t=e):n=o.y}return t?new Cf(t[0],t[1],t[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return!1;if(this.elevation||this.zoom>=6)return!this.isPointAboveHorizon(e);const t=this.pointCoordinate(e);return t.y>=0&&t.y<=1}_coordinatePoint(e,t){const n=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,r=[e.x*this.worldSize,e.y*this.worldSize,n+e.toAltitude(),1];return qh.transformMat4(r,r,this.pixelMatrix),r[3]>0?new v(r[0]/r[3],r[1]/r[3]):new v(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:t}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,i=this.pointLocation3D(new v(t,e)),o=this.pointLocation3D(new v(r,e)),a=this.pointLocation3D(new v(r,n)),s=this.pointLocation3D(new v(t,n));let l=Math.min(i.lng,o.lng,a.lng,s.lng),u=Math.max(i.lng,o.lng,a.lng,s.lng),c=Math.min(i.lat,o.lat,a.lat,s.lat),h=Math.max(i.lat,o.lat,a.lat,s.lat);const d=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,p=(e,t,n,r,i)=>{const o=(e+n)/2,a=(t+r)/2,s=new v(o,a),{lng:m,lat:_}=this.pointLocation3D(s),g=Math.max(0,l-m,c-_,m-u,_-h);l=Math.min(l,m),u=Math.max(u,m),c=Math.min(c,_),h=Math.max(h,_),(id)&&(p(e,t,o,a,i+1),p(o,a,n,r,i+1))};if(p(t,e,r,e,1),p(r,e,r,n,1),p(r,n,t,n,1),p(t,n,t,e,1),"globe"===this.projection.name){const[e,t]=function(e){const t=Jh.identity(new Float64Array(16));Jh.multiply(t,e.pixelMatrix,e.globeMatrix);const n=[0,Cd,0],r=[0,kd,0];return id.transformMat4(n,n,t),id.transformMat4(r,r,t),[n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!lf(e,new _f(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!lf(e,new _f(e.center.lat,-90))]}(this);e?(h=90,u=180,l=-180):t&&(c=-90,u=180,l=-180)}return new ju(new _f(l,c),new _f(u,h))}_getBoundsRectangular(e,t){const{top:n,left:r}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,a=new v(r,n),s=new v(o,n),l=new v(o,i),u=new v(r,i);let c=this.pointCoordinate(a,e),h=this.pointCoordinate(s,e);const d=this.pointCoordinate(l,t),f=this.pointCoordinate(u,t),p=(e,t)=>(t.y-e.y)/(t.x-e.x);return c.y>1&&h.y>=0?c=new Cf((1-f.y)/p(f,c)+f.x,1):c.y<0&&h.y<=1&&(c=new Cf(-f.y/p(f,c)+f.x,0)),h.y>1&&c.y>=0?h=new Cf((1-d.y)/p(d,h)+d.x,1):h.y<0&&c.y<=1&&(h=new Cf(-d.y/p(d,h)+d.x,0)),(new ju).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(d))}_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(e){this.maxBounds=e,this.minLat=-Sf,this.maxLat=Sf,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLngc&&(a=c-l),c-ut&&(o=t-s),t-e{for(let i=0;i<16;i++)e[i]=Ex(t[i],n[i],r)})(a,a,s,Mx(this.pitch>=15?1:this.pitch/15))}else a=s;const l=Jh.mul([],s,o);let u=Jh.mul([],a,o);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),t=Jh.identity([]);Jh.translate(t,t,[e.x*this.worldSize,e.y*this.worldSize,0]),Jh.multiply(t,t,Qv(this)),Jh.translate(t,t,[-e.x*this.worldSize,-e.y*this.worldSize,0]),Jh.multiply(u,u,t),Jh.multiply(l,l,t),this.inverseAdjustmentMatrix=function(e){const t=Qv(e,!0);return Hh.invert([],[t[0],t[1],t[4],t[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=Jh.scale([],u,[this.worldSize,this.worldSize,this.worldSize/i,1]),this.projMatrix=u,this.invProjMatrix=Jh.invert(new Float64Array(16),this.projMatrix),t){const t=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);t[8]=2*-e.x/this.width,t[9]=2*e.y/this.height,this.expandedFarZProjMatrix=Jh.mul([],t,o)}else this.expandedFarZProjMatrix=this.projMatrix;const c=Jh.invert([],a);this.frustumCorners=xd.fromInvProjectionMatrix(c,this.horizonLineFromTop(),this.height),this.cameraFrustum=Ed.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!t);const h=new Float32Array(16);Jh.identity(h),Jh.scale(h,h,[1,-1,1]),Jh.rotateX(h,h,this._pitch),Jh.rotateZ(h,h,this.angle);const d=Jh.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=Jh.clone(d);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;d[8]=2*-e.x/this.width,d[9]=2*(e.y+f)/this.height,this.skyboxMatrix=Jh.multiply(h,d,h);const p=this.point,m=p.x,_=p.y,g=this.width%2/2,y=this.height%2/2,v=Math.cos(this.angle),x=Math.sin(this.angle),b=m-Math.round(m)+v*g+x*y,w=_-Math.round(_)+v*y+x*g,T=new Float64Array(u);if(Jh.translate(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=T,u=Jh.create(),Jh.scale(u,u,[this.width/2,-this.height/2,1]),Jh.translate(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=Jh.create(),Jh.scale(u,u,[1,-1,1]),Jh.translate(u,u,[-1,-1,0]),Jh.scale(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=Jh.multiply(new Float64Array(16),this.labelPlaneMatrix,l),this._calcFogMatrices(),this._distanceTileDataCache={},u=Jh.invert(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=function(e){const{x:t,y:n}=e.point,{lng:r,lat:i}=e._center;return Jd(t,n,e.worldSize,r,i)}(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=id.transformMat4(e,e,o),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,t=this.cameraPixelsPerMeter,n=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,i=[e,e,t];id.scale(i,i,r),id.scale(n,n,-1),id.multiply(n,n,i);const o=Jh.create();Jh.translate(o,o,n),Jh.scale(o,o,i),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,r)}_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(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=this._camera.position[2],r=e[2];let i=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(i=Math.min((t-n)/r,1)),this._camera.position=id.scaleAndAdd([],this._camera.position,e,i),this._updateStateFromCamera()}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:n,bearing:r}=this._camera.getPitchBearing(),i=xf(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(T(this._maxPitch)),a=Math.max((e[2]-i)/Math.cos(n),o),s=this._zoomFromMercatorZ(a);id.scaleAndAdd(e,e,t,a),this._pitch=O(n,T(this.minPitch),T(this.maxPitch)),this.angle=R(r,-Math.PI,Math.PI),this._setZoom(O(s,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new Cf(e[0],e[1],e[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(e){let t=0,n=6,r=0,i=1/0;for(;n-t>1e-6&&n>t;){const o=t+.5*(n-t),a=this.tileSize*Math.pow(2,o),s=this.getCameraToCenterDistance(this.projection,o,a),l=this.scaleZoom(s/(e*this.tileSize)),u=Math.abs(o-l);ul||n.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+S(this.fovAboveCenter)>88||this.anyCornerOffEdge(new v(0,0),new v(this.width,this.height))}zoomDeltaToMovement(e,t){const n=id.length(id.sub([],this._camera.position,e)),r=this._zoomFromMercatorZ(n)+t;return n-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function([e,t,n],r){const i=[e,t,n,1];qh.transformMat4(i,i,r);const o=i[3]=Math.max(i[3],1e-6);return i[0]/=o,i[1]/=o,i[2]/=o,i}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new v(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new v(0,e))}}getCameraToCenterDistance(e,t=this.zoom,n=this.worldSize){const r=tx(e,t,this.width,this.height,1024),i=e.pixelSpaceConversion(this.center.lat,n,r);let o=.5/Math.tan(.5*this._fov)*this.height*i;return this.isOrthographic&&(o=Ex(1,o,Mx(this.pitch>=15?1:this.pitch/15))),o}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&Jh.multiply(e,e,this.globeMatrix),e}getFrustum(e){return Ed.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,"meters"===this.projection.zAxisUnit)}}function Ix(e,t,n){Jh.identity(e),Jh.rotateZ(e,e,T(t[2])),Jh.rotateX(e,e,T(t[0])),Jh.rotateY(e,e,T(t[1])),Jh.scale(e,e,n),Jh.multiply(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function Cx(e,t,n,r,i,o,a,s){const l=[n[0]-t[0],n[1]-t[1],0],u=[r[0]-t[0],r[1]-t[1],0];if(id.length(l)<1e-12||id.length(u)<1e-12)return ed.identity(e);const c=id.cross([],l,u);id.normalize(c,c),id.subtract(u,r,t),l[2]=(o-i)*s,u[2]=(a-i)*s;const h=l;return id.cross(h,l,u),id.normalize(h,h),ed.rotationTo(e,c,h)}function kx(e,t,n=!1){const r=ef(t.zoom),i=function(e,t,n){const r=t.worldSize,i=[e[12],e[13],e[14]],o=wf(i[1]/r),a=bf(i[0]/r),s=Jh.identity([]),l=xf(1,o)*r,u=xf(1,0)*r*Mf(o,t.zoom),c=1/Yd(r);let h=u*c;if(n){const e=tx(t.projection,t.zoom,t.width,t.height,1024);h=c*t.projection.pixelSpaceConversion(t.center.lat,r,e)}const d=qd(o,a);id.add(d,d,id.scale([],id.normalize([],d),l*h*i[2]));const f=function(e){const t=[e[0],e[1],e[2]];let n=[0,1,0];const r=id.cross([],n,t);return id.cross(n,t,r),0===id.squaredLength(n)&&(n=[0,1,0],id.cross(r,t,n)),id.normalize(r,r),id.normalize(n,n),id.normalize(t,t),[r[0],r[1],r[2],0,n[0],n[1],n[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(d);Jh.scale(s,s,[h,h,h*l]),Jh.translate(s,s,[-i[0],-i[1],-i[2]]);const p=Jh.multiply([],t.globeMatrix,f);return Jh.multiply(p,p,s),Jh.multiply(p,p,e),p}(e,t,n);return r>0?function(e,t,n){const r=(e,t,n)=>{const r=id.length(e),i=id.length(t),o=Bd(e,t,n);return id.scale(o,o,1/id.length(o)*Yr(r,i,n))},i=r([e[0],e[1],e[2]],[t[0],t[1],t[2]],n),o=r([e[4],e[5],e[6]],[t[4],t[5],t[6]],n),a=r([e[8],e[9],e[10]],[t[8],t[9],t[10]],n),s=Bd([e[12],e[13],e[14]],[t[12],t[13],t[14]],n);return[i[0],i[1],i[2],0,o[0],o[1],o[2],0,a[0],a[1],a[2],0,s[0],s[1],s[2],1]}(i,function(e,t){const n=t.worldSize,r=xf(1,0)*n*Mf(t.center.lat,t.zoom)/Yd(n),i=xf(1,t.center.lat)*n,o=Jh.identity([]);return Jh.rotateY(o,o,T(t.center.lng)),Jh.rotateX(o,o,T(t.center.lat)),Jh.translate(o,o,[0,0,Ad]),Jh.scale(o,o,[r,r,r*i]),Jh.translate(o,o,[t.point.x-.5*n,t.point.y-.5*n,0]),Jh.multiply(o,o,e),Jh.multiply(o,t.globeMatrix,o)}(e,t),r):i}const Ox=[1,1,1];class Px{constructor(e,t,n,r){this.id=e,this.position=null!=t?new _f(t[0],t[1]):new _f(0,0),this.orientation=null!=n?n:[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new Md([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[]}_applyTransformations(e,t){if(Jh.multiply(e.matrix,t,e.matrix),e.meshes)for(const t of e.meshes){const n=Md.applyTransform(t.aabb,e.matrix);this.aabb.encapsulate(n)}if(e.children)for(const t of e.children)this._applyTransformations(t,e.matrix)}computeBoundsAndApplyParent(){const e=Jh.identity([]);for(const t of this.nodes)this._applyTransformations(t,e)}_positionModelOnTerrain(e,t){const n=e.elevation;if(!n)return 0;const r=Md.projectAabbCorners(this.aabb,this.matrix),i=xf(1,this.position.lat)*e.worldSize,o=function(e,t){const n=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const i of r){const r=e[i.corners[0]],o=e[i.corners[1]],a=e[i.corners[2]],s=[o[0]-r[0],o[1]-r[1],t*(o[2]-r[2])],l=id.cross(s,s,[a[0]-r[0],a[1]-r[1],t*(a[2]-r[2])]);id.normalize(l,l),i.dotProductWithUp=id.dot(l,n)}return r.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),r[0].corners}(r,i),a=r[o[0]],s=r[o[1]],l=r[o[2]],u=r[o[3]],c=n.getAtPointOrZero(new Cf(a[0]/e.worldSize,a[1]/e.worldSize),0),h=n.getAtPointOrZero(new Cf(s[0]/e.worldSize,s[1]/e.worldSize),0),d=n.getAtPointOrZero(new Cf(l[0]/e.worldSize,l[1]/e.worldSize),0),f=n.getAtPointOrZero(new Cf(u[0]/e.worldSize,u[1]/e.worldSize),0),p=(c+f)/2,m=(h+d)/2;return p>m?h=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function Dx(e,t,n){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Nv.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,qv.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Gv.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Uv:Vv).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,Zv.members,!0)),e.segments=Ql.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&Rx(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&Rx(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&Rx(r.normalTexture,t),r.occlusionTexture&&Rx(r.occlusionTexture,t,n),r.emissionTexture&&Rx(r.emissionTexture,t)}function Lx(e,t,n){if(e.meshes)for(const r of e.meshes)Dx(r,t,n);if(e.children)for(const r of e.children)Lx(r,t,n)}function zx(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)zx(t)}function Bx(e){if(e.meshes)for(const n of e.meshes)n.vertexBuffer&&(n.vertexBuffer.destroy(),n.indexBuffer.destroy(),n.normalBuffer&&n.normalBuffer.destroy(),n.texcoordBuffer&&n.texcoordBuffer.destroy(),n.colorBuffer&&n.colorBuffer.destroy(),n.pbrBuffer&&n.pbrBuffer.destroy(),n.segments.destroy(),n.material&&((t=n.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));var t;if(e.children)for(const t of e.children)Bx(t)}class Fx{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0]}}class jx{constructor(){this.instancedDataArray=new Bl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={}}}class Nx{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0}}populate(e,t,n,r){this.tileToMeter=If(n);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:a,index:s,sourceLayerIndex:l}of e){const e=Ff(o,i);if(!this.layers[0]._featureFilter.filter(new Ns(this.zoom),e,n))continue;const u={id:a,sourceLayerIndex:l,index:s,geometry:i?e.geometry:Bf(o,n,r),properties:o.properties,type:o.type,patterns:{}},c=this.addFeature(u,u.geometry,e);c&&t.featureIndex.insert(o,u.geometry,s,l,this.index,this.instancesPerModel[c].instancedDataArray.length)}this.lookup=null}update(e,t,n,r){for(const t in this.instancesPerModel){const n=this.instancesPerModel[t];for(const t in e)n.idToFeaturesIndex.hasOwnProperty(t)&&this.evaluate(n.features[n.idToFeaturesIndex[t]],e[t],n,!0)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let e=!1;for(const t in this.instancesPerModel){const n=this.instancesPerModel[t];for(const t of n.features){const r=this.layers[0],i=t.feature,o=this.canonical,a=r.paint.get("model-rotation").evaluate(i,{},o),s=r.paint.get("model-scale").evaluate(i,{},o),l=r.paint.get("model-translation").evaluate(i,{},o);id.exactEquals(t.rotation,a)&&id.exactEquals(t.scale,s)&&id.exactEquals(t.translation,l)||(this.evaluate(t,t.featureStates,n,!0),e=!0)}}return e}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return!1;return!0}uploadPending(){return!this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const n=this.instancesPerModel[t];n.instancedDataArray.length<0||0===n.instancedDataArray.length||(n.instancedDataBuffer?n.instancedDataBuffer.updateData(n.instancedDataArray):n.instancedDataBuffer=e.createVertexBuffer(n.instancedDataArray,Wv.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}}addFeature(e,t,n){const r=this.layers[0],i=r.layout.get("model-id").evaluate(n,{},this.canonical);if(!i)return X(`modelId is not evaluated for layer ${r.id} and it is not going to get rendered.`),i;this.instancesPerModel[i]||(this.instancesPerModel[i]=new jx);const o=this.instancesPerModel[i],a=o.instancedDataArray,s=new Fx(n,a.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=hr||t.y<0||t.y>=hr)continue;const e=(this.lookupDim-1)/hr,n=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[n])continue;this.lookup[n]=1}this.instanceCount++;const r=a.length;a.resize(r+1),o.instancesEvaluatedElevation.push(0),a.float32[16*r]=t.x,a.float32[16*r+1]=t.y}return s.instancedDataCount=o.instancedDataArray.length-s.instancedDataOffset,s.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(s),this.evaluate(s,{},o,!1)),i}evaluate(e,t,n,r){const i=this.layers[0],o=e.feature,a=this.canonical,s=e.rotation=i.paint.get("model-rotation").evaluate(o,t,a),l=e.scale=i.paint.get("model-scale").evaluate(o,t,a),u=e.translation=i.paint.get("model-translation").evaluate(o,t,a),c=i.paint.get("model-color").evaluate(o,t,a);c.a=i.paint.get("model-color-mix-intensity").evaluate(o,t,a);const h=[];this.maxVerticalOffset10?this.tileToMeter:If(a,f)),s[o+4]=u[0],s[o+5]=u[1],s[o+6]=u[2]+l,s[o+7]=h[0],s[o+8]=h[1],s[o+9]=h[2],s[o+10]=h[4],s[o+11]=h[5],s[o+12]=h[6],s[o+13]=h[8],s[o+14]=h[9],s[o+15]=h[10],n.instancesEvaluatedElevation[i]=u[2]}}}xa(Nx,"ModelBucket",{omit:["layers"]}),xa(jx,"PerModelAttributes"),xa(Fx,"ModelFeature");const Ux=new Js({visibility:new Xs(Pt.layout_model.visibility),"model-id":new Ys(Pt.layout_model["model-id"])});var Vx={paint:new Js({"model-opacity":new Xs(Pt.paint_model["model-opacity"]),"model-rotation":new Ys(Pt.paint_model["model-rotation"]),"model-scale":new Ys(Pt.paint_model["model-scale"]),"model-translation":new Ys(Pt.paint_model["model-translation"]),"model-color":new Ys(Pt.paint_model["model-color"]),"model-color-mix-intensity":new Ys(Pt.paint_model["model-color-mix-intensity"]),"model-type":new Xs(Pt.paint_model["model-type"]),"model-cast-shadows":new Xs(Pt.paint_model["model-cast-shadows"]),"model-receive-shadows":new Xs(Pt.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new Xs(Pt.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new Ys(Pt.paint_model["model-emissive-strength"]),"model-roughness":new Ys(Pt.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new Ys(Pt.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new Xs(Pt.paint_model["model-cutoff-fade-range"])}),layout:Ux};const Gx=new Float32Array(262144),qx=new Uint8Array(262144);function Wx(e){let t=0;if(e.meshes)for(const n of e.meshes)t=Math.max(t,n.aabb.max[2]);if(e.children)for(const n of e.children)t=Math.max(t,Wx(n));return t}const Zx=["","wall","door","roof","window","lamp","logo"];class Hx{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:e.id,geometry:[],properties:{height:Wx(e)}}}}class $x{constructor(e,t,n,r){this.nodes=e,this.id=t,this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=4),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1}update(){console.log("Update 3D model bucket")}populate(){console.log("populate 3D model bucket")}uploadPending(){return!this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const n of t){const t=n.node;this.uploaded?this.updatePbrBuffer(t):Lx(t,e,!0)}for(const e of t)zx(e.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const n of e.meshes)n.pbrBuffer&&(n.pbrBuffer.updateData(n.featureArray),t=!0);return t}needsReEvaluation(e,t,n){const r=e.transform.projectionOptions,i=e.style.getBrightness(),o=this.brightness!==i;return!!(!this.uploaded||this.dirty||r.name!==this.projection.name||Xx(n.paint.get("model-color").value,o)||Xx(n.paint.get("model-color-mix-intensity").value,o)||Xx(n.paint.get("model-roughness").value,o)||Xx(n.paint.get("model-emissive-strength").value,o)||Xx(n.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=r,this.brightness=i,!0)}evaluateScale(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const n=this.getNodesInfo(),r=this.id.canonical;for(const e of n){const n=e.feature;e.evaluatedScale=t.paint.get("model-scale").evaluate(n,{},r)}}evaluate(e){const t=this.getNodesInfo();for(const n of t){if(!n.node.meshes)continue;const t=n.feature,r=n.node.meshes&&n.node.meshes[0].featureData,i=n.evaluatedColor[2],o=n.evaluatedRMEA[2],a=this.id.canonical;if(n.hasTranslucentParts=!1,r){for(let r=0;r=e)continue;const h=Gx[u],d=Math.abs(h);d>s&&(a=h,s=d,l=i,c=t)}if(s>.1){const o=1-(e+.5*Math.abs(l*c))/u;let s=t._dem.get(r,n)+a*o;const h=t._dem.get(r+l,n+c),d=t._dem.get(r-l,n-c,!0);(s-h)*(s-d)>0&&(s=(h+d)/2),Gx[i]=t._dem.set(r,n,s),qx[i]=e}}}}}a&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=ft.now())}getNodesInfo(){if(!this.nodesInfo){this.nodesInfo=[];for(const e of this.nodes)this.nodesInfo.push(new Hx(e));this.freeNodes()}return this.nodesInfo}freeNodes(){if(this.nodes){for(const e of this.nodes)Bx(e);this.nodes.splice(0,this.nodes.length)}}destroy(){this.freeNodes();const e=this.getNodesInfo();for(const t of e)zx(t.node),Bx(t.node)}isEmpty(){return!this.nodes.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped()),r=this.getNodesInfo();for(let e=0;ee.footprint===t.footprint)}}getHeightAtTileCoord(e,t){const n=this.getNodesInfo(),r=[];for(let i=0;ia.aabb.max[0]||t>a.aabb.max[1])continue;const s=(e-a.aabb.min[0])/(a.aabb.max[0]-a.aabb.min[0])*64|0,l=64*Math.min(63,(t-a.aabb.min[1])/(a.aabb.max[1]-a.aabb.min[1])*64|0)+Math.min(63,s);if(!(a.heightmap[l]<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return{height:a.heightmap[l],maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new v(e,t),new v(e,t),r),r.length>0)return{height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function Xx(e,t){return!e.isLightConstant&&t}function Yx(e,t,n,r,i,o,a,s){let l=(61440&t|(61440&t)>>4)>>8,u=(3840&t|(3840&t)>>4)>>4,c=240&t|(240&t)>>4;n[3]>0&&(l=Yr(l,255*n[0],n[3]),u=Yr(u,255*n[1],n[3]),c=Yr(c,255*n[2],n[3]));const h=l<<8|u,d=c<<8|Math.floor(255*r[3]),f=function(e){const t=O(e,0,2);return Math.min(Math.round(.5*t*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],p=O(i[0],0,1),m=O(i[1],0,1),_=O(i[2],0,1),g=O(i[3],0,1);let y,v,x,b;if(p!==m&&a!==o&&m!==p){const e=a-o;v=1/(e*(m-p)),x=-(o+e*p)/(e*(m-p));const t=O(i[4],-1,1);b=Math.pow(10,t),y=255*_<<8|255*g}else y=65535,v=0,x=1,b=1;if(e.emplaceBack(h,d,f,y,v,x,b),s){const e=s.length;s.clear();for(let t=0;t>16&65535,u=e.evaluatedRMEA[s],c=e.evaluatedColor[s],h=e.emissionHeightBasedParams[s];if(o&&2===s&&n.lights&&(r=new Fl,r.resize(10*n.lights.length)),Yx(i.featureArray,l,c,u,h,i.aabb.min[2],i.aabb.max[2],r),r&&o){o=!1;const e=n.meshes[n.lightMeshIndex];e.featureArray=r,e.featureArray._trim()}}i.featureArray._trim(),r++}}xa($x,"Tiled3dModelBucket",{omit:["layers"]}),xa(Hx,"Tiled3dModelFeature");class Jx{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[]}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e){const t=nb(new v(0,0),new v(hr,hr),e),n=[];for(const r of this._activeRegions){if(r.hiddenByOverlap)continue;if(!tb(t,r))continue;const i=rb(r.min,r.max,e);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[r.priority],footprint:r.footprint,footprintTileId:r.tileId})}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const n of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(n).buckets[e.layer];if(r)for(const e of r.getNodesInfo()){const r=e.node;r.footprint&&t.push({footprint:r.footprint,id:n.toUnwrapped()})}}return t}})))}_addSource(e){const t=e.getFootprints();if(0!==t.length){for(const e of t){if(!e.footprint)continue;const t=nb(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint})}this._sourceIds.push(e.getSourceId())}}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Qx(e.min,t.min)||Qx(e.max,t.max));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0,n=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],i=this._prevRegions[n];e=r.priority!==i.priority||!eb(r,i),++t,++n}}if(e){++this._updateTime;const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const n=t[e].priority;for(;e1){let t=0,n=e(t);for(;t!==n;){let r=t;const i=t;for(;r!==n;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement()}}function Qx(e,t){return e.x-t.x||e.y-t.y}function eb(e,t){return 0===Qx(e.min,t.min)&&0===Qx(e.max,t.max)}function tb(e,t){return!(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew v(e.x*o.x*hr*s-a.x*hr,e.y*o.y*hr*s-a.y*hr))}return ib(n,i,e.indices,0,e.indices.length,0,0)}const ab=km.types,sb=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius"],lb=["fill-extrusion-flood-light-ground-radius"],ub=Math.pow(2,13),cb=Math.pow(2,15)-1,hb=new v(0,1),db=2147483648;function fb(e,t,n,r,i,o,a,s){e.emplaceBack((t<<1)+a,(n<<1)+o,(Math.floor(r*ub)<<1)+i,Math.round(s))}function pb(e,t,n,r,i,o){e.emplaceBack(t.x,t.y,(n.x<<1)+r,(n.y<<1)+i,o)}function mb(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class _b{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class gb{constructor(){this.centroidXY=new v(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new v(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new v(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0}span(){return new v(this.max.x-this.min.x,this.max.y-this.min.y)}}class yb{constructor(){this.acc=new v(0,0),this.accCount=0,this.centroidDataIndex=0}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y)}appendEdge(e,t,n){this.accCount++,this.acc._add(t);let r=!!this.borders;t.xe.max.x&&(e.max.x=t.x,r=!0),t.ye.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===hr)&&t.x===n.x)!=((0===t.y||t.y===hr)&&t.y===n.y)&&this.processBorderOverlap(t,n),r&&this.checkBorderIntersection(t,n)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Yr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>hr!=e.x>hr&&this.addBorderIntersection(1,Yr(t.y,e.y,(hr-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Yr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>hr!=e.y>hr&&this.addBorderIntersection(3,Yr(t.x,e.x,(hr-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(){return 0===this.accCount?new v(0,0):new v(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0):0}}function vb(e,t){const n=e.add(t)._unit(),r=O(e.x*n.x+e.y*n.y,-1,1);var i,o,a;return i=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(i)))/4*cb*((o=e).x*(a=t).y-o.y*a.x<0?-1:1)}const xb=[e=>e.x<0,e=>e.x>hr,e=>e.y<0,e=>e.y>hr];function bb(e,t,n,r){const i=[4];if(0===r)return i;n._mult(r);const o=e.sub(n),a=t.sub(n),s=[e,t,o,a];for(let e=0;e<4;e++)for(const t of s)if(xb[e](t)){i.push(e);break}return i}class wb{constructor(e){this.vertexArray=new fl,this.indexArray=new Al,this.programConfigurations=new Ru(e.layers,e.zoom,e=>lb.includes(e)),this._segments=new Ql,this.hiddenByLandmarkVertexArray=new jl,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Ql}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,n,r=!1){const i=e.length;if(i>2){let o=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let s;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],n=e[1];s=vb(t.sub(e[i-1])._perp()._unit(),n.sub(t)._perp()._unit())}for(let l=0;le.region-t.region);for(let n=0;ne+t,0);let o=0;for(let e=0;e<=4;e++){const t=i[e];if(0!==t){let n=this.regionSegments[e];n||(n=this.regionSegments[e]=new Ql);const i={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};n.get().push(i)}o+=t}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,pm.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1)}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy()}}}}class Tb{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.fqid),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Al,this.footprintVertices=new cl,this.footprintSegments=[],this.layoutVertexArray=new dl,this.centroidVertexArray=new Yl,this.indexArray=new Al,this.programConfigurations=new Ru(e.layers,e.zoom,e=>sb.includes(e)),this.segments=new Ql,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new wb(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[]}populate(e,t,n,r){this.features=[],this.hasPattern=am("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=If(n),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:i,id:o,index:a,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ff(i,e);if(!this.layers[0]._featureFilter.filter(new Ns(this.zoom),l,n))continue;const u={id:o,sourceLayerIndex:s,index:a,geometry:e?l.geometry:Bf(i,n,r),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length;this.hasPattern?this.features.push(sm("fill-extrusion",this.layers,u,this.zoom,t)):this.addFeature(u,u.geometry,a,n,{},t.availableImages,r,t.brightness),t.featureIndex.insert(i,u.geometry,a,s,this.index,c)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,n,r,i,o){for(const e of this.features){const{geometry:a}=e;this.addFeature(e,a,e.index,t,n,r,i,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,n,r,i){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const a=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,t,a,n,r,i),this.groundEffect.update(e,t,a,n,r,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,_m),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,mm.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,fm.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,n,r,i,o,a,s){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,u=[new v(0,0),new v(hr,hr)],c=a.projection,h="globe"===c.name,d="Polygon"===ab[e.type],f=new yb;f.centroidDataIndex=this.centroidData.length;const p=new gb,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},r);p.height=_,p.vertexArrayOffset=this.layoutVertexArray.length,p.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new yl);const g=im(t,500);for(let e=g.length-1;e>=0;e--){const t=g[e];(0===t.length||(y=t[0]).every(e=>e.x<=0)||y.every(e=>e.x>=hr)||y.every(e=>e.y<=0)||y.every(e=>e.y>=hr))&&g.splice(e,1)}var y;let x;if(h)x=Pb(g,u,r);else{x=[];for(const e of g)x.push({polygon:e,bounds:u})}const b=d?this.edgeRadius:0,w=b>0&&this.zoom<17,T=(e,t)=>{if(0===e.length)return!1;const n=e[e.length-1];return t.x===n.x&&t.y===n.y};for(const{polygon:e,bounds:t}of x){let n=0,i=0;for(const t of e)d&&!t[0].equals(t[t.length-1])&&t.push(t[0]),i+=d?t.length-1:t.length;const o=this.segments.prepareSegment((d?5:4)*i,this.layoutVertexArray,this.indexArray);p.footprintSegIdx<0&&(p.footprintSegIdx=this.footprintSegments.length),p.polygonSegIdx<0&&(p.polygonSegIdx=this.polygonSegments.length);const a={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},s=new _b;if(s.vertexOffset=this.footprintVertices.length,s.indexOffset=3*this.footprintIndices.length,s.ringIndices=[],d){const i=[],a=[];n=o.vertexLength;for(let n=0;n4&&Cb(a[a.length-2],a[0],a[1]),u=b?Eb(a[a.length-2],a[0],a[1],b):0;const _=[];let g,y,v;y=a[1].sub(a[0])._perp()._unit();let x=!0;for(let e=1,i=0;e0?1:0,A=l.dist(d);if(i+A>32768&&(i=0),b){v=w.sub(d)._perp()._unit();let e=Mb(l,d,w,Sb(y,v),b);isNaN(e)&&(e=0);const t=d.sub(l)._unit();l=l.add(t.mult(u))._round(),d=d.add(t.mult(-e))._round(),u=e,y=v,m&&this.zoom>=17&&(T(_,l)||_.push(l),T(_,d)||_.push(d))}const I=o.vertexLength,C=a.length>4&&Cb(l,d,w);let k=kb(i,s,x);if(fb(this.layoutVertexArray,l.x,l.y,E,M,0,0,k),fb(this.layoutVertexArray,l.x,l.y,E,M,0,1,k),i+=A,k=kb(i,C,!x),s=C,fb(this.layoutVertexArray,d.x,d.y,E,M,0,0,k),fb(this.layoutVertexArray,d.x,d.y,E,M,0,1,k),o.vertexLength+=4,this.indexArray.emplaceBack(I+0,I+1,I+2),this.indexArray.emplaceBack(I+1,I+3,I+2),o.primitiveLength+=2,b){const r=n+(1===e?a.length-2:e-2),i=1===e?n:r+1;if(this.indexArray.emplaceBack(I+1,r,I+3),this.indexArray.emplaceBack(r,i,I+3),o.primitiveLength+=2,void 0===g&&(g=I),!Ab(w,a[e],t)){const t=e===a.length-1?g:o.vertexLength;this.indexArray.emplaceBack(I+2,I+3,t),this.indexArray.emplaceBack(I+3,t+1,t),this.indexArray.emplaceBack(I+3,i,t+1),o.primitiveLength+=3}x=!x}if(h){const e=this.layoutVertexExtArray,t=c.projectTilePoint(l.x,l.y,r),n=c.projectTilePoint(d.x,d.y,r),i=c.upVector(r,l.x,l.y),o=c.upVector(r,d.x,d.y);mb(e,t,i),mb(e,t,i),mb(e,n,o),mb(e,n,o)}}d&&(n+=a.length-1),m&&b&&this.zoom>=17&&(0!==_.length&&T(_,_[0])&&_.pop(),this.groundEffect.addData(_,t,l,b>0))}this.footprintSegments.push(s),a.triangleCount=this.indexArray.length-a.triangleArrayOffset,this.polygonSegments.push(a),++p.footprintSegLen,++p.polygonSegLen}if(p.vertexCount=this.layoutVertexArray.length-p.vertexArrayOffset,p.groundVertexCount=this.groundEffect.vertexArray.length-p.groundVertexArrayOffset,0!==p.vertexCount){if(p.centroidXY=f.borders?hb:this.encodeCentroid(f,p),this.centroidData.push(p),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}splitToSubtiles(){const e=[];for(let t=0;thr),i=2*r+(+(n.min.x+n.max.x>hr)^r);for(let r=0;re.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let n=0,r=0,i=0;for(const t of e){if(t.triangleSegmentIdx!==n)break;i++}const o=e.length;for(;r!==e.length;){n=e[r].triangleSegmentIdx;let a=0,s=r,l=r;for(let t=s;t0&&this.triangleSubSegments.push({segment:c,min:o,max:u}),s=l;for(let t=s;t[e[0]*(1-n[0])+t[0]*n[0],e[1]*(1-n[1])+t[1]*n[1]],d=[],f=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/hr,d[1]=e.min.y/hr,f[0]=e.max.x/hr,f[1]=e.max.y/hr;const t=h(l,u,d),o=h(l,u,f);if(0===new Md([t[0],t[1],r],[o[0],o[1],i]).intersectsPrecise(n)){s&&(c.segments.push(s),s=void 0);continue}const a=e.segment;s&&s.vertexOffset!==a.vertexOffset&&(c.segments.push(s),s=void 0),s?(s.vertexLength+=a.vertexLength,s.primitiveLength+=a.primitiveLength):s={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return s&&c.segments.push(s),c}encodeCentroid(e,t){const n=e.centroid(),r=t.span(),i=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new v(O(n.x,1,8191)<<3|i,O(n.y,1,8191)<<3|o)}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=db,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,n=e.vertexCount+e.vertexArrayOffset,r=e.flags&db?hb:e.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||i!==r.x){for(let e=t;ei.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(s+o.vertexOffset)+0]-n)*(t-a)/(l-a)+n&&(r=!r)}a=n}}return r}getHeightAtTileCoord(e,t){let n=Number.NEGATIVE_INFINITY,r=!0;const i=4*(e+hr)*hr+(t+hr);if(this.partLookup.hasOwnProperty(i)){const e=this.partLookup[i];return e?{height:e.height,hidden:!!(e.flags&db)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||this.footprintContainsPoint(e,t,o)&&o&&o.height>n&&(n=o.height,this.partLookup[i]=o,r=!!(o.flags&db));if(n!==Number.NEGATIVE_INFINITY)return{height:n,hidden:r};this.partLookup[i]=void 0}}function Sb(e,t){const n=e.add(t)._unit();return e.x*n.x+e.y*n.y}function Eb(e,t,n,r){const i=t.sub(e)._perp()._unit(),o=n.sub(t)._perp()._unit();return Mb(e,t,n,Sb(i,o),r)}function Mb(e,t,n,r,i){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(n)/3,i*o/r)}function Ab(e,t,n){return e.xn[1].x&&t.x>n[1].x||e.yn[1].y&&t.y>n[1].y}function Ib(e,t){return e.xt[1].x||e.yt[1].y}function Cb(e,t,n){if(e.x<0||e.x>=hr||t.x<0||t.x>=hr||n.x<0||n.x>=hr)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 kb(e,t,n){const r=t?2|e:-3&e;return n?1|r:-2&r}function Ob(){const e=Math.PI/32,t=Math.tan(e),n=ff;return n*Math.sqrt(1+2*t*t)-n}function Pb(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=wf((n.y+t/hr)/r);return(vf(.5*(wf((n.y+i/hr)/r)+e))*r-n.y)*hr}})}function Rb(e,t,n,r,i,o){const a=Math.pow(2,r.z-i.z);for(let s=0;s{const s=e.transform,l=s.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Wb(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:Hb(n)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:qb(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:a,u_emissive_strength:n.paint.get("line-emissive-strength")}},Gb=(e,t,n,r,i)=>{const o=e.transform;return{u_matrix:Wb(e,t,n,r),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:qb(t,o),u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function qb(e,t){return 1/ox(e,1,t.tileZoom)}function Wb(e,t,n,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Zb=e=>{const t=[];Hb(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const n=e.paint.get("line-trim-offset");return 0===n[0]&&0===n[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER"),t};function Hb(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const $b=new class extends Ys{possiblyEvaluate(e,t){return t=new Ns(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)}}(Ub.paint.properties["line-width"].specification);function Xb(e,t){return t>0?t+2*e:e}$b.useIntegerZoom=!0;const Yb=new Js({visibility:new Xs(Pt.layout_background.visibility)});var Kb={paint:new Js({"background-color":new Xs(Pt.paint_background["background-color"]),"background-pattern":new Xs(Pt.paint_background["background-pattern"]),"background-opacity":new Xs(Pt.paint_background["background-opacity"]),"background-emissive-strength":new Xs(Pt.paint_background["background-emissive-strength"])}),layout:Yb};const Jb=new Js({visibility:new Xs(Pt.layout_raster.visibility)});var Qb={paint:new Js({"raster-opacity":new Xs(Pt.paint_raster["raster-opacity"]),"raster-color":new Ks(Pt.paint_raster["raster-color"]),"raster-color-mix":new Xs(Pt.paint_raster["raster-color-mix"]),"raster-color-range":new Xs(Pt.paint_raster["raster-color-range"]),"raster-hue-rotate":new Xs(Pt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Xs(Pt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Xs(Pt.paint_raster["raster-brightness-max"]),"raster-saturation":new Xs(Pt.paint_raster["raster-saturation"]),"raster-contrast":new Xs(Pt.paint_raster["raster-contrast"]),"raster-resampling":new Xs(Pt.paint_raster["raster-resampling"]),"raster-fade-duration":new Xs(Pt.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new Xs(Pt.paint_raster["raster-emissive-strength"]),"raster-array-band":new Xs(Pt.paint_raster["raster-array-band"]),"raster-elevation":new Xs(Pt.paint_raster["raster-elevation"])}),layout:Jb};function ew(e,t,n,r,i,o,a,s){const l=[e,n,i,t,r,o,1,1,1],u=[a,s,1],c=Yh.adjoint([],l),[h,d,f]=id.transformMat3(u,u,Yh.transpose(c,c));return Yh.multiply(l,[h,0,0,0,d,0,0,0,f],l)}class tw extends Ot{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.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new Ct("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ce(this.map._requestManager.transformRequest(this.url,ve.Image),(t,r)=>{if(this._imageRequest=null,this._loaded=!0,t)this.fire(new kt(t));else if(r){const{HTMLImageElement:t}=n;this.image=r instanceof t?ft.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading()}})}loaded(){return this._loaded}updateImage(e){return 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}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Dy(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Ct("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 instanceof Dy||this.texture.destroy()}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],n=e[0][1];for(const r of e)r[1]>n&&(n=r[1]),r[1]Sf?this.onNorthPole=!0:r<-Sf&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(Cf.fromLngLat);this.tileID=function(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x),i=Math.max(i,o.y);const o=Math.max(r-t,i-n),a=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),s=Math.pow(2,a);return new pd(a,Math.floor((t+r)/2*s),Math.floor((n+i)/2*s))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){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 t=jg(this.tileID,this.map.transform.projection),[n,r,i,o]=this.coordinates.map(e=>{const n=t.projection.project(e[0],e[1]);return Ug(t,n)._round()});this.perspectiveTransform=function(e,t,n,r,i,o,a,s,l,u){const c=ew(0,0,e,0,0,t,e,t),h=ew(n,r,i,o,a,s,l,u);return Yh.multiply(h,Yh.adjoint(c,c),h),[h[6]/h[8]*e/hr,h[7]/h[8]*t/hr]}(this.width,this.height,n.x,n.y,r.x,r.y,o.x,o.y,i.x,i.y);const a=this._boundsArray=new dl;a.emplaceBack(n.x,n.y,0,0),a.emplaceBack(r.x,r.y,hr,0),a.emplaceBack(o.x,o.y,0,hr),a.emplaceBack(i.x,i.y,hr,hr),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,Ny.members),this.boundsSegments=Ql.simpleSegment(0,0,4,2)}prepare(){const e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;const t=this.map.painter.context,n=t.gl;!this._dirty||this.texture instanceof Dy||(this.texture?this.texture.update(this.image):(this.texture=new Ry(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this._dirty=!1),e&&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}}class nw extends rl{constructor(e){super(e,{}),this.implementation=e,e.slot&&(this.slot=e.slot)}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(e){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)}}const rw=new Js({visibility:new Xs(Pt.layout_sky.visibility)});var iw={paint:new Js({"sky-type":new Xs(Pt.paint_sky["sky-type"]),"sky-atmosphere-sun":new Xs(Pt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Xs(Pt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Xs(Pt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Xs(Pt.paint_sky["sky-gradient-radius"]),"sky-gradient":new Ks(Pt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Xs(Pt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Xs(Pt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Xs(Pt.paint_sky["sky-opacity"])}),layout:rw};function ow(e,t,n){const r=[0,0,1],i=ed.identity([]);return ed.rotateY(i,i,n?-T(e)+Math.PI:T(e)),ed.rotateX(i,i,-T(t)),id.transformQuat(r,r,i),id.normalize(r,r)}var aw={paint:new Js({})};const sw={circle:class extends rl{constructor(e,t){super(e,sp,t)}createBucket(e){return new Uf(e)}queryRadius(e){const t=e;return np("circle-radius",this,t)+np("circle-stroke-width",this,t)+rp(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=op(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 hp(e,r,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return["circle"]}getDefaultProgramParams(e,t){const n=cp(this);return{config:new Pu(this,t),defines:n,overrideFog:!1}}},heatmap:class extends rl{createBucket(e){return new _p(e)}constructor(e,t){super(e,Sp,t),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Ep({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 np("heatmap-radius",this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=this.paint.get("heatmap-radius").evaluate(t,n);return hp(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"]}getDefaultProgramParams(e,t){return"heatmap"===e?{config:new Pu(this,t),overrideFog:!1}:{}}},hillshade:class extends rl{constructor(e,t){super(e,Ap,t)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t){return{overrideFog:!1}}},fill:class extends rl{constructor(e,t){super(e,cm,t)}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}getDefaultProgramParams(e,t){return{config:new Pu(this,t),overrideFog:!1}}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 lm(e)}queryRadius(){return rp(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,n,r,i,o){return!e.queryGeometry.isAboveHorizon&&qf(ip(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 rl{constructor(e,t){super(e,Lb,t),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new Tb(e)}queryRadius(){return rp(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}hasShadowPass(){return!0}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,n,r,i,o,a,s,l){const u=op(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 Tb){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=Ob();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=jb(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),id.transformMat4(p,p,o),id.transformMat4(m,m,o),t.push(new zb(p[0],p[1],p[2])),y.push(new zb(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=jb(c,d,t,n,o,a,s,l);h[0]=c,h[1]=d,h[2]=p.base,h[3]=1,qh.transformMat4(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new zb(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,qh.transformMat4(h,h,i),h[3]=Math.max(h[3],1e-5);const _=new zb(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),T=m+h,S=_+d,E=g+f,M=Math.max(y+p,1e-5);e.push(new zb(v/w,x/w,b/w)),n.push(new zb(T/M,S/M,E/M))}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;qf(n,t)&&(r=Fb(n,t[0]));for(let i=0;i=3)for(let t=0;t=0)r=t;else{const i=e.points[n-4];r=Kr(i,t,i[2]/(i[2]-t[2]))}if(yw(this.state,r[0],r[1],0,this._transform)>=mw)return!0}return!1}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(e,t,n){return(!n||!1!==n.validate)&&ma(this,e.call(ra,z({value:t,style:{glyphs:!0,sprite:!0},styleSpec:Pt})))}}class ww{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class Tw{constructor(){this.tasks={},this.taskQueue=[],G(["process"],this),this.invoker=new ww(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){ee();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(){ee();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{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||ee()){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(Sa(t.error)):n(null,Sa(t.data)))}else{const n=new Set,r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Ta(t):null,data:Ta(r,n)},n)}:e=>{},i=Sa(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,i.scope)[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)}}class Ew{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=j();const n=this.workerPool.acquire(this.id);for(let e=0;e{this.ready=!0})}broadcast(e,t,n){D(this.actors,(n,r)=>{n.send(e,t,r)},n=n||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)}}Ew.Actor=Sw;class Mw extends Ot{constructor(e,t,n,r){super(),this.scope=n,this._options=e,this.properties=new $s(t),this._transitionable=new Gs(t,new Map(r)),this._transitionable.setTransitionOrValue(e.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e))}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t)}shadowsEnabled(){return!!this.properties&&!0===this.properties.get("cast-shadows")}}const Aw=new Js({color:new Xs(Pt.properties_light_ambient.color),intensity:new Xs(Pt.properties_light_ambient.intensity)}),Iw=new Js({direction:new class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const n=J([1,e,t]);return{x:n.x,y:n.y,z:n.z}}(e.expression.evaluate(t))}interpolate(e,t,n){return{x:Yr(e.x,t.x,n),y:Yr(e.y,t.y,n),z:Yr(e.z,t.z,n)}}}(Pt.properties_light_directional.direction),color:new Xs(Pt.properties_light_directional.color),intensity:new Xs(Pt.properties_light_directional.intensity),"cast-shadows":new Xs(Pt.properties_light_directional["cast-shadows"]),"shadow-intensity":new Xs(Pt.properties_light_directional["shadow-intensity"])});class Cw{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(e,t){let n,r;if(e instanceof v||"number"==typeof e[0]){const i=v.convert(e);n=[i],r=t.isPointAboveHorizon(i)}else{const i=v.convert(e[0]),o=v.convert(e[1]);n=[i,o],r=I(i,o).every(e=>t.isPointAboveHorizon(e))}return new Cw(n,t.getCameraPoint(),r,t)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return I(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const t=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new v(1,1)):this.screenBounds[1],r=I(t,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>t.x&&this.cameraPoint.x=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=t.x&&(r[3]=this.cameraPoint)),function(e,t){const n=[];for(let r=0;rt.y)+(i.y>n.y))+((i.x>t.x)+(i.x>n.x))){case 0:r[0]=i,r[4]=i.clone();break;case 1:r.splice(1,0,i);break;case 2:r[1]=i;break;case 3:r.splice(4,0,i);break;case 5:r.splice(2,0,i);break;case 6:r[3]=i;break;case 7:r.splice(3,0,i);break;case 8:r[2]=i}return r}containsTile(e,t,n,r=0){const i=e.queryPadding/t._pixelsPerMercatorPixel+1,o=n?this._bufferedCameraMercator(i,t):this._bufferedScreenMercator(i,t);let a=e.tileID.wrap+(o.unwrapped?r:0);const s=o.polygon.map(t=>Ug(e.tileTransform,t,a));if(!Jf(s,0,0,hr,hr))return;a=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const l=this.screenGeometryMercator.polygon.map(t=>Vg(e.tileTransform,t,a)),u=l.map(e=>new v(e[0],e[1])),c=t.getFreeCameraOptions().position||new Cf(0,0,0),h=Vg(e.tileTransform,c,a),d=l.map(e=>{const t=id.sub(e,e,h);return id.normalize(t,t),new vd(h,t)}),f=ox(e,1,t.zoom)*t._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:d,bufferedTilespaceGeometry:s,bufferedTilespaceBounds:(p=A(s),p.min.x=O(p.min.x,0,hr),p.min.y=O(p.min.y,0,hr),p.max.x=O(p.max.x,0,hr),p.max.y=O(p.max.y,0,hr),p),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:f};var p}_bufferedScreenMercator(e,t){const n=Pw(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=Pw(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(e,t){const n=function(e,t){const n=Jh.multiply([],t.pixelMatrix,t.globeMatrix),r=[0,-Ad,0,1],i=[0,Ad,0,1],o=[0,0,0,1];qh.transformMat4(r,r,n),qh.transformMat4(i,i,n),qh.transformMat4(o,o,n);const a=new v(r[0]/r[3],r[1]/r[3]),s=new v(i[0]/i[3],i[1]/i[3]),l=Kf(e,a)&&r[3]1?kw(e.slice(0,h),t):[],p=hnew v(Ow(e.x),e.y)),p=p.map(e=>new v(Ow(e.x),e.y));const m=[...f];0===m.length&&m.push(p[p.length-1]);const _=Yr(m[m.length-1].y,(0===p.length?f[0]:p[0]).y,d);let g;return g=l?[new v(0,_),new v(0,0),new v(1,0),new v(1,_)]:[new v(1,_),new v(1,1),new v(0,1),new v(0,_)],m.push(...g),0===p.length?m.push(f[0]):m.push(...p),{polygon:m.map(e=>new Cf(e.x,e.y)),unwrapped:!1}}(e,t);if(n)return n;const r=function(e,t){let n=!1,r=-1/0,i=0;for(let t=0;tr&&(r=e[t].x,i=t);for(let t=0;t.5&&(o.x{e.x-=1}),{polygon:e,unwrapped:n}}(kw(e,t).map(e=>new v(Ow(e.x),e.y)),t);return{polygon:r.polygon.map(e=>new Cf(e.x,e.y)),unwrapped:r.unwrapped}}}function kw(e,t){return Of(e,e=>{const n=t.pointCoordinate3D(e);e.x=n.x,e.y=n.y},1/256)}function Ow(e){return e<0?1+e%1:e%1}function Pw(e){return 100*e|0}function Rw(e,t,n,r,i){const o=function(n,r){if(n)return i(n);if(r){e.url&&r.tiles&&e.tiles&&delete e.tiles;const n=B(z(r,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(n.vectorLayers=r.vector_layers,n.vectorLayerIds=n.vectorLayers.map(e=>e.id)),n.tiles=t.canonicalizeTileset(n,e.url),i(null,n)}};return e.url?Te(t.transformRequest(t.normalizeSourceURL(e.url,null,n,r),ve.Source),o):ft.frame(()=>o(null,e))}class Dw{constructor(e,t,n){this.bounds=ju.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=n||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(e){const t=Math.pow(2,e.z),n=Math.floor(yf(this.bounds.getWest())*t),r=Math.floor(vf(this.bounds.getNorth())*t),i=Math.ceil(yf(this.bounds.getEast())*t),o=Math.ceil(vf(this.bounds.getSouth())*t);return e.x>=n&&e.x=r&&e.y1&&(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 X("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t=t.maxzoom||"none"!==t.visibility&&(Fw(e,this.zoom,u.brightness,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:d,sourceID:this.source,projection:this.projection.spec})).populate(f,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 this.status="done",i(h);if(this.extraShadowCaster)this.status="done",i(null,{buckets:L(s).filter(e=>!e.isEmpty()),featureIndex:a,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:u.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(d&&f&&p){const e=new zw(d),t=new hg(f,p);for(const r in s){const i=s[r];i instanceof Ey?(Fw(i.layers,this.zoom,u.brightness,n),Ig(i,d,e.positions,f,t.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):i.hasPattern&&(i instanceof Py||i instanceof lm||i instanceof Tb)&&(Fw(i.layers,this.zoom,u.brightness,n),i.addFeatures(u,this.tileID.canonical,t.patternPositions,n,this.tileTransform,this.brightness))}this.status="done",i(null,{buckets:L(s).filter(e=>!e.isEmpty()),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,brightness:u.brightness})}};if(!this.extraShadowCaster){const e=W(u.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},(e,t)=>{h||(h=e,d=t,_())},void 0,!1,m):d={};const t=Object.keys(u.iconDependencies);t.length?r.send("getImages",{icons:t,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(e,t)=>{h||(h=e,f=t,_())},void 0,!1,m):f={};const n=Object.keys(u.patternDependencies);n.length?r.send("getImages",{icons:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(e,t)=>{h||(h=e,p=t,_())},void 0,!1,m):p={}}_()}}function Fw(e,t,n,r){const i=new Ns(t,{brightness:n});for(const t of e)t.recalculate(i,r)}class jw{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 Nw(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=Se(e.request,(e,r,i,o)=>{e?t(e):r&&t(null,{vectorTile:n?void 0:new Cm(new e_(r)),rawData:r,cacheControl:i,expires:o})});return()=>{r.cancel(),t()}},t)}class Uw extends Ot{constructor(e,t,n,r){if(super(),this.id=e,this.dispatcher=n,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,z(this,B(t,["url","scheme","tileSize","promoteId"])),this._options=z({type:"vector"},t),this._collectResourceTiming=!!t.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new jw}load(e){this._loaded=!1,this.fire(new Ct("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map._worldview;this._tileJSONRequest=Rw(this._options,this.map._requestManager,t,n,(r,i)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: "+t),n&&2!==n.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: "+n),this.fire(new kt(r))):i&&(z(this,i),i.bounds&&(this.tileBounds=new Dw(i.bounds,this.minzoom,this.maxzoom)),qe(i.tiles,this.map._requestManager._customAccessToken),this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=el(this.id,this.scope);this.load(()=>this.map.style.clearSource(e))}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 z({},this._options)}loadTile(e,t){const n=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,ve.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:ft.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:e.isExtraShadowCaster};if(r.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=t:e.request=e.actor.send("reloadTile",r,i.bind(this));else if(e.actor=this._tileWorkers[n]=this._tileWorkers[n]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",r,i.bind(this),void 0,!0);else{const t=Nw.call({deduped:this._deduped},r,(t,n)=>{t||!n?i.call(this,t):(r.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},e.actor&&e.actor.send("loadTile",r,i.bind(this),void 0,!0))},!0);e.request={cancel:t}}function i(n,r){return delete e.request,e.aborted?t(null):n&&404!==n.status?t(n):(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),ye(this.dispatcher),t(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.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,scope:this.scope})}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Vw extends Ot{constructor(e,t,n,r){super(),this.id=e,this.dispatcher=n,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=z({type:"raster"},t),z(this,B(t,["url","scheme","tileSize"]))}load(e){this._loaded=!1,this.fire(new Ct("dataloading",{dataType:"source"})),this._tileJSONRequest=Rw(this._options,this.map._requestManager,null,null,(t,n)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new kt(t)):n&&(z(this,n),n.bounds&&(this.tileBounds=new Dw(n.bounds,this.minzoom,this.maxzoom)),qe(n.tiles),this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))),e&&e(t)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const e=el(this.id,this.scope);this.load(()=>this.map.style.clearSource(e))}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 z({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const n=ft.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);e.request=Ce(this.map._requestManager.transformRequest(r,ve.Tile),(n,r,i,o)=>(delete e.request,e.aborted?(e.state="unloaded",t(null)):n?(e.state="errored",t(n)):r?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:i,expires:o}),e.setTexture(r,this.map.painter),e.state="loaded",ye(this.dispatcher),void t(null)):t(null)))}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&e.texture instanceof Ry?(e.destroy(!0),e.texture&&e.texture instanceof Ry&&this.map.painter.saveTileTexture(e.texture)):e.destroy(),t()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Gw(){return null!=xI.workerClass?new xI.workerClass:new n.Worker(xI.workerUrl)}const qw="mapboxgl_preloaded_worker_pool";class Ww{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[qw]}numActive(){return Object.keys(this.active).length}}let Zw;function Hw(){return Zw||(Zw=new Ww),Zw}Ww.workerCount=2;let $w,Xw,Yw,Kw=null;function Jw(){return ee()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:Xw||o.DRACO_URL}const Qw={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},eT={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",5123:"DT_UINT16",5125:"DT_UINT32",5126:"DT_FLOAT32"},tT={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function nT(e,t,n){const r=n.json.bufferViews.length,i=n.buffers.length;t.bufferView=r,n.json.bufferViews[r]={buffer:i,byteLength:e.byteLength},n.buffers[i]=e}const rT="KHR_draco_mesh_compression";function iT(e,t){const n=e.extensions&&e.extensions[rT];if(!n)return;const r=new Yw.Decoder,i=uT(t,n.bufferView),o=new Yw.Mesh;if(!r.DecodeArrayToMesh(i,i.byteLength,o))throw new Error("Failed to decode Draco mesh");const a=t.json.accessors[e.indices],s=Qw[a.componentType],l=a.count*s.BYTES_PER_ELEMENT,u=Yw._malloc(l);s===Uint16Array?r.GetTrianglesUInt16Array(o,l,u):r.GetTrianglesUInt32Array(o,l,u),nT(Yw.memory.buffer.slice(u,u+l),a,t),Yw._free(u);for(const i of Object.keys(n.attributes)){const a=r.GetAttributeByUniqueId(o,n.attributes[i]),s=t.json.accessors[e.attributes[i]],l=eT[s.componentType],u=s.count*tT[s.type]*Qw[s.componentType].BYTES_PER_ELEMENT,c=Yw._malloc(u);r.GetAttributeDataArrayForAllPoints(o,a,Yw[l],u,c),nT(Yw.memory.buffer.slice(c,c+u),s,t),Yw._free(c)}r.destroy(),o.destroy(),delete e.extensions[rT]}const oT=1179937895,aT=new TextDecoder("utf8");function sT(e,t){return new URL(e,t).href}function lT(e,t,n,r){return fetch(sT(e.uri,r)).then(e=>e.arrayBuffer()).then(e=>{t.buffers[n]=e})}function uT(e,t){const n=e.json.bufferViews[t];return new Uint8Array(e.buffers[n.buffer],n.byteOffset||0,n.byteLength)}function cT(e,t,r,i){if(e.uri){const o=sT(e.uri,i);return fetch(o).then(e=>e.blob()).then(e=>n.createImageBitmap(e)).then(e=>{t.images[r]=e})}if(void 0!==e.bufferView){const i=uT(t,e.bufferView),o=new n.Blob([i],{type:e.mimeType});return n.createImageBitmap(o).then(e=>{t.images[r]=e})}}function hT(e,t=0,n){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===oT){const n=new Uint32Array(e,t);let i=2;const o=(n[i++]>>2)-3,a=n[i++]>>2;if(i++,r.json=JSON.parse(aT.decode(n.subarray(i,i+a))),i+=a,i{const e=[],t=s&&s.includes(rT);if(t&&e.push(function(){if(!Yw)return $w||($w=function(e){let t,n=null;function r(){t=new Uint8Array(n.buffer)}function i(){throw new Error("Unexpected Draco error.")}const o={a:{a:i,d:function(e,n,r){return t.copyWithin(e,n,n+r)},c:function(e){const i=t.length,o=Math.max(e>>>0,Math.ceil(1.2*i)),a=Math.ceil((o-i)/65536);try{return n.grow(a),r(),!0}catch(e){return!1}},b:i}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,o))).then(e=>{const{Rb:i,Qb:o,P:a,T:s,X:l,Ja:u,La:c,Qa:h,Va:d,Wa:f,eb:p,jb:m,f:_,e:g,yb:y,zb:v,Ab:x,Bb:b,Db:w,Gb:T}=e.instance.exports;n=g;const S=(()=>{let e=0,n=0,r=0,a=0;return s=>{r&&(i(a),i(e),n+=r,r=e=0),e||(n+=128,e=o(n));const l=s.length+7&-8;let u=e;l>=n&&(r=l,u=a=o(l));for(let e=0;e{Yw=e,$w=void 0}))}()),o)for(let t=0;t{if(t&&a)for(const{primitives:e}of a)for(const t of e)iT(t,r);return r})})}function dT(e){return fetch(e).then(e=>e.arrayBuffer()).then(t=>hT(t,0,e))}class fT{constructor(e,t,n){if(this.triangleCount=t.length/3,this.min=new v(0,0),this.max=new v(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length||0===n)return;const r=e.map(e=>e.x),i=e.map(e=>e.y);this.min=new v(Math.min(...r),Math.min(...i)),this.max=new v(Math.max(...r),Math.max(...i));const o=this.max.sub(this.min);o.x=Math.max(o.x,1),o.y=Math.max(o.y,1);const a=Math.max(o.x,o.y)/n;this.cellsX=Math.max(1,Math.ceil(o.x/a)),this.cellsY=Math.max(1,Math.ceil(o.y/a)),this.xScale=1/a,this.yScale=1/a;const s=[];for(let n=0;ne.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let l=0;for(;lthis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let e=0;e0){for(let i=0;i0){o.texcoordArray=new zl;const e=t.json.accessors[i.TEXCOORD_0];o.texcoordArray.reserve(e.count);const n=mT(t,e);for(let t=0;t1&&r[r.length-1].equals(r[0])&&r.pop();let i=0;for(let e=0;e0&&r.reverse();const o=rm(r.flatMap(e=>[e.x,e.y]),[]);return 0===o.length?null:{vertices:r,indices:o}}function xT(e){const t=[],n=[];let r=0;for(const i of e){r=t.length;const e=i.vertexArray.float32,o=i.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]])}return{vertices:t,indices:n}}function bT(e){const t=function(e,t){const n=[];for(const r of e.json.meshes){const i=[];for(const n of r.primitives)i.push(_T(n,e,t));n.push(i)}return n}(e,function(e,t){const r=[],i=n.WebGL2RenderingContext;if(e.json.textures)for(const n of e.json.textures){const o={magFilter:i.LINEAR,minFilter:i.NEAREST,wrapS:i.REPEAT,wrapT:i.REPEAT};void 0!==n.sampler&&Object.assign(o,e.json.samplers[n.sampler]),r.push({image:t[n.source],sampler:o,uploaded:!1})}return r}(e,e.images)),{scenes:r,scene:i,nodes:o}=e.json,a=r?r[i||0].nodes:o,s=[];for(const n of a)s.push(gT(o[n],e,t));return function(e,t,n){const r={},i=new Set;for(let o=0;o0){const t=Array.from(i.values()).sort((e,t)=>e-t);for(let n=t.length-1;n>=0;n--)e.splice(t[n],1)}}(s,a,e.json.nodes),s}function wT(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,n=e.aabb.min[0]-1,r=e.aabb.min[1]-1,i=64/(e.aabb.max[0]-n+2),o=64/(e.aabb.max[1]-r+2);for(let a=0;ae.heightmap[64*u+l]&&(e.heightmap[64*u+l]=s)}}function TT(e,t){const n={};n.indexArray=new Al,n.indexArray.reserve(4*e.length),n.vertexArray=new Ll,n.vertexArray.reserve(10*e.length),n.colorArray=new ml,n.vertexArray.reserve(10*e.length);let r=0;for(const i of e){const e=Math.min(10,Math.max(4,1.3*i.height))*t,o=[-i.normal[1],i.normal[0],0],a=Math.min(.29,.1*i.width/i.depth),s=i.width-2*i.depth*t*(a+.01),l=id.scaleAndAdd([],i.pos,o,s/2),u=id.scaleAndAdd([],i.pos,o,-s/2),c=[l[0],l[1],l[2]+i.height],h=[u[0],u[1],u[2]+i.height],d=id.scaleAndAdd([],i.normal,o,a);id.scale(d,d,e);const f=id.scaleAndAdd([],i.normal,o,-a);id.scale(f,f,e),id.add(d,l,d),id.add(f,u,f),l[2]+=.1,u[2]+=.1,n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(l[0],l[1],l[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(l[0],l[1],l[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]);const p=s/e/2;n.colorArray.emplaceBack(-p-a,-1,p,.8),n.colorArray.emplaceBack(p+a,-1,p,.8),n.colorArray.emplaceBack(-p,0,p,1.3),n.colorArray.emplaceBack(p,0,p,1.3),n.colorArray.emplaceBack(p+a,-.8,p,.7),n.colorArray.emplaceBack(p+a,-.8,p,.7),n.colorArray.emplaceBack(0,0,p,1.3),n.colorArray.emplaceBack(0,0,p,1.3),n.colorArray.emplaceBack(p+a,-1.2,p,.8),n.colorArray.emplaceBack(p+a,-1.2,p,.8),n.indexArray.emplaceBack(6+r,4+r,8+r),n.indexArray.emplaceBack(7+r,9+r,5+r),n.indexArray.emplaceBack(0+r,1+r,2+r),n.indexArray.emplaceBack(1+r,3+r,2+r),r+=10}const i={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=dn.white,i.pbrMetallicRoughness=o,n.material=i,n.aabb=new Md([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}xa(fT,"TriangleGridIndex");const ST={vector:Uw,raster:Vw,"raster-dem":class extends Vw{constructor(e,t,n,r){super(e,t,n,r),this.type="raster-dem",this.maxzoom=22,this._options=z({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox"}loadTile(e,t){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(n,r){n&&(e.state="errored",t(n)),r&&(e.dem=r,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",t(null))}e.request=Ce(this.map._requestManager.transformRequest(r,ve.Tile),function(r,o,a,s){if(delete e.request,e.aborted)e.state="unloaded",t(null);else if(r)e.state="errored",t(r);else if(o){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:a,expires:s});const t=n.ImageBitmap&&o instanceof n.ImageBitmap&&dt(),r=1-(o.width-((l=o.width)<=1?1:Math.pow(2,Math.floor(Math.log(l)/Math.LN2))))/2;r<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const u=t?o:ft.getImageData(o,r),c={uid:e.uid,coord:e.tileID,source:this.id,scope:this.scope,rawImageData:u,encoding:this.encoding,padding:r};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",c,i.bind(this),void 0,!0))}var l}.bind(this))}_getNeighboringTiles(e){const t=e.canonical,n=Math.pow(2,t.z),r=(t.x-1+n)%n,i=0===t.x?e.wrap-1:e.wrap,o=(t.x+1+n)%n,a=t.x+1===n?e.wrap+1:e.wrap,s={};return s[new _d(e.overscaledZ,i,t.z,r,t.y).key]={backfilled:!1},s[new _d(e.overscaledZ,a,t.z,o,t.y).key]={backfilled:!1},t.y>0&&(s[new _d(e.overscaledZ,i,t.z,r,t.y-1).key]={backfilled:!1},s[new _d(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},s[new _d(e.overscaledZ,a,t.z,o,t.y-1).key]={backfilled:!1}),t.y+1{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new kt(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&t&&t.resourceTiming&&t.resourceTiming[this.id]&&(e.resourceTiming=t.resourceTiming[this.id]),this.fire(new Ct("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(e,t){const n=e.actor?"reloadTile":"loadTile";e.actor=this.actor;const r={type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:ft.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};e.request=this.actor.send(n,r,(r,i)=>(delete e.request,e.destroy(),e.aborted?t(null):r?t(r):(e.loadVectorData(i,this.map.painter,"reloadTile"===n),t(null))),void 0,"loadTile"===n)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return z({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends tw{constructor(e,t,n,r){super(e,t,n,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,ve.Source).url);!function(e,t){const r=n.document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(let t=0;t{this._loaded=!0,e?this.fire(new kt(e)):t&&(this.video=t,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const t=this.video.seekable;et.end(0)?this.fire(new kt(new Rt("sources."+this.id,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e}}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 e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new Ry(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:tw,model:class extends Ot{constructor(e,t,n,r){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t}load(){const e=[];for(const t in this._options.models){const n=this._options.models[t],r=dT(this.map._requestManager.transformRequest(n.uri,ve.Model).url).then(e=>{if(!e)return;const r=bT(e),i=new Px(t,n.position,n.orientation,r);i.computeBoundsAndApplyParent(),this.models.push(i)}).catch(e=>{this.fire(new kt(new Error(`Could not load model ${t} from ${n.uri}: ${e.message}`)))});e.push(r)}return Promise.allSettled(e).then(()=>{this._loaded=!0,this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(e=>{this.fire(new kt(new Error("Could not load models: "+e.message)))})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return{type:"model"}}},"batched-model":class extends Ot{constructor(e,t,n,r){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=n,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(r)}onAdd(e){this.map=e,this.load()}load(e){this._loaded=!1,this.fire(new Ct("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map._worldview;this._tileJSONRequest=Rw(this._options,this.map._requestManager,t,n,(r,i)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: "+t),n&&2!==n.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: "+n),this.fire(new kt(r))):i&&(z(this,i),i.bounds&&(this.tileBounds=new Dw(i.bounds,this.minzoom,this.maxzoom)),qe(i.tiles,this.map._requestManager._customAccessToken),this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)})}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(e,t){const n=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,ve.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(e.actor&&"expired"!==e.state)if("loading"===e.state)e.reloadCallback=t;else{if(e.buckets){const t=Object.values(e.buckets);for(const e of t)e.dirty=!0;return void(e.state="loaded")}e.request=e.actor.send("reloadTile",r,i.bind(this))}else e.actor=this.dispatcher.getActor(),e.request=e.actor.send("loadTile",r,i.bind(this),void 0,!0);function i(n,r){return e.aborted?t(null):n&&404!==n.status?t(n):(r&&(r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&e.setExpiryData(r),e.buckets={...e.buckets,...r.buckets}),e.state="loaded",void t(null))}}serialize(){return z({},this._options)}},canvas:class extends tw{constructor(e,t,r,i){super(e,t,r,i),t.coordinates?Array.isArray(t.coordinates)&&4===t.coordinates.length&&!t.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new kt(new Rt("sources."+e,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new kt(new Rt("sources."+e,null,'missing required property "coordinates"'))),t.animate&&"boolean"!=typeof t.animate&&this.fire(new kt(new Rt("sources."+e,null,'optional "animate" property must be a boolean value'))),t.canvas?"string"==typeof t.canvas||t.canvas instanceof n.HTMLCanvasElement||this.fire(new kt(new Rt("sources."+e,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new kt(new Rt("sources."+e,null,'missing required property "canvas"'))),this.options=t,this.animate=void 0===t.animate||t.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof n.HTMLCanvasElement?this.options.canvas:n.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new kt(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 e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const t=this.map.painter.context;this.texture?!e&&!this._playing||this.texture instanceof Dy||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Ry(t,this.canvas,t.gl.RGBA,{premultiply:!0}),this._prepareData(t)}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 Ot{constructor(e,t,n,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=n,this._implementation=t,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new kt(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new kt(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Dw(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.clearTiles=this._clearTiles.bind(this),t.coveringTiles=this._coveringTiles.bind(this),z(this,B(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return B(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new Ct("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new Ct("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),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(e,t){const{x:r,y:i,z:o}=e.tileID.canonical,a=new n.AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:o},{signal:a.signal})).then(function(r){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===r?(e.state="errored",t(null)):null===r?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof n.ImageData||e instanceof n.HTMLCanvasElement||e instanceof n.ImageBitmap||e instanceof n.HTMLImageElement}(r)?(this.loadTileData(e,r),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(n=>{20!==n.code&&(e.state="errored",t(n))}),e.request.cancel=()=>a.abort()}loadTileData(e,t){e.setTexture(t,this._map.painter)}unloadTile(e,t){if(e.texture&&e.texture instanceof Ry?(e.destroy(!0),e.texture&&e.texture instanceof Ry&&this._map.painter.saveTileTexture(e.texture)):e.destroy(),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(){const e=el(this.id,this.scope);this._map.style.clearSource(e)}_update(){this.fire(new Ct("data",{dataType:"source",sourceDataType:"content"}))}}},ET=function(e,t,n,r){const i=new ST[t.type](e,t,n,r);if(i.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${i.id}`);return G(["load","abort","unload","serialize","prepare"],i),i};function MT(e,t){const n=Jh.identity([]);return Jh.scale(n,n,[.5*e.width,.5*-e.height,1]),Jh.translate(n,n,[1,-1,0]),Jh.multiply(n,n,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(n)}function AT(e,t,n,r,i,o,a,s=!1){const l=e.tilesIn(r,a,s);l.sort(CT);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,MT(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&&"slot"!==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 IT(e,t){const n=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],i={};for(let e=0;e0?n.paint.get("fill-extrusion-vertical-scale"):0);let o=r?r.getTile(t):null;if(!o&&r&&t.canonical.z>r.getSource().minzoom){let e=t.scaledTo(Math.min(r.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=r.getSource().minzoom&&(o=r.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1)}this.currentBuildingBuckets.push({bucket:o?o.getBucket(n):null,tileID:o?o.tileID:t,verticalScale:i})}e.hasAnyZOffset=!1;let n=!1;for(let r=0;r{e in t&&(n[e]=t[e])}),n}function RT(e){e=e.slice();const t=Object.create(null);for(let n=0;n0?(r-o)/a:0;return this.points[i].mult(1-s).add(this.points[t].mult(s))}}class GT{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 qT=100;class WT{constructor(e,t,n=new GT(e.width+200,e.height+200,25),r=new GT(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+qT,this.screenBottomBoundary=e.height+qT,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(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=[],_=this.transform.elevation,g=e.getProjection(),y=_?_.getAtTileOffsetFunc(p,this.transform.center.lat,this.transform.worldSize,g):null,x=new v(n.tileAnchorX,n.tileAnchorY);let{x:b,y:w,z:T}=g.projectTilePoint(x.x,x.y,p.canonical);if(y){const[e,t,n]=y(x);b+=e,w+=t,T+=n}const S="globe"===g.name,E=this.projectAndGetPerspectiveRatio(a,b,w,T,p,S||!!_||this.transform.pitch>0,g),{perspectiveRatio:M}=E,A=(c?o/M:o*M)/24,I=fx(b,w,T,s),C=E.signedDistanceFromCamera>0?gx(A,i,n.lineOffsetX*A,n.lineOffsetY*A,!1,I,x,n,r,s,{},_&&!c?y:null,c&&!!_,g,p,c):null;let k=!1,O=!1,P=!0;if(C&&!E.occluded){const e=.5*d*M+f,n=new v(-100,-100),r=new v(this.screenRightBoundary,this.screenBottomBoundary),i=new VT,{first:o,last:a}=C,s=o.path.length;let c=[];for(let e=s-1;e>=1;e--)c.push(o.path[e]);for(let e=1;e(y&&!S&&(n=y(re[3]<=0)&&(c=[]));let _=[];if(c.length>0){let e=1/0,t=-1/0,i=1/0,o=-1/0;for(const n of c)e=Math.min(e,n[0]),i=Math.min(i,n[1]),t=Math.max(t,n[0]),o=Math.max(o,n[1]);t>=n.x&&e<=r.x&&o>=n.y&&i<=r.y&&(_=[c.map(e=>new v(e[0],e[1]))],(er.x||ir.y)&&(_=lg(_,n.x,n.y,r.x,r.y)))}for(const n of _){i.reset(n,.25*e);let r=0;r=i.length<=.5*e?1:Math.ceil(i.paddedLength/p)+1;for(let n=0;n0?(qh.transformMat4(s,s,e),this.fogState&&i&&"globe"!==a.name&&(l=function(e,t,n,r,i,o){const a=o.calculateFogTileMatrix(i),s=[t,n,r];return id.transformMat4(s,s,a),_w(e,id.length(s),o.pitch,o._fov)}(this.fogState,t,n,r,i.toUnwrapped(),this.transform)>.9)):Sx(s,s,e);const u=s[3];return{point:new v((s[0]/u+1)/2*this.transform.width+qT,(-s[1]/u+1)/2*this.transform.height+qT),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:o&&s[2]>u||l}}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 tS(e,t,n,r,i){const{horizontalAlign:o,verticalAlign:a}=K_(e),s=-(o-.5)*t,l=-(a-.5)*n,u=Ag(e,r);return new v(s+u[0]*i,l+u[1]*i)}function nS(e,t,n,r,i){const o=new v(e,t);return n&&o._rotate(r?i:-i),o}class rS{constructor(e,t,n,r,i,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new WT(this.transform,i),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new eS(n),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,t,n,r){const i=n.getBucket(t),o=n.latestFeatureIndex;if(!i||!o||t.fqid!==i.layerIds[0])return;const a=i.layers[0].layout,s=n.collisionBoxArray,l=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),u=n.tileSize/hr,c=n.tileID.toUnwrapped();this.transform.setProjection(i.projection);const h=(d=n.tileID,f=i.getProjection(),p=this.transform,f.name===this.projection?p.calculateProjMatrix(d.toUnwrapped()):ZT(p,f,d));var d,f,p;const m="map"===a.get("text-pitch-alignment"),_="map"===a.get("text-rotation-alignment");t.compileFilter();const g=t.dynamicFilter(),y=t.dynamicFilterNeedsFeature(),v=this.transform.calculatePixelsToTileUnitsMatrix(n),x=hx(h,n.tileID.canonical,m,_,this.transform,i.getProjection(),v);let b=null;if(m){const e=dx(h,n.tileID.canonical,m,_,this.transform,i.getProjection(),v);b=Jh.multiply([],this.transform.labelPlaneMatrix,e)}let w=null;g&&n.latestFeatureIndex&&(w={unwrappedTileID:c,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:n.latestFeatureIndex}),this.retainedQueryData[i.bucketInstanceId]=new QT(i.bucketInstanceId,o,i.sourceLayerIndex,i.index,n.tileID);const T={bucket:i,layout:a,posMatrix:h,textLabelPlaneMatrix:x,labelToScreenMatrix:b,clippingData:w,scale:l,textPixelRatio:u,holdingForFade:n.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:P_(i.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:P_(i.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(i.sourceID)};if(r)for(const t of i.sortKeyRanges){const{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=t;e.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:T})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:i.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=tS(e,n,r,b,i),T=this.collisionIndex.placeCollisionBox(f,i,t,nS(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,nS(w.x,w.y,o,a,this.transform.angle),c,s,l,u.predicate).box.length)return}if(T.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:T}}}placeLayerBucketPart(e,t,n,r){const{bucket:i,layout:o,posMatrix:a,textLabelPlaneMatrix:s,labelToScreenMatrix:l,clippingData:u,textPixelRatio:c,holdingForFade:h,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:p,collisionGroup:m}=e.parameters,_=o.get("text-optional"),g=o.get("icon-optional"),y=o.get("text-allow-overlap"),x=o.get("icon-allow-overlap"),b="map"===o.get("text-rotation-alignment"),w="map"===o.get("text-pitch-alignment"),T="viewport-y"===o.get("symbol-z-order"),S=o.get("symbol-z-elevate");this.transform.setProjection(i.projection);let E=y&&(x||!i.hasIconData()||g),M=x&&(y||!i.hasTextData()||_);!i.collisionArrays&&d&&i.deserializeCollisionBoxes(d),n&&r&&i.updateCollisionDebugBuffers(this.transform.zoom,d);const A=(e,r,d)=>{const{crossTileID:T,numVerticalGlyphVertices:S}=e;if(u){const n={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(u.dynamicFilterNeedsFeature){const t=this.retainedQueryData[i.bucketInstanceId];r=u.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(n,r,this.retainedQueryData[i.bucketInstanceId].tileID.canonical,new v(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[T]=new KT(!1,!1,!1,!0),void t.add(T)}if(t.has(T))return;if(h)return void(this.placements[T]=new KT(!1,!1,!1));let A=!1,I=!1,C=!0,k=!1,O=!1,P=null,R={box:null,offscreen:null,occluded:null},D={box:null,offscreen:null,occluded:null},L=null,z=null,B=null,F=0,j=0,N=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(j=d.verticalTextFeatureIndex);const U=t=>{t.tileID=this.retainedQueryData[i.bucketInstanceId].tileID;const n=this.transform.elevation;t.elevation=e.zOffset+(n?n.getAtTileOffset(t.tileID,t.tileAnchorX,t.tileAnchorY):0)},V=d.textBox;if(V){U(V);const t=t=>{let n=U_.horizontal;if(i.allowVerticalPlacement&&!t&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[T];t&&(this.placedOrientations[T]=t,n=t,this.markUsedOrientation(i,n,e))}return n},n=(e,t)=>{if(i.allowVerticalPlacement&&S>0&&d.verticalTextBox){for(const n of i.writingModes)if(n===U_.vertical?(R=t(),D=R):R=e(),R&&R.box&&R.box.length)break}else R=e()};if(o.get("text-variable-anchor")){let s=o.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];s.indexOf(e.anchor)>0&&(s=s.filter(t=>t!==e.anchor),s.unshift(e.anchor))}const l=(t,n,o)=>{const l=i.getSymbolInstanceTextSize(f,e,this.transform.zoom,r),u=(t.x2-t.x1)*l+2*t.padding,h=(t.y2-t.y1)*l+2*t.padding,d=e.hasIconTextFit&&!x?n:null;d&&U(d);let _={box:[],offscreen:!1,occluded:!1};const g=y?2*s.length:s.length;for(let n=0;n=s.length,e,r,i,o,d,f,p);if(g&&(_=g.placedGlyphBoxes,_&&_.box&&_.box.length)){A=!0,P=g.shift;break}}return _};n(()=>l(V,d.iconBox,U_.horizontal),()=>{const e=d.verticalTextBox;return e&&U(e),i.allowVerticalPlacement&&!(R&&R.box&&R.box.length)&&S>0&&e?l(e,d.verticalIconBox,U_.vertical):{box:null,offscreen:null,occluded:null}}),R&&(A=R.box,C=R.offscreen,k=R.occluded);const u=t(!(!R||!R.box));if(!A&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[T];t&&(this.variableOffsets[T]=t,this.markUsedJustification(i,t.anchor,e,u))}}else{const o=(t,n)=>{const o=i.getSymbolInstanceTextSize(f,e,this.transform.zoom,r),s=this.collisionIndex.placeCollisionBox(i,o,t,new v(0,0),y,c,a,m.predicate);return s&&s.box&&s.box.length&&(this.markUsedOrientation(i,n,e),this.placedOrientations[T]=n),s};n(()=>o(V,U_.horizontal),()=>{const e=d.verticalTextBox;return i.allowVerticalPlacement&&S>0&&e?(U(e),o(e,U_.vertical)):{box:null,offscreen:null,occluded:null}}),t(!!(R&&R.box&&R.box.length))}}if(L=R,A=L&&L.box&&L.box.length>0,C=L&&L.offscreen,k=L&&L.occluded,e.useRuntimeCollisionCircles){const t=i.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),r=O_(i.textSizeData,f,t),u=o.get("text-padding");z=this.collisionIndex.placeCollisionCircles(i,y,t,i.lineVertexArray,i.glyphOffsetArray,r,a,s,l,n,w,m.predicate,e.collisionCircleDiameter*r/24,u,this.retainedQueryData[i.bucketInstanceId].tileID),A=y||z.circles.length>0&&!z.collisionDetected,C=C&&z.offscreen,k=z.occluded}if(d.iconFeatureIndex&&(N=d.iconFeatureIndex),d.iconBox){const t=t=>{U(t);const n=e.hasIconTextFit&&P?nS(P.x,P.y,b,w,this.transform.angle):new v(0,0),r=i.getSymbolInstanceIconSize(p,this.transform.zoom,e.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(i,r,t,n,x,c,a,m.predicate)};D&&D.box&&D.box.length&&d.verticalIconBox?(B=t(d.verticalIconBox),I=B.box.length>0):(B=t(d.iconBox),I=B.box.length>0),C=C&&B.offscreen,O=B.occluded}const G=_||0===e.numHorizontalGlyphVertices&&0===S,q=g||0===e.numIconVertices;if(G||q?q?G||(I=I&&A):A=I&&A:I=A=I&&A,A&&L&&L.box&&this.collisionIndex.insertCollisionBox(L.box,o.get("text-ignore-placement"),i.bucketInstanceId,D&&D.box&&j?j:F,m.ID),I&&B&&this.collisionIndex.insertCollisionBox(B.box,o.get("icon-ignore-placement"),i.bucketInstanceId,N,m.ID),z&&(A&&this.collisionIndex.insertCollisionCircles(z.circles,o.get("text-ignore-placement"),i.bucketInstanceId,F,m.ID),n)){const e=i.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new JT);for(let e=0;e=0;--t){const n=e[t];A(i.symbolInstances.get(n),n,i.collisionArrays[n])}i.hasAnyZOffset&&X(i.layerIds[0]+" layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y")}else if(i.hasAnyZOffset){const e=i.getSortedIndexesByZOffset();for(let t=0;t=0&&(e.text.placedSymbolArray.get(i).crossTileID=c>=0&&i!==c?0:l),o>=0&&(e.text.placedSymbolArray.get(o).crossTileID=c>=0&&o!==c?0:l),a>=0&&(e.text.placedSymbolArray.get(a).crossTileID=c>=0&&a!==c?0:l),s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=c>=0&&s!==c?0:l)}markUsedOrientation(e,t,n){const r=t===U_.horizontal||t===U_.horizontalOnly?t:0,i=t===U_.vertical?t:0,{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:l}=n,u=e.text.placedSymbolArray;o>=0&&(u.get(o).placedOrientation=r),a>=0&&(u.get(a).placedOrientation=r),s>=0&&(u.get(s).placedOrientation=r),l>=0&&(u.get(l).placedOrientation=i)}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 YT(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 YT(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 YT(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.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,n,r.collisionBoxArray),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,r.tileID),t.updateZOffset()))}}updateBucketOpacities(e,t,n){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const r=e.layers[0].layout,i=!!e.layers[0].dynamicFilter(),o=new YT(null,0,!1,!1,!0),a=r.get("text-allow-overlap"),s=r.get("icon-allow-overlap"),l=r.get("text-variable-anchor"),u="map"===r.get("text-rotation-alignment"),c="map"===r.get("text-pitch-alignment"),h=new YT(null,0,a&&(s||!e.hasIconData()||r.get("icon-optional")),s&&(a||!e.hasTextData()||r.get("text-optional")),!0);!e.collisionArrays&&n&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(n);const d=(e,t,n)=>{for(let r=0;r0||s>0,x=m>0,b=this.placedOrientations[p],w=b===U_.vertical,T=b===U_.horizontal||b===U_.horizontalOnly;if(!y&&!x||g.isHidden()||f++,y){const t=dS(g.text);d(e.text,a,w?fS:t),d(e.text,s,T?fS:t);const n=g.text.isHidden(),{leftJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:u}=r,c=e.text.placedSymbolArray,h=n||w?1:0;i>=0&&(c.get(i).hidden=h),o>=0&&(c.get(o).hidden=h),l>=0&&(c.get(l).hidden=h),u>=0&&(c.get(u).hidden=n||T?1:0);const f=this.variableOffsets[p];f&&this.markUsedJustification(e,f.anchor,r,b);const m=this.placedOrientations[p];m&&(this.markUsedJustification(e,"left",r,m),this.markUsedOrientation(e,m,r))}if(x){const t=dS(g.icon),{placedIconSymbolIndex:n,verticalPlacedIconSymbolIndex:i}=r,o=e.icon.placedSymbolArray,a=g.icon.isHidden()?1:0;n>=0&&(d(e.icon,m,w?fS:t),o.get(n).hidden=a),i>=0&&(d(e.icon,r.numVerticalIconVertices,T?fS:t),o.get(i).hidden=a)}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const t=e.collisionArrays[n];if(t){let n=new v(0,0),o=!0;if(t.textBox||t.verticalTextBox){if(l){const e=this.variableOffsets[p];e?(n=tS(e.anchor,e.width,e.height,e.textOffset,e.textScale),u&&n._rotate(c?this.transform.angle:-this.transform.angle)):o=!1}i&&(o=!g.clipped),t.textBox&&iS(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||w,n.x,n.y),t.verticalTextBox&&iS(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||T,n.x,n.y)}const a=o&&Boolean(!T&&t.verticalIconBox);t.iconBox&&iS(e.iconCollisionBox.collisionVertexArray,g.icon.placed,a,r.hasIconTextFit?n.x:0,r.hasIconTextFit?n.y:0),t.verticalIconBox&&iS(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!a,r.hasIconTextFit?n.x:0,r.hasIconTextFit?n.y:0)}}}if(e.fullyClipped=0===f,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(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 iS(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 oS=Math.pow(2,25),aS=Math.pow(2,24),sS=Math.pow(2,17),lS=Math.pow(2,16),uS=Math.pow(2,9),cS=Math.pow(2,8),hS=Math.pow(2,1);function dS(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*oS+t*aS+n*sS+t*lS+n*uS+t*cS+n*hS+t}const fS=0;class pS{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 e=ft.now()-i;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const i=t[e[this._currentPlacementIndex]],a=this.placement.collisionIndex.transform.zoom;if("symbol"===i.type&&(!i.minzoom||i.minzoom<=a)&&(!i.maxzoom||i.maxzoom>a)){const e=i,t=e.layout.get("symbol-z-elevate"),a=this._inProgressLayer=this._inProgressLayer||new pS(e),s=el(i.source,i.scope);if(a.continuePlacement(t?r[s]:n[s],this.placement,this._showCollisionBoxes,i,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const _S=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class gS{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=_S[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 gS(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=_S.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(yS(t,n,i,r),n[2*o+a]>s&&yS(t,n,i,o);ls;)u--}n[2*i+a]===s?yS(t,n,i,u):(u++,yS(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++)xS(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];xS(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 yS(e,t,n,r){vS(e,n,r),vS(t,2*n,2*r),vS(t,2*n+1,2*r+1)}function vS(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function xS(e,t,n,r){const i=e-n,o=t-r;return i*i+o*o}const bS=.03125;class wS{constructor(e,t,n){this.tileID=e,this.bucketInstanceId=n,this.index=new gS(t.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=e.canonical.x*hr,i=e.canonical.y*hr;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]}}var MS="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w-0.0001;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",AS="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out 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;}",IS="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;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 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*texture(u_dem,pos).r;\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=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;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*texture(u_dem_prev,pos).r;\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=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;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(texture(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(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(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) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return 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",CS="#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;out 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",kS="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in 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 opacity_limit) {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,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}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;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",OS="#ifdef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);vec4 _raTexLinearCoord(vec2 texCoord,vec2 texResolution,out vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return (texCoord.xxyy+vec2(1.5,0.5).xyxy)/texResolution.xxyy;}vec2 _raTexLinearMix(vec2 fxy,vec4 colorMix,float colorOffset,vec4 t00,vec4 t10,vec4 t01,vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec2 fxy;vec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texture(u_image0,c.yz),texture(u_image0,c.xz),texture(u_image0,c.yw),texture(u_image0,c.xw)\n);}vec2 raTexture2D_image1_linear(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec2 fxy;vec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texture(u_image1,c.yz),texture(u_image1,c.xz),texture(u_image1,c.yw),texture(u_image1,c.xw)\n);}vec2 raTexture2D_image0_nearest(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec4 t=texture(u_image0,texCoord);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec4 t=texture(u_image1,texCoord);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",PS="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",RS="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const DS=[];NS(MS,DS);const LS={"_prelude_fog.vertex.glsl":CS,"_prelude_terrain.vertex.glsl":IS,"_prelude_shadow.vertex.glsl":PS,"_prelude_fog.fragment.glsl":kS,"_prelude_shadow.fragment.glsl":RS,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":OS},zS={};US("",IS),US(kS,CS),US(RS,PS),US(OS,"");const BS=US("\nout vec4 glFragColor;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#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif","\n#define EXTENT 8192.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\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;}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+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);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const 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);}"),FS=MS;var jS={background:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin 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\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in 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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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;in vec2 a_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in 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\nuniform float u_emissive_strength;void 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_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\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;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nout vec3 v_data;out 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:US("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:US('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in 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);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nout 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:US("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:US("in float v_placed;in 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);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in float a_size_scale;in vec2 a_padding;in float a_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+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:US("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in 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);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out 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:US("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void 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_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 v_pos;uniform float u_emissive_strength;\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_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in vec2 v_pos;in 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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform 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;in vec2 a_pos;out vec2 v_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in vec2 v_pos;uniform float u_emissive_strength;\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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nuniform float u_emissive_strength;in float v_height;void main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_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);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,v_depth);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,u_emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef RENDER_CUTOFF\ncolor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#ifdef RENDER_CUTOFF\ninvariant gl_Position;\n#endif\nuniform 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;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 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) || defined(LIGHTING_3D_MODE)\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);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\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);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\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=vec2(mix(concave,-concave,start),y_ground);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\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\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=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),fillExtrusionDepth:US("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=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\nvec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\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);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp 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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*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\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform 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;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in 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\nout vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp 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_normal=normal;\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}'),groundShadow:US('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,v_depth));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0)).r);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);v_depth=gl_Position.w;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:US("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;HANDLE_WIREFRAME_DEBUG;\n#endif\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;\n#ifdef FORCE_ABS_FL_GROUND_RADIUS\nfl_ground_radius=abs(flood_light_ground_radius);\n#endif\nfloat flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(1.0,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:US("precision highp float;uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}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));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(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);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\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 lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\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\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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=texture(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=texture(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\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(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);if (border_color.a==0.0) { \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);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trimmed,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin 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;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out 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\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\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\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in 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=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in 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;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;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;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.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_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform vec4 u_tl_br;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#elif defined(PROJECTION_GLOBE_VIEW)\nin vec2 a_pos;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;void main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec2 globe_tl=vec2(u_tl_br.x,u_tl_br.y);vec2 globe_br=vec2(u_tl_br.z,u_tl_br.w);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=1.0-((mercatorY-globe_br.y)/(globe_tl.y-globe_br.y));float mercatorX=mercatorXfromLng(latLng[1]);float uvX=(mercatorX-globe_br.x)/(globe_tl.x-globe_br.x);vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);uv=vec2(uvX,uvY);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 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,u_raster_elevation,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);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\nuv=a_texture_pos/8192.0;\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),symbolIcon:US('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nuniform mediump float u_icon_saturation;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b)*alpha;\n#else\nout_color=texture(u_texture,v_tex_a)*alpha;\n#endif\n#ifdef SATURATION\nvec3 luma=vec3(dot(out_color.rgb,vec3(0.2126,0.7152,0.0722)));out_color.rgb=mix(luma,out_color.rgb,u_icon_saturation);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\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\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\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;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;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;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 out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:US('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in 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\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\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;bool draw_halo=v_draw_halo > 0.0;if (draw_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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in 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 bool u_is_halo;\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\nout float v_draw_halo;out vec2 v_data0;out 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\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\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;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;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;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));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:US('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;in float v_draw_halo;in vec4 v_data0;in 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\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=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;bool draw_halo=v_draw_halo > 0.0;if (draw_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=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in 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;uniform bool u_is_halo;\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\nout float v_draw_halo;out vec4 v_data0;out 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\n#pragma mapbox: define lowp float emissive_strength\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\n#pragma mapbox: initialize lowp float emissive_strength\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;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;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;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\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\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,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,v_depth,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\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\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_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:US("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out 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:US('#include "_prelude_fog.fragment.glsl"\nin 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=texture(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);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',AS),skyboxGradient:US('#include "_prelude_fog.fragment.glsl"\nin 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=texture(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);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',AS),skyboxCapture:US("\nin 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;precision highp float;\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;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out 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:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in 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=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform 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\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;\n#endif\nout vec2 v_pos0;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);globe_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:US('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;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) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp 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;\n#ifdef ALPHA_PASS\nfloat 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);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 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=c2;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\nglFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in 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;out highp vec3 v_ray_dir;out 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);}"),model:US('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\ntexColor.rgb=sRGBToLinear(texColor.rgb);if(u_baseTextureIsAlpha) {if (texColor.w < 0.5) {discard;}albedo*=mix(vec4(texColor.rgb,texColor.a),vec4(texColor.a),float(u_baseTextureIsAlpha));} else {albedo*=texColor;}\n#endif\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 diffuse=getDiffuseShadedColor(getBaseColor().rgb,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(diffuse,1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nao=(texture(u_occlusionTexture,uv_2f).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);color=mix(color,v_color_mix.rgb,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=u_matrix*pos;pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=local_pos;\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normalize(normal_3f));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1);v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:US("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:US("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}")};function NS(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 US(e,t){const n=/#include\s+"([^"]+)"/g,r=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let i=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);i&&(i=i.map(e=>{const t=e.split(" ");return t[t.length-1]}),i=[...new Set(i)]);const o={},a=[],s=[];e=e.replace(n,(e,t)=>(s.push(t),"")),t=t.replace(n,(e,t)=>(a.push(t),""));let l=[...DS];NS(e,l),NS(t,l);for(const e of[...a,...s])LS[e]||console.error("Undefined include: "+e),zS[e]||(zS[e]=[],NS(LS[e],zS[e])),l=[...l,...zS[e]];return{fragmentSource:e=e.replace(r,(e,t,n,r,i)=>(o[i]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${i}\nin ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = u_${i};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\n in ${n} ${r} ${i};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(r,(e,t,n,r,i)=>{const a="float"===r?"vec2":r,s=i.match(/color/)?"color":a;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\nin ${n} ${r} a_${i};\n#endif\n`:o[i]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\nout ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:"initialize"===t?"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = unpack_mix_${s}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\n in ${n} ${r} a_${i};\n out ${n} ${r} ${i};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\n ${i} = a_${i};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:"define-instanced"===t?"mat4"===s?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${i}0;\nin vec4 a_${i}1;\nin vec4 a_${i}2;\nin vec4 a_${i}3;\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${n} ${a} a_${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${i}\n ${n} ${r} ${i} = a_${i};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = unpack_mix_${s}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`}),staticAttributes:i,usedDefines:l,vertexIncludes:a,fragmentIncludes:s}}class VS{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,s){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e{const i=n.paint.get("hillshade-shadow-color"),o=n.paint.get("hillshade-highlight-color"),a=n.paint.get("hillshade-accent-color"),s=n.paint.get("hillshade-emissive-strength");let l=T(n.paint.get("hillshade-illumination-direction"));if("viewport"===n.paint.get("hillshade-illumination-anchor"))l-=e.transform.angle;else if(e.style&&e.style.enable3dLights()&&e.style.directionalLight){const t=e.style.directionalLight.properties.get("direction");l=T(Q(t.x,t.y,t.z)[1])}const u=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),u),u_image:0,u_latrange:GS(0,t.tileID),u_light:[n.paint.get("hillshade-exaggeration"),l],u_shadow:i,u_highlight:o,u_emissive_strength:s,u_accent:a}})(e,n,r,e.terrain?t.projMatrix:null);e.uploadCommonUniforms(s,h,t.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:p,tileBoundsSegments:m}=e.getTileBoundsBuffers(n);h.draw(e,l.TRIANGLES,i,o,a,Dv.disabled,d,r.id,f,p,m)}function WS(e,t,n){if(!t.needsDEMTextureUpload)return;const r=e.context,i=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||e.getTileTexture(n.stride);const o=n.getPixels();t.demTexture?t.demTexture.update(o,{premultiply:!1}):t.demTexture=new Ry(r,o,i.R32F,{premultiply:!1}),t.needsDEMTextureUpload=!1}function ZS(e,t,n){const r=e.context,i=r.gl;if(!t.dem)return;const o=t.dem;if(r.activeTexture.set(i.TEXTURE1),WS(e,t,o),!t.demTexture)return;t.demTexture.bind(i.NEAREST,i.CLAMP_TO_EDGE);const a=o.dim;r.activeTexture.set(i.TEXTURE0);let s=t.hillshadeFBO;if(!s){const e=new Ry(r,{width:a,height:a,data:null},i.RGBA);e.bind(i.LINEAR,i.CLAMP_TO_EDGE),s=t.hillshadeFBO=r.createFramebuffer(a,a,!0,"renderbuffer"),s.colorAttachment.set(e.texture)}r.bindFramebuffer.set(s.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:l,tileBoundsIndexBuffer:u,tileBoundsSegments:c}=e.getMercatorTileBoundsBuffers(),h=[];e.linearFloatFilteringSupported()&&h.push("TERRAIN_DEM_FLOAT_FORMAT"),e.getOrCreateProgram("hillshadePrepare",{defines:h}).draw(e,i.TRIANGLES,Ov.disabled,Pv.disabled,Rv.unblended,Dv.disabled,((e,t)=>{const n=t.stride,r=Jh.create();return Jh.ortho(r,0,hr,-hr,0,0,1),Jh.translate(r,r,[0,-hr,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:e.overscaledZ}})(t.tileID,o),n.id,l,u,c),t.needsHillshadePrepare=!1}const HS=e=>({u_matrix:new bu(e),u_image0:new pu(e),u_skirt_height:new mu(e),u_ground_shadow_factor:new gu(e)}),$S=(e,t,n)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:n}),XS=(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}),YS=(e,t)=>{if(t>0&&e.terrain&&X("Cutoff is currently disabled on terrain"),t<=0||e.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,0]}};const n=e.transform,r=Math.max(Math.abs(n._zoom-(e.minCutoffZoom-1)),1),i=n.isLODDisabled(!1)?P(60,45,n.pitch):P(30,15,n.pitch),o=n._farZ-n._nearZ,a=t*n.height,s=((1-(l=i))*(.75*n.cameraToCenterDistance)+l*(n._farZ+a))*r;var l;return{shouldRenderCutoff:i<1,uniformValues:{u_cutoff_params:[n._nearZ,n._farZ,(s-n._nearZ)/o,(s-a-n._nearZ)/o]}}};function KS(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const JS=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()}},QS={0:null,1:"TERRAIN_VERTEX_MORPHING"};function eE(e,t,n){if(0===t)return 0;const r=t<1&&514===n?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function tE(e,t){const n=1<({u_matrix:e});function rE(e,t,n,r,i){if(i>0){const o=ft.now(),a=(o-e.timeAdded)/i,s=t?(o-t.timeAdded)/i:-1,l=n.getSource(),u=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),c=!t||Math.abs(t.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),h=c&&e.refreshedUponExpiration?1:O(c?a:1-s,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),t?{opacity:1,mix:1-h}:{opacity:h,mix:0}}return{opacity:1,mix:0}}class iE extends zv{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},n=new Ew(Hw(),null),r=ET("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 oE extends zv{constructor(e){const t=ET("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new Ew(Hw(),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(e,t,n){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((t,n)=>{if(t[n.key]="",!this._tiles[n.key]){const t=new Vy(n,this._source.tileSize*n.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[n.key]=t}return t},{});for(const e in this._tiles)e in r||(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 aE extends _d{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 sE extends 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),s=r.upVectorScale(e.canonical,t,n).metersToTile;return id.scale(a,a,o*s),a}}getForTilePoints(e,t,n,r){if(this.isUsingMockSource())return!1;const i=__.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<o||e<0||e>o?24575:0,i=O(Math.round(n),0,hr),a=O(Math.round(e),0,hr);t.emplaceBack(i+r,a)}const a=(e,t)=>{const i=t*r+e;n.emplaceBack(i+1,i,i+r),n.emplaceBack(i+r,i+r+1,i+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return[0,129].forEach(e=>{for(let t=0;t<130;t++)a(t,e),a(e,t)}),[t,n,32768]}(),o=e.context;this.gridBuffer=o.createVertexBuffer(n,hd.members),this.gridIndexBuffer=o.createIndexBuffer(r),this.gridSegments=Ql.simpleSegment(0,0,n.length,r.length),this.gridNoSkirtSegments=Ql.simpleSegment(0,0,n.length,i),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new oE(t.map),this.orthoMatrix=Jh.create(),Jh.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,hr,0,hr,0,1);const a=o.gl;this._overlapStencilMode=new Pv({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=t,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new iE(t.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(e,t,n){if(e&&e.terrain){this._style!==e&&(this.style=e,this._evaluationZoom=void 0);const r=e.terrain.properties,i=0===e.terrain.drapeRenderMode,o=e.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=ft.now();const a=e.terrain&&e.terrain.scope,s=r.get("source"),l=i?this._mockSourceCache:e.getSourceCache(s,a);if(!l)return void X(`Couldn't find terrain source "${s}".`);if(this.sourceCache=l,this._exaggeration=o?this.calculateExaggeration(t):r.get("exaggeration"),!t.projection.requiresDraping&&o&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{this.sourceCache.used&&X(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.getScaledDemTileSize();this.sourceCache.update(t,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),t.updateElevation(!0,n),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(t),this._emptyDEMTextureDirty=!0,this._previousZoom=t.zoom}else this._disable()}calculateExaggeration(e){const t=this._previousCameraAltitude,n=e.getFreeCameraOptions().position.z/e.pixelsPerMeter*e.worldSize;this._previousCameraAltitude=n;const r=null!=t?n-t:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const i=e.zoom,o=this._style.terrain;if(!this._previousUpdateTimestamp)return o.getExaggeration(i);let a=i-this._previousZoom;const s=this._previousUpdateTimestamp;let l=i;null!=this._evaluationZoom&&(l=this._evaluationZoom,Math.abs(i-l)>.5&&(a=.5*(i-l+a)),a*r<0&&(l+=a)),this._evaluationZoom=l;const u=o.getExaggeration(l),c=u===o.getExaggeration(Math.max(0,l-.1));if(c&&Math.abs(u-this._exaggeration)<.01)return u;let h=Math.min(.1,.00375*(this._updateTimestamp-s));return(c||u<.1||Math.abs(a)<1e-4)&&(h=Math.min(.2,4*h)),Yr(this._exaggeration,u,h)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[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),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_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(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const t=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(Cf.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=t.getIds().map(e=>{const r=t.getTileByID(e).tileID;return r.projMatrix=n.calculateProjMatrix(r.toUnwrapped()),r});!function(e,t){const n=t.transform.pointCoordinate(t.transform.getCameraPoint()),r=new v(n.x,n.y);e.sort((e,t)=>{if(t.overscaledZ-e.overscaledZ)return t.overscaledZ-e.overscaledZ;const n=new v(e.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const o=this._style._mergedSourceCaches;for(const t in o){const n=o[t];if(!n.used)continue;if(n!==this.sourceCache&&this.resetTileLookupCache(n.id),this._setupProxiedCoordsForOrtho(n,e[t],i),n.usedForTerrain)continue;const r=e[t];n.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[t.id]=r.map(e=>new aE(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(i),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const n=t.tileID.key;n in a||(this._visibleDemTiles.push(t),a[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),WS(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 e=this.painter.context,t=e.gl;if(!this._emptyDepthBufferTexture){const n=new bp({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new Ry(e,n,t.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 e=this.painter.context,t=e.gl;e.activeTexture.set(t.TEXTURE2);const n=this._getLoadedAreaMinimum(),[r,i]=(()=>{const e=new wp({width:1,height:1},new Float32Array([n]));return[t.R32F,e]})();this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(i,{premultiply:!1}):o=this._emptyDEMTexture=new Ry(e,i,r,{premultiply:!1}),o}setupElevationDraw(e,t,n){const r=this.painter.context,i=r.gl,o={u_dem:2,u_dem_prev:4,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};o.u_exaggeration=this.exaggeration();let a=null,s=null,l=1;if(n&&n.morphing&&this._useVertexMorphing){const t=n.morphing.srcDemTile,r=n.morphing.dstDemTile;l=n.morphing.phase,t&&r&&(this._prepareDemTileUniforms(e,t,o,"_prev")&&(s=t),this._prepareDemTileUniforms(e,r,o)&&(a=r))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?i.LINEAR:i.NEAREST,c=e=>{o.u_dem_size=1===e.size[0]?1:e.size[0]-2};if(s&&a)r.activeTexture.set(i.TEXTURE2),a.demTexture.bind(u(a),i.CLAMP_TO_EDGE),r.activeTexture.set(i.TEXTURE4),s.demTexture.bind(u(s),i.CLAMP_TO_EDGE),a.demTexture&&c(a.demTexture),o.u_dem_lerp=l;else{a=this.terrainTileForTile[e.tileID.key],r.activeTexture.set(i.TEXTURE2);const t=this._prepareDemTileUniforms(e,a,o)?a.demTexture:this.emptyDEMTexture;t.bind(u(a),i.CLAMP_TO_EDGE),c(t)}if(r.activeTexture.set(i.TEXTURE3),n&&n.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(i.NEAREST,i.CLAMP_TO_EDGE),this._depthFBO&&(o.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(i.NEAREST,i.CLAMP_TO_EDGE),o.u_depth_size_inv=[1,1]),n&&n.useMeterToDem&&a){const e=(1<{if(l===n)return;const r=[QS[n],"PROJECTION_GLOBE_VIEW"];c&&r.push("CUSTOM_ANTIALIASING");const i=e.isTileAffectedByFog(t);s=e.getOrCreateProgram("globeRaster",{defines:r,overrideFog:i}),l=n},d=e.colorModeForRenderPass(),f=new Ov(a.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D);JS.update(i);const p=Qd(u),m=[yf(u.center.lng),vf(u.center.lat)],_=e.globeSharedBuffers,g=[u.width*ft.devicePixelRatio,u.height*ft.devicePixelRatio],y=Float32Array.from(u.globeMatrix),v={useDenormalizedUpVectorScale:!0};{const u=e.transform,c=eE(u.zoom,t.exaggeration(),t.sourceCache._source.tileSize);l=-1;const x=a.TRIANGLES;for(const l of r){const r=n.getTile(l),b=Pv.disabled,w=t.prevTerrainTileForTile[l.key],T=t.terrainTileForTile[l.key];KS(w,T)&&JS.newMorphing(l.key,w,T,i,250),o.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=JS.getMorphValuesForProxy(l.key),E=S?1:0;S&&Lt(v,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:M(S.phase)}});const A=Ud(l.canonical),I=of(A.getCenter().lat),C=rf(l.canonical,A,I,u.worldSize/u._pixelsPerMercatorPixel),k=$d(zd(l.canonical)),O=XS(u.expandedFarZProjMatrix,y,p,k,ef(u.zoom),m,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,g,c,C);if(h(l,E),s&&(t.setupElevationDraw(r,s,v),e.uploadCommonUniforms(o,s,l.toUnwrapped()),_)){const[t,n,r]=_.getGridBuffers(I,0!==c);s.draw(e,x,f,b,d,Dv.backCCW,O,"globe_raster",t,n,r)}}}if(_&&(e.renderDefaultNorthPole||e.renderDefaultSouthPole)){const i=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];c&&i.push("CUSTOM_ANTIALIASING"),s=e.getOrCreateProgram("globeRaster",{defines:i});for(const i of r){const{x:r,y:l,z:c}=i.canonical,h=0===l,p=l===(1<t.draw(e,a.TRIANGLES,f,Pv.disabled,d,Dv.disabled,XS(u.expandedFarZProjMatrix,_,_,T,0,m,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,g,0),"globe_pole_raster",n,b,w);t.setupElevationDraw(l,s,v),e.uploadCommonUniforms(o,s,i.toUnwrapped()),h&&e.renderDefaultNorthPole&&S(s,y),p&&e.renderDefaultSouthPole&&(_=Jh.scale(Jh.create(),_,[1,-1,1]),S(s,x))}}}}(e,t,n,r,i);else{const o=e.context,a=o.gl;let s,l;const u=e.shadowRenderer,c=YS(e,e.longestCutoffRange),h=t=>{if(l===t)return;const n=[];n.push(QS[t]),c.shouldRenderCutoff&&n.push("RENDER_CUTOFF"),s=e.getOrCreateProgram("terrainRaster",{defines:n}),l=t},d=e.colorModeForRenderPass(),f=new Ov(a.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D);JS.update(i);const p=e.transform,m=eE(p.zoom,t.exaggeration(),t.sourceCache._source.tileSize);let _=[0,0,0];if(u){const t=e.style.directionalLight,n=e.style.ambientLight;t&&n&&(_=$M(t,n))}{l=-1;const g=a.TRIANGLES,[y,v]=[t.gridIndexBuffer,t.gridSegments];for(const l of r){const r=n.getTile(l),x=Pv.disabled,b=t.prevTerrainTileForTile[l.key],w=t.terrainTileForTile[l.key];KS(b,w)&&JS.newMorphing(l.key,b,w,i,250),o.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=JS.getMorphValuesForProxy(l.key),S=T?1:0;let E;T&&(E={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:M(T.phase)}});const A=$S(l.projMatrix,tE(l.canonical,p.renderWorldCopies)?m/10:m,_);if(h(S),!s)continue;t.setupElevationDraw(r,s,E);const I=l.toUnwrapped();u&&u.setupShadows(I,s),e.uploadCommonUniforms(o,s,I,null,c),s.draw(e,g,f,x,d,Dv.backCCW,A,"terrain_raster",t.gridBuffer,y,v)}}}}(t,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,t.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const t=this.painter,n=this.painter.context,r=this.proxySourceCache,i=this.proxiedCoords[r.id],o=this._drapedRenderBatches.shift(),a=t.style.order,s=[];let l=0;for(const u of i){const i=r.getTileByID(u.proxyTileKey),c=r.proxyCachedFBO[u.key]?r.proxyCachedFBO[u.key][e]:void 0,h=void 0!==c?r.renderCache[c]:this.pool[l++],d=void 0!==c;if(i.texture=h.tex,d&&!h.dirty){s.push(i.tileID);continue}let f;n.bindFramebuffer.set(h.fb.framebuffer),this.renderedToTile=!1,h.dirty&&(n.clear({color:dn.transparent,stencil:0}),h.dirty=!1);for(let e=o.start;e<=o.end;++e){const r=t.style._mergedLayers[a[e]];if(r.isHidden(t.transform.zoom))continue;const i=t.style.getLayerSourceCache(r),o=i?this.proxyToSource[u.key][i.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,h.fb.width,h.fb.height]),f!==(i?i.id:null)&&(this._setupStencil(h,o,r,i),f=i?i.id:null),t.renderLayer(t,i,r,s)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const r=t.style._mergedLayers[a[e]];if(r.isHidden(t.transform.zoom))continue;const i=t.style.getLayerSourceCache(r),o=i?this.proxyToSource[u.key][i.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,h.fb.width,h.fb.height]),f!==(i?i.id:null)&&(this._setupStencil(h,o,r,i),f=i?i.id:null),t.renderLayer(t,i,r,s)}this.renderedToTile?(h.dirty=!0,s.push(i.tileID)):d||--l,5===l&&(l=0,this.renderToBackBuffer(s))}return this.renderToBackBuffer(s),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height]),o.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let n=-1,r=t;for(let i=0;in}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter(e=>e.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 e=this.painter.context,t=e.gl,n=this.drapeBufferSize;e.activeTexture.set(t.TEXTURE0);const r=new Ry(e,{width:n[0],height:n[1],data:null},t.RGBA);r.bind(t.LINEAR,t.CLAMP_TO_EDGE);const i=e.createFramebuffer(n[0],n[1],!0,null);return i.colorAttachment.set(r.texture),i.depthAttachment=new Cv(e,i.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,n[0],n[1]),this._stencilRef=0,i.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):i.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:i,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],n=t.isHidden(this.painter.transform.zoom);return"custom"===t.type?!n&&t.shouldRedrape():!n&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let e=!1;for(const t of this._style.getSources())if(t instanceof Uw){e=!0;break}if(!e)return;const t={};for(let e=0;et>e.end)||X("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=n}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.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(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):Pv.disabled}_renderTileClippingMasks(e,t){const n=this.painter,r=this.painter.context,i=r.gl;n._tileClippingMaskIDs={},r.setColorMode(Rv.disabled),r.setDepthMode(Ov.disabled);const o=n.getOrCreateProgram("clippingMask");for(const r of e){const e=n._tileClippingMaskIDs[r.key]=--t;o.draw(n,i.TRIANGLES,Ov.disabled,new Pv({func:i.ALWAYS,mask:0},e,255,i.KEEP,i.KEEP,i.REPLACE),Rv.disabled,Dv.disabled,nE(r.projMatrix),"$clipping",n.tileExtentBuffer,n.quadTriangleIndexBuffer,n.tileExtentSegments)}}pointCoordinate(e){const t=this.painter.transform;if(e.x<0||e.x>t.width||e.y<0||e.y>t.height)return null;const n=[e.x,e.y,1,1];qh.transformMat4(n,n,t.pixelMatrixInverse),qh.scale(n,n,1/n[3]),n[0]/=t.worldSize,n[1]/=t.worldSize;const r=t._camera.position,i=xf(1,t.center.lat),o=[r[0],r[1],r[2]/i,0],a=id.subtract([],n.slice(0,3),o);id.normalize(a,a);const s=this.raycast(o,a,this._exaggeration);return null!==s&&s?(id.scaleAndAdd(o,o,a,s),o[3]=o[2],o[2]*=i,o):null}drawDepth(){const e=this.painter,t=e.context,n=this.proxySourceCache,r=Math.ceil(e.width),i=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===i||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=t.gl,n=t.createFramebuffer(r,i,!0,"renderbuffer");t.activeTexture.set(e.TEXTURE0);const o=new Ry(t,{width:r,height:i,data:null},e.RGBA);o.bind(e.NEAREST,e.CLAMP_TO_EDGE),n.colorAttachment.set(o.texture);const a=t.createRenderbuffer(t.gl.DEPTH_COMPONENT16,r,i);n.depthAttachment.set(a),this._depthFBO=n,this._depthTexture=o}t.bindFramebuffer.set(this._depthFBO.framebuffer),t.viewport.set([0,0,r,i]),function(e,t,n,r){if("globe"===e.transform.projection.name)return;const i=e.context,o=i.gl;i.clear({depth:1});const a=e.getOrCreateProgram("terrainDepth"),s=new Ov(o.LESS,Ov.ReadWrite,e.depthRangeFor3D);for(const i of r){const r=n.getTile(i),l=$S(i.projMatrix,0,[0,0,0]);t.setupElevationDraw(r,a),a.draw(e,o.TRIANGLES,s,Pv.disabled,Rv.unblended,Dv.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments)}}(e,this,n,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,n){if(e.getSource()instanceof tw)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 v(Number.MAX_VALUE,Number.MAX_VALUE),max:new v(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(e,t)=>{const n=e.wrap+e.canonical.x/(1<o+l.max.x||r+ia+l.max.y};for(let o=0;oe.key===t.tileID.key);if(e)return e}if(t.tileID.key!==e.key){const n=e.canonical.z-t.tileID.canonical.z;let i,o,a;r=Jh.create();const s=t.tileID.wrap-e.wrap<0?(i=hr>>n,o=i*((t.tileID.canonical.x<=r){const n=e.canonical.z-r;t.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,t.transform.tileZoom),o=new _d(a,e.wrap,r,e.canonical.x>>n,e.canonical.y>>n)):0!==n&&(a=r,o=new _d(a,e.wrap,r,e.canonical.x>>n,e.canonical.y>>n))}o.key!==e.key&&(l.push(o.key),n=t.getTile(o))}const u=e=>{l.forEach(t=>{r[t]=e}),l.length=0};for(a-=1;a>=s&&(!n||!n.hasData());a--){n&&u(n.tileID.key);const e=o.calculateScaledKey(a);if(n=t.getTileByID(e),n&&n.hasData())break;const i=r[e];if(null===i)break;void 0===i?l.push(e):n=t.getTileByID(i)}return u(n?n.tileID.key:null),n&&n.hasData()?n: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}}function lE(e,t,n){const r=function(e,t,n){const r=id.dot(t,e),i=id.dot(n,[.2126,.7152,.0722]),o=(e,t,n)=>(1-n)*e+n*t,a=o(1-.3*Math.min(i,1),1,Math.min(r+1,1));return o(.92,1,Math.asin(O(t[2],-1,1))/Math.PI+.5)*a}(e,[0,0,1],t),i=[0,0,0];id.scale(i,n.slice(0,3),r);const o=[0,0,0];id.scale(o,t.slice(0,3),e[2]);const a=[0,0,0];return id.add(a,i,o),le(a)}const uE=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],cE=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class hE{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(e,t,n,r,i,o){const a=e.gl;this.program=a.createProgram(),this.configuration=r,this.name=t,this.fixedDefines=[...o];const s=r?r.getBinderAttributes():[],l=(n.staticAttributes||[]).concat(s);let u=r?r.defines():[];u=u.concat(o.map(e=>"#define "+e));const c="#version 300 es\n";let h=c+u.concat("precision mediump float;",FS,BS.fragmentSource).join("\n");for(const e of n.fragmentIncludes)h+="\n"+LS[e];h+="\n"+n.fragmentSource;let d=c+u.concat("precision highp float;",FS,BS.vertexSource).join("\n");for(const e of n.vertexIncludes)d+="\n"+LS[e];d+="\n"+n.vertexSource;const f=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(f,h),a.compileShader(f),a.attachShader(this.program,f);const p=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(p,d),a.compileShader(p),a.attachShader(this.program,p),this.attributes={},this.numAttributes=l.length;for(let e=0;e({u_dem:new pu(e),u_dem_prev:new pu(e),u_dem_tl:new _u(e),u_dem_scale:new mu(e),u_dem_tl_prev:new _u(e),u_dem_scale_prev:new mu(e),u_dem_size:new mu(e),u_dem_lerp:new mu(e),u_exaggeration:new mu(e),u_depth:new pu(e),u_depth_size_inv:new _u(e),u_meter_to_dem:new mu(e),u_label_plane_matrix_inv:new bu(e)}))(e)),o.includes("GLOBE")&&(this.globeUniforms=(e=>({u_tile_tl_up:new gu(e),u_tile_tr_up:new gu(e),u_tile_br_up:new gu(e),u_tile_bl_up:new gu(e),u_tile_up_scale:new mu(e)}))(e)),o.includes("FOG")&&(this.fogUniforms=(e=>({u_fog_matrix:new bu(e),u_fog_range:new _u(e),u_fog_color:new yu(e),u_fog_horizon_blend:new mu(e),u_fog_vertical_limit:new _u(e),u_fog_temporal_offset:new mu(e),u_frustum_tl:new gu(e),u_frustum_tr:new gu(e),u_frustum_br:new gu(e),u_frustum_bl:new gu(e),u_globe_pos:new gu(e),u_globe_radius:new mu(e),u_globe_transition:new mu(e),u_is_globe:new pu(e),u_viewport:new _u(e)}))(e)),o.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(e=>({u_cutoff_params:new yu(e)}))(e)),o.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(e=>({u_lighting_ambient_color:new gu(e),u_lighting_directional_dir:new gu(e),u_lighting_directional_color:new gu(e),u_ground_radiance:new gu(e)}))(e)),o.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(e=>({u_light_matrix_0:new bu(e),u_light_matrix_1:new bu(e),u_fade_range:new _u(e),u_shadow_normal_offset:new gu(e),u_shadow_intensity:new mu(e),u_shadow_texel_size:new mu(e),u_shadow_map_resolution:new mu(e),u_shadow_direction:new gu(e),u_shadow_bias:new gu(e),u_shadowmap_0:new pu(e),u_shadowmap_1:new pu(e)}))(e))}}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])}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const n=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const n=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const n=this.shadowUniforms;e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}_drawDebugWireframe(e,t,n,r,i,o,a,s,l,u){const c=e.options.wireframe;if(!1===c.terrain&&!1===c.layers2D&&!1===c.layers3D)return;const h=e.context;if(!(()=>!(!c.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!c.layers2D||e._terrain&&e._terrain.renderingToTexture||!uE.includes(this.name))||!(!c.layers3D||!cE.includes(this.name)))())return;const d=h.gl,f=e.wireframeDebugCache.getLinesFromTrianglesBuffer(e.frameCounter,i,h);if(!f)return;const p=[...this.fixedDefines];p.push("DEBUG_WIREFRAME");const m=e.getOrCreateProgram(this.name,{config:this.configuration,defines:p});h.program.set(m.program);const _=(e,t,n)=>{if(t[e]&&n[e])for(const r in t[e])n[e][r]&&n[e][r].set(n.program,r,t[e][r].current)};l&&l.setUniforms(m.program,h,m.binderUniforms,a,{zoom:s}),_("fixedUniforms",this,m),_("terrainUniforms",this,m),_("globeUniforms",this,m),_("fogUniforms",this,m),_("lightsUniforms",this,m),_("shadowUniforms",this,m),f.bind(),h.setColorMode(new Rv([d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ZERO,d.ONE],dn.transparent,[!0,!0,!0,!1])),h.setDepthMode(new Ov(t.func===d.LESS?d.LEQUAL:t.func,Ov.ReadOnly,t.range)),h.setStencilMode(Pv.disabled);const g=3*o.primitiveLength*2,y=3*o.primitiveOffset*2*2;u&&u>1?d.drawElementsInstanced(d.LINES,g,d.UNSIGNED_SHORT,y,u):d.drawElements(d.LINES,g,d.UNSIGNED_SHORT,y),i.bind(),h.program.set(this.program),h.setDepthMode(t),h.setStencilMode(n),h.setColorMode(r)}draw(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m){const _=e.context,g=_.gl;if(this.failedToCreate)return;_.program.set(this.program),_.setDepthMode(n),_.setStencilMode(r),_.setColorMode(i),_.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);f&&f.setUniforms(this.program,_,this.binderUniforms,h,{zoom:d});const y={[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],v=m&&m>0?1:void 0;for(const o of c.get()){const a=o.vaos||(o.vaos={});(a[s]||(a[s]=new VS)).bind(_,this,l,f?f.getPaintVertexBuffers():[],u,o.vertexOffset,p||[],v),m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2,m):g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2),t===g.TRIANGLES&&this._drawDebugWireframe(e,n,r,i,u,o,h,d,f,m)}}}function dE(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?t.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/ox(t,1,e.transform.tileZoom),u_pixel_coord_upper:[i>>16,o>>16],u_pixel_coord_lower:[65535&i,65535&o]}}const fE=Jh.create(),pE=(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m)=>{const _=t.style.light,g=_.properties.get("position"),y=[g.x,g.y,g.z],v=Yh.create();"viewport"===_.properties.get("anchor")&&(Yh.fromRotation(v,-t.transform.angle),id.transformMat3(y,y,v));const x=_.properties.get("color"),b=t.transform,w={u_matrix:e,u_lightpos:y,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[x.r,x.g,x.b],u_vertical_gradient:+n,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:fE,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:i,u_edge_radius:o,u_flood_light_color:h,u_vertical_scale:d,u_flood_light_intensity:f,u_ground_shadow_factor:p,u_emissive_strength:m};return"globe"===b.projection.name&&(w.u_tile_id=[a.canonical.x,a.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_vertical_scale:n}),_E=(e,t,n,r,i,o,a,s,l,u,c,h,d,f)=>{const p=pE(e,t,n,r,i,o,a,l,u,c,h,d,f,1,[0,0,0],0),m={u_height_factor:-Math.pow(2,a.overscaledZ)/s.tileSize/8};return z(p,dE(t,s),m)},gE=(e,t)=>({u_matrix:e,u_emissive_strength:t}),yE=(e,t,n,r)=>z(gE(e,t),dE(n,r)),vE=(e,t,n)=>({u_matrix:e,u_world:n,u_emissive_strength:t}),xE=(e,t,n,r,i)=>z(yE(e,t,n,r),{u_world:i}),bE=(e,t,n,r)=>{const i=hr/n.tileSize;return{u_matrix:e,u_camera_to_center_distance:t.getCameraToCenterDistance(r),u_extrude_scale:[t.pixelsToGLUnits[0]/i,t.pixelsToGLUnits[1]/i]}},wE=(e,t,n=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:n}),TE=Jh.create(),SE=(e,t,n,r,i,o,a)=>{const s=e.transform,l="globe"===s.projection.name,u=l?Kd(s.zoom,t.canonical)*s._pixelsPerMercatorPixel:ox(n,1,o),c={u_matrix:t.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:TE,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=r,c.u_merc_center=i,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{return{u_matrix:e,u_normalize_matrix:t,u_globe_matrix:n,u_merc_matrix:r,u_grid_matrix:i,u_tl_parent:o,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:(T=d.paint.get("raster-saturation"),T>0?1-1/(1.001-T):-T),u_contrast_factor:(w=d.paint.get("raster-contrast"),w>0?1/(1-w):1+w),u_spin_weights:ME(d.paint.get("raster-hue-rotate")),u_perspective_transform:f,u_raster_elevation:p,u_tl_br:a,u_zoom_transition:s,u_merc_center:l,u_cutoff_params:u,u_colorization_mix:AE(_,y),u_colorization_offset:IE(g,y),u_color_ramp:m,u_texture_offset:[x/(v+2*x),v/(v+2*x)],u_texture_res:[v+2*x,v+2*x],u_emissive_strength:b};var w,T};function ME(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]}function AE([e,t,n,r],[i,o]){if(i===o)return[0,0,0,0];const a=259/257/(o-i);return[e*a,t*a,n*a,r*a]}function IE(e,[t,n]){return t===n?0:((e-t)/(n-t)*259-1)/257}const CE=Jh.create(),kE=(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g)=>{const y=i.transform,v={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:y.getCameraToCenterDistance(m),u_rotate_symbol:+n,u_aspect_ratio:y.width/y.height,u_fade_change:i.options.fadeDuration?i.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:a,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:CE,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:CE,u_up_vector:[0,-1,0],u_icon_transition:g||0,u_icon_saturation:_};return"globe"===m.name&&(v.u_tile_id=[c.canonical.x,c.canonical.y,1<z(kE(e,t,n,r,i,o,a,s,l,u,h,d,f,p,m,_,1),{u_gamma_scale:r?i.transform.getCameraToCenterDistance(_)*Math.cos(i.terrain?0:i.transform._pitch):1,u_device_pixel_ratio:ft.devicePixelRatio,u_is_halo:+c,undefined:void 0}),PE=(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m)=>z(OE(e,t,n,r,i,o,a,s,!0,l,!0,c,h,d,f,p,m),{u_texsize_icon:u,u_texture_icon:1}),RE=(e,t,n,r)=>({u_matrix:e,u_emissive_strength:t,u_opacity:n,u_color:r}),DE=(e,t,n,r,i,o,a)=>z(function(e,t,n,r){const i=n.imageManager.getPattern(e.toString(),t),{width:o,height:a}=n.imageManager.getPixelSize(t),s=Math.pow(2,r.tileID.overscaledZ),l=r.tileSize*Math.pow(2,n.transform.tileZoom)/s,u=l*(r.tileID.canonical.x+r.tileID.wrap*s),c=l*r.tileID.canonical.y;return{u_image:0,u_pattern_tl:i.tl,u_pattern_br:i.br,u_texsize:[o,a],u_pattern_size:i.displaySize,u_tile_units_to_pixels:1/ox(r,1,n.transform.tileZoom),u_pixel_coord_upper:[u>>16,c>>16],u_pixel_coord_lower:[65535&u,65535&c]}}(i,o,r,a),{u_matrix:e,u_emissive_strength:t,u_opacity:n}),LE=5,zE=6,BE=7,FE=8,jE=9,NE=10,UE=(e,t,n,r,i,o,a,s,l,u,c,h,d=[0,0,0])=>{const f=r.style.light,p=f.properties.get("position"),m=[-p.x,-p.y,p.z],_=Yh.create();"viewport"===f.properties.get("anchor")&&(Yh.fromRotation(_,-r.transform.angle),id.transformMat3(m,m,_));const g="MASK"===u.alphaMode,y=f.properties.get("color"),v=h.paint.get("model-ambient-occlusion-intensity"),x=h.paint.get("model-color").constantOr(dn.white),b=h.paint.get("model-color-mix-intensity").constantOr(0);return{u_matrix:e,u_lighting_matrix:t,u_normal_matrix:n,u_lightpos:m,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_camera_pos:d,u_opacity:i,u_baseTextureIsAlpha:0,u_alphaMask:+g,u_alphaCutoff:u.alphaCutoff,u_baseColorFactor:[o.r,o.g,o.b,o.a],u_emissiveFactor:[a[0],a[1],a[2],1],u_metallicFactor:s,u_roughnessFactor:l,u_baseColorTexture:LE,u_metallicRoughnessTexture:zE,u_normalTexture:BE,u_occlusionTexture:FE,u_emissionTexture:jE,u_color_mix:[x.r,x.g,x.b,b],u_aoIntensity:v,u_emissive_strength:c}},VE=new Float32Array(16),GE=(e,t=VE,n=VE)=>({u_matrix:e,u_instance:t,u_node_matrix:n}),qE={fillExtrusion:e=>({u_matrix:new bu(e),u_lightpos:new gu(e),u_lightintensity:new mu(e),u_lightcolor:new gu(e),u_vertical_gradient:new mu(e),u_opacity:new mu(e),u_edge_radius:new mu(e),u_ao:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_up_dir:new gu(e),u_height_lift:new mu(e),u_flood_light_color:new gu(e),u_vertical_scale:new mu(e),u_flood_light_intensity:new mu(e),u_ground_shadow_factor:new gu(e),u_emissive_strength:new mu(e)}),fillExtrusionDepth:e=>({u_matrix:new bu(e),u_edge_radius:new mu(e),u_vertical_scale:new mu(e)}),fillExtrusionPattern:e=>({u_matrix:new bu(e),u_lightpos:new gu(e),u_lightintensity:new mu(e),u_lightcolor:new gu(e),u_vertical_gradient:new mu(e),u_height_factor:new mu(e),u_edge_radius:new mu(e),u_ao:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_up_dir:new gu(e),u_height_lift:new mu(e),u_image:new pu(e),u_texsize:new _u(e),u_pixel_coord_upper:new _u(e),u_pixel_coord_lower:new _u(e),u_tile_units_to_pixels:new mu(e),u_opacity:new mu(e)}),fillExtrusionGroundEffect:e=>({u_matrix:new bu(e),u_opacity:new mu(e),u_ao_pass:new mu(e),u_meter_to_tile:new mu(e),u_ao:new _u(e),u_flood_light_intensity:new mu(e),u_flood_light_color:new gu(e),u_attenuation:new mu(e),u_edge_radius:new mu(e),u_fb:new pu(e),u_fb_size:new mu(e)}),fill:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e)}),fillPattern:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_image:new pu(e),u_texsize:new _u(e),u_pixel_coord_upper:new _u(e),u_pixel_coord_lower:new _u(e),u_tile_units_to_pixels:new mu(e)}),fillOutline:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_world:new _u(e)}),fillOutlinePattern:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_world:new _u(e),u_image:new pu(e),u_texsize:new _u(e),u_pixel_coord_upper:new _u(e),u_pixel_coord_lower:new _u(e),u_tile_units_to_pixels:new mu(e)}),circle:e=>({u_camera_to_center_distance:new mu(e),u_extrude_scale:new Eu(e),u_device_pixel_ratio:new mu(e),u_matrix:new bu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_up_dir:new gu(e),u_emissive_strength:new mu(e)}),collisionBox:e=>({u_matrix:new bu(e),u_camera_to_center_distance:new mu(e),u_extrude_scale:new _u(e)}),collisionCircle:e=>({u_matrix:new bu(e),u_inv_matrix:new bu(e),u_camera_to_center_distance:new mu(e),u_viewport_size:new _u(e)}),debug:e=>({u_color:new vu(e),u_matrix:new bu(e),u_overlay:new pu(e),u_overlay_scale:new mu(e)}),clippingMask:e=>({u_matrix:new bu(e)}),heatmap:e=>({u_extrude_scale:new mu(e),u_intensity:new mu(e),u_matrix:new bu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_up_dir:new gu(e)}),heatmapTexture:e=>({u_image:new pu(e),u_color_ramp:new pu(e),u_opacity:new mu(e)}),hillshade:e=>({u_matrix:new bu(e),u_image:new pu(e),u_latrange:new _u(e),u_light:new _u(e),u_shadow:new vu(e),u_highlight:new vu(e),u_emissive_strength:new mu(e),u_accent:new vu(e)}),hillshadePrepare:e=>({u_matrix:new bu(e),u_image:new pu(e),u_dimension:new _u(e),u_zoom:new mu(e)}),line:e=>({u_matrix:new bu(e),u_pixels_to_tile_units:new Eu(e),u_device_pixel_ratio:new mu(e),u_units_to_pixels:new _u(e),u_dash_image:new pu(e),u_gradient_image:new pu(e),u_image_height:new mu(e),u_texsize:new _u(e),u_tile_units_to_pixels:new mu(e),u_alpha_discard_threshold:new mu(e),u_trim_offset:new _u(e),u_emissive_strength:new mu(e)}),linePattern:e=>({u_matrix:new bu(e),u_texsize:new _u(e),u_pixels_to_tile_units:new Eu(e),u_device_pixel_ratio:new mu(e),u_image:new pu(e),u_units_to_pixels:new _u(e),u_tile_units_to_pixels:new mu(e),u_alpha_discard_threshold:new mu(e)}),raster:e=>({u_matrix:new bu(e),u_normalize_matrix:new bu(e),u_globe_matrix:new bu(e),u_merc_matrix:new bu(e),u_grid_matrix:new Tu(e),u_tl_parent:new _u(e),u_scale_parent:new mu(e),u_fade_t:new mu(e),u_opacity:new mu(e),u_image0:new pu(e),u_image1:new pu(e),u_brightness_low:new mu(e),u_brightness_high:new mu(e),u_saturation_factor:new mu(e),u_contrast_factor:new mu(e),u_spin_weights:new gu(e),u_perspective_transform:new _u(e),u_raster_elevation:new mu(e),u_tl_br:new yu(e),u_zoom_transition:new mu(e),u_merc_center:new _u(e),u_cutoff_params:new yu(e),u_colorization_mix:new yu(e),u_colorization_offset:new mu(e),u_color_ramp:new pu(e),u_texture_offset:new _u(e),u_texture_res:new _u(e),u_emissive_strength:new mu(e)}),symbolIcon:e=>({u_is_size_zoom_constant:new pu(e),u_is_size_feature_constant:new pu(e),u_size_t:new mu(e),u_size:new mu(e),u_camera_to_center_distance:new mu(e),u_rotate_symbol:new pu(e),u_aspect_ratio:new mu(e),u_fade_change:new mu(e),u_matrix:new bu(e),u_label_plane_matrix:new bu(e),u_coord_matrix:new bu(e),u_is_text:new pu(e),u_pitch_with_map:new pu(e),u_texsize:new _u(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_camera_forward:new gu(e),u_tile_matrix:new bu(e),u_up_vector:new gu(e),u_ecef_origin:new gu(e),u_texture:new pu(e),u_icon_transition:new mu(e),u_icon_saturation:new mu(e)}),symbolSDF:e=>({u_is_size_zoom_constant:new pu(e),u_is_size_feature_constant:new pu(e),u_size_t:new mu(e),u_size:new mu(e),u_camera_to_center_distance:new mu(e),u_rotate_symbol:new pu(e),u_aspect_ratio:new mu(e),u_fade_change:new mu(e),u_matrix:new bu(e),u_label_plane_matrix:new bu(e),u_coord_matrix:new bu(e),u_is_text:new pu(e),u_pitch_with_map:new pu(e),u_texsize:new _u(e),u_texture:new pu(e),u_gamma_scale:new mu(e),u_device_pixel_ratio:new mu(e),u_tile_id:new gu(e),u_zoom_transition:new mu(e),u_inv_rot_matrix:new bu(e),u_merc_center:new _u(e),u_camera_forward:new gu(e),u_tile_matrix:new bu(e),u_up_vector:new gu(e),u_ecef_origin:new gu(e),u_is_halo:new pu(e)}),symbolTextAndIcon:e=>({u_is_size_zoom_constant:new pu(e),u_is_size_feature_constant:new pu(e),u_size_t:new mu(e),u_size:new mu(e),u_camera_to_center_distance:new mu(e),u_rotate_symbol:new pu(e),u_aspect_ratio:new mu(e),u_fade_change:new mu(e),u_matrix:new bu(e),u_label_plane_matrix:new bu(e),u_coord_matrix:new bu(e),u_is_text:new pu(e),u_pitch_with_map:new pu(e),u_texsize:new _u(e),u_texsize_icon:new _u(e),u_texture:new pu(e),u_texture_icon:new pu(e),u_gamma_scale:new mu(e),u_device_pixel_ratio:new mu(e),u_is_halo:new pu(e)}),background:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_opacity:new mu(e),u_color:new vu(e)}),backgroundPattern:e=>({u_matrix:new bu(e),u_emissive_strength:new mu(e),u_opacity:new mu(e),u_image:new pu(e),u_pattern_tl:new _u(e),u_pattern_br:new _u(e),u_texsize:new _u(e),u_pattern_size:new _u(e),u_pixel_coord_upper:new _u(e),u_pixel_coord_lower:new _u(e),u_tile_units_to_pixels:new mu(e)}),terrainRaster:HS,terrainDepth:HS,skybox:e=>({u_matrix:new bu(e),u_sun_direction:new gu(e),u_cubemap:new pu(e),u_opacity:new mu(e),u_temporal_offset:new mu(e)}),skyboxGradient:e=>({u_matrix:new bu(e),u_color_ramp:new pu(e),u_center_direction:new gu(e),u_radius:new mu(e),u_opacity:new mu(e),u_temporal_offset:new mu(e)}),skyboxCapture:e=>({u_matrix_3f:new Tu(e),u_sun_direction:new gu(e),u_sun_intensity:new mu(e),u_color_tint_r:new yu(e),u_color_tint_m:new yu(e),u_luminance:new mu(e)}),globeRaster:e=>({u_proj_matrix:new bu(e),u_globe_matrix:new bu(e),u_normalize_matrix:new bu(e),u_merc_matrix:new bu(e),u_zoom_transition:new mu(e),u_merc_center:new _u(e),u_image0:new pu(e),u_grid_matrix:new Tu(e),u_skirt_height:new mu(e),u_frustum_tl:new gu(e),u_frustum_tr:new gu(e),u_frustum_br:new gu(e),u_frustum_bl:new gu(e),u_globe_pos:new gu(e),u_globe_radius:new mu(e),u_viewport:new _u(e)}),globeAtmosphere:e=>({u_frustum_tl:new gu(e),u_frustum_tr:new gu(e),u_frustum_br:new gu(e),u_frustum_bl:new gu(e),u_horizon:new mu(e),u_transition:new mu(e),u_fadeout_range:new mu(e),u_color:new yu(e),u_high_color:new yu(e),u_space_color:new yu(e),u_temporal_offset:new mu(e),u_horizon_angle:new mu(e)}),model:e=>({u_matrix:new bu(e),u_lighting_matrix:new bu(e),u_normal_matrix:new bu(e),u_lightpos:new gu(e),u_lightintensity:new mu(e),u_lightcolor:new gu(e),u_camera_pos:new gu(e),u_opacity:new mu(e),u_baseColorFactor:new yu(e),u_emissiveFactor:new yu(e),u_metallicFactor:new mu(e),u_roughnessFactor:new mu(e),u_baseTextureIsAlpha:new pu(e),u_alphaMask:new pu(e),u_alphaCutoff:new mu(e),u_baseColorTexture:new pu(e),u_metallicRoughnessTexture:new pu(e),u_normalTexture:new pu(e),u_occlusionTexture:new pu(e),u_emissionTexture:new pu(e),u_color_mix:new yu(e),u_aoIntensity:new mu(e),u_emissive_strength:new mu(e)}),modelDepth:e=>({u_matrix:new bu(e),u_instance:new bu(e),u_node_matrix:new bu(e)}),groundShadow:e=>({u_matrix:new bu(e),u_ground_shadow_factor:new gu(e)}),stars:e=>({u_matrix:new bu(e),u_up:new gu(e),u_right:new gu(e),u_intensity_multiplier:new mu(e)})};let WE;function ZE(e,t,n,r,i,o,a){const s=e.context,l=s.gl,u=e.transform,c=e.getOrCreateProgram("collisionBox"),h=[];let d=0,f=0;for(let s=0;s0){const e=Jh.create(),t=y;Jh.mul(e,_.placementInvProjMatrix,u.glCoordMatrix),Jh.mul(e,e,_.placementViewportMatrix),h.push({circleArray:x,circleOffset:f,transform:t,invTransform:e,projection:_.getProjection()}),d+=x.length/4,f=d}v&&(e.terrain&&e.terrain.setupElevationDraw(m,c),c.draw(e,l.LINES,Ov.disabled,Pv.disabled,e.colorModeForRenderPass(),Dv.disabled,bE(y,u,m,_.getProjection()),n.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,null,u.zoom,null,[v.collisionVertexBuffer,v.collisionVertexBufferExt]))}if(!a||!h.length)return;const p=e.getOrCreateProgram("collisionCircle"),m=new El;m.resize(4*d),m._trim();let _=0;for(const e of h)for(let t=0;t=0&&(p[v.associatedIconIndex]={x:S,y:E,z:M,angle:O})}else Tx(w,d)}if(c){f.clear();const t=e.icon.placedSymbolArray;for(let e=0;e0&&Q.push("ICON_TRANSITION"),h.zOffsetVertexBuffer&&Q.push("Z_OFFSET");const ee=f&&0!==n.paint.get(i?"text-halo-width":"icon-halo-width").constantOr(1);let te;f?te=l.iconsInText?PE(w.kind,k,v,g,e,$,X,Y,O,L,s,j,T,K,F,l.getProjection()):OE(w.kind,k,v,g,e,$,X,Y,i,O,!0,s,j,T,K,F,l.getProjection()):(c<1&&Q.push("SATURATION"),te=kE(w.kind,k,v,g,e,$,X,Y,i,O,s,j,T,K,F,l.getProjection(),c,J));const ne={program:e.getOrCreateProgram(YE(f,i,l),{config:d,defines:Q}),buffers:h,uniformValues:te,atlasTexture:P,atlasTextureIcon:z,atlasInterpolation:R,atlasInterpolationIcon:D,isSDF:f,hasHalo:ee,tile:r,labelPlaneMatrixInv:G};if(x&&l.canOverlap){b=!0;const e=h.segments.get();for(const t of e)M.push({segments:new Ql([t]),sortKey:t.sortKey,state:ne})}else M.push({segments:h.segments,sortKey:0,state:ne})}b&&M.sort((e,t)=>e.sortKey-t.sortKey);for(const t of M){const r=t.state;if(e.terrain&&e.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:m.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:r.labelPlaneMatrixInv}),f.activeTexture.set(p.TEXTURE0),r.atlasTexture&&r.atlasTexture.bind(r.atlasInterpolation,p.CLAMP_TO_EDGE),r.atlasTextureIcon&&(f.activeTexture.set(p.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),e.uploadCommonLightUniforms(e.context,r.program),r.hasHalo){const i=r.uniformValues;i.u_is_halo=1,JE(r.buffers,t.segments,n,e,r.program,w,h,d,i,2),i.u_is_halo=0}else{if(r.isSDF){const i=r.uniformValues;r.hasHalo&&(i.u_is_halo=1,JE(r.buffers,t.segments,n,e,r.program,w,h,d,i,1)),i.u_is_halo=0}JE(r.buffers,t.segments,n,e,r.program,w,h,d,r.uniformValues,1)}}}function JE(e,t,n,r,i,o,a,s,l,u){const c=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];i.draw(r,r.context.gl.TRIANGLES,o,a,s,Dv.disabled,l,n.id,e.layoutVertexBuffer,e.indexBuffer,t,n.paint,r.transform.zoom,e.programConfigurations.get(n.id),c,u)}function QE(e,t,n,r,i,o,a){const s=e.context.gl,l=n.paint.get("fill-pattern"),u=l&&l.constantOr(1);let c,h,d,f,p;a?(h=u&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",c=s.LINES):(h=u?"fillPattern":"fill",c=s.TRIANGLES);for(const m of r){const r=t.getTile(m);if(u&&!r.patternsLoaded())continue;const _=r.getBucket(n);if(!_)continue;e.prepareDrawTile();const g=_.programConfigurations.get(n.id),y=e.isTileAffectedByFog(m),v=e.getOrCreateProgram(h,{config:g,overrideFog:y});u&&(e.context.activeTexture.set(s.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),g.updatePaintBuffers());const x=l.constantOr(null);if(x&&r.imageAtlas){const e=r.imageAtlas.patternPositions[x.toString()];e&&g.setConstantPatternPositions(e)}const b=e.translatePosMatrix(m.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor")),w=n.paint.get("fill-emissive-strength");if(a){f=_.indexBuffer2,p=_.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[s.drawingBufferWidth,s.drawingBufferHeight];d="fillOutlinePattern"===h&&u?xE(b,w,e,r,t):vE(b,w,t)}else f=_.indexBuffer,p=_.segments,d=u?yE(b,w,e,r):gE(b,w);e.uploadCommonUniforms(e.context,v,m.toUnwrapped()),v.draw(e,c,i,e.stencilModeForClipping(m),o,Dv.disabled,d,n.id,_.layoutVertexBuffer,f,p,n.paint,e.transform.zoom,g,void 0)}}function eM(e,t,n,r,i,o,a,s){n.resetLayerRenderingStats();const l=e.context,u=l.gl,c=e.transform,h=n.paint.get("fill-extrusion-pattern"),d=h.constantOr(1),f=n.paint.get("fill-extrusion-opacity"),p=e.style.enable3dLights(),m=n.paint.get(p&&!d?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),_=[n.paint.get("fill-extrusion-ambient-occlusion-intensity"),m],g=n.layout.get("fill-extrusion-edge-radius"),y=g>0&&!n.paint.get("fill-extrusion-rounded-roof"),v=y?0:g,x="globe"===c.projection.name?Ob():0,b="globe"===c.projection.name,w=b?ef(c.zoom):0,T=[yf(c.center.lng),vf(c.center.lat)],S=n.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),E=n.paint.get("fill-extrusion-flood-light-intensity"),M=n.paint.get("fill-extrusion-vertical-scale"),A=YS(e,n.paint.get("fill-extrusion-cutoff-fade-range")),I=n.paint.get("fill-extrusion-emissive-strength"),C=[];let k;b&&C.push("PROJECTION_GLOBE_VIEW"),_[0]>0&&C.push("FAUX_AO"),y&&C.push("ZERO_ROOF_RADIUS"),s&&C.push("HAS_CENTROID"),E>0&&C.push("FLOOD_LIGHT"),A.shouldRenderCutoff&&C.push("RENDER_CUTOFF");const O="shadow"===e.renderPass,P=e.shadowRenderer,R=O&&!!P;e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0);let D=[0,0,0];if(P){const t=e.style.directionalLight,n=e.style.ambientLight;t&&n&&(D=$M(t,n)),k=C.concat(["SHADOWS_SINGLE_CASCADE"])}const L=R?"fillExtrusionDepth":d?"fillExtrusionPattern":"fillExtrusion",z=n.getLayerRenderingStats();for(const p of r){const r=t.getTile(p),m=r.getBucket(n);if(!m||m.projection.name!==c.projection.name)continue;let g=!1;P&&(g=0===P.getMaxCascadeForTile(p.toUnwrapped()));const y=e.isTileAffectedByFog(p),R=m.programConfigurations.get(n.id),B=e.getOrCreateProgram(L,{config:R,defines:g?k:C,overrideFog:y});if(e.terrain&&e.terrain.setupElevationDraw(r,B,{useMeterToDem:!0}),!m.centroidVertexBuffer){const e=B.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}!O&&P&&P.setupShadows(r.tileID.toUnwrapped(),B,"vector-tile",r.tileID.overscaledZ),d&&(e.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),R.updatePaintBuffers());const F=h.constantOr(null);if(F&&r.imageAtlas){const e=r.imageAtlas.patternPositions[F.toString()];e&&R.setConstantPatternPositions(e)}const j=n.paint.get("fill-extrusion-vertical-gradient");let N;if(O&&P){if(aM(r.tileID,m,e))continue;const t=P.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());N=mE(t,v,M)}else{const t=e.translatePosMatrix(p.expandedProjMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),i=c.projection.createInversionMatrix(c,p.canonical);N=d?_E(t,e,j,f,_,v,p,r,x,w,T,i,S,M):pE(t,e,j,f,_,v,p,x,w,T,i,S,M,E,D,I)}e.uploadCommonUniforms(l,B,p.toUnwrapped(),null,A);let U=m.segments;if("mercator"===c.projection.name&&!O&&(U=m.getVisibleSegments(r.tileID,e.terrain,e.transform.getFrustum(0)),!U.get().length))continue;if(z)if(O)for(const e of U.get())z.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of U.get())z.numRenderedVerticesInTransparentPass+=e.primitiveLength;const V=[];(e.terrain||s)&&V.push(m.centroidVertexBuffer),b&&V.push(m.layoutVertexExtBuffer),B.draw(e,l.gl.TRIANGLES,i,o,a,Dv.backCCW,N,n.id,m.layoutVertexBuffer,m.indexBuffer,U,n.paint,e.transform.zoom,R,V)}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1)}function tM(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y){const v=e.context,x=v.gl,b=e.transform,w=e.transform.zoom,T=[],S=YS(e,n.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===u?(T.push("CLEAR_SUBPASS"),y&&(T.push("CLEAR_FROM_TEXTURE"),v.activeTexture.set(x.TEXTURE0),y.bind(x.LINEAR,x.CLAMP_TO_EDGE))):"sdf"===u&&T.push("SDF_SUBPASS"),_&&T.push("HAS_CENTROID"),S.shouldRenderCutoff&&T.push("RENDER_CUTOFF");const E=n.layout.get("fill-extrusion-edge-radius"),M=(t,r,u,g,x)=>{const b=r.programConfigurations.get(n.id),M=e.isTileAffectedByFog(t),A=e.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:T,overrideFog:M}),I=((e,t,n,r,i,o,a,s,l,u,c)=>({u_matrix:t,u_opacity:n,u_ao_pass:r?1:0,u_meter_to_tile:i,u_ao:o,u_flood_light_intensity:a,u_flood_light_color:s,u_attenuation:l,u_edge_radius:u,u_fb:0,u_fb_size:c}))(0,g,c,l,x,[h,d*x],f,p,m,w>=17?0:E*x,y?y.size[0]:0),C=[];_&&C.push(r.hiddenByLandmarkVertexBuffer),e.uploadCommonUniforms(v,A,t.toUnwrapped(),null,S),A.draw(e,v.gl.TRIANGLES,i,o,a,s,I,n.id,r.vertexBuffer,r.indexBuffer,u,n.paint,w,b,C)};for(const i of r){const r=t.getTile(i),o=r.getBucket(n);if(!o||o.projection.name!==b.projection.name||!o.groundEffect||o.groundEffect&&!o.groundEffect.hasData())continue;const a=o.groundEffect,s=1/o.tileToMeter;{const t=e.translatePosMatrix(i.projMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),o=a.getDefaultSegment();M(i,a,o,t,s)}if(g)for(let o=0;o<4;o++){const a=yd[o](i),l=t.getTile(a);if(!l)continue;const u=l.getBucket(n);if(!u||u.projection.name!==b.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const c=u.groundEffect;let h,d;0===o?(h=[-hr,0,0],d=1):1===o?(h=[hr,0,0],d=0):2===o?(h=[0,-hr,0],d=3):(h=[0,hr,0],d=2);const f=c.regionSegments[d];if(!f)continue;const p=new Float32Array(16);Jh.translate(p,i.projMatrix,h),M(i,c,f,e.translatePosMatrix(p,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),s)}}}function nM(e,t,n,r,i,o,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const s=o?o.findDEMTileFor(n):null;if(!(s&&s.dem||a))return;const l=e=>{const n=t.getSource().minzoom,r=e=>{const n=t.getTileByID(e);if(n&&n.hasData())return n.getBucket(i)},o=[0,-1,1];for(const t of o){if(e.overscaledZ+t(u[0]=Math.min(e.min.y,t.min.y),u[1]=Math.max(e.max.y,t.max.y),u[2]=hr-t.min.x>e.max.x?t.min.x-hr:e.max.x,u),h=(e,t)=>(u[0]=Math.min(e.min.x,t.min.x),u[1]=Math.max(e.max.x,t.max.x),u[2]=hr-t.min.y>e.max.y?t.min.y-hr:e.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=(e,t,r,i,a,l,u)=>{if(!o)return 0;const c=[[l?r:e,l?e:r,0],[l?r:t,l?t:r,0]],h=u<0?hr+u:u,d=[l?h:(e+t)/2,l?(e+t)/2:h,0];return 0===r&&u<0||0!==r&&u>0?o.getForTilePoints(a,[d],!0,i):c.push(d),o.getForTilePoints(n,c,!0,s),Math.max(c[0][2],c[1][2],d[2])/o.exaggeration()};for(let e=0;e<4;e++){const t=r.borderFeatureIndices[e];if(0===t.length)continue;const i=yd[e](n),s=l(i);if(!(s&&s instanceof Tb))continue;if(r.borderDoneWithNeighborZ[e]===s.canonical.z)continue;0===s.centroidVertexArray.length&&s.createCentroidsBuffer();const u=o?o.findDEMTileFor(i):null;if(!(u&&u.dem||a))continue;const c=(e<2?1:5)-e,h=s.borderDoneWithNeighborZ[c]!==r.canonical.z,g=s.borderFeatureIndices[c];let y=0;if(r.canonical.z!==s.canonical.z){for(const e of t)r.showCentroid(r.featuresOnBorder[e]);if(h)for(const e of g)s.showCentroid(s.featuresOnBorder[e]);r.borderDoneWithNeighborZ[e]=s.canonical.z,s.borderDoneWithNeighborZ[c]=r.canonical.z}for(const n of t){const t=r.featuresOnBorder[n],o=r.centroidData[t.centroidDataIndex],l=t.borders[e];let h;for(;yl[0]+3||e[0]>l[0]-3)break;s.showCentroid(h),y++}if(h&&yl[1]-3)&&(x++,++y!==g.length);)h=s.featuresOnBorder[g[y]];if(h=s.featuresOnBorder[g[n]],x>1){const e=h.borders[c];Math.abs(l[0]-e[0])<3&&Math.abs(l[1]-e[1])<3&&(x=1,y=n+1)}else if(0===x){r.showCentroid(t);continue}const b=s.centroidData[h.centroidDataIndex];a&&1===x&&(((m=o).flags|(_=b).flags)&db?(m.flags|=db,_.flags|=db):(m.flags&=2147483647,_.flags&=2147483647));let w=new v(0,0);if(x>1)y=n;else if(u&&u.dem&&!(t.intersectsCount()>1||h.intersectsCount()>1)){const t=d[e](o,b),n=e%2?8191:0;p=f(t[0],Math.min(8191,t[1]),n,u,i,e<2,t[2]),w=new v(Math.ceil(7*(p+450)),0)}o.centroidXY=b.centroidXY=w,r.writeCentroidToBuffer(o),s.writeCentroidToBuffer(b)}else r.showCentroid(t)}r.borderDoneWithNeighborZ[e]=s.canonical.z,s.borderDoneWithNeighborZ[c]=r.canonical.z}var p,m,_;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(e)}const rM=[1,0,0],iM=[0,1,0],oM=[0,0,1];function aM(e,t,n){const r=n.transform,i=n.shadowRenderer;if(!i)return!0;const o=e.toUnwrapped(),a=r.tileSize*i._cascades[n.currentShadowCascade].scale;let s=t.maxHeight;if(r.elevation){const t=r.elevation.getMinMaxForTile(e);t&&(s+=t.max)}const l=[...i.shadowDirection];l[2]=-l[2];const u=i.computeSimplifiedTileShadowVolume(o,s,a,l);if(!u)return!1;const c=[rM,iM,oM,l,[l[0],0,l[2]],[0,l[1],l[2]]],h="globe"===r.projection.name,d=r.scaleZoom(a),f=Ed.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,d,!h),p=i.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(u.vertices,u.planes,c)||0===p.intersectsPrecise(u.vertices,u.planes,c)}function sM(e){const t=e._nearZ,n=e.projection.farthestPixelDistance(e),r=n-t,i=.2*e.height,o=t+i;return[t,n,(o-i-t)/r,(o-t)/r]}const lM=new dn(1,0,0,1),uM=new dn(0,1,0,1),cM=new dn(0,0,1,1),hM=new dn(1,0,1,1),dM=new dn(0,1,1,1);function fM(e,t,n){const r=e.context,i=e.transform,o=r.gl,a="globe"===i.projection.name,s=a?["PROJECTION_GLOBE_VIEW"]:[];let l=n.projMatrix;if(a&&ef(i.zoom)>0){const e=Xd(Fd(n.canonical,i));l=Jh.multiply(new Float32Array(16),i.globeMatrix,e),Jh.multiply(l,i.projMatrix,l)}const u=e.getOrCreateProgram("debug",{defines:s}),c=t.getTileByID(n.key);e.terrain&&e.terrain.setupElevationDraw(c,u);const h=Ov.disabled,d=Pv.disabled,f=e.colorModeForRenderPass(),p="$debug";r.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),a?c._makeGlobeTileDebugBuffers(e.context,i):c._makeDebugTileBoundsBuffers(e.context,i.projection);const m=c._tileDebugBuffer||e.debugBuffer,_=c._tileDebugIndexBuffer||e.debugIndexBuffer,g=c._tileDebugSegments||e.debugSegments;u.draw(e,o.LINE_STRIP,h,d,f,Dv.disabled,wE(l,dn.red),p,m,_,g,null,null,null,[c._globeTileDebugBorderBuffer]);const y=c.latestRawTileData,v=Math.floor((y&&y.byteLength||0)/1024),x=t.getTile(n).tileSize,b=512/Math.min(x,512)*(n.overscaledZ/i.zoom)*.5;let w=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(w+=" => "+n.overscaledZ),w+=` ${v}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)}(e,w);const T=c._tileDebugTextBuffer||e.debugBuffer,S=c._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,E=c._tileDebugTextSegments||e.debugSegments;u.draw(e,o.TRIANGLES,h,d,Rv.alphaBlended,Dv.disabled,wE(l,dn.transparent,b),p,T,S,E,null,null,null,[c._globeTileDebugTextBuffer])}function pM(e,t,n,r){_M(e,0,t+n/2,e.transform.width,n,r)}function mM(e,t,n,r){_M(e,t-n/2,0,n,e.transform.height,r)}function _M(e,t,n,r,i,o){const a=e.context,s=a.gl;s.enable(s.SCISSOR_TEST),s.scissor(t*ft.devicePixelRatio,n*ft.devicePixelRatio,r*ft.devicePixelRatio,i*ft.devicePixelRatio),a.clear({color:o}),s.disable(s.SCISSOR_TEST)}const gM=ll([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:yM}=gM;function vM(e,t,n,r){e.emplaceBack(t,n,r)}class xM{constructor(e){this.vertexArray=new Ll,this.indices=new Al,vM(this.vertexArray,-1,-1,1),vM(this.vertexArray,1,-1,1),vM(this.vertexArray,-1,1,1),vM(this.vertexArray,1,1,1),vM(this.vertexArray,-1,-1,-1),vM(this.vertexArray,1,-1,-1),vM(this.vertexArray,-1,1,-1),vM(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=e.createVertexBuffer(this.vertexArray,yM),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=Ql.simpleSegment(0,0,36,12)}}function bM(e,t,n,r,i,o){const a=e.context.gl,s=t.paint.get("sky-atmosphere-color"),l=t.paint.get("sky-atmosphere-halo-color"),u=t.paint.get("sky-atmosphere-sun-intensity"),c=((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}))(Yh.fromMat4(Yh.create(),r),i,u,s,l);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+o,t.skyboxTexture,0),n.draw(e,a.TRIANGLES,Ov.disabled,Pv.disabled,Rv.unblended,Dv.frontCW,c,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}const wM=ll([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class TM{constructor(e){const t=new Ol;t.emplaceBack(-1,1,1,0,0),t.emplaceBack(1,1,1,1,0),t.emplaceBack(1,-1,1,1,1),t.emplaceBack(-1,-1,1,0,1);const n=new Al;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(t,wM.members),this.indexBuffer=e.createIndexBuffer(n),this.segments=Ql.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const SM=ll([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class EM{constructor(){this.colorModeAlphaBlendedWriteRGB=new Rv([1,771,1,771],dn.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Rv([1,0,1,0],dn.transparent,[!1,!1,!1,!0])}update(e){const t=e.context;if(!this.atmosphereBuffer){this.atmosphereBuffer=new TM(t);const e=100,n=200,r=function(e){const t=Gi(30),n=[];for(let e=0;e<16e3;++e){const e=2*Math.PI*t(),r=Math.acos(1-2*t())-.5*Math.PI;n.push(id.fromValues(Math.cos(r)*Math.cos(e),Math.cos(r)*Math.sin(e),Math.sin(r)))}return n}(),i=Gi(300),o=new Pl,a=new Al;let s=0;for(let t=0;t{const c="globe"===i.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];t&&c.push("ALPHA_PASS");const d=e.getOrCreateProgram("globeAtmosphere",{defines:c}),p=((e,t,n,r,i,o,a,s,l,u,c,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:n,u_frustum_bl:r,u_horizon:i,u_transition:o,u_fadeout_range:a,u_color:s,u_high_color:l,u_space_color:u,u_temporal_offset:c,u_horizon_angle:h}))(i.frustumCorners.TL,i.frustumCorners.TR,i.frustumCorners.BR,i.frustumCorners.BL,i.frustumCorners.horizon,a,h,s,l,u,f,_);e.uploadCommonUniforms(n,d);const m=this.atmosphereBuffer;m&&d.draw(e,r.TRIANGLES,o,Pv.disabled,t?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Dv.backCW,p,t?"atmosphere_glow_alpha":"atmosphere_glow",m.vertexBuffer,m.indexBuffer,m.segments)};g(!1),g(!0)}drawStars(e,t){const n=O(t.properties.get("star-intensity"),0,1);if(0===n)return;const r=e.context,i=r.gl,o=e.transform,a=e.getOrCreateProgram("stars"),s=ed.identity([]);ed.rotateX(s,s,-o._pitch),ed.rotateZ(s,s,-o.angle),ed.rotateX(s,s,T(o._center.lat)),ed.rotateY(s,s,-T(o._center.lng));const l=Jh.fromQuat(new Float32Array(16),s),u=Jh.multiply([],o.starsProjMatrix,l),c=Yh.fromMat4([],l),h=Yh.invert([],c),d=[0,1,0];id.transformMat3(d,d,h),id.scale(d,d,.15);const f=[1,0,0];id.transformMat3(f,f,h),id.scale(f,f,.15);const p=((e,t,n,r)=>({u_matrix:Float32Array.from(e),u_up:t,u_right:n,u_intensity_multiplier:r}))(u,d,f,n);e.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(e,i.TRIANGLES,Ov.disabled,Pv.disabled,this.colorModeAlphaBlendedWriteRGB,Dv.disabled,p,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}function MM(e,t){const n=[...e],r=t.cameraWorldSizeForFog/t.worldSize,i=Jh.identity([]);return Jh.scale(i,i,[r,r,1]),Jh.multiply(n,i,n),Jh.multiply(n,t.worldToFogMatrix,n),n}function AM(e,t,n,r){const i=n.material,o=r.context,{baseColorTexture:a,metallicRoughnessTexture:s}=i.pbrMetallicRoughness,{normalTexture:l,occlusionTexture:u,emissionTexture:c}=i;function h(t,n,r){if(t&&(e.push(n),o.activeTexture.set(o.gl.TEXTURE0+r),t.gfxTexture)){const{minFilter:e,magFilter:n,wrapS:r,wrapT:i}=t.sampler;t.gfxTexture.bindExtraParam(e,n,r,i)}}h(a,"HAS_TEXTURE_u_baseColorTexture",LE),h(s,"HAS_TEXTURE_u_metallicRoughnessTexture",zE),h(l,"HAS_TEXTURE_u_normalTexture",BE),h(u,"HAS_TEXTURE_u_occlusionTexture",FE),h(c,"HAS_TEXTURE_u_emissionTexture",jE),n.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(n.texcoordBuffer)),n.colorBuffer&&(e.push(12===n.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(n.colorBuffer)),n.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(n.normalBuffer)),n.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(n.pbrBuffer)),"OPAQUE"!==i.alphaMode&&"MASK"!==i.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),i.defined||e.push("DIFFUSE_SHADED"),e.push("USE_STANDARD_DERIVATIVES")}function IM(e,t,n,r,i,o){const a=n.paint.get("model-opacity"),s=t.context,l=new Ov(t.context.gl.LEQUAL,Ov.ReadWrite,t.depthRangeFor3D),u=t.transform,c=e.mesh,h=c.material,d=h.pbrMetallicRoughness,f=t.style.fog;let p;p="pixels"===t.transform.projection.zAxisUnit?[...e.nodeModelMatrix]:Jh.multiply([],r.zScaleMatrix,e.nodeModelMatrix),Jh.multiply(p,r.negCameraPosMatrix,p);const m=Jh.invert([],p);Jh.transpose(m,m);const _=n.paint.get("model-emissive-strength").constantOr(0),g=UE(new Float32Array(e.worldViewProjection),new Float32Array(p),new Float32Array(m),t,a,d.baseColorFactor,h.emissiveFactor,d.metallicFactor,d.roughnessFactor,h,_,n),y={defines:[]},v=[];AM(y.defines,v,c,t);const x=t.shadowRenderer;x&&(x.useNormalOffset=!1);let b=null;if(f){const n=MM(e.nodeModelMatrix,t.transform);if(b=new Float32Array(n),"globe"!==u.projection.name){const e=c.aabb.min,t=c.aabb.max,[r,i]=f.getOpacityForBounds(n,e[0],e[1],t[0],t[1]);y.overrideFog=r>=mw||i>=mw}}const w=YS(t,n.paint.get("model-cutoff-fade-range"));w.shouldRenderCutoff&&y.defines.push("RENDER_CUTOFF");const T=t.getOrCreateProgram("model",y);t.uploadCommonUniforms(s,T,null,b,w),"shadow"!==t.renderPass&&x&&x.setupShadowsFromMatrix(e.nodeModelMatrix,T),T.draw(t,s.gl.TRIANGLES,l,i,o,c.material.doubleSided?Dv.disabled:Dv.backCCW,g,n.id,c.vertexBuffer,c.indexBuffer,c.segments,n.paint,t.transform.zoom,void 0,v)}function CM(e,t,n,r,i,o,a){let s;s="globe"===e.projection.name?kx(n,e):[...n],Jh.multiply(s,s,t.matrix);const l=Jh.multiply([],r,s);if(t.meshes)for(const e of t.meshes){if("BLEND"!==e.material.alphaMode){a.push({mesh:e,depth:0,modelIndex:i,worldViewProjection:l,nodeModelMatrix:s});continue}const t=id.transformMat4([],e.centroid,l);t[2]>0&&o.push({mesh:e,depth:t[2],modelIndex:i,worldViewProjection:l,nodeModelMatrix:s})}if(t.children)for(const s of t.children)CM(e,s,n,r,i,o,a)}function kM(e,t,n,r){const i=n.shadowRenderer;if(!i)return;const o=i.getShadowPassDepthMode(),a=i.getShadowPassColorMode(),s=i.calculateShadowPassMatrixFromMatrix(t),l=GE(s);n.getOrCreateProgram("modelDepth",{defines:["DEPTH_TEXTURE"]}).draw(n,n.context.gl.TRIANGLES,o,Pv.disabled,a,Dv.backCCW,l,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,n.transform.zoom,void 0,void 0)}function OM(e,t,n){const r=t.updateZoomBasedPaintProperties(),i=function(e,t,n){let r,i,o,a=e.terrain?e.terrain.exaggeration():0;if(e.terrain&&a>0){const t=e.terrain,i=t.findDEMTileFor(n);i&&i.dem?r=__.create(t,n,i):a=0}if(0===a&&(t.terrainElevationMin=0,t.terrainElevationMax=0),a===t.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===t.validForDEMTile.id&&r._dem._timestamp===t.validForDEMTile.timestamp))return!1;for(const e in t.instancesPerModel){const n=t.instancesPerModel[e];for(let e=0;eu&&(u=t.max)}const c=O(r.x,o,a)-r.x,h=O(r.y,s,l)-r.y,d=xf(u,t.center.lat)-r.z;return t._zoomFromMercatorZ(Math.sqrt(c*c+h*h+d*d))}function DM(e,t,n,r,i,o,a){const s=e.context,l="shadow"===e.renderPass,u=e.shadowRenderer,c=l&&u?u.getShadowPassDepthMode():new Ov(s.gl.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o);if(n.meshes)for(const d of n.meshes){const f=["MODEL_POSITION_ON_GPU"],p=[];let m,_,g;r.instancedDataArray.length>20&&f.push("INSTANCED_ARRAYS");const y=YS(e,t.paint.get("model-cutoff-fade-range"));if(y.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&u)m=e.getOrCreateProgram("modelDepth",{defines:f}),_=GE(a.shadowTileMatrix,a.shadowTileMatrix,Float32Array.from(n.matrix)),g=u.getShadowPassColorMode();else{AM(f,p,d,e),m=e.getOrCreateProgram("model",{defines:f,overrideFog:h});const r=d.material,l=r.pbrMetallicRoughness,c=t.paint.get("model-opacity"),v=t.paint.get("model-emissive-strength").constantOr(0);_=UE(o.expandedProjMatrix,Float32Array.from(n.matrix),new Float32Array(16),e,c,l.baseColorFactor,r.emissiveFactor,l.metallicFactor,l.roughnessFactor,r,v,t,i),u&&(a.shadowUniformsInitialized?m.setShadowUniformValues(s,u.getShadowUniformValues()):(u.setupShadows(o.toUnwrapped(),m,"model-tile",o.overscaledZ),a.shadowUniformsInitialized=!0)),g=y.shouldRenderCutoff||c<1||"OPAQUE"!==r.alphaMode?Rv.alphaBlended:Rv.unblended}e.uploadCommonUniforms(s,m,o.toUnwrapped(),null,y);const v=d.material.doubleSided?Dv.disabled:Dv.backCCW;if(r.instancedDataArray.length>20)p.push(r.instancedDataBuffer),m.draw(e,s.gl.TRIANGLES,c,Pv.disabled,g,v,_,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,p,r.instancedDataArray.length);else{const n=l?"u_instance":"u_normal_matrix";for(let i=0;i30&&(n.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}const jM={symbol:function(e,t,n,r,i){if("translucent"!==e.renderPass)return;const o=Pv.disabled,a=e.colorModeForRenderPass();n.layout.get("text-variable-anchor")&&function(e,t,n,r,i,o,a){const s=t.transform,l="map"===i,u="map"===o;for(const t of e){const e=r.getTile(t),i=e.getBucket(n);if(!i||!i.text||!i.text.segments.get().length)continue;const o=P_(i.textSizeData,s.zoom),c=$T(t,i.getProjection(),s),h=s.calculatePixelsToTileUnitsMatrix(e),d=cx(c,e.tileID.canonical,u,l,s,i.getProjection(),h),f=i.hasIconTextFit()&&i.hasIconData();if(o){const n=Math.pow(2,s.zoom-e.tileID.overscaledZ);XE(i,l,u,a,R_,s,d,t,n,o,f)}}}(r,e,n,t,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),i),0!==n.paint.get("icon-opacity").constantOr(1)&&KE(e,t,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),n.paint.get("icon-color-saturation"),o,a),0!==n.paint.get("text-opacity").constantOr(1)&&KE(e,t,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),n.paint.get("icon-color-saturation"),o,a),t.map.showCollisionBoxes&&(ZE(e,t,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),ZE(e,t,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(e,t,n,r){if("translucent"!==e.renderPass)return;const i=n.paint.get("circle-opacity"),o=n.paint.get("circle-stroke-width"),a=n.paint.get("circle-stroke-opacity"),s=void 0!==n.layout.get("circle-sort-key").constantOr(1),l=n.paint.get("circle-emissive-strength");if(0===i.constantOr(1)&&(0===o.constantOr(1)||0===a.constantOr(1)))return;const u=e.context,c=u.gl,h=e.transform,d=e.depthModeForSublayer(0,Ov.ReadOnly),f=Pv.disabled,p=e.colorModeForDrapableLayerRenderPass(l),m="globe"===h.projection.name,_=[yf(h.center.lng),vf(h.center.lat)],g=[];for(let i=0;ie.sortKey-t.sortKey);const y={useDepthForOcclusion:h.depthOcclusionForSymbolsAndCircles};for(const t of g){const{programConfiguration:r,program:i,layoutVertexBuffer:o,globeExtVertexBuffer:a,indexBuffer:s,uniformValues:l,tile:m}=t.state,_=t.segments;e.terrain&&e.terrain.setupElevationDraw(m,i,y),e.uploadCommonUniforms(u,i,m.tileID.toUnwrapped()),i.draw(e,c.TRIANGLES,d,f,p,Dv.disabled,l,n.id,o,s,_,n.paint,h.zoom,r,[a])}},heatmap:function(e,t,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const i=e.context,o=i.gl,a=Pv.disabled,s=new Rv([o.ONE,o.ONE,o.ONE,o.ONE],dn.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,!0,null),function(e,t,n,r,i,o){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?a.RGBA16F:a.RGBA,i,o,0,a.RGBA,e.extRenderToTextureHalfFloat?a.HALF_FLOAT: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)}(i,e,n,"globe"===e.transform.projection.name?.5:.25),i.clear({color:dn.transparent});const l=e.transform,u="globe"===l.projection.name,c=u?["PROJECTION_GLOBE_VIEW"]:[],h=u?Dv.frontCCW:Dv.disabled,d=[yf(l.center.lng),vf(l.center.lat)];for(let f=0;f({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,t),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom)}(e,n))},line:function(e,t,n,r){if("translucent"!==e.renderPass)return;const i=n.paint.get("line-opacity"),o=n.paint.get("line-width");if(0===i.constantOr(1)||0===o.constantOr(1))return;const a=n.paint.get("line-emissive-strength"),s=e.depthModeForSublayer(0,Ov.ReadOnly),l=e.colorModeForDrapableLayerRenderPass(a),u=e.terrain&&e.terrain.renderingToTexture?1:ft.devicePixelRatio,c=n.paint.get("line-dasharray"),h=c.constantOr(1),d=n.layout.get("line-cap"),f=n.paint.get("line-pattern"),p=f.constantOr(1),m=n.paint.get("line-pattern").constantOr(1),_=1!==n.paint.get("line-opacity").constantOr(1);let g=!m&&_;const y=n.paint.get("line-gradient"),v=p?"linePattern":"line",x=e.context,b=x.gl,w=Zb(n);e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(g=!1);for(const i of r){const r=t.getTile(i);if(p&&!r.patternsLoaded())continue;const o=r.getBucket(n);if(!o)continue;e.prepareDrawTile();const a=o.programConfigurations.get(n.id),m=e.isTileAffectedByFog(i),_=e.getOrCreateProgram(v,{config:a,defines:w,overrideFog:m}),T=f.constantOr(null);if(T&&r.imageAtlas){const e=r.imageAtlas.patternPositions[T.toString()];e&&a.setConstantPatternPositions(e)}const S=c.constantOr(null),E=d.constantOr(null);if(!p&&S&&E&&r.lineAtlas){const e=r.lineAtlas.getDash(S,E);e&&a.setConstantPatternPositions(e)}let[M,A]=n.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;M!==A&&(0===M&&(M-=e),1===A&&(A+=e))}const I=e.terrain?i.projMatrix:null,C=p?Gb(e,r,n,I,u):Vb(e,r,n,I,o.lineClipsArray.length,u,[M,A]);if(y){const r=o.gradients[n.id];let a=r.texture;if(n.gradientVersion!==r.version){let s=256;if(n.stepInterpolant){const n=t.getSource().maxzoom,r=i.canonical.z===n?Math.ceil(1<{_.draw(e,b.TRIANGLES,s,t,l,Dv.disabled,C,n.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,n.paint,e.transform.zoom,a,[o.layoutVertexBuffer2])};if(g){const t=e.stencilModeForClipping(i).ref;0===t&&e.terrain&&x.clear({stencil:0});const n={func:b.EQUAL,mask:255};C.u_alpha_discard_threshold=.8,k(new Pv(n,t,255,b.KEEP,b.KEEP,b.INVERT)),C.u_alpha_discard_threshold=0,k(new Pv(n,t,255,b.KEEP,b.KEEP,b.KEEP))}else k(e.stencilModeForClipping(i))}g&&(e.resetStencilClippingMasks(),e.terrain&&x.clear({stencil:0}))},fill:function(e,t,n,r){const i=n.paint.get("fill-color"),o=n.paint.get("fill-opacity");if(0===o.constantOr(1))return;const a=n.paint.get("fill-emissive-strength"),s=e.colorModeForDrapableLayerRenderPass(a),l=n.paint.get("fill-pattern"),u=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===i.constantOr(dn.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";if(e.renderPass===u){const i=e.depthModeForSublayer(1,"opaque"===e.renderPass?Ov.ReadWrite:Ov.ReadOnly);QE(e,t,n,r,i,s,!1)}if("translucent"===e.renderPass&&n.paint.get("fill-antialias")){const i=e.depthModeForSublayer(n.getPaintProperty("fill-outline-color")?2:0,Ov.ReadOnly);QE(e,t,n,r,i,s,!0)}},"fill-extrusion":function(e,t,n,r){const i=n.paint.get("fill-extrusion-opacity"),o=e.context,a=o.gl,s=e.terrain,l=s&&s.renderingToTexture,u=n.paint.get("fill-extrusion-cutoff-fade-range");if(0===i)return;const c=e.conflationActive&&e.layerUsedInConflation(n,t.getSource());if(c&&function(e,t,n,r){for(const i of r){const r=t.getTile(i).getBucket(n);r&&(r.updateReplacement(i,e.replacementSource),r.uploadCentroid(e.context))}}(e,t,n,r),s||c)for(const i of r){const r=t.getTile(i).getBucket(n);r&&nM(e.context,t,i,r,n,s,c)}if("shadow"===e.renderPass&&e.shadowRenderer){const o=e.shadowRenderer;if(s&&i<.65&&n._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof vo)return;const a=o.getShadowPassDepthMode(),l=o.getShadowPassColorMode();eM(e,t,n,r,a,Pv.disabled,l,c)}else if("translucent"===e.renderPass){const h=!n.paint.get("fill-extrusion-pattern").constantOr(1);if(!l){const o=new Ov(e.context.gl.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D);0===u&&1===i&&h?eM(e,t,n,r,o,Pv.disabled,Rv.unblended,c):(eM(e,t,n,r,o,Pv.disabled,Rv.disabled,c),eM(e,t,n,r,o,e.stencilModeFor3D(),e.colorModeForRenderPass(),c),e.resetStencilClippingMasks())}if(e.style.enable3dLights()&&h&&(!s&&"globe"!==e.transform.projection.name||l)){const i=n.paint.get("fill-extrusion-opacity"),u=n.paint.get("fill-extrusion-ambient-occlusion-intensity"),h=n.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),d=n.paint.get("fill-extrusion-flood-light-intensity"),f=n.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),p=u>0&&h>0,m=d>0,_=(e,t,n)=>(1-n)*e+n*t,g=o=>{const s=e.depthModeForSublayer(1,Ov.ReadOnly,a.LEQUAL,!0),l=n.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),p=_(.1,3,l),m=e._showOverdrawInspector;if(!m){const l=new Pv({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),m=new Rv([a.ONE,a.ONE,a.ONE,a.ONE],dn.transparent,[!1,!1,!1,!0],a.MIN);tM(e,t,n,r,s,l,m,Dv.disabled,o,"sdf",i,u,h,d,f,p,c,!1)}{const l=m?Pv.disabled:new Pv({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),_=m?e.colorModeForRenderPass():new Rv([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],dn.transparent,[!0,!0,!0,!0]);tM(e,t,n,r,s,l,_,Dv.disabled,o,"color",i,u,h,d,f,p,c,!1)}};if(l){const l=(o,s,l)=>{const p=e.depthModeForSublayer(1,Ov.ReadOnly,a.LEQUAL,!1),m=n.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),g=_(.1,3,m);{const l=new Rv([a.ONE,a.ONE,a.ONE,a.ONE],dn.transparent,[!1,!1,!1,!0]);tM(e,t,n,r,p,Pv.disabled,l,Dv.disabled,o,"clear",i,u,h,d,f,g,c,s)}{const l=new Pv({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),m=new Rv([a.ONE,a.ONE,a.ONE,a.ONE],dn.transparent,[!1,!1,!1,!0],a.MIN);tM(e,t,n,r,p,l,m,Dv.disabled,o,"sdf",i,u,h,d,f,g,c,s)}{const l=o?a.ZERO:a.ONE_MINUS_DST_ALPHA,m=new Pv({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),_=new Rv([l,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],dn.transparent,[!0,!0,!0,!0]);tM(e,t,n,r,p,m,_,Dv.disabled,o,"color",i,u,h,d,f,g,c,s)}{const m=new Rv([a.ONE,a.ONE,a.ONE,o?a.ZERO:a.ONE],dn.transparent,[!1,!1,!1,!0],o?a.FUNC_ADD:a.MAX);tM(e,t,n,r,p,Pv.disabled,m,Dv.disabled,o,"clear",i,u,h,d,f,g,c,s,l)}};if(p||m){let t;if(e.prepareDrawTile(),s){const e=s.drapeBufferSize[0],n=s.drapeBufferSize[1];t=s.framebufferCopyTexture,t&&(!t||t.size[0]===e&&t.size[1]===n)||(t&&t.destroy(),t=s.framebufferCopyTexture=new Ry(o,new bp({width:e,height:n}),a.RGBA)),t.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,e,n,0)}p&&l(!0,!1,t),m&&l(!1,!0,t)}}else p&&g(!0),m&&g(!1)}}},hillshade:function(e,t,n,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const i=e.context,o=e.terrain&&e.terrain.renderingToTexture,[a,s]="translucent"!==e.renderPass||o?[{},r]:e.stencilConfigForOverlap(r);for(const r of s){const i=t.getTile(r);if(i.needsHillshadePrepare&&"offscreen"===e.renderPass)ZS(e,i,n);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Ov.ReadOnly),s=n.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(s),u=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):a[r.overscaledZ];qS(e,r,i,n,t,u,l)}}i.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,t,n,r,i,o){if("translucent"!==e.renderPass)return;if(0===n.paint.get("raster-opacity"))return;const a=e.context,s=a.gl,l=t.getSource(),u=function(e,t,n){const r=e.paint.get("raster-color"),i=[],o=e.paint.get("raster-resampling"),a=e.paint.get("raster-color-mix"),s=e.paint.get("raster-color-range"),l=[a[0],a[1],a[2],0],u=a[3],c="nearest"===o?n.NEAREST:n.LINEAR;if(r&&i.push("RASTER_COLOR"),r){t.activeTexture.set(n.TEXTURE2);let r=e.colorRampTexture;r||(r=e.colorRampTexture=new Ry(t,e.colorRamp,n.RGBA)),r.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:l,range:s,offset:u,defines:i,resampling:c}}(n,a,s),c=u.defines,h="globe"===e.transform.projection.name;let d=!1;if(l instanceof tw&&!r.length){if(!h)return;if(l.onNorthPole)d=!0,c.push("GLOBE_POLES");else{if(!l.onSouthPole)return;d=!0,c.push("GLOBE_POLES")}}const f=n.paint.get("raster-emissive-strength"),p=e.colorModeForDrapableLayerRenderPass(f),m=e.terrain&&e.terrain.renderingToTexture,_=l instanceof tw&&0!==n.paint.get("raster-elevation"),g=!e.options.moving,y="nearest"===n.paint.get("raster-resampling")?s.NEAREST:s.LINEAR;if(d){const r=t.getSource();if(!(r instanceof tw))return;const i=r.texture;if(!i)return;const o=e.globeSharedBuffers;if(!o)return;const l=new Ov(s.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D),c=Float32Array.from(e.transform.expandedFarZProjMatrix);let h=tf(0,0,e.transform);const d=Float32Array.from($d(zd(new pd(0,0,0)))),m={opacity:1,mix:0};e.terrain&&e.terrain.prepareDrawTile(),a.activeTexture.set(s.TEXTURE0),i.bind(y,s.CLAMP_TO_EDGE),a.activeTexture.set(s.TEXTURE1),i.bind(y,s.CLAMP_TO_EDGE),i.useMipmap&&a.extTextureFilterAnisotropic&&e.transform.pitch>20&&s.texParameterf(s.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax);const[_,g,v,x]=o.getPoleBuffers(0,!0);let b;r.onNorthPole?(b=_,e.renderDefaultNorthPole=!1):(h=Jh.scale(Jh.create(),h,[1,-1,1]),b=g,e.renderDefaultSouthPole=!1);const w=((e,t,n,r,i,o,a,s,l,u,c,h)=>EE(e,t,n,new Float32Array(16),new Float32Array(9),[0,0],[0,0,0,0],0,[0,0],[0,0,0,0],1,r,i,o||[0,0],a,2,l,u,c,1,0,h))(c,d,h,m,n,r.perspectiveTransform||[0,0],n.paint.get("raster-elevation"),0,u.mix,u.offset,u.range,f),T=e.getOrCreateProgram("raster",{defines:u.defines});return e.uploadCommonUniforms(a,T,null),void T.draw(e,s.TRIANGLES,l,Pv.disabled,p,Dv.disabled,w,n.id,b,v,x)}if(!r.length)return;const[v,x]=l instanceof tw||m?[{},r]:e.stencilConfigForOverlap(r),b=x[x.length-1].overscaledZ,w=_&&h;w&&u.defines.push("PROJECTION_GLOBE_VIEW"),_&&u.defines.push("RENDER_CUTOFF");for(const r of x){const i=r.toUnwrapped(),c=t.getTile(r);if(m&&(!c||!c.hasData()))continue;if(!c.texture)continue;let d,x;m?(d=Ov.disabled,x=r.projMatrix):_?(d=new Ov(s.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D),x=h?Float32Array.from(e.transform.expandedFarZProjMatrix):e.transform.calculateProjMatrix(i,g)):(d=e.depthModeForSublayer(r.overscaledZ-b,1===n.paint.get("raster-opacity")?Ov.ReadWrite:Ov.ReadOnly,s.LESS),x=e.transform.calculateProjMatrix(i,g));const T=e.terrain&&m?e.terrain.stencilModeForRTTOverlap(r):v[r.overscaledZ],S=o?0:n.paint.get("raster-fade-duration");c.registerFadeDuration(S);const E=t.findLoadedParent(r,0),M=rE(c,E,t,e.transform,S);let A,I;e.terrain&&e.terrain.prepareDrawTile(),a.activeTexture.set(s.TEXTURE0),c.texture&&c.texture.bind(y,s.CLAMP_TO_EDGE),a.activeTexture.set(s.TEXTURE1),E?(E.texture&&E.texture.bind(y,s.CLAMP_TO_EDGE),A=Math.pow(2,E.tileID.overscaledZ-c.tileID.overscaledZ),I=[c.tileID.canonical.x*A%1,c.tileID.canonical.y*A%1]):c.texture&&c.texture.bind(y,s.CLAMP_TO_EDGE),c.texture&&c.texture.useMipmap&&a.extTextureFilterAnisotropic&&e.transform.pitch>20&&s.texParameterf(s.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax);const C=e.transform,k=l instanceof tw?l.perspectiveTransform:[0,0],O=_?sM(C):[0,0,0,0];let P,R,D,L,z,B;if(w&&l instanceof tw&&l.coordinates.length>3){P=Float32Array.from($d(zd(new pd(0,0,0)))),R=Float32Array.from(C.globeMatrix),D=Float32Array.from(Qd(C)),L=[yf(C.center.lng),vf(C.center.lat)],B=[yf(l.coordinates[1][0]),vf(l.coordinates[1][1]),yf(l.coordinates[3][0]),vf(l.coordinates[3][1])];const t=new ju(l.coordinates[1],l.coordinates[3]);z=Float32Array.from(rf(new pd(0,0,0),t,0,C.worldSize/e.transform._pixelsPerMercatorPixel))}else P=new Float32Array(16),R=new Float32Array(9),D=new Float32Array(16),L=[0,0],z=new Float32Array(16),B=[0,0,0,0];const F=EE(x,P,R,D,z,I||[0,0],B,ef(e.transform.zoom),L,O,A||1,M,n,k,_?n.paint.get("raster-elevation"):0,2,u.mix,u.offset,u.range,1,0,f),j=e.isTileAffectedByFog(r),N=e.getOrCreateProgram("raster",{defines:u.defines,overrideFog:j});if(e.uploadCommonUniforms(a,N,i),l instanceof tw){if(m||!h)l.boundsBuffer&&l.boundsSegments&&N.draw(e,s.TRIANGLES,d,Pv.disabled,p,Dv.disabled,F,n.id,l.boundsBuffer,e.quadTriangleIndexBuffer,l.boundsSegments);else if(e.globeSharedBuffers){const[t,r,i]=e.globeSharedBuffers.getGridBuffers(0,!1);N.draw(e,s.TRIANGLES,d,Pv.disabled,p,Dv.frontCCW,F,n.id,t,r,i),N.draw(e,s.TRIANGLES,d,Pv.disabled,p,Dv.backCCW,F,n.id,t,r,i)}}else{const{tileBoundsBuffer:t,tileBoundsIndexBuffer:r,tileBoundsSegments:i}=e.getTileBoundsBuffers(c);N.draw(e,s.TRIANGLES,d,T,p,Dv.disabled,F,n.id,t,r,i)}}e.resetStencilClippingMasks()},background:function(e,t,n,r){const i=n.paint.get("background-color"),o=n.paint.get("background-opacity"),a=n.paint.get("background-emissive-strength");if(0===o)return;const s=e.context,l=s.gl,u=e.transform,c=u.tileSize,h=n.paint.get("background-pattern");if(e.isPatternMissing(h,n.scope))return;const d=!h&&1===i.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==d)return;const f=Pv.disabled,p=e.depthModeForSublayer(0,"opaque"===d?Ov.ReadWrite:Ov.ReadOnly),m=e.colorModeForDrapableLayerRenderPass(a),_=h?"backgroundPattern":"background";let g,y=r;y||(g=e.getBackgroundTiles(),y=Object.values(g).map(e=>e.tileID)),h&&(s.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context,n.scope));for(const d of y){const y=e.isTileAffectedByFog(d),v=e.getOrCreateProgram(_,{overrideFog:y}),x=d.toUnwrapped(),b=r?d.projMatrix:e.transform.calculateProjMatrix(x);e.prepareDrawTile();const w=t?t.getTile(d):g?g[d.key]:new Vy(d,c,u.zoom,e),T=h?DE(b,a,o,e,h,n.scope,{tileID:d,tileSize:c}):RE(b,a,o,i);e.uploadCommonUniforms(s,v,x);const{tileBoundsBuffer:S,tileBoundsIndexBuffer:E,tileBoundsSegments:M}=e.getTileBoundsBuffers(w);v.draw(e,l.TRIANGLES,p,f,m,Dv.disabled,T,n.id,S,E,M)}},sky:function(e,t,n){const r=e._atmosphere?ef(e.transform.zoom):1,i=n.paint.get("sky-opacity")*r;if(0===i)return;const o=e.context,a=n.paint.get("sky-type"),s=new Ov(o.gl.LEQUAL,Ov.ReadOnly,[0,1]),l=e.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===e.renderPass?n.needsSkyboxCapture(e)&&(function(e,t,n,r){const i=e.context,o=i.gl;let a=t.skyboxFbo;if(!a){a=t.skyboxFbo=i.createFramebuffer(32,32,!0,null),t.skyboxGeometry=new xM(i),t.skyboxTexture=i.gl.createTexture(),o.bindTexture(o.TEXTURE_CUBE_MAP,t.skyboxTexture),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR);for(let e=0;e<6;++e)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,o.RGBA,32,32,0,o.RGBA,o.UNSIGNED_BYTE,null)}i.bindFramebuffer.set(a.framebuffer),i.viewport.set([0,0,32,32]);const s=t.getCenter(e,!0),l=e.getOrCreateProgram("skyboxCapture"),u=new Float64Array(16);Jh.identity(u),Jh.rotateY(u,u,.5*-Math.PI),bM(e,t,l,u,s,0),Jh.identity(u),Jh.rotateY(u,u,.5*Math.PI),bM(e,t,l,u,s,1),Jh.identity(u),Jh.rotateX(u,u,.5*-Math.PI),bM(e,t,l,u,s,2),Jh.identity(u),Jh.rotateX(u,u,.5*Math.PI),bM(e,t,l,u,s,3),Jh.identity(u),bM(e,t,l,u,s,4),Jh.identity(u),Jh.rotateY(u,u,Math.PI),bM(e,t,l,u,s,5),i.viewport.set([0,0,e.width,e.height])}(e,n),n.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,t,n,r,i){const o=e.context,a=o.gl,s=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,t.skyboxTexture);const u=((e,t,n,r,i)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:i}))(s.skyboxMatrix,t.getCenter(e,!1),0,r,i);e.uploadCommonUniforms(o,l),l.draw(e,a.TRIANGLES,n,Pv.disabled,e.colorModeForRenderPass(),Dv.backCW,u,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,n,s,i,l):"gradient"===a&&"sky"===e.renderPass&&function(e,t,n,r,i){const o=e.context,a=o.gl,s=e.transform,l=e.getOrCreateProgram("skyboxGradient");t.skyboxGeometry||(t.skyboxGeometry=new xM(o)),o.activeTexture.set(a.TEXTURE0);let u=t.colorRampTexture;u||(u=t.colorRampTexture=new Ry(o,t.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const c=((e,t,n,r,i)=>({u_matrix:e,u_color_ramp:0,u_center_direction:t,u_radius:T(n),u_opacity:r,u_temporal_offset:i}))(s.skyboxMatrix,t.getCenter(e,!1),t.paint.get("sky-gradient-radius"),r,i);e.uploadCommonUniforms(o,l),l.draw(e,a.TRIANGLES,n,Pv.disabled,e.colorModeForRenderPass(),Dv.backCW,c,"skyboxGradient",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(e,n,s,i,l)},debug:function(e,t,n){for(let r=0;r{a&&(a.useNormalOffset=!0,s||(a.enabled=!0))},u=t.getSource();if("light-beam"===e.renderPass&&"batched-model"!==u.type)return;if("vector"===u.type||"geojson"===u.type)return function(e,t,n,r){const i=e.transform;if("mercator"!==i.projection.name)return void X(`Drawing 3D models for ${i.projection.name} projection is not yet implemented`);const o=i.getFreeCameraOptions().position;if(!e.modelManager)return;const a=e.modelManager,s=e.shadowRenderer;if(!n._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const l=n._unevaluatedLayout._values["model-id"],u={...n.layout.get("model-id").parameters};for(const c of r){const r=t.getTile(c).getBucket(n);if(!r||r.projection.name!==i.projection.name)continue;const h=RM(c,i);u.zoom=h;const d=l.possiblyEvaluate(u);if(OM(e,r,c),PM.shadowUniformsInitialized=!1,PM.useSingleShadowCascade=!!s&&0===s.getMaxCascadeForTile(c.toUnwrapped()),"shadow"===e.renderPass&&s){if(1===e.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const t=i.calculatePosMatrix(c.toUnwrapped(),i.worldSize);if(PM.tileMatrix.set(t),PM.shadowTileMatrix=Float32Array.from(s.calculateShadowPassMatrixFromMatrix(t)),PM.aabb.min.fill(0),PM.aabb.max[0]=PM.aabb.max[1]=hr,PM.aabb.max[2]=0,zM(r,PM,e,n.scope))continue}const f=1<0&&(t=d.evaluate(i.features[0].feature,{}));const o=a.getModel(t,n.scope);if(o&&o.uploaded)for(const t of o.nodes)DM(e,n,t,i,p,c,PM)}}}(e,t,n,r),void l();if(!u.loaded())return;if("batched-model"===u.type)return function(e,t,n,r){const i=e.context,o=e.transform,a=e.style.fog,s=e.shadowRenderer;if("mercator"!==o.projection.name)return void X(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`);const l=e.transform.getFreeCameraOptions().position,u=id.scale([],[l.x,l.y,l.z],e.transform.worldSize);id.negate(u,u);const c=Jh.identity([]),h=Mf(o.center.lat,o.zoom),d=Jh.fromScaling([],[1,1,1/h]);Jh.translate(c,c,u);const f=n.paint.get("model-opacity"),p=new Ov(i.gl.LEQUAL,Ov.ReadWrite,e.depthRangeFor3D),m=new Ov(i.gl.LEQUAL,Ov.ReadOnly,e.depthRangeFor3D),_=function(l,u){for(const h of r){const r=t.getTile(h).getBucket(n);if(!r||!r.uploaded)continue;let _=!1;s&&(_=0===s.getMaxCascadeForTile(h.toUnwrapped()));const g=o.calculatePosMatrix(h.toUnwrapped(),o.worldSize),y=r.modelTraits;for(const t of r.getNodesInfo()){if(t.hiddenByReplacement)continue;if(!t.node.meshes)continue;const r=t.node,v="light-beam"===e.renderPass,x=[...g],b=t.evaluatedScale;let w=0;e.terrain&&r.elevation&&(w=r.elevation*e.terrain.exaggeration()),Jh.translate(x,x,[(r.anchor?r.anchor[0]:0)*(b[0]-1),(r.anchor?r.anchor[1]:0)*(b[1]-1),w]),b!==Ox&&Jh.scale(x,x,b),Jh.multiply(x,x,r.matrix);const T=Jh.multiply([],d,x);Jh.multiply(T,c,T);const S=Jh.invert([],T);Jh.transpose(S,S),Jh.scale(S,S,LM);const E=Jh.multiply([],o.expandedFarZProjMatrix,x);for(let c=0;c=mw||i>=mw}}const I=e.getOrCreateProgram("model",b);!M&&s&&(s.useNormalOffset=!!d.normalBuffer,s.setupShadowsFromMatrix(x,I,s.useNormalOffset)),e.uploadCommonUniforms(i,I,h.toUnwrapped(),A);const C=d.material,k=C.pbrMetallicRoughness;k.metallicFactor=.9,k.roughnessFactor=.5;const O=0,P=UE(new Float32Array(E),new Float32Array(T),new Float32Array(S),e,f,k.baseColorFactor,C.emissiveFactor,k.metallicFactor,k.roughnessFactor,C,O,n);I.draw(e,i.gl.TRIANGLES,u&&!g?p:m,Pv.disabled,l?g||f<1||t.hasTranslucentParts?Rv.alphaBlended:Rv.unblended:Rv.disabled,Dv.backCCW,P,n.id,d.vertexBuffer,d.indexBuffer,d.segments,n.paint,e.transform.zoom,void 0,w)}}}};(function(e,t,n,r){const i=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const a of r){const r=t.getTile(a).getBucket(n);r&&(e.conflationActive&&r.updateReplacement(a,e.replacementSource),r.evaluateScale(e,n),e.terrain&&i>0&&r.elevationUpdate(e.terrain,i,a,n.source),r.needsReEvaluation(e,o,n)&&r.evaluate(n))}})(e,t,n,r),1===f?_(!0,!0):(_(!1,!0),_(!0,!1))}(e,t,n,r),void l();const c=u.getModels(),h=[],d=e.transform.getFreeCameraOptions().position,f=id.scale([],[d.x,d.y,d.z],e.transform.worldSize);id.negate(f,f);const p=[],m=[];let _=0;for(const t of c){const r=n.paint.get("model-rotation").constantOr(null),i=n.paint.get("model-scale").constantOr(null),o=n.paint.get("model-translation").constantOr(null);t.computeModelMatrix(e,r,i,o,!0,!0,!1);const a=Jh.identity([]),s=Mf(t.position.lat,e.transform.zoom),l=Jh.fromScaling([],[1,1,1/s]);Jh.translate(a,a,f),h.push({zScaleMatrix:l,negCameraPosMatrix:a});for(const n of t.nodes)CM(e.transform,n,t.matrix,e.transform.expandedFarZProjMatrix,_,p,m);_++}if(p.sort((e,t)=>t.depth-e.depth),"shadow"!==e.renderPass){if(1===i)for(const t of m)IM(t,e,n,h[t.modelIndex],Pv.disabled,e.colorModeForRenderPass());else{for(const t of m)IM(t,e,n,h[t.modelIndex],Pv.disabled,Rv.disabled);for(const t of m)IM(t,e,n,h[t.modelIndex],e.stencilModeFor3D(),e.colorModeForRenderPass());e.resetStencilClippingMasks()}for(const t of p)IM(t,e,n,h[t.modelIndex],Pv.disabled,e.colorModeForRenderPass());l()}else{for(const t of m)kM(t.mesh,t.nodeModelMatrix,e,n);for(const t of p)kM(t.mesh,t.nodeModelMatrix,e,n);l()}}},NM={modelUpload:function(e,t,n){const r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(e.modelManager&&e.modelManager.upload(e,n));if("batched-model"===r.type)return;const i=r.getModels();for(const t of i)t.upload(e.context)}};class UM{constructor(e,t,n){this.context=new Lv(e,t),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=zv.maxUnderzooming+zv.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new Jx,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new WM(this),this._wireframeDebugCache=new FM,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0}updateTerrain(e,t){const n=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(n||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new sE(this,e));const r=this._terrain;this.transform.elevation=n?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.enabled&&(this.transform.elevation=null)}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[n,r]=t.getFovAdjustedRange(this.transform._fov);if(n>r)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}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(e,t){if(this.width=e*ft.devicePixelRatio,this.height=t*ft.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize()}setup(){const e=this.context,t=new cl;t.emplaceBack(0,0),t.emplaceBack(hr,0),t.emplaceBack(0,hr),t.emplaceBack(hr,hr),this.tileExtentBuffer=e.createVertexBuffer(t,hd.members),this.tileExtentSegments=Ql.simpleSegment(0,0,4,2);const r=new cl;r.emplaceBack(0,0),r.emplaceBack(hr,0),r.emplaceBack(0,hr),r.emplaceBack(hr,hr),this.debugBuffer=e.createVertexBuffer(r,hd.members),this.debugSegments=Ql.simpleSegment(0,0,4,5);const i=new cl;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(-1,1),i.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(i,hd.members),this.viewportSegments=Ql.simpleSegment(0,0,4,2);const o=new dl;o.emplaceBack(0,0,0,0),o.emplaceBack(hr,0,hr,0),o.emplaceBack(0,hr,0,hr),o.emplaceBack(hr,hr,hr,hr),this.mercatorBoundsBuffer=e.createVertexBuffer(o,Ny.members),this.mercatorBoundsSegments=Ql.simpleSegment(0,0,4,2);const a=new Al;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(a);const s=new Dl;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=e.createIndexBuffer(s),this.emptyTexture=new Ry(e,new bp({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=Jh.create();const l=this.context.gl;this.stencilClearMode=new Pv({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(n.performance.now())}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 e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,Ov.disabled,this.stencilClearMode,Rv.disabled,Dv.disabled,nE(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,n){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!n||0===n.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of n)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,i=r.gl;this.nextStencilID+n.length>256&&this.clearStencil(),r.setColorMode(Rv.disabled),r.setDepthMode(Ov.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of n){const n=t.getTile(e),r=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:a,tileBoundsIndexBuffer:s,tileBoundsSegments:l}=this.getTileBoundsBuffers(n);o.draw(this,i.TRIANGLES,Ov.disabled,new Pv({func:i.ALWAYS,mask:0},r,255,i.KEEP,i.KEEP,i.REPLACE),Rv.disabled,Dv.disabled,nE(e.projMatrix),"$clipping",a,s,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Pv({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new Pv({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,n=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();const e={};for(let n=0;nthis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Rv([t.ONE,t.ONE_MINUS_SRC_ALPHA,t.CONSTANT_ALPHA,t.ONE_MINUS_SRC_ALPHA],new dn(0,0,0,void 0===e?0:e),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,n,r=!1){if(!this.opaquePassEnabledForLayer()&&!r)return Ov.disabled;const i=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Ov(n||this.context.gl.LEQUAL,t,[i,i])}opaquePassEnabledForLayer(){return this.currentLayerr[e]),a=this.style._mergedSourceCaches;this.imageManager=e.imageManager,this.modelManager=e.modelManager,this.symbolFadeChange=e.placement.symbolFadeChange(ft.now()),this.imageManager.beginFrame();let s=0,l=!1;for(const e in a){const t=a[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++s)}const u={},c={},h={},d={},f={};for(const e in a){const t=a[e];u[e]=t.getVisibleCoordinates(),c[e]=u[e].slice().reverse(),h[e]=t.getVisibleCoordinates(!0).reverse(),d[e]=t.getShadowCasterCoordinates(),f[e]=t.sortCoordinatesByDistance(u[e])}const p=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(s){const e=[];for(const t of o)this.layerUsedInConflation(t,p(t))&&e.push(t);if(e&&e.length>1){const t=[];for(const n of e){const e=this.style.getLayerSourceCache(n);e&&e.used&&e.getSource().usedInConflation&&t.push({layer:n.fqid,cache:e})}this.replacementSource.setSources(t),l=!0}}l||this.replacementSource.clear(),this.conflationActive=l,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const e of o){const t=e.cutoffRange();if(this.longestCutoffRange=Math.max(t,this.longestCutoffRange),t>0){const t=p(e);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),e.minzoom&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom))}}this.opaquePassCutoff=1/0;for(let e=0;e{if(t.showOverdrawInspector)return dn.black;if(this.style.fog&&this.transform.projection.supportsFog&&!y){const e=this.style.fog.properties.get("color").toArray01();return new dn(...e)}if(this.style.fog&&this.transform.projection.supportsFog&&y){const e=this.style.fog.properties.get("space-color").toArray01();return new dn(...e)}return dn.transparent})();if(this.context.clear({color:v,depth:1}),this.clearStencil(),this._showOverdrawInspector=t.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){const t=o[this.currentLayer],n=e.getLayerSourceCache(t);if(t.isSky())continue;const r=n?(t.is3D()?f:c)[n.id]:void 0;this._renderTileClippingMasks(t,n,r),this.renderLayer(this,n,t,r)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||ef(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&t.hasShadowPass()&&0==--x&&(_.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const t=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=t;this.currentLayer++){const t=o[this.currentLayer];if(!t.hasLightBeamPass())continue;const n=e.getLayerSourceCache(t);this.renderLayer(this,n,t,n?c[n.id]:void 0)}this.currentLayer=t,this.renderPass="translucent"}++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let t=null;o.forEach(n=>{const r=e.getLayerSourceCache(n);r&&!n.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!t||t.getSource().maxzoom0?t.pop():null}isPatternMissing(e,t){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString(),t)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,n){const r=void 0===n?this.terrain&&this.terrain.renderingToTexture:n,i=this.terrain&&0===this.terrain.exaggeration(),o=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(o.push("LIGHTING_3D_MODE"),o.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||o.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||o.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?o.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):o.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(o.push("TERRAIN"),this.linearFloatFilteringSupported()&&o.push("TERRAIN_DEM_FLOAT_FORMAT"),i&&o.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&o.push("GLOBE"),!this._fogVisible||r||void 0!==t&&!t||o.push("FOG","FOG_DITHERING"),r&&o.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&o.push("OVERDRAW_INSPECTOR"),o}getOrCreateProgram(e,t){this.cache=this.cache||{};const n=t&&t.defines||[],r=t&&t.config,i=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(n),o=hE.cacheKey(jS[e],e,i,r);return this.cache[o]||(this.cache[o]=new hE(this.context,e,jS[e],r,qE[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=n.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Ry(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(e,t){if(this.style.enable3dLights()){const n=this.style.directionalLight,r=this.style.ambientLight;if(n&&r){const i=((e,t)=>{const n=e.properties.get("direction"),r=e.properties.get("color").toArray01(),i=e.properties.get("intensity"),o=t.properties.get("color").toArray01(),a=t.properties.get("intensity"),s=[n.x,n.y,n.z],l=se(o,a),u=se(r,i);return{u_lighting_ambient_color:l,u_lighting_directional_dir:s,u_lighting_directional_color:u,u_ground_radiance:lE(s,u,l)}})(n,r);t.setLightsUniformValues(e,i)}}}uploadCommonUniforms(e,t,n,r,i){if(this.uploadCommonLightUniforms(e,t),this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const i=o.getOpacity(this.transform.pitch),a=((e,t,n,r,i,o,a,s,l,u,c,h)=>{const d=e.transform,f=t.properties.get("color").toArray01();f[3]=r;const p=e.frameCounter/1e3%1,[m,_]=t.properties.get("vertical-range");return{u_fog_matrix:n?d.calculateFogTileMatrix(n):h||e.identityMat,u_fog_range:t.getFovAdjustedRange(d._fov),u_fog_color:f,u_fog_horizon_blend:t.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(m,_),_],u_fog_temporal_offset:p,u_frustum_tl:i,u_frustum_tr:o,u_frustum_br:a,u_frustum_bl:s,u_globe_pos:l,u_globe_radius:u,u_viewport:c,u_globe_transition:ef(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,o,n,i,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*ft.devicePixelRatio,this.transform.height*ft.devicePixelRatio],r);t.setFogUniformValues(e,a)}i&&t.setCutoffUniformValues(e,i.uniformValues)}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 e=this._backgroundTiles,t=this._backgroundTiles={},n=this.transform.coveringTiles({tileSize:512});for(const r of n)t[r.key]=e[r.key]||new Vy(r,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={}}layerUsedInConflation(e,t){return!(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||"building"!==e.sourceLayer&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=mw||t[1]>=mw}}const VM=2048;class GM{constructor(e,t){this.aabb=e,this.lastCascade=t}}class qM{add(e,t){const n=this.receivers[e.key];void 0!==n?(n.aabb.min[0]=Math.min(n.aabb.min[0],t.min[0]),n.aabb.min[1]=Math.min(n.aabb.min[1],t.min[1]),n.aabb.min[2]=Math.min(n.aabb.min[2],t.min[2]),n.aabb.max[0]=Math.max(n.aabb.max[0],t.max[0]),n.aabb.max[1]=Math.max(n.aabb.max[1],t.max[1]),n.aabb.max[2]=Math.max(n.aabb.max[2],t.max[2])):this.receivers[e.key]=new GM(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(e,t,n){const r=Md.fromPoints(e.points);let i=0;for(const e in this.receivers){const o=this.receivers[e];if(!o)continue;if(!r.intersectsAabb(o.aabb))continue;o.aabb.min=r.closestPoint(o.aabb.min),o.aabb.max=r.closestPoint(o.aabb.max);const a=o.aabb.getCorners();for(let e=0;e1||o[1]<-1||o[1]>1){r=!1;break}}if(o.lastCascade=e,i=Math.max(i,e),r)break}}return i+1}}class WM{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new qM,this._depthMode=new Ov(e.context.gl.LEQUAL,Ov.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this.useNormalOffset=!1}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(e,t){const n=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!t||!t.properties)return;const r=t.properties.get("shadow-intensity");if(!t.shadowsEnabled()||r<=0)return;if(this._shadowLayerCount=n.style.order.reduce((t,r)=>{const i=n.style._mergedLayers[r];return t+(i.hasShadowPass()&&!i.isHidden(e.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this._enabled)return;const i=n.context,o=VM,a=VM;if(0===this._cascades.length)for(let e=0;e<2;++e){const e=n._shadowMapDebug,t=i.gl,r=i.createFramebuffer(o,a,e,"texture"),s=new Ry(i,{width:o,height:a,data:null},t.DEPTH_COMPONENT);if(r.depthAttachment.set(s.texture),e){const e=new Ry(i,{width:o,height:a,data:null},t.RGBA);r.colorAttachment.set(e.texture)}this._cascades.push({framebuffer:r,texture:s,matrix:[],far:0,boundingSphereRadius:0,frustum:new Ed,scale:0})}this.shadowDirection=HM(t);let s=0;if(e.elevation){const t=e.elevation,n=[1e4,-1e4];t.visibleDemTiles.filter(e=>e.dem).forEach(e=>{const t=e.dem.tree;n[0]=Math.min(n[0],t.minimums[0]),n[1]=Math.max(n[1],t.maximums[0])}),1e4!==n[0]&&(s=(n[1]-n[0])*t.exaggeration())}const l=1.5*e.cameraToCenterDistance,u=3*l,c=new Float64Array(16);for(let t=0;t<2;++t){const n=this._cascades[t];let r=e.height/50,i=1;0===t?i=l:(r=l,i=u);const[o,a]=XM(e,this.shadowDirection,r,i,VM,s);n.scale=e.scale,n.matrix=o,n.boundingSphereRadius=a,Jh.invert(c,n.matrix),n.frustum=Ed.fromInvProjectionMatrix(c,1,0,!0),n.far=i}this._uniformValues.u_fade_range=[.75*this._cascades[1].far,this._cascades[1].far],this._uniformValues.u_shadow_intensity=r,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=.00048828125,this._uniformValues.u_shadow_map_resolution=VM,this._uniformValues.u_shadowmap_0=NE,this._uniformValues.u_shadowmap_1=NE+1,this._groundShadowTiles=n.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const h=n.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(h){const n=h.getMinMaxForTile(e);n&&(t=n)}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max)}}get enabled(){return this._enabled}set enabled(e){this._enabled=e}drawShadowPass(e,t){if(!this._enabled)return;const n=this.painter,r=n.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(n.transform.getFrustum(0),n.transform.worldSize,this._cascades),r.viewport.set([0,0,VM,VM]);for(let i=0;i=0)return{};const i=function(e,t,n){const r=n/(1<0&&(id.add(i[1],i[1],[r[0]*o,0,0]),id.add(i[2],i[2],[r[0]*o,0,0])),r[1]<0?(id.add(i[0],i[0],[0,r[1]*o,0]),id.add(i[1],i[1],[0,r[1]*o,0])):r[1]>0&&(id.add(i[2],i[2],[0,r[1]*o,0]),id.add(i[3],i[3],[0,r[1]*o,0]));const a={};return a.vertices=i,a.planes=[ZM(i[1],i[0],i[4]),ZM(i[2],i[1],i[5]),ZM(i[3],i[2],i[6]),ZM(i[0],i[3],i[7])],a}addShadowReceiver(e,t,n){this._receivers.add(e,Md.fromTileIdAndHeight(e,t,n))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function ZM(e,t,n){const r=id.sub([],n,t),i=id.sub([],e,t),o=id.cross([],r,i),a=id.length(o);return 0===a?[0,0,1,0]:(id.scale(o,o,1/a),[o[0],o[1],o[2],-id.dot(o,t)])}function HM(e){const t=e.properties.get("direction"),n=Q(t.x,t.y,t.z);n[2]=O(n[2],0,75);const r=J([n[0],n[1],n[2]]);return id.fromValues(r.x,r.y,r.z)}function $M(e,t){const n=e.properties.get("color"),r=e.properties.get("intensity"),i=e.properties.get("direction"),o=[i.x,i.y,i.z],a=t.properties.get("color"),s=t.properties.get("intensity"),l=Math.max(id.dot([0,0,1],o),0),u=[0,0,0];id.scale(u,a.toArray01Linear().slice(0,3),s);const c=[0,0,0];return id.scale(c,n.toArray01Linear().slice(0,3),l*r),le([u[0]>0?u[0]/(u[0]+c[0]):0,u[1]>0?u[1]/(u[1]+c[1]):0,u[2]>0?u[2]/(u[2]+c[2]):0])}function XM(e,t,n,r,i,o){const a=e.zoom,s=e.scale,l=e.worldSize,u=1/l,c=e.aspect,h=Math.sqrt(1+c*c)*Math.tan(.5*e.fovX),d=h*h,f=r-n,p=r+n;let m,_;d>f/p?(m=r,_=r*h):(m=.5*p*(1+d),_=.5*Math.sqrt(f*f+2*(r*r+n*n)*d+p*p*d*d));const g=e.projection.pixelsPerMeter(e.center.lat,l),y=e._camera.getCameraToWorldMercator(),v=[0,0,-m*u];id.transformMat4(v,v,y);let x=_*u;const b=e._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const t=e._camera.getWorldToCamera(e.worldSize,"meters"===e.projection.zAxisUnit?g:1),i=e._camera.getCameraToClipPerspective(e._fov,e.width/e.height,n,r);i[8]=2*-e.centerOffset.x/e.width,i[9]=2*e.centerOffset.y/e.height;const o=new Float64Array(16);Jh.mul(o,i,t);const u=new Float64Array(16);Jh.invert(u,o);const c=Ed.fromInvProjectionMatrix(u,l,a,!0);for(const t of c.points){const n=((w=t)[0]/=s,w[1]/=s,w[2]=xf(w[2],e._center.lat),w);x=Math.max(x,id.len(id.subtract([],v,n)))}}var w;x*=i/(i-1);const T=Math.acos(t[2]),S=Math.atan2(-t[0],-t[1]),E=new Jv;E.position=v,E.setPitchBearing(T,S);const M=E.getWorldToCamera(l,g),A=x*l,I=Math.min(e._mercatorZfromZoom(17)*l*-2,-2*A),C=E.getCameraToClipOrthographic(-A,A,-A,A,I,(A+o*g)/t[2]),k=new Float64Array(16);Jh.multiply(k,C,M);const O=id.fromValues(Math.floor(1e6*v[0])/1e6*l,Math.floor(1e6*v[1])/1e6*l,0),P=.5*i,R=[0,0,0];id.transformMat4(R,O,k),id.scale(R,R,P);const D=[Math.floor(R[0]),Math.floor(R[1]),Math.floor(R[2])],L=[0,0,0];id.sub(L,R,D),id.scale(L,L,-1/P);const z=new Float64Array(16);return Jh.identity(z),Jh.translate(z,z,L),Jh.multiply(k,z,k),[k,A]}class YM extends Ot{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={}}loadModel(e,t){return dT(this.requestManager.transformRequest(t,ve.Model).url).then(t=>{if(!t)return;const n=bT(t),r=new Px(e,void 0,void 0,n);return r.computeBoundsAndApplyParent(),r}).catch(n=>{this.fire(new kt(new Error(`Could not load model ${e} from ${t}: ${n.message}`)))})}load(e,t){this.models[t]||(this.models[t]={});const n=Object.keys(e);this.numModelsLoading[t]=(this.numModelsLoading[t]||0)+n.length;const r=[];for(const t of n)r.push(this.loadModel(t,e[t]));Promise.allSettled(r).then(e=>{for(let r=0;r{this.fire(new kt(new Error("Could not load models: "+e.message)))})}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t){return!!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]}addModel(e,t,n){this.models[n]||(this.models[n]={}),this.hasModel(e,n)&&this.removeModel(e,n),this.load({[e]:this.requestManager.normalizeModelURL(t)},n)}addModels(e,t){const n={};for(const t in e)n[t]=this.requestManager.normalizeModelURL(e[t]);this.load(n,t)}removeModel(e,t){this.models[t]||(this.models[t]={});const n=this.models[t][e];delete this.models[t][e],n.destroy()}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const n in this.models[t])this.models[t][n].upload(e.context)}}const KM=(e,t)=>ma(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),JM=B(DT,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","setImportUrl","setImportData","setImportConfig"]),QM=B(DT,["setCenter","setZoom","setBearing","setPitch"]),eA={version:8,layers:[],sources:{}},tA={duration:300,delay:0},nA=new Set(["fill","line","background","hillshade","raster"]);class rA extends Ot{constructor(e,t={}){super(),this.map=e,this.scope=t.scope||"",this.fragments=[],this.importDepth=t.importDepth||0,this.importsCache=t.importsCache||new Map,this.resolvedImports=t.resolvedImports||new Set,this.transition=z({},tA),this._buildingIndex=new kT(this),this.crossTileSymbolIndex=new ES,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=t.styleChanges||new il,this.dispatcher=t.dispatcher?t.dispatcher:new Ew(Hw(),this),t.imageManager?this.imageManager=t.imageManager:(this.imageManager=new cw,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=t.glyphManager?t.glyphManager:new mg(e._requestManager,t.localFontFamily?2:t.localIdeographFontFamily?1:0,t.localFontFamily||t.localIdeographFontFamily),t.modelManager?this.modelManager=t.modelManager:(this.modelManager=new YM(e._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this.options=new Map,this._configDependentLayers=new Set,this._config=t.config,this.dispatcher.broadcast("setReferrer",be());const n=this;this._rtlTextPluginCallback=rA.registerForPluginStateChange(e=>{n.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},(e,t)=>{if(Ds(e),t&&t.every(e=>e))for(const e in n._sourceCaches){const t=n._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||t.reload()}})}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(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(e,t={}){this.fire(new Ct("dataloading",{dataType:"style"}));const n="boolean"==typeof t.validate?t.validate:!Pe(e);e=this.map._requestManager.normalizeStyleURL(e,t.accessToken),this.resolvedImports.add(e);const r=this.importsCache.get(e);if(r)return this._load(r,n);const i=this.map._requestManager.transformRequest(e,ve.Style);this._request=Te(i,(t,r)=>{if(this._request=null,t)this.fire(new kt(t));else if(r)return this.importsCache.set(e,r),this._load(r,n)})}loadJSON(e,t={}){this.fire(new Ct("dataloading",{dataType:"style"})),this._request=ft.frame(()=>{this._request=null,this._load(e,!1!==t.validate)})}loadEmpty(){this.fire(new Ct("dataloading",{dataType:"style"})),this._load(eA,!1)}_loadImports(e,t){if(this.importDepth>=4)return X("Style doesn't support nesting deeper than 5"),Promise.resolve();const n=[];for(const r of e){const e=this._createFragmentStyle(r),i=new Promise(t=>{e.once("style.import.load",t),e.once("error",t)}).then(()=>this.mergeAll());if(n.push(i),this.resolvedImports.has(r.url)){e.loadEmpty();continue}const o=r.data||this.importsCache.get(r.url);o?e.loadJSON(o,{validate:t}):r.url?e.loadURL(r.url,{validate:t}):e.loadEmpty(),this.fragments.push({style:e,id:r.id,config:r.config})}return Promise.allSettled(n)}_createFragmentStyle(e){const t=this.scope?el(e.id,this.scope):e.id,n=new rA(this.map,{scope:t,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:e.config});return n.setEventedParent(this.map,{style:n}),n}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options});const e=this.isRootStyle();this._shouldPrecompile=e,this.fire(new Ct(e?"style.load":"style.import.load"))}_load(e,t){const n=e.schema;if(this.isRootStyle()&&(e.fragment||n&&!1!==e.fragment)){const n=z({},eA,{imports:[{id:"basemap",data:e,url:""}]});return void this._load(n,t)}if(this.setConfig(this._config,n),t&&KM(this,ra(e)))return;this._loaded=!0,this.stylesheet=H(e);for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1,isInitialLoad:!0});e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(e.glyphs,this.scope);const r=RT(this.stylesheet.layers);if(this._order=r.map(e=>e.id),this.stylesheet.light&&X("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new dw(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new dw(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const e of r){const t=lw(e,this.options);t.setScope(this.scope),t.isConfigDependent&&this._configDependentLayers.add(t.fqid),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize();const n=this.getOwnLayerSourceCache(t),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();n&&t.canCastShadows()&&r&&(n.castsShadows=!0)}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const i=this.stylesheet.terrain;i&&(void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=ft.hasCanvasFingerprintNoise()),this.disableElevatedTerrain?X("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."):this.terrainSetForDrapingOnly()||this._createTerrain(i,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new Ct("data",{dataType:"style"})),e.imports?this._loadImports(e.imports,t).then(()=>this._reloadImports()):this._reloadImports()}isRootStyle(){return 0===this.importDepth}mergeAll(){let e,t,n,r,i,o,a,s;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(l=>{if(l.stylesheet){if(null!=l.light&&(e=l.light),l.stylesheet.lights)for(const e of l.stylesheet.lights)"ambient"===e.type&&null!=l.ambientLight&&(t=l.ambientLight),"directional"===e.type&&null!=l.directionalLight&&(n=l.directionalLight);r=this._prioritizeTerrain(r,l.terrain,l.stylesheet.terrain),l.stylesheet.fog&&null!=l.fog&&(i=l.fog),null!=l.stylesheet.camera&&(s=l.stylesheet.camera),null!=l.stylesheet.projection&&(o=l.stylesheet.projection),null!=l.stylesheet.transition&&(a=l.stylesheet.transition)}}),this.light=e,this.ambientLight=t,this.directionalLight=n,this.fog=i,null===r?delete this.terrain:this.terrain=r,this.camera=s||{"camera-projection":"perspective"},this.projection=o||{name:"mercator"},this.transition=z({},tA,a),this.mergeSources(),this.mergeLayers()}forEachFragmentStyle(e){const t=n=>{for(const e of n.fragments)t(e.style);e(n)};t(this)}_prioritizeTerrain(e,t,n){const r=e&&0===e.drapeRenderMode;return null===n?t&&0===t.drapeRenderMode?t:r?e:null:null!=t&&(!e||r||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain)}),null===e?delete this.terrain:this.terrain=e}mergeProjection(){let e;this.forEachFragmentStyle(t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)}),this.projection=e||{name:"mercator"}}mergeSources(){const e={},t={},n={};this.forEachFragmentStyle(r=>{for(const t in r._sourceCaches){const n=el(t,r.scope);e[n]=r._sourceCaches[t]}for(const e in r._otherSourceCaches){const n=el(e,r.scope);t[n]=r._otherSourceCaches[e]}for(const e in r._symbolSourceCaches){const t=el(e,r.scope);n[t]=r._symbolSourceCaches[e]}}),this._mergedSourceCaches=e,this._mergedOtherSourceCaches=t,this._mergedSymbolSourceCaches=n}mergeLayers(){const e={},t=[],n={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(n=>{for(const r of n._order){const i=n._layers[r];if("slot"===i.type){const t=tl(r);if(e[t])continue;e[t]=[]}i.slot&&e[i.slot]?e[i.slot].push(i):t.push(i)}}),this._mergedOrder=[];const r=(t=[])=>{for(const i of t)if("slot"===i.type){const t=tl(i.id);e[t]&&r(e[t])}else{const e=el(i.id,i.scope);this._mergedOrder.push(e),n[e]=i,i.is3D()&&(this._has3DLayers=!0),"circle"===i.type&&(this._hasCircleLayers=!0),"symbol"===i.type&&(this._hasSymbolLayers=!0)}};r(t),this._mergedLayers=n,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=z({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),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.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(e){this._spriteRequest=function(e,t,n){let r,i,o;const a=ft.devicePixelRatio>1?"@2x":"";let s=Te(t.transformRequest(t.normalizeSpriteURL(e,a,".json"),ve.SpriteJSON),(e,t)=>{s=null,o||(o=e,r=t,u())}),l=Ce(t.transformRequest(t.normalizeSpriteURL(e,a,".png"),ve.SpriteImage),(e,t)=>{l=null,o||(o=e,i=t,u())});function u(){if(o)n(o);else if(r&&i){const e=ft.getImageData(i),t={};for(const n in r){const{width:i,height:o,x:a,y:s,sdf:l,pixelRatio:u,stretchX:c,stretchY:h,content:d}=r[n],f=new bp({width:i,height:o});bp.copy(e,f,{x:a,y:s},{x:0,y:0},{width:i,height:o}),t[n]={data:f,pixelRatio:u,sdf:l,stretchX:c,stretchY:h,content:d}}n(null,t)}}return{cancel(){s&&(s.cancel(),s=null),l&&(l.cancel(),l=null)}}}(e,this.map._requestManager,(e,t)=>{if(this._spriteRequest=null,e)this.fire(new kt(e));else if(t)for(const e in t)this.imageManager.addImage(e,this.scope,t[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new Ct("data",{dataType:"style"}))})}_validateLayer(e){const t=this.getOwnSource(e.source);if(!t)return;const n=e.sourceLayer;n&&("geojson"===t.type||t.vectorLayerIds&&-1===t.vectorLayerIds.indexOf(n))&&this.fire(new kt(new Error(`Source layer "${n}" does not exist on source "${t.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;if(!this.imageManager.isLoaded())return!1;if(!this.modelManager.isLoaded())return!1;for(const{style:e}of this.fragments)if(!e.loaded())return!1;return!0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map((e,t)=>{const n=this.fragments[t];return n&&n.style&&(e.data=n.style.serialize()),e})}_serializeSources(){const e={};for(const t in this._sourceCaches){const n=this._sourceCaches[t].getSource();e[n.id]||(e[n.id]=n.serialize())}return e}_serializeLayers(e){const t=[];for(const n of e){const e=this._layers[n];e&&"custom"!==e.type&&t.push(e.serialize())}return t}hasLightTransitions(){return!(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return!!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())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.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&("function"==typeof e.isLayerDraped?e.isLayerDraped(this.getLayerSourceCache(e)):nA.has(e.type))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(e){const t=this.getOwnLayer(e);if(t)return t;this.fire(new kt(new Error(`The layer '${e}' does not exist in the map's style.`)))}_checkSource(e){const t=this.getOwnSource(e);if(t)return t;this.fire(new kt(new Error(`The source '${e}' does not exist in the map's style.`)))}update(e){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(e),this.directionalLight&&this.directionalLight.recalculate(e);const t=this.calculateLightsBrightness();e.brightness=t||0,t!==this._brightness&&(this._brightness=t,this.dispatcher.broadcast("setBrightness",t));const n=this._changes.isDirty();if(this._changes.isDirty()){const t=this._changes.getLayerUpdatesByScope();for(const e in t){const{updatedIds:n,removedIds:r}=t[e];(n||r)&&this._updateWorkerLayers(e,n,r)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(e),this.light&&this.light.updateTransitions(e),this.ambientLight&&this.ambientLight.updateTransitions(e),this.directionalLight&&this.directionalLight.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._changes.reset()}const r={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];r[e]=t.used,t.used=!1}for(const t of this._mergedOrder){const n=this._mergedLayers[t];if(n.recalculate(e,this._availableImages),!n.isHidden(e.zoom)){const e=this.getLayerSourceCache(n);e&&(e.used=!0)}if(!this._precompileDone&&this._shouldPrecompile)for(let t=n.minzoom||0;t<(n.maxzoom||25.5);t++){const t=this.map.painter;if(t){const r=n.getProgramIds();if(!r)continue;for(const i of r){const r=n.getDefaultProgramParams(i,e.zoom);r&&(t.style=this,this.fog&&(t._fogVisible=!0,r.overrideFog=!0,t.getOrCreateProgram(i,r)),t._fogVisible=!1,r.overrideFog=!1,t.getOrCreateProgram(i,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,t.getOrCreateProgram(i,r)))}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const e in r){const t=this._mergedSourceCaches[e];r[e]!==t.used&&t.getSource().fire(new Ct("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}))}this.light&&this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new Ct("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages()}}_updateWorkerLayers(e,t,n){const r=this.getFragmentStyle(e);r&&this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:n||[],options:r.options})}setState(e){if(this._checkLoaded(),KM(this,ra(e)))return!1;(e=H(e)).layers=RT(e.layers);const t=function(e,t){if(!e)return[{command:DT.setStyle,args:[t]}];let n=[];try{if(!x(e.version,t.version))return[{command:DT.setStyle,args:[t]}];x(e.center,t.center)||n.push({command:DT.setCenter,args:[t.center]}),x(e.zoom,t.zoom)||n.push({command:DT.setZoom,args:[t.zoom]}),x(e.bearing,t.bearing)||n.push({command:DT.setBearing,args:[t.bearing]}),x(e.pitch,t.pitch)||n.push({command:DT.setPitch,args:[t.pitch]}),x(e.sprite,t.sprite)||n.push({command:DT.setSprite,args:[t.sprite]}),x(e.glyphs,t.glyphs)||n.push({command:DT.setGlyphs,args:[t.glyphs]}),x(e.imports,t.imports)||function(e=[],t=[],n){t=t||[];const r=(e=e||[]).map(NT),i=t.map(NT),o=e.reduce(UT,{}),a=t.reduce(UT,{}),s=r.slice();let l,u,c,h;for(l=0,u=0;l{e.source&&r[e.source]?n.push({command:DT.removeLayer,args:[e.id]}):o.push(e)});let a=e.terrain;a&&r[a.source]&&(n.push({command:DT.setTerrain,args:[void 0]}),a=void 0),n=n.concat(i),x(a,t.terrain)||n.push({command:DT.setTerrain,args:[t.terrain]}),function(e,t,n){t=t||[];const r=(e=e||[]).map(NT),i=t.map(NT),o=e.reduce(UT,{}),a=t.reduce(UT,{}),s=r.slice(),l=Object.create(null);let u,c,h,d,f,p,m;for(u=0,c=0;u!(e.command in QM));if(0===t.length)return!1;const n=t.filter(e=>!(e.command in JM));if(n.length>0)throw new Error(`Unimplemented: ${n.map(e=>e.command).join(", ")}.`);return t.forEach(e=>{this[e.command].apply(this,e.args)}),this.stylesheet=e,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(e,t){return this.getImage(e)?this.fire(new kt(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,this.scope,t),this._afterImageUpdated(e),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t)}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e,this.scope),this._afterImageUpdated(e),this):this.fire(new kt(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(e),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new Ct("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,n={}){return this._checkLoaded(),this._validate(fa,"models."+e,t,null,n)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(e){return this.hasModel(e)?(this.modelManager.removeModel(e,this.scope),this):this.fire(new kt(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(e,t,n={}){if(this._checkLoaded(),void 0!==this.getOwnSource(e))throw new Error(`There is already a source with ID "${e}".`);if(!t.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(t.type)>=0&&this._validate(ia,"sources."+e,t,null,n))return;this.map&&this.map._collectResourceTiming&&(t.collectResourceTiming=!0);const r=ET(e,t,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id}));const i=e=>{const t=(e?"symbol:":"other:")+r.id,n=el(t,this.scope),i=this._sourceCaches[t]=new zv(n,r,e);(e?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=i,i.onAdd(this.map)};i(!1),"vector"!==t.type&&"geojson"!==t.type||i(!0),r.onAdd&&r.onAdd(this.map),n.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(e){this._checkLoaded();const t=this.getOwnSource(e);if(!t)throw new Error("There is no source with this ID");for(const t in this._layers)if(this._layers[t].source===e)return this.fire(new kt(new Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===e)return this.fire(new kt(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const n=this.getOwnSourceCaches(e);for(const e of n){const t=tl(e.id);delete this._sourceCaches[t],this._changes.discardSourceCacheUpdate(e.id),e.fire(new Ct("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles()}return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],this.mergeSources(),t.setEventedParent(null),t.onRemove&&t.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty()}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const n=this.getOwnSourceCache(t);n&&e.push(n.getSource())}return e}setLights(e){if(this._checkLoaded(),!e)return delete this.ambientLight,void delete this.directionalLight;const t=this._getTransitionParameters();for(const n of e){if(this._validate(aa,"lights",n))return;switch(n.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(n),e.updateTransitions(t)}else this.ambientLight=new Mw(n,Aw,this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(n),e.updateTransitions(t)}else this.directionalLight=new Mw(n,Iw,this.scope,this.options)}}const n=new Ns(this.z||0,t);this.ambientLight&&this.ambientLight.recalculate(n),this.directionalLight&&this.directionalLight.recalculate(n),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const e=this.directionalLight,t=this.ambientLight;if(!e||!t)return;const n=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=e.properties.get("color").toArray01(),i=e.properties.get("intensity"),o=e.properties.get("direction"),a=1-Q(o.x,o.y,o.z)[2]/90,s=n(r)*i*a,l=t.properties.get("color").toArray01(),u=t.properties.get("intensity");return(s+n(l)*u)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return!!this.ambientLight&&!!this.directionalLight}getFragmentStyle(e){if(!e)return this;if(Qs(e)){const t=function(e){const t=e.indexOf("");return t>=0?e.slice(t+1):""}(e),n=this.fragments.find(({id:e})=>e===t);if(!n)throw new Error("Style import not found: "+e);const r=tl(e);return n.style.getFragmentStyle(r)}{const t=this.fragments.find(({id:t})=>t===e);if(!t)throw new Error("Style import not found: "+e);return t.style}}getConfigProperty(e,t){const n=this.getFragmentStyle(e);if(!n)return null;const r=n.options.get(t),i=r?r.value||r.default:null;return i?i.serialize():null}setConfigProperty(e,t,n){const r=go(n);if("success"!==r.result)return void KM(this,r.value);const i=r.value.expression,o=this.getFragmentStyle(e);if(!o)return;const a=o.options.get(t);a&&(o.options.set(t,{...a,value:i}),o.updateConfigDependencies())}setConfig(e,t){if(this._config=e,e||t)if(t){this.options.clear();for(const n in t){let r,i;const o=go(t[n].default);if("success"===o.result&&(r=o.value.expression),e&&void 0!==e[n]){const t=go(e[n]);"success"===t.result&&(i=t.value.expression)}const{minValue:a,maxValue:s,stepValue:l,type:u,values:c}=t[n];r?this.options.set(n,{default:r,value:i,minValue:a,maxValue:s,stepValue:l,type:u,values:c}):this.fire(new kt(new Error(`No schema defined for config option "${n}".`)))}}else this.fire(new kt(new Error("Attempting to set config for a style without schema.")))}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t))}this.ambientLight&&this.ambientLight.scope===this.scope&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.scope===this.scope&&this.directionalLight.updateConfig(this.options),this._changes.setDirty()}addLayer(e,t,n={}){this._checkLoaded();const r=e.id;if(this._layers[r])return void this.fire(new kt(new Error(`Layer with id "${r}" already exists on this map`)));let i;if("custom"===e.type){if(KM(this,function(e){const t=[],n=e.id;return void 0===n&&t.push({message:`layers.${n}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${n}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${n}: property "renderingMode" must be either "2d" or "3d"`}),t}(e)))return;i=lw(e,this.options)}else{if("object"==typeof e.source&&(this.addSource(r,e.source),e=z(e=H(e),{source:r})),this._validate(ua,"layers."+r,e,{arrayIndex:-1},n))return;i=lw(e,this.options),this._validateLayer(i),i.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[i.id]=i.serialize()}i.isConfigDependent&&this._configDependentLayers.add(i.fqid),i.setScope(this.scope);let o=this._order.length;if(t){const e=this._order.indexOf(t);if(-1===e)return void this.fire(new kt(new Error(`Layer with id "${t}" does not exist on this map.`)));i.slot===this._layers[t].slot?o=e:X(`Layer with id "${t}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,r),this._layerOrderChanged=!0,this._layers[r]=i;const a=this.getOwnLayerSourceCache(i),s=!!this.directionalLight&&this.directionalLight.shadowsEnabled();a&&i.canCastShadows()&&s&&(a.castsShadows=!0);const l=this._changes.getRemovedLayer(i);if(l&&i.source&&a&&"custom"!==i.type){this._changes.discardLayerRemoval(i);const e=el(i.source,i.scope);l.type!==i.type?this._changes.updateSourceCache(e,"clear"):(this._changes.updateSourceCache(e,"reload"),a.pause())}this._updateLayer(i),i.onAdd&&i.onAdd(this.map),i.scope=this.scope,this.mergeLayers()}moveLayer(e,t){this._checkLoaded();const n=this._checkLayer(e);if(!n)return;if(e===t)return;const r=this._order.indexOf(e);this._order.splice(r,1);let i=this._order.length;if(t){const e=this._order.indexOf(t);if(-1===e)return void this.fire(new kt(new Error(`Layer with id "${t}" does not exist on this map.`)));n.slot===this._layers[t].slot?i=e:X(`Layer with id "${t}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(i,0,e),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers()}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const n=this._order.indexOf(e);this._order.splice(n,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const n in this._layers)if(this._layers[n].source===t.source&&this._layers[n].canCastShadows()){e=!0;break}r.castsShadows=e}t.onRemove&&t.onRemove(this.map),this.mergeLayers()}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(e,t,n){this._checkLoaded();const r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===n||(null!=t&&(r.minzoom=t),null!=n&&(r.maxzoom=n),this._updateLayer(r)))}setSlot(e,t){this._checkLoaded();const n=this._checkLayer(e);n&&n.slot!==t&&(n.slot=t,this._updateLayer(n))}setFilter(e,t,n={}){this._checkLoaded();const r=this._checkLayer(e);if(r&&!x(r.filter,t))return null==t?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(ca,`layers.${r.id}.filter`,t,{layerType:r.type},n)||(r.filter=H(t),this._updateLayer(r)))}getFilter(e){const t=this._checkLayer(e);if(t)return H(t.filter)}setLayoutProperty(e,t,n,r={}){this._checkLoaded();const i=this._checkLayer(e);i&&(x(i.getLayoutProperty(t),n)||(i.setLayoutProperty(t,n,r),i.isConfigDependent&&this._configDependentLayers.add(i.fqid),this._updateLayer(i)))}getLayoutProperty(e,t){const n=this._checkLayer(e);if(n)return n.getLayoutProperty(t)}setPaintProperty(e,t,n,r={}){this._checkLoaded();const i=this._checkLayer(e);if(!i)return;if(x(i.getPaintProperty(t),n))return;const o=i.setPaintProperty(t,n,r);i.isConfigDependent&&this._configDependentLayers.add(i.fqid),o&&this._updateLayer(i),this._changes.updatePaintProperties(i)}getPaintProperty(e,t){const n=this._checkLayer(e);if(n)return n.getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();const n=e.source,r=e.sourceLayer,i=this._checkSource(n);if(!i)return;const o=i.type;if("geojson"===o&&r)return void this.fire(new kt(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!r)return void this.fire(new kt(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new kt(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(n);for(const n of a)n.setFeatureState(r,e.id,t)}removeFeatureState(e,t){this._checkLoaded();const n=e.source,r=this._checkSource(n);if(!r)return;const i=r.type,o="vector"===i?e.sourceLayer:void 0;if("vector"===i&&!o)return void this.fire(new kt(new Error("The sourceLayer parameter must be provided for vector source types.")));if(t&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new kt(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(n);for(const n of a)n.removeFeatureState(o,e.id,t)}getFeatureState(e){this._checkLoaded();const t=e.source,n=e.sourceLayer,r=this._checkSource(t);if(r){if("vector"!==r.type||n)return void 0===e.id&&this.fire(new kt(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(t)[0].getFeatureState(n,e.id);this.fire(new kt(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(e){return this.stylesheet.transition=z({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return z({},this.stylesheet.transition)}serialize(){this._checkLoaded();const e=this.getTerrain(),t=e&&this.terrain&&this.terrain.scope===this.scope?e:this.stylesheet.terrain;return Z({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:t,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:this._serializeSources(),layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateLayer(e){this._changes.updateLayer(e);const t=this.getLayerSourceCache(e),n=el(e.source,e.scope),r=this._changes.getUpdatedSourceCaches();e.source&&!r[n]&&t&&"raster"!==t.getSource().type&&(this._changes.updateSourceCache(n,"reload"),t.pause()),e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type,n=this.order,r={},i=[];for(let o=n.length-1;o>=0;o--){const a=n[o];if(t(a)){r[a]=o;for(const t of e){const e=t[a];if(e)for(const t of e)i.push(t)}}}i.sort((e,t)=>t.intersectionZ-e.intersectionZ);const o=[];for(let a=n.length-1;a>=0;a--){const s=n[a];if(t(s))for(let e=i.length-1;e>=0;e--){const t=i[e].feature;if(r[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()}):this.has3DLayers(),s=Cw.createFromScreenPoints(e,n);for(const e in this._mergedSourceCaches){const l=this._mergedSourceCaches[e].getSource();if(!l||l.scope!==t.scope)continue;const u=this._mergedSourceCaches[e].getSource().id;t.layers&&!r[u]||i.push(AT(this._mergedSourceCaches[e],this._mergedLayers,o,s,t,n,a,!!this.map._showQueryGeometry))}return this.placement&&i.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(CT);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._mergedLayers,o,this.getLayerSourceCache.bind(this),s.screenGeometry,t,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(i)}querySourceFeatures(e,t){t&&t.filter&&this._validate(ca,"querySourceFeatures.filter",t.filter,null,t);const n=this.getOwnSourceCaches(e);let r=[];for(const e of n)r=r.concat(IT(e,t));return r}addSourceType(e,t,n){return rA.getSourceType(e)?n(new Error(`A source type called "${e}" already exists.`)):(rA.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},n):n(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,t,n={}){this._checkLoaded();const r=this.light.getLight();let i=!1;for(const t in e)if(!x(e[t],r[t])){i=!0;break}if(!i)return;const o=this._getTransitionParameters();this.light.setLight(e,t,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(e,t=1){if(this._checkLoaded(),!e)return delete this.terrain,null===e?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let n=e;const r=null==e.source;if(1===t){if("object"==typeof n.source){const e="terrain-dem-src";this.addSource(e,n.source),n=H(n),n=z(n,{source:e})}const e=z({},n),t={};if(this.terrain&&r){e.source=this.terrain.get().source;const n=this.terrain?this.getFragmentStyle(this.terrain.scope):null;n&&(t.style=n.serialize())}if(this._validate(sa,"terrain",e,t))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&t!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,t),this.fire(new Ct("data",{dataType:"style"}))}else{const t=this.terrain,r=t.get();for(const e of Object.keys(Pt.terrain))!n.hasOwnProperty(e)&&Pt.terrain[e].default&&(n[e]=Pt.terrain[e].default);for(const n in e)if(!x(e[n],r[n])){t.set(e,this.options),this.stylesheet.terrain=e;const n=this._getTransitionParameters({duration:0});t.updateTransitions(n),this.fire(new Ct("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new bw(e,this.map.transform);this.stylesheet.fog=t.get();const n=this._getTransitionParameters({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 t=this.fog;if(!x(t.get(),e)){t.set(e),this.stylesheet.fog=t.get();const n=this._getTransitionParameters({duration:0});t.updateTransitions(n)}}else this._createFog(e);this._markersNeedUpdate=!0}_getTransitionParameters(e){return{now:ft.now(),transition:z(this.transition,e)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const n in this._mergedLayers)this.isLayerDraped(this._mergedLayers[n])?e.push(n):t.push(n);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const n=this.terrain=new pw(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({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(e,t,n,r,i={}){if(i&&!1===i.validate)return!1;const o=z({},this.serialize());return KM(this,e.call(ra,z({key:t,style:o,value:n,styleSpec:Pt},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),zs.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove())}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles()}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[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){let t;this.directionalLight&&(t=HM(this.directionalLight));for(const n in this._mergedSourceCaches)this._mergedSourceCaches[n].update(e,void 0,void 0,t)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(e,t,n,r,i=!1){let o=!1,a=!1;const s={},l={};for(const t of this._mergedOrder){const n=this._mergedLayers[t];if("symbol"!==n.type)continue;const r=el(n.source,n.scope);let i=s[r];if(!i){const e=this.getLayerSourceCache(n);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));l[r]=t.slice(),i=s[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const a=this.crossTileSymbolIndex.addLayer(n,i,e.center.lng,e.projection);o=o||a}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),i=i||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new Ct("neworder")),(i||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(ft.now(),e.zoom))&&(this.pauseablePlacement=new mS(e,this._mergedOrder,i,t,n,r,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,s,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ft.now()),a=!0),o&&this.pauseablePlacement.placement.setStale()),a||o)for(const e of this._mergedOrder){const t=this._mergedLayers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,s[el(t.source,t.scope)])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(ft.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}addImport(e){this._checkLoaded();const t=this.stylesheet.imports=this.stylesheet.imports||[];return-1!==t.findIndex(({id:t})=>t===e.id)?this.fire(new kt(new Error(`Import with id '${e.id}' already exists in the map's style.`))):(t.push(e),this._loadImports([e],!0),this)}setImportUrl(e,t){this._checkLoaded();const n=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;n[r].url=t;const i=this.fragments[r];return i.style=this._createFragmentStyle(n[r]),i.style.on("style.import.load",()=>this.mergeAll()),i.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];return-1===n?this:t?(this.fragments[n].style.setState(t),this._reloadImports(),this):(delete r[n].data,this.setImportUrl(e,r[n].url))}setImportConfig(e,t){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===n)return this;t?r[n].config=t:delete r[n].config;const i=this.fragments[n],o=i.style.stylesheet&&i.style.stylesheet.schema;return i.config=t,i.style.setConfig(t,o),i.style.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],n=this.getImportIndex(e);return-1===n||(t.splice(n,1),this.fragments[n].style._remove(),this.fragments.splice(n,1),this._reloadImports()),this}getImportIndex(e){const t=(this.stylesheet.imports||[]).findIndex(t=>t.id===e);return-1===t&&this.fire(new kt(new Error(`Import '${e}' does not exist in the map's style and cannot be updated.`))),t}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const n=this._mergedOtherSourceCaches[t];n&&e.push(n.getSource())}return e}getSource(e,t){const n=this.getSourceCache(e,t);return n&&n.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(e,t){const n=el(e,t);return this._mergedOtherSourceCaches[n]}getLayerSourceCache(e){const t=el(e.source,e.scope);return"symbol"===e.type?this._mergedSymbolSourceCaches[t]:this._mergedOtherSourceCaches[t]}getSourceCaches(e){const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const n=e[t];"reload"===n?this.reloadSource(t):"clear"===n&&this.clearSource(t)}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const n of t){const t=this.getLayer(n);t&&t.updateTransitions(e)}}getImages(e,t,n){this.imageManager.getImages(t.icons,t.scope,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,t.scope,n)}getResource(e,t,n){return we(t,n)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(e){const t=this.getOwnSourceCaches(e);return 0===t.length?(this.fire(new kt(new Error(`There is no source with ID '${e}'`))),!1):t.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}function iA(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)}rA.getSourceType=function(e){return ST[e]},rA.setSourceType=function(e,t){ST[e]=t},rA.registerForPluginStateChange=function(e){return e({pluginStatus:Ps,pluginURL:Rs}),zs.on("pluginStateChange",e),e};class oA{constructor(e){this._hashName=e&&encodeURIComponent(e),G(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=iA(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,n.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),n.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const t=aA(e);if(this._hashName){const e=this._hashName;let r=!1;const i=n.location.hash.slice(1).split("&").map(n=>{const i=n.split("=")[0];return i===e?(r=!0,`${i}=${t}`):n}).filter(e=>e);return r||i.push(`${e}=${t}`),"#"+i.join("&")}return"#"+t}_getCurrentHash(){const e=n.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map(e=>e.split("=")).forEach(e=>{e[0]===this._hashName&&(t=e)}),(t&&t[1]||"").split("/")}return e.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 e=n.location.href.replace(/(#.+)?$/,this.getHashString());n.history.replaceState(n.history.state,null,e)}}function aA(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 sA={linearity:.3,easing:C(0,0,.3,1)},lA=z({deceleration:2500,maxSpeed:1400},sA),uA=z({deceleration:20,maxSpeed:1400},sA),cA=z({deceleration:1e3,maxSpeed:360},sA),hA=z({deceleration:1e3,maxSpeed:90},sA);class dA{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ft.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=ft.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const t={zoom:0,bearing:0,pitch:0,pan:new v(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)t.zoom+=e.zoomDelta||0,t.bearing+=e.bearingDelta||0,t.pitch+=e.pitchDelta||0,e.panDelta&&t.pan._add(e.panDelta),e.around&&(t.around=e.around),e.pinchAround&&(t.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(t.pan.mag()){const i=pA(t.pan.mag(),n,z({},lA,e||{}));r.offset=t.pan.mult(i.amount/t.pan.mag()),r.center=this._map.transform.center,fA(r,i)}if(t.zoom){const e=pA(t.zoom,n,uA);r.zoom=this._map.transform.zoom+e.amount,fA(r,e)}if(t.bearing){const e=pA(t.bearing,n,cA);r.bearing=this._map.transform.bearing+O(e.amount,-179,179),fA(r,e)}if(t.pitch){const e=pA(t.pitch,n,hA);r.pitch=this._map.transform.pitch+e.amount,fA(r,e)}if(r.zoom||r.bearing){const e=void 0===t.pinchAround?t.around:t.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function fA(e,t){(!e.duration||e.durationt.unproject(e)),a=i.reduce((e,t,n,r)=>e.add(t.div(r.length)),new v(0,0));super(e,{points:i,point:a,lngLats:o,lngLat:t.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class gA extends Ct{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class yA{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new gA(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new mA(e.type,this._map,e))}mouseup(e){this._map.fire(new mA(e.type,this._map,e))}preclick(e){const t=z({},e);t.type="preclick",this._map.fire(new mA(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new mA(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new mA(e.type,this._map,e))}mouseover(e){this._map.fire(new mA(e.type,this._map,e))}mouseout(e){this._map.fire(new mA(e.type,this._map,e))}touchstart(e){return this._firePreventable(new _A(e.type,this._map,e))}touchmove(e){this._map.fire(new _A(e.type,this._map,e))}touchend(e){this._map.fire(new _A(e.type,this._map,e))}touchcancel(e){this._map.fire(new _A(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class vA{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new mA(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new mA("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new mA(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class xA{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&&(vt(),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(${o}px,${s}px)`,this._box.style.width=a-o+"px",this._box.style.height=l-s+"px")})}mouseupWindow(e,t){if(!this._active)return;const n=this._startPos,r=t;if(n&&0===e.button){if(this.reset(),wt(),n.x!==r.x||n.y!==r.y)return this._map.fire(new Ct("boxzoomend",{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(n,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}}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),xt(),delete this._startPos,delete this._lastPos}_fireEvent(e,t){return this._map.fire(new Ct(e,{originalEvent:t}))}}function bA(e,t){const n={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=function(e){const t=new v(0,0);for(const n of e)t._add(n);return t.div(e.length)}(t),this.touches=bA(n,t)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;const r=bA(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 TA{constructor(e){this.singleTap=new wA(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 SA{constructor(){this._zoomIn=new TA({numTouches:1,numTaps:2}),this._zoomOut=new TA({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 EA={0:1,2:2};class MA{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=Et(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=EA[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 r=bA(n,t),i=new v(0,0),o=new v(0,0);let a=0;for(const e in r){const t=r[e],n=this._touches[e];n&&(i._add(t),o._add(t.sub(n)),a++,r[e]=t)}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class OA{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=PA(n,t,i),s=PA(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=PA(n,t,r),a=PA(n,t,i);o&&a||(this._active&&wt(),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 PA(e,t,n){for(let r=0;rMath.abs(e.x)}class FA extends OA{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,BA(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,n){const r=this._lastPoints;if(!r)return;const i=e[0].sub(r[0]),o=e[1].sub(r[1]);return this._map._cooperativeGestures&&!re()&&n.touches.length<3||(this._valid=this.gestureBeginsVertically(i,o,n.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(i.y+o.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 BA(e)&&BA(t)&&o}}const jA={panStep:100,bearingStep:15,pitchStep:10};class NA{constructor(){const e=jA;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:UA,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 UA(e){return e*(2-e)}const VA=4.000244140625;class GA{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._handler=t,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,G(["_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(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||re()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let t=e.deltaMode===n.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=ft.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==t&&t%VA==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(i*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.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=Tt(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 e=this._map.transform;"wheel"===this._type&&e.projection.wrap&&(e._center.lng>=180||e._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const t=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const n="wheel"===this._type&&Math.abs(this._delta)>VA?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&0!==r&&(r=1/r);const i=t(),o=Math.pow(2,i),a="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(a*r))),"wheel"===this._type&&(this._startZoom=i,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const n="number"==typeof this._targetZoom?this._targetZoom:t(),r=this._startZoom,i=this._easing;let o,a=!1;if("wheel"===this._type&&r&&i){const e=Math.min((ft.now()-this._lastWheelEventTime)/200,1);o=Yr(r,n,i(e)),e<1?this._frameId||(this._frameId=!0):a=!0}else o=n,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let s=o-t();return s*this._lastDelta<0&&(s=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=k;if(this._prevEase){const e=this._prevEase,n=(ft.now()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),i=.27/Math.sqrt(r*r+1e-4)*.01;t=C(i,Math.sqrt(.0729-i*i),.25,1)}return this._prevEase={start:ft.now(),duration:e,easing:t},t}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=pt("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(n.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 qA{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 WA{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 ZA{constructor(){this._tap=new TA({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 HA{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 $A{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 XA{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 YA=e=>e.zoom||e.drag||e.pitch||e.rotate;class KA extends Ct{}class JA{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,t){const n=id.sub([],t,e);this.radius=id.length(n[2]<0?id.div([],n,this.constants):[n[0],n[1],0])}projectRay(e){id.div(e,e,this.constants),id.normalize(e,e),id.mul(e,e,this.constants);const t=id.scale([],e,this.radius);if(t[2]>0){const e=id.scale([],[0,0,1],id.dot(t,[0,0,1])),n=id.scale([],id.normalize([],[t[0],t[1],0]),this.radius),r=id.add([],t,id.scale([],id.sub([],id.add([],n,e),t),2));t[0]=r[0],t[1]=r[1]}return t}}function QA(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class eI{constructor(e,t){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new dA(e),this._bearingSnap=t.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new JA,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(t),G(["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],[n.document,"mousemove",{capture:!0}],[n.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],[n,"blur",void 0]];for(const[e,t,r]of this._listeners)e.addEventListener(t,e===n.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[e,t,r]of this._listeners)e.removeEventListener(t,e===n.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){const t=this._map,n=t.getCanvasContainer();this._add("mapEvent",new yA(t,e));const r=t.boxZoom=new xA(t,e);this._add("boxZoom",r);const i=new SA,o=new WA;t.doubleClickZoom=new qA(o,i),this._add("tapZoom",i),this._add("clickZoom",o);const a=new ZA;this._add("tapDragZoom",a);const s=t.touchPitch=new FA(t);this._add("touchPitch",s);const l=new IA(e),u=new CA(e);t.dragRotate=new $A(e,l,u),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);const c=new AA(e),h=new kA(t,e);t.dragPan=new HA(n,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new zA,f=new DA;t.touchZoomRotate=new XA(n,f,d,a),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),this._add("blockableMapEvent",new vA(t));const p=t.scrollZoom=new GA(t,this);this._add("scrollZoom",p,["mousePan"]);const m=t.keyboard=new NA;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=[],this._originalZoom=void 0}}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!!YA(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?St(this._el,s):n?void 0:Tt(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||QA(i))&&(this._changes.push([i,o,u]),this._triggerRenderFrame()),(Object.keys(a).length||QA(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(e,t,n,r,i){if(!n)return;z(e,n);const o={handlerName:r,originalEvent:n.originalEvent||i};void 0!==n.zoomDelta&&(t.zoom=o),void 0!==n.panDelta&&(t.drag=o),void 0!==n.pitchDelta&&(t.pitch=o),void 0!==n.bearingDelta&&(t.rotate=o)}_applyChanges(){const e={},t={},n={};for(const[r,i,o]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new v(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.aroundCoord&&(e.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),z(t,i),z(n,o);this._updateMapTransform(e,t,n),this._changes=[]}_updateMapTransform(e,t,n){const r=this._map,i=r.transform,o=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!QA(e)){const e=i.zoom;i.cameraElevationReference="sea",null!=this._originalZoom&&i._orthographicProjectionAtLowPitch&&"globe"!==i.projection.name&&0===i.pitch?(i.cameraElevationReference="ground",i.zoom=this._originalZoom):(i.recenterOnTerrain(),i.cameraElevationReference="ground"),e!==i.zoom&&this._map._update(!0)}if(i._isCameraConstrained&&r._stop(!0),!QA(e))return void this._fireEvents(t,n,!0);let{panDelta:a,zoomDelta:s,bearingDelta:l,pitchDelta:u,around:c,aroundCoord:h,pinchAround:d}=e;i._isCameraConstrained&&(s>0&&(s=0),i._isCameraConstrained=!1),void 0!==d&&(c=d),(s||(e=>t[e]&&!this._eventsInProgress[e])("drag"))&&c&&(this._dragOrigin=o(i.pointCoordinate3D(c)),this._originalZoom=i.zoom,this._trackingEllipsoid.setup(i._camera.position,this._dragOrigin)),i.cameraElevationReference="sea",r._stop(!0),c=c||r.transform.centerPoint,l&&(i.bearing+=l),u&&(i.pitch+=u),i._updateCameraState();const f=[0,0,0];if(a)if("mercator"===i.projection.name){const e=this._trackingEllipsoid.projectRay(i.screenPointToMercatorRay(c).dir),t=this._trackingEllipsoid.projectRay(i.screenPointToMercatorRay(c.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const e=i.pointCoordinate(c);if("globe"===i.projection.name){a=a.rotate(-i.angle);const t=i._pixelsPerMercatorPixel/i.worldSize;f[0]=-a.x*Af(wf(e.y))*t,f[1]=-a.y*Af(i.center.lat)*t}else{const t=i.pointCoordinate(c.sub(a));e&&t&&(f[0]=t.x-e.x,f[1]=t.y-e.y)}}const p=i.zoom,m=[0,0,0];if(s){const e=o(h||i.pointCoordinate3D(c)),t={dir:id.normalize([],id.sub([],e,i._camera.position))};if(t.dir[2]<0){const n=i.zoomDeltaToMovement(e,s);id.scale(m,t.dir,n)}}const _=id.add(f,f,m);i._translateCameraConstrained(_),s&&Math.abs(i.zoom-p)>1e-4&&i.recenterOnTerrain(),i.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,n,!0)}_fireEvents(e,t,n){const r=YA(this._eventsInProgress),i=YA(e),o={};for(const t in e){const{originalEvent:n}=e[t];this._eventsInProgress[t]||(o[t+"start"]=n),this._eventsInProgress[t]=e[t]}!r&&i&&this._fireEvent("movestart",i.originalEvent);for(const e in o)this._fireEvent(e,o[e]);i&&this._fireEvent("move",i.originalEvent);for(const t in e){const{originalEvent:n}=e[t];this._fireEvent(t,n)}const a={};let s;for(const e in this._eventsInProgress){const{handlerName:n,originalEvent:r}=this._eventsInProgress[e];this._handlersById[n].isActive()||(delete this._eventsInProgress[e],s=t[n]||r,a[e+"end"]=s)}for(const e in a)this._fireEvent(e,a[e]);const l=YA(this._eventsInProgress);if(n&&(r||i)&&!l){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new KA("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const tI="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class nI extends Ot{constructor(e,t){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=t.bearingSnap,this._respectPrefersReducedMotion=!1!==t.respectPrefersReducedMotion,G(["_renderFrameCallback"],this)}getCenter(){return new _f(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(e,t,n){return e=v.convert(e).mult(-1),this.panTo(this.transform.center,z({offset:e},t),n)}panTo(e,t,n){return this.easeTo(z({center:e},t),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,n){return this.easeTo(z({zoom:e},t),n)}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(e,t,n){return this.easeTo(z({bearing:e},t),n)}resetNorth(e,t){return this.rotateTo(0,z({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(z({bearing:0,pitch:0,duration:1e3},e),t),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(e,t,n,r,i,o){const a=e.clone(),s=this._extendCameraOptions(o);a.bearing=r,a.pitch=i;const l=_f.convert(t),u=_f.convert(n),c=.5*(l.lat+u.lat),h=.5*(l.lng+u.lng),d=qd(c,h),f=id.normalize([],d),p=id.normalize([],id.cross([],f,[0,1,0])),m=id.cross([],p,f),_=[p[0],p[1],p[2],0,m[0],m[1],m[2],0,f[0],f[1],f[2],0,0,0,0,1],g=[d,qd(l.lat,l.lng),qd(u.lat,l.lng),qd(u.lat,u.lng),qd(l.lat,u.lng),qd(c,l.lng),qd(c,u.lng),qd(l.lat,h),qd(u.lat,h)];let y=Md.fromPoints(g.map(e=>[id.dot(p,e),id.dot(m,e),id.dot(f,e)]));const v=id.transformMat4([],y.center,_);0===id.squaredLength(v)&&id.set(v,0,0,1),id.normalize(v,v),id.scale(v,v,Ad),a.center=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 _f(S(i),S(o))}(v);const x=a.getWorldToCameraMatrix(),b=Jh.invert(new Float64Array(16),x);y=Md.applyTransform(y,Jh.multiply([],x,_)),id.transformMat4(v,v,x);const w=.5*(y.max[2]-y.min[2]),T=this._minimumAABBFrustumDistance(a,y),E=id.scale([],[0,0,1],w),M=id.add(E,v,E),A=T+(0===a.pitch?0:id.distance(v,M)),I=a.globeCenterInViewSpace,C=id.sub([],v,[I[0],I[1],I[2]]);id.normalize(C,C),id.scale(C,C,A);const k=id.add([],v,C);id.transformMat4(k,k,b);const O=ff/Ad,P=id.length(k),R=xf(Math.max(P*O-ff,Number.EPSILON),0),D=Math.min(a.zoomFromMercatorZAdjusted(R),s.maxZoom);return D>5.5?(a.setProjection({name:"mercator"}),a.zoom=D,this._cameraForBounds(a,t,n,r,i,o)):{center:a.center,zoom:D,bearing:r,pitch:i}}queryTerrainElevation(e,t){const n=this.transform.elevation;return n?(t=z({},{exaggerated:!0},t),n.getAtPoint(Cf.fromLngLat(e),null,t.exaggerated)):null}_cameraForBounds(e,t,n,r,i,o){if("globe"===e.projection.name)return this._cameraForBoundsOnGlobe(e,t,n,r,i,o);const a=e.clone(),s=this._extendCameraOptions(o),l=a.padding;a.bearing=r,a.pitch=i;const u=_f.convert(t),c=_f.convert(n),h=new _f(u.lng,c.lat),d=new _f(c.lng,u.lat),f=a.project(u),p=a.project(c),m=this.queryTerrainElevation(u),_=this.queryTerrainElevation(c),g=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),x=[[f.x,f.y,Math.min(m||0,_||0,g||0,y||0)],[p.x,p.y,Math.max(m||0,_||0,g||0,y||0)]];let b=Md.fromPoints(x);const w=a.getWorldToCameraMatrix(),S=Jh.invert(new Float64Array(16),w);b=Md.applyTransform(b,w);const E=id.sub([],b.max,b.min),M=l.left||0,A=l.right||0,I=l.bottom||0,C=l.top||0,{left:k,right:O,top:P,bottom:R}=s.padding,D=.5*(M+A),L=.5*(C+I),z=Math.min(a.scaleZoom(a.scale*Math.min((a.width-(M+A+k+O))/E[0],(a.height-(I+C+R+P))/E[1])),s.maxZoom),B=a.scale/a.zoomScale(z);b=new Md([b.min[0]-(k+D)*B,b.min[1]-(R+L)*B,b.min[2]],[b.max[0]+(O+D)*B,b.max[1]+(P+L)*B,b.max[2]]);const F=.5*E[2],j=this._minimumAABBFrustumDistance(a,b),N=[0,0,1,0];qh.transformMat4(N,N,w),qh.normalize(N,N);const U=id.scale([],N,j+F),V=id.add([],b.center,U),G=("number"==typeof s.offset.x&&"number"==typeof s.offset.y?new v(s.offset.x,s.offset.y):v.convert(s.offset)).rotate(-T(r));b.center[0]-=G.x*B,b.center[1]+=G.y*B,id.transformMat4(b.center,b.center,S),id.transformMat4(V,V,S);const q=[b.center[0],b.center[1],V[2]*a.pixelsPerMeter];id.scale(q,q,1/a.worldSize);const W=bf(q[0]),Z=wf(q[1]),H=Math.min(a._zoomFromMercatorZ(q[2]),s.maxZoom),$=new _f(W,Z);return a.mercatorFromTransition&&H<5.5?(a.setProjection({name:"globe"}),a.zoom=H,this._cameraForBounds(a,t,n,r,i,o)):{center:$,zoom:H,bearing:r,pitch:i}}fitBounds(e,t,n){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,n)}fitScreenCoordinates(e,t,n,r,i){const o=v.convert(e),a=v.convert(t),s=new v(Math.min(o.x,a.x),Math.min(o.y,a.y)),l=new v(Math.max(o.x,a.x),Math.max(o.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(o,a))return this;const u=this.transform.pointLocation3D(s),c=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(new v(s.x,l.y)),d=this.transform.pointLocation3D(new v(l.x,s.y)),f=[Math.min(u.lng,c.lng,h.lng,d.lng),Math.min(u.lat,c.lat,h.lat,d.lat)],p=[Math.max(u.lng,c.lng,h.lng,d.lng),Math.max(u.lat,c.lat,h.lat,d.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,f,p,n,m,r);return this._fitInternal(_,r,i)}_fitInternal(e,t,n){return e?(delete(t=z(e,t)).padding,t.linear?this.easeTo(t,n):this.flyTo(t,n)):this}jumpTo(e,t){this.stop();const n=e.preloadOnly?this.transform.clone():this.transform;let r=!1,i=!1,o=!1;return"zoom"in e&&n.zoom!==+e.zoom&&(r=!0,n.zoom=+e.zoom),void 0!==e.center&&(n.center=_f.convert(e.center)),"bearing"in e&&n.bearing!==+e.bearing&&(i=!0,n.bearing=+e.bearing),"pitch"in e&&n.pitch!==+e.pitch&&(o=!0,n.pitch=+e.pitch),null==e.padding||n.isPaddingEqual(e.padding)||(n.padding=e.padding),e.preloadOnly?(this._preloadTiles(n),this):(this.fire(new Ct("movestart",t)).fire(new Ct("move",t)),r&&this.fire(new Ct("zoomstart",t)).fire(new Ct("zoom",t)).fire(new Ct("zoomend",t)),i&&this.fire(new Ct("rotatestart",t)).fire(new Ct("rotate",t)).fire(new Ct("rotateend",t)),o&&this.fire(new Ct("pitchstart",t)).fire(new Ct("pitch",t)).fire(new Ct("pitchend",t)),this.fire(new Ct("moveend",t)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||X(tI),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,t){const n=this.transform;if(!n.projection.supportsFreeCamera)return X(tI),this;this.stop();const r=n.zoom,i=n.pitch,o=n.bearing;n.setFreeCameraOptions(e);const a=r!==n.zoom,s=i!==n.pitch,l=o!==n.bearing;return this.fire(new Ct("movestart",t)).fire(new Ct("move",t)),a&&this.fire(new Ct("zoomstart",t)).fire(new Ct("zoom",t)).fire(new Ct("zoomend",t)),l&&this.fire(new Ct("rotatestart",t)).fire(new Ct("rotate",t)).fire(new Ct("rotateend",t)),s&&this.fire(new Ct("pitchstart",t)).fire(new Ct("pitch",t)).fire(new Ct("pitchend",t)),this.fire(new Ct("moveend",t)),this}easeTo(e,t){this._stop(!1,e.easeId),(!1===(e=z({offset:[0,0],duration:500,easing:k},e)).animate||this._prefersReducedMotion(e))&&(e.duration=0);const n=this.transform,r=this.getZoom(),i=this.getBearing(),o=this.getPitch(),a=this.getPadding(),s="zoom"in e?+e.zoom:r,l="bearing"in e?this._normalizeBearing(e.bearing,i):i,u="pitch"in e?+e.pitch:o,c="padding"in e?e.padding:n.padding,h=v.convert(e.offset);let d,f,p;if("globe"===n.projection.name){const t=Cf.fromLngLat(n.center),r=h.rotate(-n.angle);t.x+=r.x/n.worldSize,t.y+=r.y/n.worldSize;const i=t.toLngLat(),o=_f.convert(e.center||i);this._normalizeCenter(o),d=n.centerPoint.add(r),f=new v(t.x,t.y).mult(n.worldSize),p=new v(yf(o.lng),vf(o.lat)).mult(n.worldSize).sub(f)}else{d=n.centerPoint.add(h);const t=n.pointLocation(d),r=_f.convert(e.center||t);this._normalizeCenter(r),f=n.project(t),p=n.project(r).sub(f)}const m=n.zoomScale(s-r);let _,g;e.around&&(_=_f.convert(e.around),g=n.locationPoint(_));const y=this._zooming||s!==r,x=this._rotating||i!==l,b=this._pitching||u!==o,w=!n.isPaddingEqual(c),T=n=>v=>{if(y&&(n.zoom=Yr(r,s,v)),x&&(n.bearing=Yr(i,l,v)),b&&(n.pitch=Yr(o,u,v)),w&&(n.interpolatePadding(a,c,v),d=n.centerPoint.add(h)),_)n.setLocationAtPoint(_,g);else{const e=n.zoomScale(n.zoom-r),t=s>r?Math.min(2,m):Math.max(.5,m),i=Math.pow(t,1-v),o=n.unproject(f.add(p.mult(v*i)).mult(e));n.setLocationAtPoint(n.renderWorldCopies?o.wrap():o,d)}return e.preloadOnly||this._fireMoveEvents(t),n};if(e.preloadOnly){const t=this._emulate(T,e.duration,n);return this._preloadTiles(t),this}const S={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,S),this._ease(T(n),e=>{"sea"===n.cameraElevationReference&&n.recenterOnTerrain(),this._afterEase(t,e)},e),this}_prepareEase(e,t,n={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),t||n.moving||this.fire(new Ct("movestart",e)),this._zooming&&!n.zooming&&this.fire(new Ct("zoomstart",e)),this._rotating&&!n.rotating&&this.fire(new Ct("rotatestart",e)),this._pitching&&!n.pitching&&this.fire(new Ct("pitchstart",e))}_fireMoveEvents(e){this.fire(new Ct("move",e)),this._zooming&&this.fire(new Ct("zoom",e)),this._rotating&&this.fire(new Ct("rotate",e)),this._pitching&&this.fire(new Ct("pitch",e))}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const n=this._zooming,r=this._rotating,i=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new Ct("zoomend",e)),r&&this.fire(new Ct("rotateend",e)),i&&this.fire(new Ct("pitchend",e)),this.fire(new Ct("moveend",e))}flyTo(e,t){if(this._prefersReducedMotion(e)){const n=B(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(n,t)}this.stop(),e=z({offset:[0,0],speed:1.2,curve:1.42,easing:k},e);const n=this.transform,r=this.getZoom(),i=this.getBearing(),o=this.getPitch(),a=this.getPadding(),s="zoom"in e?O(+e.zoom,n.minZoom,n.maxZoom):r,l="bearing"in e?this._normalizeBearing(e.bearing,i):i,u="pitch"in e?+e.pitch:o,c="padding"in e?e.padding:n.padding,h=n.zoomScale(s-r),d=v.convert(e.offset);let f=n.centerPoint.add(d);const p=n.pointLocation(f),m=_f.convert(e.center||p);this._normalizeCenter(m);const _=n.project(p),g=n.project(m).sub(_);let y=e.curve;const x=Math.max(n.width,n.height),b=x/h,w=g.mag();if("minZoom"in e){const t=O(Math.min(e.minZoom,r,s),n.minZoom,n.maxZoom),i=x/n.zoomScale(t-r);y=Math.sqrt(i/w*2)}const T=y*y;function S(e){const t=(b*b-x*x+(e?-1:1)*T*T*w*w)/(2*(e?b:x)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function M(e){return(Math.exp(e)+Math.exp(-e))/2}const A=S(0);let I=function(e){return M(A)/M(A+y*e)},C=function(e){return x*((M(A)*(E(t=A+y*e)/M(t))-E(A))/T)/w;var t},P=(S(1)-A)/y;if(Math.abs(w)<1e-6||!isFinite(P)){if(Math.abs(x-b)<1e-6)return this.easeTo(e,t);const n=be.maxDuration&&(e.duration=0);const R=i!==l,D=u!==o,L=!n.isPaddingEqual(c),F=n=>h=>{const p=h*P,y=1/I(p);n.zoom=1===h?s:r+n.scaleZoom(y),R&&(n.bearing=Yr(i,l,h)),D&&(n.pitch=Yr(o,u,h)),L&&(n.interpolatePadding(a,c,h),f=n.centerPoint.add(d));const v=1===h?m:n.unproject(_.add(g.mult(C(p))).mult(y));return n.setLocationAtPoint(n.renderWorldCopies?v.wrap():v,f),n._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(t),n};if(e.preloadOnly){const t=this._emulate(F,e.duration,n);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=R,this._pitching=D,this._padding=L,this._prepareEase(t,!1),this._ease(F(n),()=>this._afterEase(t),e),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(e,t,n){!1===n.animate||0===n.duration?(e(1),t()):(this._easeStart=ft.now(),this._easeOptions=n,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((ft.now()-this._easeStart)/this._easeOptions.duration,1),t=this._onEaseFrame;t&&t(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,t){e=R(e,-180,180);const n=Math.abs(e-t);return Math.abs(e-360-t)180?-360:n<-180?360:0}_prefersReducedMotion(e){return this._respectPrefersReducedMotion&&ft.prefersReducedMotion&&!(e&&e.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 rI{constructor(e={}){this.options=e,G(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=pt("button","mapboxgl-ctrl-attrib-button",this._container),pt("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=pt("div","mapboxgl-ctrl-attrib-inner",this._container),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.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 e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const t=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||o.ACCESS_TOKEN}];if(e){const n=t.reduce((e,n,r)=>(n.value&&(e+=`${n.key}=${n.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 iI{constructor(){G(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=pt("div","mapboxgl-ctrl");const t=pt("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 oI{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 aI(e,t,n){if(e=new _f(e.lng,e.lat),t){const r=new _f(e.lng-360,e.lat),i=new _f(e.lng+360,e.lat),o=360*Math.ceil(Math.abs(e.lng-n.center.lng)/360),a=n.locationPoint(e).distSqr(t),s=t.x<0||t.y<0||t.x>n.width||t.y>n.height;n.locationPoint(r).distSqr(t)180;){const t=n.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e}const sI={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 lI extends Ot{constructor(e,t){if(super(),(e instanceof n.HTMLElement||t)&&(e=z({element:e},t)),G(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=e&&e.occludedOpacity||.2,e&&e.element)this._element=e.element,this._offset=v.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=pt("div");const t=41,n=27,r=mt("svg",{display:"block",height:t*this._scale+"px",width:n*this._scale+"px",viewBox:`0 0 ${n} ${t}`},this._element),i=mt("radialGradient",{id:"shadowGradient"},mt("defs",{},r));mt("stop",{offset:"10%","stop-opacity":.4},i),mt("stop",{offset:"100%","stop-opacity":.05},i),mt("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),mt("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"},r),mt("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"},r),mt("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=v.convert(e&&e.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),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 sI)r.remove("mapboxgl-marker-anchor-"+e);r.add("mapboxgl-marker-anchor-"+this._anchor);const i=e&&e.className?e.className.trim().split(/\s+/):[];r.add(...i),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(e){return this._lngLat=_f.convert(e),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 e=this._map;if(!e)return;const t=this._pos;if(!t||t.x<0||t.x>e.transform.width||t.y<0||t.y>e.transform.height)return void this._clearFadeTimer();const n=e.unproject(t);let r;e._showingGlobe()&&lf(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(n),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=""+r,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),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 ${sI[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const e=this._pos,t=this._map,n=this.getPitchAlignment();if(!t||!e||"map"!==n)return"";if(!t._showingGlobe()){const e=t.getPitch();return e?`rotateX(${e}deg)`:""}const r=S(sf(t.transform,this._lngLat)),i=e.sub(af(t.transform)),o=Math.abs(i.x)+Math.abs(i.y);if(0===o)return"";const a=r/o;return`rotateX(${-i.y*a}deg) rotateY(${i.x*a}deg)`}_calculateZTransform(){const e=this._pos,t=this._map;if(!t||!e)return"";let n=0;const r=this.getRotationAlignment();if("map"===r)if(t._showingGlobe()){const e=t.project(new _f(this._lngLat.lng,this._lngLat.lat+.001)),r=t.project(new _f(this._lngLat.lng,this._lngLat.lat-.001)).sub(e);n=S(Math.atan2(r.y,r.x))-90}else n=-t.getBearing();else if("horizon"===r){const r=P(4,6,t.getZoom()),i=af(t.transform);i.y+=r*t.transform.height;const o=e.sub(i),a=S(Math.atan2(o.y,o.x));n=(a>90?a-270:a+90)*(1-r)}return n+=this._rotation,n?`rotateZ(${n}deg)`:""}_update(e){n.cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=aI(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!0===e?this._updateFrameId=n.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(e){return this._offset=v.convert(e),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(e){const t=this._map;if(!t)return;const n=this._pointerdownPos,r=this._positionDelta;if(n&&r){if(!this._isDragging){const r=this._clickTolerance||t._clickTolerance;if(e.point.dist(n)=this._endTime)return this._end;const t=M((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-t)+this._end*t}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 fI={"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"},pI={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,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1},mI={showCompass:!0,showZoom:!0,visualizePitch:!1};class _I{constructor(e,t,n=!1){this._clickTolerance=10,this.element=t,this.mouseRotate=new IA({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,n&&(this.mousePitch=new CA({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),G(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),vt()}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(){xt(),n.removeEventListener("mousemove",this.mousemove),n.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(z({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),Tt(this.element,e)),n.addEventListener("mousemove",this.mousemove),n.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,Tt(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=St(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=St(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)e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==ne){const t=e.navigator?e.navigator.userAgent:null;ne=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return ne}(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/))}(n)&&(e.antialias=!1,X("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Ax(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._collectResourceTiming=e.collectResourceTiming,this._language=this._parseLanguage(e.language),this._worldview=e.worldview,this._renderTaskQueue=new oI,this._domRenderTaskQueue=new oI,this._controls=[],this._markers=[],this._popups=[],this._mapId=j(),this._locale=z({},fI,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._performanceMetricsCollection=e.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new dI(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new Oe(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,this._contextCreateOptions=e.contextCreateOptions?{...e.contextCreateOptions}:{},"string"==typeof e.container){if(this._container=n.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container.toString()}' not found.`)}else{if(!(e.container instanceof n.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(this._container.childNodes.length>0&&X("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),e.maxBounds&&this.setMaxBounds(e.maxBounds),G(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==n&&(this._fullscreenchangeEvent="onfullscreenchange"in n.document?"fullscreenchange":"webkitfullscreenchange",n.addEventListener("online",this._onWindowOnline,!1),n.addEventListener("resize",this._onWindowResize,!1),n.addEventListener("orientationchange",this._onWindowResize,!1),n.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),n.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new eI(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,(e.style||!e.testMode)&&this.setStyle(e.style||o.DEFAULT_STYLE,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),e.hash&&(this._hash=new oA("string"==typeof e.hash&&e.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==t.center&&null==t.zoom||(this.transform._unmodified=!1),this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch});const n=e.bounds;n&&(this.resize(),this.fitBounds(n,z({},e.fitBoundsOptions,{duration:0})))}this.resize(),e.attributionControl&&this.addControl(new rI({customAttribution:e.customAttribution})),this._logoControl=new iI,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new Ct(e.dataType+"data",e))}),this.on("dataloading",e=>{this.fire(new Ct(e.dataType+"dataloading",e))})}_getMapId(){return this._mapId}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new kt(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[t];return-1!==t.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new kt(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const t=!this._moving;return t&&this.fire(new Ct("movestart",e)).fire(new Ct("move",e)),this.fire(new Ct("resize",e)),t&&this.fire(new Ct("moveend",e)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(ju.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new Ct("zoomstart")).fire(new Ct("zoom")).fire(new Ct("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new Ct("pitchstart")).fire(new Ct("pitch")).fire(new Ct("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(e){return"auto"===e?n.navigator.language:Array.isArray(e)?0===e.length?void 0:e.map(e=>"auto"===e?n.navigator.language:e):e}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.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const e=this.transform,t=e.projection.name;let n;"globe"===t&&e.zoom>=6?(e.setMercatorFromTransition(),n=!0):"mercator"===t&&e.zoom<6&&(e.setProjection({name:"globe"}),n=!0),n&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(e){let t;return t="globe"===e.name&&this.transform.zoom>=6?this.transform.setMercatorFromTransition():this.transform.setProjection(e),this.style.applyProjectionUpdate(),t&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(e){return this.transform.locationPoint3D(_f.convert(e))}unproject(e){return this.transform.pointLocation3D(v.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_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 mA(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 mA(e,this,i.originalEvent)))},o=t=>{r&&(r=!1,n.call(this,new mA(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);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;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);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;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]);for(const e of t)if(!this._isValidId(e))return this;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{e?this.fire(new kt(e)):n&&this._updateDiff(n,t)})}else"object"==typeof e&&this._updateDiff(e,t)}_updateDiff(e,t){try{this.style.setState(e)&&this._update(!0)}catch(n){X(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(e,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(X("There is no style added to the map."),!1)}_isValidId(e){return null==e?(this.fire(new kt(new Error("IDs can't be empty."))),!1):!Qs(e)||(this.fire(new kt(new Error(`IDs can't contain special symbols: "${e}".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return!!this._isValidId(e)&&!!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._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(e,t,{pixelRatio:r=1,sdf:i=!1,stretchX:o,stretchY:a,content:s}={}){if(this._lazyInitEmptyStyle(),t instanceof n.HTMLImageElement||n.ImageBitmap&&t instanceof n.ImageBitmap){const{width:n,height:l,data:u}=ft.getImageData(t);this.style.addImage(e,{data:new bp({width:n,height:l},u),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0})}else if(void 0===t.width||void 0===t.height)this.fire(new kt(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:n,height:l}=t,u=t;this.style.addImage(e,{data:new bp({width:n,height:l},new Uint8Array(u.data)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}updateImage(e,t){this._lazyInitEmptyStyle();const r=this.style.getImage(e);if(!r)return void this.fire(new kt(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=t instanceof n.HTMLImageElement||n.ImageBitmap&&t instanceof n.ImageBitmap?ft.getImageData(t):t,{width:o,height:a}=i;void 0!==o&&void 0!==a?o===r.data.width&&a===r.data.height?(r.data.replace(i.data,!(t instanceof n.HTMLImageElement||n.ImageBitmap&&t instanceof n.ImageBitmap)),this.style.updateImage(e,r)):this.fire(new kt(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 kt(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(e){return e?!!this.style&&!!this.style.getImage(e):(this.fire(new kt(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e,t){Ce(this._requestManager.transformRequest(e,ve.Image),(e,r)=>{t(e,r instanceof n.HTMLImageElement?ft.getImageData(r):r)})}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(e){return e?this.style.hasModel(e):(this.fire(new kt(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e)}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}setLayerZoomRange(e,t,n){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,n),this._update(!0)):this}setFilter(e,t,n={}){return this._isValidId(e)?(this.style.setFilter(e,t,n),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,n,r={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,n,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,n,r={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,n,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,n){return this.style.setConfigProperty(e,t,n),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat")}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}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}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(_f.convert(e),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let r,i,o,a=this._container;for(;a&&(!i||!o);){const e=n.getComputedStyle(a).transform;e&&"none"!==e&&(r=e.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(e/i):e,this._containerHeight=o?Math.abs(t/o):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==n.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&X("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=pt("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=pt("div","mapboxgl-canvas-container",e);this._canvas=pt("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),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=pt("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{r[e]=pt("div","mapboxgl-ctrl-"+e,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t){const n=ft.devicePixelRatio||1;this._canvas.width=n*Math.ceil(e),this._canvas.height=n*Math.ceil(t),this._canvas.style.width=e+"px",this._canvas.style.height=t+"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 e=z({},it.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl2",e);t?(Je(t,!0),this.painter=new UM(t,this._contextCreateOptions,this.transform),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),a.testSupport(t)):this.fire(new kt(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new Ct("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new Ct("webglcontextrestored",{originalEvent:e}))}_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(e){let t;this.fire(new Ct("renderstart"));const r=this.painter.context.extTimerQuery,i=ft.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(t=o.createQuery(),o.beginQuery(r.TIME_ELAPSED_EXT,t)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],n.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],n.performance.now())),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;this._updateProjectionTransition();const a=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,t=this.transform.pitch,n=ft.now(),r=new Ns(e,{now:n,fadeDuration:a,pitch:t,transition:this.style.transition});this.style.update(r)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(i),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):s=this._updateAverageElevation(i),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,a,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,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 Ct("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new Ct("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),t){const e=ft.now()-i;o.endQuery(r.TIME_ELAPSED_EXT),setTimeout(()=>{const r=o.getQueryParameter(t,o.QUERY_RESULT)/1e6;o.deleteQuery(t),this.fire(new Ct("gpu-timing-frame",{cpuTime:e,gpuTime:r})),n.performance.mark("frame-gpu",{startTime:i,detail:{gpuTime:r}})},50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout(()=>{const t=this.painter.queryGpuTimers(e);this.fire(new Ct("gpu-timing-layer",{layerTimes:t}))},50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const t=this.painter.queryGpuTimeDeferredRender(e);this.fire(new Ct("gpu-timing-deferred-render",{gpuTime:t}))},50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(l||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(s=this._updateAverageElevation(i,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new Ct("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new Ct("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,et.mark(Qe.fullLoad),this._performanceMetricsCollection&&$e(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);const r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let i=this.transform.sampleAverageElevation();this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(i)?i=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-i);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(i),n(i);this._averageElevation.easeTo(i,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(i),n(i)}return!!this._averageElevation.isEasing(e)&&n(this._averageElevation.getValue(e))}_authenticate(){Ye(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,e=>{if(e&&(e.message===ke||401===e.status)){const e=this.painter.context.gl;Je(e,!1),this._logoControl instanceof iI&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new kt(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/")))}}),Ze(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(e){return D(this.style?Object.values(this.style._sourceCaches):[],(t,n)=>t._preloadTiles(e,n),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===n.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 showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=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(e,t){!function(e,t){de=e,fe=t}(e,t)}get version(){return r}},NavigationControl:class{constructor(e){this.options=z({},mI,e),this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(G(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),pt("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})}),pt("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(G(["_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=pt("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 _I(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=pt("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 Ot{constructor(e){super(),this.options=z({geolocation:n.navigator.geolocation},gI,e),G(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=iA(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(e){const t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==n.navigator.permissions?n.navigator.permissions.query({name:"geolocation"}).then(e=>t("denied"!==e.state)).catch(()=>t()):t()}_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(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new Ct("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new Ct("geolocate",e)),this._finish()}}_updateCamera(e){const t=new _f(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r=z({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(n),r,{geolocateSource:!0})}_updateMarker(e){if(e){const t=new _f(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,t=xf(1,e._center.lat)*e.worldSize,n=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=n+"px",this._circleElement.style.height=n+"px"}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const 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===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new Ct("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=pt("button","mapboxgl-ctrl-geolocate",this._container),pt("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){X("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const 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=pt("div","mapboxgl-user-location"),this._dotElement.appendChild(pt("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(pt("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new lI({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=pt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new lI({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new Ct("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 X("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 Ct("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 Ct("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 Ct("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 e=()=>{n.addEventListener("ondeviceorientationabsolute"in n?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==n.DeviceMotionEvent&&"function"==typeof n.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e()}).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),n.removeEventListener("deviceorientation",this._onDeviceOrientation),n.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:rI,ScaleControl:class{constructor(e){this.options=z({},yI,e),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),G(["_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} ${vI[n]}`,this._container.style.width=e*i+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=pt("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(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof n.HTMLElement?this._container=e.container:X("Full screen control 'container' must be a DOM element.")),G(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in n.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in n.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=pt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",X("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,n.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!n.document.fullscreenEnabled&&!n.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=pt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);pt("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),n.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(){(n.document.fullscreenElement||n.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()?n.document.exitFullscreen?n.document.exitFullscreen():n.document.webkitCancelFullScreen&&n.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends Ot{constructor(e){super(),this.options=z(Object.create(uI),e),G(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),e._addPopup(this),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new Ct("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),e._canvasContainer&&e._canvasContainer.classList.remove("mapboxgl-track-pointer"),e._removePopup(this),this._map=void 0),this.fire(new Ct("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=_f.convert(e),this._pos=null,this._trackPointer=!1,this._update();const t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._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(e){return this.setDOMContent(n.document.createTextNode(e))}setHTML(e){const t=n.document.createDocumentFragment(),r=n.document.createElement("body");let i;for(r.innerHTML=e;i=r.firstChild,i;)t.appendChild(i);return this.setDOMContent(t)}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=pt("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=pt("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(e){const t=this._map,n=this._content;if(!t||!this._lngLat&&!this._trackPointer||!n)return;let r=this._container;if(r||(r=this._container=pt("div","mapboxgl-popup",t.getContainer()),this._tip=pt("div","mapboxgl-popup-tip",r),r.appendChild(n)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=aI(this._lngLat,this._pos,t.transform)),!this._trackPointer||e){const n=this._pos=this._trackPointer&&e?e:t.project(this._lngLat),r=hI(this.options.offset),i=this._anchor=this._getAnchor(r.y),o=hI(this.options.offset,i),a=n.add(o).round();t._requestDomTask(()=>{this._container&&i&&(this._container.style.transform=`${sI[i]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&t._showingGlobe()){const e=lf(t.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(cI);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:lI,Style:rA,LngLat:_f,LngLatBounds:ju,Point:v,MercatorCoordinate:Cf,FreeCameraOptions:Kv,Evented:Ot,config:o,prewarm:function(){Hw().acquire(qw)},clearPrewarmedResources:function(){const e=Zw;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(qw),Zw=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 o.ACCESS_TOKEN},set accessToken(e){o.ACCESS_TOKEN=e},get baseApiUrl(){return o.API_URL},set baseApiUrl(e){o.API_URL=e},get workerCount(){return Ww.workerCount},set workerCount(e){Ww.workerCount=e},get maxParallelImageRequests(){return o.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){o.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){!function(e){if(!pe())return;const t=n.caches.delete(ue);e&&t.catch(e).then(()=>e())}(e)},workerUrl:"",workerClass:null,get dracoUrl(){return Jw()},set dracoUrl(e){!function(e){Xw=ft.resolveURL(e),Kw||(Kw=new Ew(Hw(),new Ot)),Kw.broadcast("setDracoUrl",Xw)}(e)},setNow:ft.setNow,restoreNow:ft.restoreNow};e.A=Sw,e.D=m_,e.E=hr,e.F=g_,e.K=gS,e.O=_d,e.P=v,e.T=$x,e.V=km,e.a=gm,e.b=Rm,e.c=lw,e.d=class extends Ot{constructor(e,t,n,r,i,o){super(),this.actor=e,this.layerIndex=t,this.availableImages=n,this.loadVectorData=i||Nw,this.loading={},this.loaded={},this.deduped=new jw(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=o}loadTile(e,t){const n=e.uid,r=e&&e.request,i=r&&r.collectResourceTiming,o=this.loading[n]=new Bw(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 Cm(new e_(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=rt(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.projection=e.projection,o.brightness=e.brightness,o.tileTransform=jg(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster;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())}else t(null,void 0)}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.e=go,e.f=rt,e.g=f,e.h=Te,e.i=Se,e.j=function(e,t){const n=bT(e);for(const e of n){for(const t of e.meshes)wT(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(TT(e.lights,t)))}return n},e.k=Ns,e.l=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==oT){const n=new Uint32Array(e,0,7),[,,r,i,o,a]=n;t=n.byteLength+i+o+a+o,(r!==e.byteLength||t>=e.byteLength)&&X("Invalid b3dm header information.")}return hT(e,t)},e.m=uy,e.n=js,e.o=Ct,e.p=g,e.q=function(e){me(),ce&&ce.then(t=>{t.keys().then(n=>{for(let r=0;rthis._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}=t,s=e.w.ImageBitmap&&o instanceof e.w.ImageBitmap?this.getImageData(o,a):o;n(null,new e.D(r,s,i,a<1))}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.g((function e(t,n){var r,i=t&&t.type;if("FeatureCollection"===i)for(r=0;r>31}function T(e,t){for(var n=e.loadGeometry(),r=e.type,i=0,o=0,a=n.length,s=0;se},A=Math.fround||(I=new Float32Array(1),e=>(I[0]=+e,I[0]));var I;class C{constructor(e){this.options=Object.assign(Object.create(M),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(P(n),R(o),P(i),R(r)),l=a.data,u=[];for(const e of s){const t=this.stride*e;u.push(l[t+5]>1?k(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?k(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=O(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=P(r),c=R(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 k(e,t,n){return{type:"Feature",id:e[t+3],properties:O(e,t,n),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),D(e[t+1])]}};var r}function O(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 P(e){return e/360+.5}function R(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 D(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var L={exports:{}};L.exports=function(){function e(n,r,i,o){for(var a,s=o,l=i-r>>1,u=i-r,c=n[r],h=n[r+1],d=n[i],f=n[i+1],p=r+3;ps)a=p,s=m;else if(m===s){var _=Math.abs(p-l);_o&&(a-r>3&&e(n,r,a,o),n[a+2]=s,i-a>3&&e(n,a,i,o))}function t(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 n(e,t,n,i){var o={id:void 0===e?null:e,type:t,geometry:n,tags:i,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)r(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var i=0;i0&&(s+=i?(o*d-h*a)/2:Math.sqrt(Math.pow(h-o,2)+Math.pow(d-a,2))),o=h,a=d}var f=n.length-3;n[2]=1,e(n,0,f,r),n[f+2]=1,n.size=Math.abs(s),n.start=0,n.end=n.size}function s(e,t,n,r){for(var i=0;i1?1:n}function c(e,t,r,i,o,a,s,l){if(i/=t,a>=(r/=t)&&s=i)return null;for(var u=[],c=0;c=r&&y=i)){var v=[];if("Point"===_||"MultiPoint"===_)h(m,v,r,i,o);else if("LineString"===_)d(m,v,r,i,o,!1,l.lineMetrics);else if("MultiLineString"===_)p(m,v,r,i,o,!1);else if("Polygon"===_)p(m,v,r,i,o,!0);else if("MultiPolygon"===_)for(var x=0;x=n&&a<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function d(e,t,n,r,i,o,a){for(var s,l,u=f(e),c=0===i?_:g,h=e.start,d=0;dn&&(l=c(u,p,y,x,b,n),a&&(u.start=h+s*l)):w>r?T=n&&(l=c(u,p,y,x,b,n),S=!0),T>r&&w<=r&&(l=c(u,p,y,x,b,r),S=!0),!o&&S&&(a&&(u.end=h+s*l),t.push(u),u=f(e)),a&&(h+=s)}var E=e.length-3;p=e[E],y=e[E+1],v=e[E+2],(w=0===i?p:y)>=n&&w<=r&&m(u,p,y,v),E=u.length-3,o&&E>=3&&(u[E]!==u[0]||u[E+1]!==u[1])&&m(u,u[0],u[1],u[2]),u.length&&t.push(u)}function f(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function p(e,t,n,r,i,o){for(var a=0;aa.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function T(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"),f=this.tiles[d]=w(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,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));var p="z"+t;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(f.source=e,i){if(t===l.maxZoom||t===i)continue;var m=1<1&&console.time("clipping");var _,g,y,v,x,b,T=.5*l.buffer/l.extent,S=.5-T,E=.5+T,A=1+T;_=g=y=v=null,x=c(e,h,n-T,n+E,0,f.minX,f.maxX,l),b=c(e,h,n+S,n+A,0,f.minX,f.maxX,l),e=null,x&&(_=c(x,h,r-T,r+E,1,f.minY,f.maxY,l),g=c(x,h,r+S,r+A,1,f.minY,f.maxY,l),x=null),b&&(y=c(b,h,r-T,r+E,1,f.minY,f.maxY,l),v=c(b,h,r+S,r+A,1,f.minY,f.maxY,l),b=null),u>1&&console.timeEnd("clipping"),s.push(_||[],t+1,2*n,2*r),s.push(g||[],t+1,2*n,2*r+1),s.push(y||[],t+1,2*n+1,2*r),s.push(v||[],t+1,2*n+1,2*r+1)}}},E.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[M(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]?x(this.tiles[s],i):null):null},function(e,t){return new E(e,t)}}();var z=e.g(L.exports);function B(t,n){const r=t.tileID.canonical;if(!this._geoJSONIndex)return n(null,null);const i=this._geoJSONIndex.getTile(r.z,r.x,r.y);if(!i)return n(null,null);const o=new class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.E,this.length=t.length,this._features=t}feature(t){return new class{constructor(t){this._feature=t,this.extent=e.E,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const n of this._feature.geometry)t.push([new e.P(n[0],n[1])]);return t}{const t=[];for(const n of this._feature.geometry){const r=[];for(const t of n)r.push(new e.P(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,n){return l.call(this,e,t,n)}}(this._features[t])}}(i.features);let a=E(o);0===a.byteOffset&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),n(null,{vectorTile:o,rawData:a.buffer})}class F extends e.d{constructor(e,t,n,r,i,o){super(e,t,n,r,B,o),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.e(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.e(a),l=e.e("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):z(a,t.geojsonVtOptions)}catch(o){return n(o)}this.loaded={};const l={};if(i){const n=e.f(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.h(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 j{constructor(t,n){this.tileID=new e.O(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=n}parse(t,n,r,i){this.status="parsing";const o=new e.O(r.tileID.overscaledZ,r.tileID.wrap,r.tileID.canonical.z,r.tileID.canonical.x,r.tileID.canonical.y),a={},s=n.familiesBySource[r.source],l=new e.F(o,r.promoteId);return l.bucketLayerIDs=[],e.l(t).then(t=>{if(!t)return i(new Error("Could not parse tile"));const n=e.j(t,1/e.t(r.tileID.canonical)),u=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features"),c=new e.k(this.zoom,{brightness:this.brightness});for(const r in s)for(const i of s[r]){const r=i[0],s=t.json.extensionsUsed;r.recalculate(c,[]);const l=new e.T(n,o,s&&s.includes("MAPBOX_mesh_features"),this.brightness);u||(l.needsUpload=!0),a[r.fqid]=l,l.evaluate(r)}this.status="done",i(null,{buckets:a,featureIndex:l})}).catch(e=>i(new Error(e.message)))}}class N{constructor(e,t,n,r,i,o){this.actor=e,this.layerIndex=t,this.brightness=o,this.loading={},this.loaded={}}loadTile(t,n){const r=t.uid,i=this.loading[r]=new j(t,this.brightness);e.i(t.request,(e,o)=>{const a=!this.loading[r];return delete this.loading[r],a||e?(i.status="done",a||(this.loaded[r]=i),n(e)):o&&0!==o.byteLength?void i.parse(o,this.layerIndex,t,(e,t)=>{i.status="done",this.loaded=this.loaded||{},this.loaded[r]=i,e||!t?n(e):n(null,t)}):(i.status="done",this.loaded[r]=i,n())})}reloadTile(e,t){const n=this.loaded,r=e.uid;if(n&&n[r]){const i=n[r];i.projection=e.projection,i.brightness=e.brightness;const o=(n,r)=>{i.reloadCallback&&(delete i.reloadCallback,this.loadTile(e,t)),t(n,r)};"parsing"===i.status?i.reloadCallback=o:"done"===i.status&&this.loadTile(e,t)}}abortTile(e,t){const n=e.uid;this.loading[n]&&delete this.loading[n],t()}removeTile(e,t){const n=this.loaded,r=e.uid;n&&n[r]&&delete n[r],t()}}class U{constructor(t){this.self=t,this.actor=new e.A(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.m({name:"mercator"}),this.workerSourceTypes={vector:e.d,geojson:F,"batched-model":N},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.n.isParsed())throw new Error("RTL text plugin already registered.");e.n.applyArabicShaping=t.applyArabicShaping,e.n.processBidirectionalText=t.processBidirectionalText,e.n.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,{scope:n,isLoaded:r}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][n]=r,this.workerSources[t]&&this.workerSources[t][n])for(const i in this.workerSources[t][n]){const o=this.workerSources[t][n][i];for(const t in o)o[t]instanceof e.d&&(o[t].isSpriteLoaded=r,o[t].fire(new e.o("isSpriteLoaded")))}}setImages(e,{scope:t,images:n},r){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=n,this.workerSources[e]&&this.workerSources[e][t]){for(const r in this.workerSources[e][t]){const i=this.workerSources[e][t][r];for(const e in i)i[e].availableImages=n}r()}else r()}setProjection(t,n){this.projections[t]=e.m(n)}setBrightness(e,t,n){this.brightness=t,n()}setLayers(e,t,n){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),n()}updateLayers(e,t,n){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),n()}loadTile(e,t,n){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,n)}loadDEMTile(e,t,n){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,n)}reloadTile(e,t,n){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,n)}abortTile(e,t,n){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,n)}removeTile(e,t,n){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,n)}removeSource(e,t,n){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const r=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][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.n.setState(n);const t=e.n.getPluginURL();if(e.n.isLoaded()&&!e.n.isParsed()&&null!=t){this.self.importScripts(t);const n=e.n.isParsed();r(n?void 0:new Error("RTL Text Plugin failed to import scripts from "+t),n)}}catch(e){r(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let n=this.availableImages[e][t];return n||(n=[]),n}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let n=this.layerIndexes[e][t];return n||(n=this.layerIndexes[e][t]=new r,n.scope=t),n}getWorkerSource(e,t,n,r){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][r]||(this.workerSources[e][r]={}),this.workerSources[e][r][t]||(this.workerSources[e][r][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!this.workerSources[e][r][t][n]){const i={send:(t,n,r,i,o,a)=>{this.actor.send(t,n,r,e,o,a)},scheduler:this.actor.scheduler};this.workerSources[e][r][t][n]=new this.workerSourceTypes[t](i,this.getLayerIndex(e,r),this.getAvailableImages(e,r),this.isSpriteLoaded[e][r],void 0,this.brightness)}return this.workerSources[e][r][t][n]}getDEMWorkerSource(e,t,n){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][n]||(this.demWorkerSources[e][n]={}),this.demWorkerSources[e][n][t]||(this.demWorkerSources[e][n][t]=new i),this.demWorkerSources[e][n][t]}enforceCacheSizeLimit(t,n){e.q(n)}getWorkerPerformanceMetrics(e,t,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new U(self)),U})),i(0,(function(e){return e.s})),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(3),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||g,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 _(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 g(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+"[]",_(e))})),!1;return!!a(e)||(n.append(l(i,t,f),_(e)),!1)}const y=[],v=Object.assign(u,{defaultVisitor:g,convertValue:_,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},_=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(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),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(C)>3?"":" "}function V(e,t){for(;--t&&R()&&!(C<48||C>102||C>57&&C<65||C>70&&C<97););return z(e,L()+(t<6&&32==D()&&32==R()))}function G(e,t){for(;R()&&e+C!==57&&(e+C!==84||47!==D()););return"/*"+z(t,I-1)+"*"+d(47===e?e:R())}function q(e){for(;!B(D());)R();return z(e,I)}function W(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,S=1,A=0,O="",P=o,z=a,B=i,F=O;for(;w;)switch(_=A,A=R()){case 40:if(108!=_&&58==v(F,f-1)){-1!=y(F+=g(N(A),"&","&\f"),"&\f")&&(S=-1);break}case 34:case 39:case 91:F+=N(A);break;case 9:case 10:case 13:case 32:F+=U(_);break;case 92:F+=V(L()-1,7);continue;case 47:switch(D()){case 42:case 47:T(H(G(R(),L()),n,r),u);break;default:F+="/"}break;case 123*x:l[c++]=b(F)*S;case 125*x:case 59:case 0:switch(A){case 0:case 125:w=0;case 59+h:-1==S&&(F=g(F,/\f/g,"")),m>0&&b(F)-f&&T(m>32?$(F+";",i,r,f-1):$(g(F," ","")+";",i,r,f-2),u);break;case 59:F+=";";default:if(T(B=Z(F,n,r,c,h,o,l,O,P=[],z=[],f),a),123===A)if(0===h)e(F,n,B,B,P,a,f,l,z);else switch(99===p&&110===v(F,3)?100:p){case 100:case 108:case 109:case 115:e(t,B,B,i&&T(Z(t,B,B,0,0,o,l,O,o,P=[],f),z),o,z,f,l,i?P:z);break;default:e(F,B,B,B,[""],z,0,l,z)}}c=h=m=0,x=S=1,O=F="",f=s;break;case 58:f=1+b(F),m=_;default:if(x<1)if(123==A)--x;else if(125==A&&0==x++&&125==(C=I>0?v(k,--I):0,M--,10===C&&(M=1,E--),C))continue;switch(F+=d(A),A*x){case 38:S=h>0?1:(F+="\f",-1);break;case 44:l[c++]=(b(F)-1)*S,S=1;break;case 64:45===D()&&(F+=N(R())),p=D(),h=f=b(O=F+=q(L())),A++;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[T]+" "+S:g(S,/&\f/g,p[T])))&&(u[b++]=E);return O(e,t,n,0===i?l:s,u,c,d)}function H(e,t,n){return O(e,t,n,s,d(C),x(e,2,-2),0)}function $(e,t,n,r){return O(e,t,n,u,x(e,0,r),x(e,r+1,-1),r)}function X(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 X([P(e,{value:g(e.value,"@","@"+a)})],r);case l:if(e.length)return S(e.props,(function(t){switch(_(t,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return X([P(e,{props:[g(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return X([P(e,{props:[g(t,/:(plac\w+)/,":"+a+"input-$1")]}),P(e,{props:[g(t,/:(plac\w+)/,":-moz-$1")]}),P(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){if(G(n))return e.decorate_20223_(t,n);V(t,n,e)}),e)}function V(e,t,n){k(e,N)||w(e,N,D({},e[N])),function(e){return"override"===e.annotationType_}(n)||(e[N][t]=n)}function G(e){return"object"==typeof e&&"string"==typeof e.kind}var q=Symbol("mobx administration"),W=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_=Ze.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 gt(this)},t.reportChanged=function(){mt(),yt(this),_t()},t.toString=function(){return this.name_},e}(),Z=S("Atom",W);function H(e,t,n){void 0===t&&(t=_),void 0===n&&(n=_);var r,i=new W(e);return t!==_&&zt("onBO",i,t,r),n!==_&&Lt(i,n),i}var $={identity:function(e,t){return e===t},structural:function(e,t){return Yn(e,t)},default:function(e,t){return Object.is?Object.is(e,t):e===t?0!==e||1/e==1/t:e!=e&&t!=t},shallow:function(e,t){return Yn(e,t,1)}};function X(e,t,n){return Zt(e)?e:Array.isArray(e)?Oe.array(e,{name:n}):x(e)?Oe.object(e,void 0,{name:n}):E(e)?Oe.map(e,{name:n}):M(e)?Oe.set(e,{name:n}):"function"!=typeof e||Ot(e)||qt(e)?e:b(e)?Vt(e):kt(n,e)}function Y(e){return e}function K(e,t){return{annotationType_:e,options_:t,make_:J,extend_:Q,decorate_20223_:ee}}function J(e,t,n,r){var i;if(null!=(i=this.options_)&&i.bound)return null===this.extend_(e,t,n,!1)?0:1;if(r===e.target_)return null===this.extend_(e,t,n,!1)?0:2;if(Ot(n.value))return 1;var o=te(e,this,t,n,!1);return l(r,t,o),2}function Q(e,t,n,r){var i=te(e,this,t,n);return e.defineProperty_(t,i,r)}function ee(e,t){var n=t.kind,i=t.name,o=t.addInitializer,a=this;if("field"!=n){var s,l,u,c,h,d;if("method"==n)return Ot(e)||(l=e,e=Ne(null!=(u=null==(c=a.options_)?void 0:c.name)?u:i.toString(),l,null!=(h=null==(d=a.options_)?void 0:d.autoAction)&&h)),null!=(s=this.options_)&&s.bound&&o((function(){var e=this[i].bind(this);e.isMobxAction=!0,this[i]=e})),e;r("Cannot apply '"+a.annotationType_+"' to '"+String(i)+"' (kind: "+n+"):\n'"+a.annotationType_+"' can only be used on properties with a function value.")}else o((function(){V(this,i,a)}))}function te(e,t,n,r,i){var o,a,s,l,u,c,h,d;void 0===i&&(i=ht.safeDescriptors),d=r,t.annotationType_,d.value;var f,p=r.value;null!=(o=t.options_)&&o.bound&&(p=p.bind(null!=(f=e.proxy_)?f:e.target_));return{value:Ne(null!=(a=null==(s=t.options_)?void 0:s.name)?a:n.toString(),p,null!=(l=null==(u=t.options_)?void 0:u.autoAction)&&l,null!=(c=t.options_)&&c.bound?null!=(h=e.proxy_)?h:e.target_:void 0),configurable:!i||e.isPlainObject_,enumerable:!1,writable:!i}}function ne(e,t){return{annotationType_:e,options_:t,make_:re,extend_:ie,decorate_20223_:oe}}function re(e,t,n,r){var i;if(r===e.target_)return null===this.extend_(e,t,n,!1)?0:2;if(null!=(i=this.options_)&&i.bound&&(!k(e.target_,t)||!qt(e.target_[t]))&&null===this.extend_(e,t,n,!1))return 0;if(qt(n.value))return 1;var o=ae(e,this,t,n,!1,!1);return l(r,t,o),2}function ie(e,t,n,r){var i,o=ae(e,this,t,n,null==(i=this.options_)?void 0:i.bound);return e.defineProperty_(t,o,r)}function oe(e,t){var n;var r=t.name,i=t.addInitializer;return qt(e)||(e=Vt(e)),null!=(n=this.options_)&&n.bound&&i((function(){var e=this[r].bind(this);e.isMobXFlow=!0,this[r]=e})),e}function ae(e,t,n,r,i,o){var a;void 0===o&&(o=ht.safeDescriptors),a=r,t.annotationType_,a.value;var s,l=r.value;(qt(l)||(l=Vt(l)),i)&&((l=l.bind(null!=(s=e.proxy_)?s:e.target_)).isMobXFlow=!0);return{value:l,configurable:!o||e.isPlainObject_,enumerable:!1,writable:!o}}function se(e,t){return{annotationType_:e,options_:t,make_:le,extend_:ue,decorate_20223_:ce}}function le(e,t,n){return null===this.extend_(e,t,n,!1)?0:1}function ue(e,t,n,r){return function(e,t,n,r){t.annotationType_,r.get;0}(0,this,0,n),e.defineComputedProperty_(t,D({},this.options_,{get:n.get,set:n.set}),r)}function ce(e,t){var n=this,r=t.name;return(0,t.addInitializer)((function(){var t=In(this)[q],i=D({},n.options_,{get:e,context:this});i.name||(i.name="ObservableObject."+r.toString()),t.values_.set(r,new $e(i))})),function(){return this[q].getObservablePropValue_(r)}}function he(e,t){return{annotationType_:e,options_:t,make_:de,extend_:fe,decorate_20223_:pe}}function de(e,t,n){return null===this.extend_(e,t,n,!1)?0:1}function fe(e,t,n,r){var i,o;return function(e,t,n,r){t.annotationType_;0}(0,this),e.defineObservableProperty_(t,n.value,null!=(i=null==(o=this.options_)?void 0:o.enhancer)?i:X,r)}function pe(e,t){var n=this,r=t.kind,i=t.name,o=new WeakSet;function a(e,t){var r,a,s=In(e)[q],l=new We(t,null!=(r=null==(a=n.options_)?void 0:a.enhancer)?r:X,"ObservableObject."+i.toString(),!1);s.values_.set(i,l),o.add(e)}if("accessor"==r)return{get:function(){return o.has(this)||a(this,e.get.call(this)),this[q].getObservablePropValue_(i)},set:function(e){return o.has(this)||a(this,e),this[q].setObservablePropValue_(i,e)},init:function(e){return o.has(this)||a(this,e),e}}}var me=_e();function _e(e){return{annotationType_:"true",options_:e,make_:ge,extend_:ye,decorate_20223_:ve}}function ge(e,t,n,r){var i,o,a,s;if(n.get)return De.make_(e,t,n,r);if(n.set){var u=Ne(t.toString(),n.set);return r===e.target_?null===e.defineProperty_(t,{configurable:!ht.safeDescriptors||e.isPlainObject_,set:u})?0:2:(l(r,t,{configurable:!0,set:u}),2)}if(r!==e.target_&&"function"==typeof n.value)return b(n.value)?(null!=(s=this.options_)&&s.autoBind?Vt.bound:Vt).make_(e,t,n,r):(null!=(a=this.options_)&&a.autoBind?kt.bound:kt).make_(e,t,n,r);var c,h=!1===(null==(i=this.options_)?void 0:i.deep)?Oe.ref:Oe;"function"==typeof n.value&&null!=(o=this.options_)&&o.autoBind&&(n.value=n.value.bind(null!=(c=e.proxy_)?c:e.target_));return h.make_(e,t,n,r)}function ye(e,t,n,r){var i,o,a;if(n.get)return De.extend_(e,t,n,r);if(n.set)return e.defineProperty_(t,{configurable:!ht.safeDescriptors||e.isPlainObject_,set:Ne(t.toString(),n.set)},r);"function"==typeof n.value&&null!=(i=this.options_)&&i.autoBind&&(n.value=n.value.bind(null!=(a=e.proxy_)?a:e.target_));return(!1===(null==(o=this.options_)?void 0:o.deep)?Oe.ref:Oe).extend_(e,t,n,r)}function ve(e,t){r("'"+this.annotationType_+"' cannot be used as a decorator")}var xe={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};function be(e){return e||xe}Object.freeze(xe);var we=he("observable"),Te=he("observable.ref",{enhancer:Y}),Se=he("observable.shallow",{enhancer:function(e,t,n){return null==e||On(e)||_n(e)||wn(e)||En(e)?e:Array.isArray(e)?Oe.array(e,{name:n,deep:!1}):x(e)?Oe.object(e,void 0,{name:n,deep:!1}):E(e)?Oe.map(e,{name:n,deep:!1}):M(e)?Oe.set(e,{name:n,deep:!1}):void 0}}),Ee=he("observable.struct",{enhancer:function(e,t){return Yn(e,t)?t:e}}),Me=U(we);function Ae(e){return!0===e.deep?X:!1===e.deep?Y:(t=e.defaultDecorator)&&null!=(n=null==(r=t.options_)?void 0:r.enhancer)?n:X;var t,n,r}function Ie(e,t,n){return G(t)?we.decorate_20223_(e,t):y(t)?void V(e,t,we):Zt(e)?e:x(e)?Oe.object(e,t,n):Array.isArray(e)?Oe.array(e,t):E(e)?Oe.map(e,t):M(e)?Oe.set(e,t):"object"==typeof e&&null!==e?e:Oe.box(e,t)}a(Ie,Me);var Ce,ke,Oe=a(Ie,{box:function(e,t){var n=be(t);return new We(e,Ae(n),n.name,!0,n.equals)},array:function(e,t){var n=be(t);return(!1===ht.useProxies||!1===n.proxy?qn:sn)(e,Ae(n),n.name)},map:function(e,t){var n=be(t);return new bn(e,Ae(n),n.name)},set:function(e,t){var n=be(t);return new Sn(e,Ae(n),n.name)},object:function(e,t,n){return $n((function(){return Bt(!1===ht.useProxies||!1===(null==n?void 0:n.proxy)?In({},n):function(e,t){var n,r;return p(),e=In(e,t),null!=(r=(n=e[q]).proxy_)?r:n.proxy_=new Proxy(e,Xt)}({},n),e,t)}))},ref:U(Te),shallow:U(Se),deep:Me,struct:U(Ee)}),Pe=se("computed"),Re=se("computed.struct",{equals:$.structural}),De=function(e,t){if(G(t))return Pe.decorate_20223_(e,t);if(y(t))return V(e,t,Pe);if(x(e))return U(se("computed",e));var n=x(t)?t:{};return n.get=e,n.name||(n.name=e.name||""),new $e(n)};Object.assign(De,Pe),De.struct=U(Re);var Le,ze=0,Be=1,Fe=null!=(Ce=null==(ke=s((function(){}),"name"))?void 0:ke.configurable)&&Ce,je={value:"action",configurable:!0,writable:!1,enumerable:!1};function Ne(e,t,n,r){function i(){return Ue(e,n,t,r||this,arguments)}return void 0===n&&(n=!1),i.isMobxAction=!0,i.toString=function(){return t.toString()},Fe&&(je.value=e,l(i,"name",je)),i}function Ue(e,t,n,i,o){var a=function(e,t,n,r){0;var i=ht.trackingDerivation,o=!t||!i;mt();var a=ht.allowStateChanges;o&&(rt(),a=Ve(!0));var s=ot(!0),l={runAsAction_:o,prevDerivation_:i,prevAllowStateChanges_:a,prevAllowStateReads_:s,notifySpy_:!1,startTime_:0,actionId_:Be++,parentActionId_:ze};return ze=l.actionId_,l}(0,t);try{return n.apply(i,o)}catch(e){throw a.error_=e,e}finally{!function(e){ze!==e.actionId_&&r(30);ze=e.parentActionId_,void 0!==e.error_&&(ht.suppressReactionErrors=!0);Ge(e.prevAllowStateChanges_),at(e.prevAllowStateReads_),_t(),e.runAsAction_&&it(e.prevDerivation_);0;ht.suppressReactionErrors=!1}(a)}}function Ve(e){var t=ht.allowStateChanges;return ht.allowStateChanges=e,t}function Ge(e){ht.allowStateChanges=e}Le=Symbol.toPrimitive;var qe,We=function(e){function t(t,n,r,i,o){var a;return void 0===r&&(r="ObservableValue"),void 0===i&&(i=!0),void 0===o&&(o=$.default),(a=e.call(this,r)||this).enhancer=void 0,a.name_=void 0,a.equals=void 0,a.hasUnreportedChange_=!1,a.interceptors_=void 0,a.changeListeners_=void 0,a.value_=void 0,a.dehancer=void 0,a.enhancer=n,a.name_=r,a.equals=o,a.value_=n(t,void 0,r),a}L(t,e);var n=t.prototype;return n.dehanceValue=function(e){return void 0!==this.dehancer?this.dehancer(e):e},n.set=function(e){this.value_;if((e=this.prepareNewValue_(e))!==ht.UNCHANGED){0,this.setNewValue_(e)}},n.prepareNewValue_=function(e){if(Qe(this),Yt(this)){var t=Jt(this,{object:this,type:rn,newValue:e});if(!t)return ht.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.value_,this.name_),this.equals(this.value_,e)?ht.UNCHANGED:e},n.setNewValue_=function(e){var t=this.value_;this.value_=e,this.reportChanged(),Qt(this)&&tn(this,{type:rn,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},n.intercept_=function(e){return Kt(this,e)},n.observe_=function(e,t){return t&&e({observableKind:"value",debugObjectName:this.name_,object:this,type:rn,newValue:this.value_,oldValue:void 0}),en(this,e)},n.raw=function(){return this.value_},n.toJSON=function(){return this.get()},n.toString=function(){return this.name_+"["+this.value_+"]"},n.valueOf=function(){return C(this.get())},n[Le]=function(){return this.valueOf()},t}(W);qe=Symbol.toPrimitive;var Ze,He,$e=function(){function e(e){this.dependenciesState_=Ze.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.isBeingObserved_=!1,this.isPendingUnobservation_=!1,this.observers_=new Set,this.diffValue_=0,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Ze.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new Ye(null),this.name_=void 0,this.triggeredBy_=void 0,this.isComputing_=!1,this.isRunningSetter_=!1,this.derivation=void 0,this.setter_=void 0,this.isTracing_=He.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||r(31),this.derivation=e.get,this.name_=e.name||"ComputedValue",e.set&&(this.setter_=Ne("ComputedValue-setter",e.set)),this.equals_=e.equals||(e.compareStructural||e.struct?$.structural:$.default),this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}var t=e.prototype;return t.onBecomeStale_=function(){!function(e){if(e.lowestObserverState_!==Ze.UP_TO_DATE_)return;e.lowestObserverState_=Ze.POSSIBLY_STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ze.UP_TO_DATE_&&(e.dependenciesState_=Ze.POSSIBLY_STALE_,e.onBecomeStale_())}))}(this)},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.get=function(){if(this.isComputing_&&r(32,this.name_,this.derivation),0!==ht.inBatch||0!==this.observers_.size||this.keepAlive_){if(gt(this),Je(this)){var e=ht.trackingContext;this.keepAlive_&&!e&&(ht.trackingContext=this),this.trackAndCompute()&&function(e){if(e.lowestObserverState_===Ze.STALE_)return;e.lowestObserverState_=Ze.STALE_,e.observers_.forEach((function(t){t.dependenciesState_===Ze.POSSIBLY_STALE_?t.dependenciesState_=Ze.STALE_:t.dependenciesState_===Ze.UP_TO_DATE_&&(e.lowestObserverState_=Ze.UP_TO_DATE_)}))}(this),ht.trackingContext=e}}else Je(this)&&(this.warnAboutUntrackedRead_(),mt(),this.value_=this.computeValue_(!1),_t());var t=this.value_;if(Ke(t))throw t.cause;return t},t.set=function(e){if(this.setter_){this.isRunningSetter_&&r(33,this.name_),this.isRunningSetter_=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter_=!1}}else r(34,this.name_)},t.trackAndCompute=function(){var e=this.value_,t=this.dependenciesState_===Ze.NOT_TRACKING_,n=this.computeValue_(!0),r=t||Ke(e)||Ke(n)||!this.equals_(e,n);return r&&(this.value_=n),r},t.computeValue_=function(e){this.isComputing_=!0;var t,n=Ve(!1);if(e)t=et(this,this.derivation,this.scope_);else if(!0===ht.disableErrorBoundaries)t=this.derivation.call(this.scope_);else try{t=this.derivation.call(this.scope_)}catch(e){t=new Ye(e)}return Ge(n),this.isComputing_=!1,t},t.suspend_=function(){this.keepAlive_||(tt(this),this.value_=void 0)},t.observe_=function(e,t){var n=this,r=!0,i=void 0;return Pt((function(){var o=n.get();if(!r||t){var a=rt();e({observableKind:"computed",debugObjectName:n.name_,type:rn,object:n,newValue:o,oldValue:i}),it(a)}r=!1,i=o}))},t.warnAboutUntrackedRead_=function(){},t.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},t.valueOf=function(){return C(this.get())},t[qe]=function(){return this.valueOf()},e}(),Xe=S("ComputedValue",$e);!function(e){e[e.NOT_TRACKING_=-1]="NOT_TRACKING_",e[e.UP_TO_DATE_=0]="UP_TO_DATE_",e[e.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",e[e.STALE_=2]="STALE_"}(Ze||(Ze={})),function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"}(He||(He={}));var Ye=function(e){this.cause=void 0,this.cause=e};function Ke(e){return e instanceof Ye}function Je(e){switch(e.dependenciesState_){case Ze.UP_TO_DATE_:return!1;case Ze.NOT_TRACKING_:case Ze.STALE_:return!0;case Ze.POSSIBLY_STALE_:for(var t=ot(!0),n=rt(),r=e.observing_,i=r.length,o=0;or&&(r=s.dependenciesState_)}n.length=i,e.newObserving_=null,o=t.length;for(;o--;){var l=t[o];0===l.diffValue_&&ft(l,e),l.diffValue_=0}for(;i--;){var u=n[i];1===u.diffValue_&&(u.diffValue_=0,dt(u,e))}r!==Ze.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}(e),at(r),i}function tt(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)ft(t[n],e);e.dependenciesState_=Ze.NOT_TRACKING_}function nt(e){var t=rt();try{return e()}finally{it(t)}}function rt(){var e=ht.trackingDerivation;return ht.trackingDerivation=null,e}function it(e){ht.trackingDerivation=e}function ot(e){var t=ht.allowStateReads;return ht.allowStateReads=e,t}function at(e){ht.allowStateReads=e}function st(e){if(e.dependenciesState_!==Ze.UP_TO_DATE_){e.dependenciesState_=Ze.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=Ze.UP_TO_DATE_}}var lt=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},ut=!0,ct=!1,ht=function(){var e=o();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(ut=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==(new lt).version&&(ut=!1),ut?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new lt):(setTimeout((function(){ct||r(35)}),1),new lt)}();function dt(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function ft(e,t){e.observers_.delete(t),0===e.observers_.size&&pt(e)}function pt(e){!1===e.isPendingUnobservation_&&(e.isPendingUnobservation_=!0,ht.pendingUnobservations.push(e))}function mt(){ht.inBatch++}function _t(){if(0==--ht.inBatch){bt();for(var e=ht.pendingUnobservations,t=0;t0&&pt(e),!1)}function yt(e){e.lowestObserverState_!==Ze.STALE_&&(e.lowestObserverState_=Ze.STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ze.UP_TO_DATE_&&e.onBecomeStale_(),e.dependenciesState_=Ze.STALE_})))}var vt=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_=Ze.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_=He.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,ht.pendingReactions.push(this),bt())},t.isScheduled=function(){return this.isScheduled_},t.runReaction_=function(){if(!this.isDisposed_){mt(),this.isScheduled_=!1;var e=ht.trackingContext;if(ht.trackingContext=this,Je(this)){this.isTrackPending_=!0;try{this.onInvalidate_()}catch(e){this.reportExceptionInDerivation_(e)}}ht.trackingContext=e,_t()}},t.track=function(e){if(!this.isDisposed_){mt();0,this.isRunning_=!0;var t=ht.trackingContext;ht.trackingContext=this;var n=et(this,e,void 0);ht.trackingContext=t,this.isRunning_=!1,this.isTrackPending_=!1,this.isDisposed_&&tt(this),Ke(n)&&this.reportExceptionInDerivation_(n.cause),_t()}},t.reportExceptionInDerivation_=function(e){var t=this;if(this.errorHandler_)this.errorHandler_(e,this);else{if(ht.disableErrorBoundaries)throw e;var n="[mobx] uncaught error in '"+this+"'";ht.suppressReactionErrors||console.error(n,e),ht.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed_||(this.isDisposed_=!0,this.isRunning_||(mt(),tt(this),_t()))},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[q]=this,n},t.toString=function(){return"Reaction["+this.name_+"]"},t.trace=function(e){void 0===e&&(e=!1)},e}();var xt=function(e){return e()};function bt(){ht.inBatch>0||ht.isRunningReactions||xt(wt)}function wt(){ht.isRunningReactions=!0;for(var e=ht.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)?Ne(t,n,e):G(n)?(e?Mt:St).decorate_20223_(t,n):y(n)?V(t,n,e?Mt:St):y(t)?U(K(e?"autoAction":"action",{name:t,autoAction:e})):void 0}}var Ct=It(!1);Object.assign(Ct,St);var kt=It(!0);function Ot(e){return g(e)&&!0===e.isMobxAction}function Pt(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 vt(l,(function(){this.track(d)}),t.onError,t.requiresObservable);else{var u=Dt(t),c=!1;s=new vt(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(kt,Mt),Ct.bound=U(Et),kt.bound=U(At);var Rt=function(e){return e()};function Dt(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:Rt}function Lt(e,t,n){return zt("onBUO",e,t,n)}function zt(e,t,n,r){var i="function"==typeof r?Wn(t,n):Wn(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 Bt(e,t,n,r){var i=O(t);return $n((function(){var t=In(e,r)[q];I(i).forEach((function(e){t.extend_(e,i[e],!n||(!(e in n)||n[e]))}))})),e}var Ft=0;function jt(){this.message="FLOW_CANCELLED"}jt.prototype=Object.create(Error.prototype);var Nt=ne("flow"),Ut=ne("flow.bound",{bound:!0}),Vt=Object.assign((function(e,t){if(G(t))return Nt.decorate_20223_(e,t);if(y(t))return V(e,t,Nt);var n=e,r=n.name||"",i=function(){var e,t=this,i=arguments,o=++Ft,a=Ct(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=Ct(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=Ct(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=Ct(r+" - runid: "+o+" - cancel",(function(){try{s&&Gt(s);var t=a.return(void 0),n=Promise.resolve(t.value);n.then(_,_),Gt(n),e(new jt)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),Nt);function Gt(e){g(e.cancel)&&e.cancel()}function qt(e){return!0===(null==e?void 0:e.isMobXFlow)}function Wt(e,t){return!!e&&(void 0!==t?!!On(e)&&e[q].values_.has(t):On(e)||!!e[q]||Z(e)||Tt(e)||Xe(e))}function Zt(e){return Wt(e)}function Ht(e,t){void 0===t&&(t=void 0),mt();try{return e.apply(t)}finally{_t()}}function $t(e){return e[q]}Vt.bound=U(Ut);var Xt={has:function(e,t){return $t(e).has_(t)},get:function(e,t){return $t(e).get_(t)},set:function(e,t,n){var r;return!!y(t)&&(null==(r=$t(e).set_(t,n,!0))||r)},deleteProperty:function(e,t){var n;return!!y(t)&&(null==(n=$t(e).delete_(t,!0))||n)},defineProperty:function(e,t,n){var r;return null==(r=$t(e).defineProperty_(t,n))||r},ownKeys:function(e){return $t(e).ownKeys_()},preventExtensions:function(e){r(13)}};function Yt(e){return void 0!==e.interceptors_&&e.interceptors_.length>0}function Kt(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 Jt(e,t){var n=rt();try{for(var i=[].concat(e.interceptors_||[]),o=0,a=i.length;o0}function en(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 tn(e,t){var n=rt(),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 Kt(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}),en(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&&Gn(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),Yt(this)){var o=Jt(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 un(e,t){"function"==typeof Array.prototype[e]&&(ln[e]=t(e))}function cn(e){return function(){var t=this[q];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function hn(e){return function(t,n){var r=this,i=this[q];return i.atom_.reportObserved(),i.dehanceValues_(i.values_)[e]((function(e,i){return t.call(n,e,i,r)}))}}function dn(e){return function(){var t=this,n=this[q];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)}}un("at",cn),un("concat",cn),un("flat",cn),un("includes",cn),un("indexOf",cn),un("join",cn),un("lastIndexOf",cn),un("slice",cn),un("toString",cn),un("toLocaleString",cn),un("toSorted",cn),un("toSpliced",cn),un("with",cn),un("every",hn),un("filter",hn),un("find",hn),un("findIndex",hn),un("findLast",hn),un("findLastIndex",hn),un("flatMap",hn),un("forEach",hn),un("map",hn),un("some",hn),un("toReversed",hn),un("reduce",dn),un("reduceRight",dn);var fn,pn,mn=S("ObservableArrayAdministration",an);function _n(e){return v(e)&&mn(e[q])}var gn={},yn="add";fn=Symbol.iterator,pn=Symbol.toStringTag;var vn,xn,bn=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[q]=gn,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),$n((function(){i.keysAtom_=H("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(!ht.trackingDerivation)return this.has_(e);var n=this.hasMap_.get(e);if(!n){var r=n=new We(this.has_(e),Y,"ObservableMap.key?",!1);this.hasMap_.set(e,r),Lt(r,(function(){return t.hasMap_.delete(e)}))}return n.get()},t.set=function(e,t){var n=this.has_(e);if(Yt(this)){var r=Jt(this,{type:n?rn:yn,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_,Yt(this))&&!Jt(this,{type:"delete",object:this,name:e}))return!1;if(this.has_(e)){var n=Qt(this),r=n?{observableKind:"map",debugObjectName:this.name_,type:"delete",object:this,oldValue:this.data_.get(e).value_,name:e}:null;return Ht((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&&tn(this,r),!0}return!1},t.updateValue_=function(e,t){var n=this.data_.get(e);if((t=n.prepareNewValue_(t))!==ht.UNCHANGED){var r=Qt(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:rn,object:this,oldValue:n.value_,name:e,newValue:t}:null;0,n.setNewValue_(t),r&&tn(this,i)}},t.addValue_=function(e,t){var n=this;this.keysAtom_,Ht((function(){var r,i=new We(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=Qt(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:yn,object:this,name:e,newValue:t}:null;r&&tn(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 Jn({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 Jn({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},t[fn]=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 wn(e)&&(e=new Map(e)),Ht((function(){x(e)?function(e){var t=Object.keys(e);if(!A)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)})):E(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;Ht((function(){nt((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 Ht((function(){for(var n,i=function(e){if(E(e)||wn(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 en(this,e)},t.intercept_=function(e){return Kt(this,e)},R(e,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:pn,get:function(){return"Map"}}]),e}(),wn=S("ObservableMap",bn);var Tn={};vn=Symbol.iterator,xn=Symbol.toStringTag;var Sn=function(){function e(e,t,n){var i=this;void 0===t&&(t=X),void 0===n&&(n="ObservableSet"),this.name_=void 0,this[q]=Tn,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.enhancer_=function(e,r){return t(e,r,n)},$n((function(){i.atom_=H(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;Ht((function(){nt((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_,Yt(this))&&!Jt(this,{type:yn,object:this,newValue:e}))return this;if(!this.has(e)){Ht((function(){t.data_.add(t.enhancer_(e,void 0)),t.atom_.reportChanged()}));var n=Qt(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:yn,object:this,newValue:e}:null;0,n&&tn(this,r)}return this},t.delete=function(e){var t=this;if(Yt(this)&&!Jt(this,{type:"delete",object:this,oldValue:e}))return!1;if(this.has(e)){var n=Qt(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:"delete",object:this,oldValue:e}:null;return Ht((function(){t.atom_.reportChanged(),t.data_.delete(e)})),n&&tn(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 Jn({next:function(){var r=e;return e+=1,rFn){for(var t=Fn;t=0&&r++}t=Kn(t),n=Kn(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],!k(n,d)||!e(t[d],n[d],r-1,i,o))return!1}return i.pop(),o.pop(),!0}(e,t,n)}function Kn(e){return _n(e)?e.slice():E(e)||wn(e)||M(e)||En(e)?Array.from(e.entries()):e}function Jn(e){return e[Symbol.iterator]=Qn,e}function Qn(){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:Hn},$mobx:q})}).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,_="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 T?e(T,{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),_=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; /* @license Papa Parse v5.4.1 @@ -19,7 +19,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]",T="[object ArrayBuffer]",S="[object DataView]",E="[object Float32Array]",M="[object Float64Array]",A="[object Int8Array]",I="[object Int16Array]",C="[object Int32Array]",k="[object Uint8Array]",O="[object Uint16Array]",P="[object Uint32Array]",R=/\b__p \+= '';/g,D=/\b(__p \+=) '' \+/g,L=/(__e\(.*?\)|\b__t\)) \+\n'';/g,z=/&(?:amp|lt|gt|quot|#39);/g,B=/[&<>"']/g,F=RegExp(z.source),j=RegExp(B.source),N=/<%-([\s\S]+?)%>/g,U=/<%([\s\S]+?)%>/g,V=/<%=([\s\S]+?)%>/g,G=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,q=/^\w*$/,W=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Z=/[\\^$.*+?()[\]{}|]/g,H=RegExp(Z.source),$=/^\s+/,X=/\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]",Te="(?:\\ud83c[\\udde6-\\uddff]){2}",Se="[\\ud800-\\udbff][\\udc00-\\udfff]",Ee="[A-Z\\xc0-\\xd6\\xd8-\\xde]",Me="(?:"+ve+"|"+xe+")",Ae="(?:"+Ee+"|"+xe+")",Ie="(?:"+_e+"|"+be+")"+"?",Ce="[\\ufe0e\\ufe0f]?"+Ie+("(?:\\u200d(?:"+[we,Te,Se].join("|")+")[\\ufe0e\\ufe0f]?"+Ie+")*"),ke="(?:"+[ye,Te,Se].join("|")+")"+Ce,Oe="(?:"+[we+_e+"?",_e,Te,Se,pe].join("|")+")",Pe=RegExp("['’]","g"),Re=RegExp(_e,"g"),De=RegExp(be+"(?="+be+")|"+Oe+Ce,"g"),Le=RegExp([Ee+"?"+ve+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[me,Ee,"$"].join("|")+")",Ae+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[me,Ee+Me,"$"].join("|")+")",Ee+"?"+Me+"+(?:['’](?:d|ll|m|re|s|t|ve))?",Ee+"+(?:['’](?: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,ke].join("|"),"g"),ze=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[E]=Ne[M]=Ne[A]=Ne[I]=Ne[C]=Ne[k]=Ne["[object Uint8ClampedArray]"]=Ne[O]=Ne[P]=!0,Ne[l]=Ne[u]=Ne[T]=Ne[c]=Ne[S]=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[T]=Ue[S]=Ue[c]=Ue[h]=Ue[E]=Ue[M]=Ue[A]=Ue[I]=Ue[C]=Ue[m]=Ue[_]=Ue[g]=Ue[y]=Ue[v]=Ue[x]=Ue[b]=Ue[k]=Ue["[object Uint8ClampedArray]"]=Ue[O]=Ue[P]=!0,Ue[d]=Ue[f]=Ue[w]=!1;var Ve={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ge=parseFloat,qe=parseInt,We="object"==typeof e&&e&&e.Object===Object&&e,Ze="object"==typeof self&&self&&self.Object===Object&&self,He=We||Ze||Function("return this")(),$e=t&&!t.nodeType&&t,Xe=$e&&"object"==typeof r&&r&&!r.nodeType&&r,Ye=Xe&&Xe.exports===$e,Ke=Ye&&We.process,Je=function(){try{var e=Xe&&Xe.require&&Xe.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 Lt(e,t){for(var n=e.length;n--&&bt(t,e[n],0)>-1;);return n}function zt(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Bt=Mt({"À":"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=Mt({"&":"&","<":"<",">":">",'"':""","'":"'"});function jt(e){return"\\"+Ve[e]}function Nt(e){return ze.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?He:Yt.defaults(He.Object(),t,Yt.pick(He,Fe))).Array,i=t.Date,X=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,Te=xe.hasOwnProperty,Se=0,Ee=(n=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Me=xe.toString,Ae=we.call(pe),Ie=He._,Ce=me("^"+we.call(Te).replace(Z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ke=Ye?t.Buffer:void 0,Oe=t.Symbol,De=t.Uint8Array,ze=ke?ke.allocUnsafe:void 0,Ve=Vt(pe.getPrototypeOf,pe),We=pe.create,Ze=xe.propertyIsEnumerable,$e=ye.splice,Xe=Oe?Oe.isConcatSpreadable:void 0,Ke=Oe?Oe.iterator:void 0,Je=Oe?Oe.toStringTag:void 0,yt=function(){try{var e=eo(pe,"defineProperty");return e({},"",{}),e}catch(e){}}(),Mt=t.clearTimeout!==He.clearTimeout&&t.clearTimeout,Kt=i&&i.now!==He.Date.now&&i.now,Jt=t.setTimeout!==He.setTimeout&&t.setTimeout,Qt=fe.ceil,en=fe.floor,tn=pe.getOwnPropertySymbols,nn=ke?ke.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=Io(fn),wn=Io(pn),Tn=Io(mn),Sn=Io(_n),En=Io(gn),Mn=Oe?Oe.prototype:void 0,An=Mn?Mn.valueOf:void 0,In=Mn?Mn.toString:void 0;function Cn(e){if(Wa(e)&&!Da(e)&&!(e instanceof Rn)){if(e instanceof Pn)return e;if(Te.call(e,"__wrapped__"))return Co(e)}return new Pn(e)}var kn=function(){function e(){}return function(t){if(!qa(t))return{};if(We)return We(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function On(){}function Pn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function Rn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Dn(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=Da(e);if(w){if(a=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&Te.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!s)return yi(e,a)}else{var R=ro(e),D=R==f||R==p;if(Fa(e))return di(e,s);if(R==g||R==l||D&&!i){if(a=u||D?{}: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,Hn(a,e))}else{if(!Ue[R])return i?e:{};a=function(e,t,n){var r=e.constructor;switch(t){case T:return fi(e);case c:case h:return new r(+e);case S:return function(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case E:case M:case A:case I:case C:case k:case"[object Uint8ClampedArray]":case O:case P: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,An?pe(An.call(i)):{}}var i}(e,R,s)}}o||(o=new Fn);var L=o.get(e);if(L)return L;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 z=w?void 0:(d?u?Hi:Zi:u?ws:bs)(e);return st(z||e,(function(r,i){z&&(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,Ot(n))),r?(o=dt,a=!1):t.length>=200&&(o=Rt,a=!1,t=new Bn(t));e:for(;++i-1},Ln.prototype.set=function(e,t){var n=this.__data__,r=Wn(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},zn.prototype.clear=function(){this.size=0,this.__data__={hash:new Dn,map:new(pn||Ln),string:new Dn}},zn.prototype.delete=function(e){var t=Ji(this,e).delete(e);return this.size-=t?1:0,t},zn.prototype.get=function(e){return Ji(this,e).get(e)},zn.prototype.has=function(e){return Ji(this,e).has(e)},zn.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 Ln,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 Ln){var r=n.__data__;if(!pn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new zn(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=Ti(),lr=Ti(!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&&Te.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,Ot(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 Dr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)s!==e&&$e.call(s,l,1),$e.call(e,l,1);return e}function zr(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)?$e.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,Hs),e+"")}function Nr(e){return Nn(ks(e))}function Ur(e,t){var n=ks(e);return Eo(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=Rt,l=new Bn}else l=t?[]:s;e:for(;++r=r?e:Zr(e,t,n)}var hi=Mt||function(e){return He.clearTimeout(e)};function di(e,t){if(t)return e.slice();var n=e.length,r=ze?ze(n):new e.constructor(n);return e.copy(r),r}function fi(e){var t=new e.constructor(e.byteLength);return new De(t).set(new De(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 Ii(e){return Wi((function(t){var n=t.length,r=n,i=Pn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new ge(o);if(i&&!s&&"wrapper"==Xi(a))var s=new Pn([],!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 So(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 Eo(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,Xo(e,n)}));function na(e){var t=Cn(e);return t.__chain__=!0,t}function ra(e,t){return t(e)}var ia=Wi((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,i=function(t){return Xn(t,e)};return!(t>1||this.__actions__.length)&&r instanceof Rn&&so(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ra,args:[i],thisArg:void 0}),new Pn(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){Te.call(e,n)?++e[n]:$n(e,n,1)}));var aa=Ai(Ro),sa=Ai(Do);function la(e,t){return(Da(e)?st:tr)(e,Ki(t,3))}function ua(e,t){return(Da(e)?lt:nr)(e,Ki(t,3))}var ca=xi((function(e,t,n){Te.call(e,n)?e[n].push(t):$n(e,n,[t])}));var ha=jr((function(e,t,n){var i=-1,o="function"==typeof t,a=za(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){$n(e,n,t)}));function fa(e,t){return(Da(e)?ft:Ir)(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]]),Rr(e,ar(t,1),[])})),_a=Kt||function(){return He.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)})),Ta=jr((function(e,t,n){return Qn(e,as(t)||0,n)}));function Sa(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(Sa.Cache||zn),n}function Ea(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)}}Sa.Cache=zn;var Ma=ui((function(e,t){var n=(t=1==t.length&&Da(t[0])?ft(t[0],Ot(Ki())):ft(ar(t,1),Ot(Ki()))).length;return jr((function(r){for(var i=-1,o=ln(r.length,n);++i=t})),Ra=xr(function(){return arguments}())?xr:function(e){return Wa(e)&&Te.call(e,"callee")&&!Ze.call(e,"callee")},Da=r.isArray,La=Qe?Ot(Qe):function(e){return Wa(e)&&pr(e)==T};function za(e){return null!=e&&Ga(e.length)&&!Ua(e)}function Ba(e){return Wa(e)&&za(e)}var Fa=nn||al,ja=et?Ot(et):function(e){return Wa(e)&&pr(e)==h};function Na(e){if(!Wa(e))return!1;var t=pr(e);return t==d||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!$a(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 Wa(e){return null!=e&&"object"==typeof e}var Za=tt?Ot(tt):function(e){return Wa(e)&&ro(e)==m};function Ha(e){return"number"==typeof e||Wa(e)&&pr(e)==_}function $a(e){if(!Wa(e)||pr(e)!=g)return!1;var t=Ve(e);if(null===t)return!0;var n=Te.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&we.call(n)==Ae}var Xa=nt?Ot(nt):function(e){return Wa(e)&&pr(e)==y};var Ya=rt?Ot(rt):function(e){return Wa(e)&&ro(e)==v};function Ka(e){return"string"==typeof e||!Da(e)&&Wa(e)&&pr(e)==x}function Ja(e){return"symbol"==typeof e||Wa(e)&&pr(e)==b}var Qa=it?Ot(it):function(e){return Wa(e)&&Ga(e.length)&&!!Ne[pr(e)]};var es=Li(Ar),ts=Li((function(e,t){return e<=t}));function ns(e){if(!e)return[];if(za(e))return Ka(e)?Ht(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:ks)(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=kt(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)||za(t))vi(t,bs(t),e);else for(var n in t)Te.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=Wi(Xn);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,Hi(e),n),r&&(n=Kn(n,7,Gi));for(var i=t.length;i--;)ei(n,t[i]);return n}));var Ms=Wi((function(e,t){return null==e?{}:function(e,t){return Dr(e,t,(function(t,n){return gs(e,n)}))}(e,t)}));function As(e,t){if(null==e)return{};var n=ft(Hi(e),(function(e){return[e]}));return t=Ki(t),Dr(e,n,(function(e,n){return t(e,n[0])}))}var Is=ji(bs),Cs=ji(ws);function ks(e){return null==e?[]:Pt(e,bs(e))}var Os=Ei((function(e,t,n){return t=t.toLowerCase(),e+(n?Ps(t):t)}));function Ps(e){return Ns(ls(e).toLowerCase())}function Rs(e){return(e=ls(e))&&e.replace(ue,Bt).replace(Re,"")}var Ds=Ei((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ls=Ei((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),zs=Si("toLowerCase");var Bs=Ei((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Fs=Ei((function(e,t,n){return e+(n?" ":"")+Ns(t)}));var js=Ei((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Ns=Si("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(Le)||[]}(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 X(e)}})),Gs=Wi((function(e,t){return st(t,(function(t){t=Ao(t),$n(e,t,va(e[t],e))})),e}));function qs(e){return function(){return e}}var Ws=Ii(),Zs=Ii(!0);function Hs(e){return e}function $s(e){return Sr("function"==typeof e?e:Kn(e,1))}var Xs=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=Pi(ft),el=Pi(ut),tl=Pi(gt);function nl(e){return uo(e)?Et(Ao(e)):function(e){return function(t){return dr(t,e)}}(e)}var rl=Di(),il=Di(!0);function ol(){return[]}function al(){return!1}var sl=Oi((function(e,t){return e+t}),0),ll=Bi("ceil"),ul=Oi((function(e,t){return e/t}),1),cl=Bi("floor");var hl,dl=Oi((function(e,t){return e*t}),1),fl=Bi("round"),pl=Oi((function(e,t){return e-t}),0);return Cn.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)}},Cn.ary=ga,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 Da(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&&!Xa(t))&&!(t=Jr(t))&&Nt(e)?ci(Ht(e),0,n):e.split(t,n):[]},Cn.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)}))},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 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})},Cn.thru=ra,Cn.toArray=ns,Cn.toPairs=Is,Cn.toPairsIn=Cs,Cn.toPath=function(e){return Da(e)?ft(e,Ao):Ja(e)?[e]:yi(Mo(ls(e)))},Cn.toPlainObject=ss,Cn.transform=function(e,t,n){var r=Da(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)?kn(Ve(e)):{}}return(i?st:ur)(e,(function(e,r,i){return t(n,e,r,i)})),n},Cn.unary=function(e){return ga(e,1)},Cn.union=Wo,Cn.unionBy=Zo,Cn.unionWith=Ho,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=$o,Cn.unzipWith=Xo,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=ks,Cn.valuesIn=function(e){return null==e?[]:Pt(e,ws(e))},Cn.without=Yo,Cn.words=Us,Cn.wrap=function(e,t){return Aa(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=Is,Cn.entriesIn=Cs,Cn.extend=cs,Cn.extendWith=hs,Ks(Cn,Cn),Cn.add=sl,Cn.attempt=Vs,Cn.camelCase=Os,Cn.capitalize=Ps,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=Rs,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=ka,Cn.escape=function(e){return(e=ls(e))&&j.test(e)?e.replace(B,Ft):e},Cn.escapeRegExp=function(e){return(e=ls(e))&&H.test(e)?e.replace(Z,"\\$&"):e},Cn.every=function(e,t,n){var r=Da(e)?ut:rr;return n&&lo(e,t,n)&&(t=void 0),r(e,Ki(t,3))},Cn.find=aa,Cn.findIndex=Ro,Cn.findKey=function(e,t){return vt(e,Ki(t,3),ur)},Cn.findLast=sa,Cn.findLastIndex=Do,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=_s,Cn.gt=Oa,Cn.gte=Pa,Cn.has=function(e,t){return null!=e&&io(e,t,_r)},Cn.hasIn=gs,Cn.head=zo,Cn.identity=Hs,Cn.includes=function(e,t,n,r){e=za(e)?e:ks(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 Wa(e)&&ro(e)==w},Cn.isWeakSet=function(e){return Wa(e)&&"[object WeakSet]"==pr(e)},Cn.join=function(e,t){return null==e?"":on.call(e,t)},Cn.kebabCase=Ds,Cn.last=No,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,Tt,i,!0)},Cn.lowerCase=Ls,Cn.lowerFirst=zs,Cn.lt=es,Cn.lte=ts,Cn.max=function(e){return e&&e.length?ir(e,Hs,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 St(e,Hs)},Cn.meanBy=function(e,t){return St(e,Ki(t,2))},Cn.min=function(e){return e&&e.length?ir(e,Hs,Ar):void 0},Cn.minBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),Ar):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?Pr(e,is(t)):void 0},Cn.noConflict=function(){return He._===this&&(He._=Ie),this},Cn.noop=Js,Cn.now=_a,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 Ri(en(i),n)+e+Ri(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=Da(e)?mt:At,i=arguments.length<3;return r(e,Ki(t,4),n,i,tr)},Cn.reduceRight=function(e,t,n){var r=Da(e)?_t:At,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),Xa(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(z,Xt):e},Cn.uniqueId=function(e){var t=++Se;return ls(e)+t},Cn.upperCase=js,Cn.upperFirst=Ns,Cn.each=la,Cn.eachRight=ua,Cn.first=zo,Ks(Cn,(hl={},ur(Cn,(function(e,t){Te.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){Rn.prototype[e]=function(n){n=void 0===n?1:sn(is(n),0);var r=this.__filtered__&&!t?new Rn(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},Rn.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;Rn.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":"");Rn.prototype[e]=function(){return this[n](1).value()[0]}})),st(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Rn.prototype[e]=function(){return this.__filtered__?new Rn(this):this[n](1)}})),Rn.prototype.compact=function(){return this.filter(Hs)},Rn.prototype.find=function(e){return this.filter(e).head()},Rn.prototype.findLast=function(e){return this.reverse().find(e)},Rn.prototype.invokeMap=jr((function(e,t){return"function"==typeof e?new Rn(this):this.map((function(n){return vr(n,e,t)}))})),Rn.prototype.reject=function(e){return this.filter(Ea(Ki(e)))},Rn.prototype.slice=function(e,t){e=is(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Rn(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)},Rn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Rn.prototype.toArray=function(){return this.take(4294967295)},ur(Rn.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 Rn,l=a[0],u=s||Da(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 Rn(this);var m=e.apply(t,a);return m.__actions__.push({func:ra,args:[c],thisArg:void 0}),new Pn(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(Da(i)?i:[],e)}return this[n]((function(n){return t.apply(Da(n)?n:[],e)}))}})),ur(Rn.prototype,(function(e,t){var n=Cn[t];if(n){var r=n.name+"";Te.call(xn,r)||(xn[r]=[]),xn[r].push({name:t,func:n})}})),xn[Ci(void 0,2).name]=[{name:"wrapper",func:void 0}],Rn.prototype.clone=function(){var e=new Rn(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},Rn.prototype.reverse=function(){if(this.__filtered__){var e=new Rn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Rn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Da(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 On;){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 Rn){var t=e;return this.__actions__.length&&(t=new Rn(this)),(t=t.reverse()).__actions__.push({func:ra,args:[qo],thisArg:void 0}),new Pn(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}();He._=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,_=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,T=void 0!==w&&w,S=e.closeOnDocumentClick,E=void 0===S||S,M=e.repositionOnResize,A=void 0===M||M,I=e.closeOnEscape,C=void 0===I||I,k=e.on,O=void 0===k?["click"]:k,P=e.contentStyle,R=void 0===P?{}:P,D=e.arrowStyle,L=void 0===D?{}:D,z=e.overlayStyle,B=void 0===z?{}:z,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,W=void 0!==q&&q,Z=e.arrow,H=void 0===Z||Z,$=e.offsetX,X=void 0===$?0:$,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,Me(),Te(),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&&W&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},we=function(){fe&&W&&(document.getElementsByTagName("body")[0].style.overflow="auto")},Te=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 Se,Ee,Me=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,H,{offsetX:X,offsetY:K},re);if(ue.current.style.top=i.top+window.scrollY+"px",ue.current.style.left=i.left+window.scrollX+"px",H&&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=L.top)||void 0===e?void 0:e.toString())||i.arrowTop,ce.current.style.left=(null===(t=L.left)||void 0===t?void 0:t.toString())||i.arrowLeft}};Se=_e,void 0===(Ee=C)&&(Ee=!0),Object(r.useEffect)((function(){if(Ee){var e=function(e){"Escape"===e.key&&Se(e)};return document.addEventListener("keyup",e),function(){Ee&&document.removeEventListener("keyup",e)}}}),[Se,Ee]),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])}(Me,A),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,E&&!T);var Ae,Ie=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,R,{pointerEvents:"auto"}),ref:ue,onClick:function(e){e.stopPropagation()}},!G&&O.indexOf("hover")>=0&&(t.onMouseEnter=ye,t.onMouseLeave=xe),t),{key:"C",role:fe?"dialog":"tooltip",id:de.current}),H&&!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"},L)},i.a.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),ie&&"function"==typeof ie?ie(_e,ae):ie);var e,t},Ce=!(O.indexOf("hover")>=0),ke=fe?u.overlay.modal:u.overlay.tooltip,Oe=[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({},ke,B,{pointerEvents:E&&T||fe?"auto":"none"}),onClick:E&&T?_e:void 0,tabIndex:-1},fe&&Ie()),!fe&&Ie()];return i.a.createElement(i.a.Fragment,null,function(){for(var e={key:"T",ref:le,"aria-describedby":de.current},t=Array.isArray(O)?O:[O],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 zt}));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 A(e){return e instanceof T(e).HTMLElement}function I(e){return e instanceof T(e).Element}function C(e){if("undefined"==typeof ShadowRoot)return!1;return e instanceof T(e).ShadowRoot||e instanceof ShadowRoot}function k(e){const{overflow:t,overflowX:n,overflowY:r}=S(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function O(){return!/^((?!chrome|android).)*safari/i.test(M())}Math.min,Math.max;const P=Math.round;function R(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&&A(e)&&(l=e.offsetWidth>0&&P(s.width)/e.offsetWidth||1,u=e.offsetHeight>0&&P(s.height)/e.offsetHeight||1);const c=I(e)?T(e):window,h=!O()&&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 D(e){return(t=e,(t instanceof T(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function L(e){return"html"===E(e)?e:e.assignedSlot||e.parentNode||(C(e)?e.host:null)||D(e)}function z(e,t){var n;void 0===t&&(t=[]);const r=function e(t){const n=L(t);return["html","body","#document"].includes(E(n))?t.ownerDocument.body:A(n)&&k(n)?n:e(n)}(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),o=T(r),a=i?[o].concat(o.visualViewport||[],k(r)?r:[]):r,s=t.concat(a);return i?s:s.concat(z(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 W(e)?window.pageYOffset:e.scrollTop}function H(e,t){W(e)?window.scrollTo(0,t):e.scrollTop=t}function $(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function X(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=$(s+=a,i,o,n);H(e,t),sn.bottom?H(e,Math.min(t.offsetTop+t.clientHeight-e.offsetHeight+i,e.scrollHeight)):r.top-i=p)return{placement:"bottom",maxHeight:t};if(S>=p&&!a)return o&&X(l,E,160),{placement:"bottom",maxHeight:t};if(!a&&S>=r||a&&w>=r)return o&&X(l,E,160),{placement:"bottom",maxHeight:a?w-v:S-v};if("auto"===i||a){var A=t,I=a?b:T;return I>=r&&(A=Math.min(I-v-s,t)),{placement:"top",maxHeight:A}}if("bottom"===i)return o&&H(l,E),{placement:"bottom",maxHeight:t};break;case"top":if(b>=p)return{placement:"top",maxHeight:t};if(T>=p&&!a)return o&&X(l,M,160),{placement:"top",maxHeight:t};if(!a&&T>=r||a&&b>=r){var C=t;return(!a&&T>=r||a&&b>=r)&&(C=a?b-x:T-x),o&&X(l,M,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],_=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"}))},Te=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}})},Se=Te,Ee=Te,Me=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)}})))),Ae=function(e){var t=e.delay,n=e.offset;return Object(x.c)("span",{css:Object(x.b)({animation:"".concat(Me," 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"},"","")})},Ie=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,{"aria-disabled":n||void 0}),t)},Ce=["data"],ke=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))},Oe=["innerRef","isDisabled","isHidden","inputClassName"],Pe={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},Re={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"},Pe)},De=function(e){return o({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Pe)},Le=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",n,t)};var ze={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:Ie,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:ke,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,Oe);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:De(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)(Ae,{delay:0,offset:n}),Object(x.c)(Ae,{delay:160,offset:!0}),Object(x.c)(Ae,{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 T=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?[...I(e)?z(e):[],...z(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}),I(e)&&!s&&d.observe(e),d.observe(t)}let f=s?R(e):null;return s&&function t(){const r=R(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(){T()}),[T]);var S=Object(c.useCallback)((function(e){u.current=e,T()}),[T]);if(!t&&"fixed"!==s||!y)return null;var E=Object(x.c)("div",d({ref:S},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)(E,t):E)},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:Le,MultiValueLabel:Le,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=e.isAppleDevice,c=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(c(a,n),".");if("menu"===t&&u){var h=s?" disabled":"",d="".concat(l?" selected":"").concat(h);return"".concat(o).concat(d,", ").concat(c(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=e.isAppleDevice,d=l.ariaLiveMessages,f=l.getOptionLabel,p=l.inputValue,m=l.isMulti,_=l.isOptionDisabled,g=l.isSearchable,y=l.menuIsOpen,v=l.options,b=l.screenReaderStatus,w=l.tabSelectsValue,T=l.isLoading,S=l["aria-label"],E=l["aria-live"],M=Object(c.useMemo)((function(){return o(o({},Ue),d||{})}),[d]),A=Object(c.useMemo)((function(){var e,n="";if(t&&M.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?f(c):"",d=i||l||void 0,p=d?d.map(f):[],m=o({isDisabled:c&&_(c,s),label:h,labels:p},t);n=M.onChange(m)}return n}),[t,M,_,s,f]),I=Object(c.useMemo)((function(){var e="",t=n||r,o=!!(n&&s&&s.includes(n));if(t&&M.onFocus){var a={focused:t,label:f(t),isDisabled:_(t,s),isSelected:o,options:i,context:t===n?"menu":"value",selectValue:s,isAppleDevice:h};e=M.onFocus(a)}return e}),[n,r,f,_,M,i,s,h]),C=Object(c.useMemo)((function(){var e="";if(y&&v.length&&!T&&M.onFilter){var t=b({count:i.length});e=M.onFilter({inputValue:p,resultsMessage:t})}return e}),[i,p,y,M,v,b,T]),k="initial-input-focus"===(null==t?void 0:t.action),O=Object(c.useMemo)((function(){var e="";if(M.guidance){var t=r?"value":y?"menu":"input";e=M.guidance({"aria-label":S,context:t,isDisabled:n&&_(n,s),isMulti:m,isSearchable:g,tabSelectsValue:w,isInitialFocus:k})}return e}),[S,n,r,m,_,g,y,M,s,w,k]),P=Object(x.c)(c.Fragment,null,Object(x.c)("span",{id:"aria-selection"},A),Object(x.c)("span",{id:"aria-focused"},I),Object(x.c)("span",{id:"aria-results"},C),Object(x.c)("span",{id:"aria-guidance"},O));return Object(x.c)(c.Fragment,null,Object(x.c)(Ne,{id:u},k&&P),Object(x.c)(Ne,{"aria-live":E,"aria-atomic":"false","aria-relevant":"additions text",role:"log"},a&&!k&&P))},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"),We={},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.cancelable&&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(){}})};function mt(e){var t;return"undefined"!=typeof window&&null!=window.navigator&&e.test((null===(t=window.navigator.userAgentData)||void 0===t?void 0:t.platform)||window.navigator.platform)}function _t(){return mt(/^Mac/i)}function gt(){return mt(/^iPhone/i)||mt(/^iPad/i)||_t()&&navigator.maxTouchPoints>1}var yt={clearIndicator:Ee,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:Se,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)":""},Re),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 vt,xt={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}},bt={"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"},vt),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=Xe(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 wt(e,t,n,r){return{type:"option",data:t,isDisabled:kt(e,t,n),isSelected:Ot(e,t,n),label:It(e,t),value:Ct(e,t),index:r}}function Tt(e,t){return e.options.map((function(n,r){if("options"in n){var i=n.options.map((function(n,r){return wt(e,n,t,r)})).filter((function(t){return Mt(e,t)}));return i.length>0?{type:"group",data:n,options:i,index:r}:void 0}var o=wt(e,n,t,r);return Mt(e,o)?o:void 0})).filter(ne)}function St(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 Et(e,t){return e.reduce((function(e,n){return"group"===n.type?e.push.apply(e,v(n.options.map((function(e){return{data:e.data,id:"".concat(t,"-").concat(n.index,"-").concat(e.index)}})))):e.push({data:n.data,id:"".concat(t,"-").concat(n.index)}),e}),[])}function Mt(e,t){var n=e.inputValue,r=void 0===n?"":n,i=t.data,o=t.isSelected,a=t.label,s=t.value;return(!Rt(e)||!o)&&Pt(e,{label:a,value:s,data:i},r)}var At=function(e,t){var n;return(null===(n=e.find((function(e){return e.data===t})))||void 0===n?void 0:n.id)||null},It=function(e,t){return e.getOptionLabel(t)},Ct=function(e,t){return e.getOptionValue(t)};function kt(e,t,n){return"function"==typeof e.isOptionDisabled&&e.isOptionDisabled(t,n)}function Ot(e,t,n){if(n.indexOf(t)>-1)return!0;if("function"==typeof e.isOptionSelected)return e.isOptionSelected(t,n);var r=Ct(e,t);return n.some((function(t){return Ct(e,t)===r}))}function Pt(e,t,n){return!e.filterOption||e.filterOption(t,n)}var Rt=function(e){var t=e.hideSelectedOptions,n=e.isMulti;return void 0===t?n:t},Dt=1,Lt=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,focusedOptionId:null,focusableOptionsWithIds:[],focusedValue:null,inputIsHidden:!1,isFocused:!1,selectValue:[],clearFocusValueOnUpdate:!1,prevWasFocused:!1,inputIsHiddenAfterUpdate:void 0,prevProps:void 0,instancePrefix:""},t.blockOptionHover=!1,t.isComposing=!1,t.commonProps=void 0,t.initialTouchX=0,t.initialTouchY=0,t.openAfterFocus=!1,t.scrollToFocusedOptionOnUpdate=!1,t.userIsDragging=void 0,t.isAppleDevice=_t()||gt(),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.getFocusedOptionId=function(e){return At(t.state.focusableOptionsWithIds,e)},t.getFocusableOptionsWithIds=function(){return Et(Tt(t.props,t.state.selectValue),t.getElementId("option"))},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){if(!t.blockOptionHover&&t.state.focusedOption!==e){var n=t.getFocusableOptions().indexOf(e);t.setState({focusedOption:e,focusedOptionId:n>-1?t.getFocusedOptionId(e):null})}},t.shouldHideSelectedOptions=function(){return Rt(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.state.instancePrefix="react-select-"+(t.props.instanceId||++Dt),t.state.selectValue=V(e.value),e.menuIsOpen&&t.state.selectValue.length){var n=t.getFocusableOptionsWithIds(),r=t.buildFocusableOptions(),s=r.indexOf(t.state.selectValue[0]);t.state.focusableOptionsWithIds=n,t.state.focusedOption=r[s],t.state.focusedOptionId=At(n,r[s])}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=t.instancePrefix,c=e.options,h=e.value,d=e.menuIsOpen,f=e.inputValue,p=e.isMulti,m=V(h),_={};if(n&&(h!==n.value||c!==n.options||d!==n.menuIsOpen||f!==n.inputValue)){var g=d?function(e,t){return St(Tt(e,t))}(e,m):[],y=d?Et(Tt(e,m),"".concat(u,"-option")):[],v=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);_={selectValue:m,focusedOption:x,focusedOptionId:At(y,x),focusableOptionsWithIds:y,focusedValue:v,clearFocusValueOnUpdate:!1}}var b=null!=i&&e!==n?{inputIsHidden:i,inputIsHiddenAfterUpdate:void 0}:{},w=a,T=s&&l;return s&&!T&&(w={value:re(p,m,m[0]||null),options:m,action:"initial-input-focus"},T=!l),"initial-input-focus"===(null==a?void 0:a.action)&&(w=null),o(o(o({},_),b),{},{prevProps:e,ariaSelection:w,prevWasFocused:T})}}],(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],focusedOptionId:this.getFocusedOptionId(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,focusedOptionId:this.getFocusedOptionId(r[i])})}}},{key:"getTheme",value:function(){return this.props.theme?"function"==typeof this.props.theme?this.props.theme(xt):o(o({},xt),this.props.theme):xt}},{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 kt(this.props,e,t)}},{key:"isOptionSelected",value:function(e,t){return Ot(this.props,e,t)}},{key:"filterOption",value:function(e,t){return Pt(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","aria-activedescendant":this.isAppleDevice?void 0:this.state.focusedOptionId||""},l&&{"aria-controls":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,T=p.menuPosition,S=p.menuPortalTarget,E=p.menuShouldBlockScroll,M=p.menuShouldScrollIntoView,A=p.noOptionsMessage,I=p.onMenuScrollToTop,C=p.onMenuScrollToBottom;if(!b)return null;var k,O=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,role:"option","aria-selected":e.isAppleDevice?void 0:a};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())k=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 O(e,"".concat(a,"-").concat(e.index))})))}if("option"===t.type)return O(t,"".concat(t.index))}));else if(g){var P=y({inputValue:_});if(null===P)return null;k=c.createElement(s,h,P)}else{var R=A({inputValue:_});if(null===R)return null;k=c.createElement(l,h,R)}var D={minMenuHeight:v,maxMenuHeight:x,menuPlacement:w,menuPosition:T,menuShouldScrollIntoView:M},L=c.createElement(ce,d({},h,D),(function(t){var n=t.ref,r=t.placerProps,a=r.placement,s=r.maxHeight;return c.createElement(i,d({},h,D,{innerRef:n,innerProps:{onMouseDown:e.onMenuMouseDown,onMouseMove:e.onMenuMouseMove},isLoading:g,placement:a}),c.createElement(dt,{captureEnabled:m,onTopArrive:I,onBottomArrive:C,lockEnabled:E},(function(t){return c.createElement(o,d({},h,{innerRef:function(n){e.getMenuListRef(n),t(n)},innerProps:{role:"listbox","aria-multiselectable":h.isMulti,id:e.getElementId("listbox")},isLoading:g,maxHeight:s,focusedOption:f}),k)})))}));return S||"fixed"===T?c.createElement(a,d({},h,{appendTo:S,controlElement:this.controlRef,menuPlacement:w,menuPosition:T}),L):L}},{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,isAppleDevice:this.isAppleDevice}))}},{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);Lt.defaultProps=bt;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 zt=Object(c.forwardRef)((function(e,t){var n,r,i,a,s,f,p,m,_,g,y,v,x,b,w,T,S,E,M,A,I,C,k,O,P,R,D,L,z,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),T=l(Object(c.useState)(void 0!==m?m:i),2),S=T[0],E=T[1],M=l(Object(c.useState)(void 0!==_?_:s),2),A=M[0],I=M[1],C=l(Object(c.useState)(void 0!==b?b:p),2),k=C[0],O=C[1],P=Object(c.useCallback)((function(e,t){"function"==typeof g&&g(e,t),O(e)}),[g]),R=Object(c.useCallback)((function(e,t){var n;"function"==typeof y&&(n=y(e,t)),E(void 0!==n?n:e)}),[y]),D=Object(c.useCallback)((function(){"function"==typeof x&&x(),I(!0)}),[x]),L=Object(c.useCallback)((function(){"function"==typeof v&&v(),I(!1)}),[v]),z=void 0!==m?m:S,B=void 0!==_?_:A,F=void 0!==b?b:k,o(o({},w),{},{inputValue:z,menuIsOpen:B,onChange:P,onInputChange:R,onMenuClose:L,onMenuOpen:D,value:F}));return c.createElement(Lt,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)||_,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,T]=y&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[a,a],S={isOnline:()=>b,isVisible:()=>{const e=v&&document.visibilityState;return u(e)||"hidden"!==e}},E={initFocus:e=>(v&&document.addEventListener("visibilitychange",e),w("focus",e),()=>{v&&document.removeEventListener("visibilitychange",e),T("focus",e)}),initReconnect:e=>{const t=()=>{b=!0,e()},n=()=>{b=!1};return w("online",t),w("offline",n),()=>{T("online",t),T("offline",n)}}},M=!i.a.useId,A=!y||"Deno"in window,I=e=>y&&void 0!==window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1),C=A?r.useEffect:r.useLayoutEffect,k="undefined"!=typeof navigator&&navigator.connection,O=!A&&k&&(["slow-2g","2g"].includes(k.effectiveType)||k.saveData),P=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 R=0;const D=()=>++R;var L=3,z=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]=P(n);if(!i)return;const[o,h]=x(t,i),[_,g,y,v]=m.get(t),b=()=>{const e=_[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,T=r;const S=D();g[i]=[S,0];const E=!u(d),M=o(),A=M.data,I=M._c,C=u(I)?A:I;if(E&&(d=c(d)?d(C,A):d,h({data:d,_c:C})),c(T))try{T=T(C)}catch(e){w=e}if(T&&c(T.then)){if(T=await T.catch(e=>{w=e}),S!==g[i][0]){if(w)throw w;return T}w&&E&&(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(T,C);h({data:e,error:s,_c:s})}else h({data:T,error:s,_c:s});if(g[i][1]=D(),Promise.resolve(b()).then(()=>{h({_c:s})}),!w)return T;if(p)throw w}}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(E,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]),!A)){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:O?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:O?5e3:3e3,compare:(e,t)=>p(e)==p(t),isPaused:()=>!1,cache:V,mutate:G,fallback:{}},S),W=(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)({}),H=y&&window.__SWR_DEVTOOLS_USE__,$=H?window.__SWR_DEVTOOLS_USE__:[],X=e=>c(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],Y=$.concat(e=>(t,n,r)=>e(t,n&&((...e)=>{const[r]=P(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));H&&(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:W(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]),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:_,refreshWhenHidden:g,refreshWhenOffline:y,keepPreviousData:v}=n,[b,w,T,S]=m.get(i),[E,k]=P(e),O=Object(r.useRef)(!1),R=Object(r.useRef)(!1),N=Object(r.useRef)(E),U=Object(r.useRef)(t),V=Object(r.useRef)(n),G=()=>V.current,q=()=>G().isVisible()&&G().isOnline(),[W,Z,H,$]=x(i,E),X=Object(r.useRef)({}).current,Y=u(d)?n.fallback[E]:d,Q=(e,t)=>{for(const n in X){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=!!E&&!!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=W(),i=$(),o=n(r),a=r===i?o:n(i);let s=o;return[()=>{const e=n(W());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,E]),te=Object(o.useSyncExternalStore)(Object(r.useCallback)(e=>H(E,(t,n)=>{Q(n,t)||e()}),[i,E]),ee[0],ee[1]),ne=!O.current,re=b[E]&&b[E].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=!!(E&&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(!E||!t||R.current||G().isPaused())return!1;let r,i,o=!0;const l=e||{},h=!T[E]||!l.dedupe,d=()=>M?!R.current&&E===N.current&&O.current:E===N.current,f={isValidating:!1,isLoading:!1},p=()=>{Z(f)},m=()=>{const e=T[E];e&&e[1]===i&&delete T[E]},_={isValidating:!0};u(W().data)&&(_.isLoading=!0);try{if(h&&(Z(_),n.loadingTimeout&&u(W().data)&&setTimeout(()=>{o&&d()&&G().onLoadingSlow(E,n)},n.loadingTimeout),T[E]=[t(k),D()]),[r,i]=T[E],r=await r,h&&setTimeout(m,n.dedupingInterval),!T[E]||T[E][1]!==i)return h&&d()&&G().onDiscarded(E),!1;f.error=s;const e=w[E];if(!u(e)&&(i<=e[0]||i<=e[1]||0===e[1]))return p(),h&&d()&&G().onDiscarded(E),!1;const l=W().data;f.data=a(l,r)?l:r,h&&d()&&G().onSuccess(r,E,n)}catch(e){m();const t=G(),{shouldRetryOnError:n}=t;t.isPaused()||(f.error=e,h&&d()&&(t.onError(e,E,t),(!0===n||c(n)&&n(e))&&q()&&t.onErrorRetry(e,E,t,e=>{const t=b[E];t&&t[0]&&t[0](L,e)},{retryCount:(l.retryCount||0)+1,dedupe:!0})))}return o=!1,p(),!0},[E,i]),pe=Object(r.useCallback)((...e)=>j(i,N.current,...e),[]);if(C(()=>{U.current=t,V.current=n,u(ie)||(se.current=ie)}),C(()=>{if(!E)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())}})(E,b,(n,r={})=>{if(n==z){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==L)return fe(r)}});return R.current=!1,N.current=E,O.current=!0,Z({_k:k}),ue&&(u(oe)||A?e():I(e)),()=>{R.current=!0,n()}},[E]),C(()=>{let e;function t(){const t=c(_)?_(W().data):_;t&&-1!==e&&(e=setTimeout(n,t))}function n(){W().error||!g&&!G().isVisible()||!y&&!G().isOnline()?t():fe(J).then(t)}return t(),()=>{e&&(clearTimeout(e),e=-1)}},[_,g,y,E]),Object(r.useDebugValue)(le),l&&u(oe)&&E){if(!M&&A)throw new Error("Fallback data is required when using suspense in SSR.");U.current=t,V.current=n,R.current=!1;const e=S[E];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 X.data=!0,le},get error(){return X.error=!0,ae},get isValidating(){return X.isValidating=!0,he},get isLoading(){return X.isLoading=!0,de}}},function(...e){const t=h(q,Object(r.useContext)(Z)),[n,i,o]=X(e),a=W(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]",_="[object Number]",g="[object Object]",y="[object RegExp]",v="[object Set]",x="[object String]",b="[object Symbol]",w="[object WeakMap]",T="[object ArrayBuffer]",S="[object DataView]",E="[object Float32Array]",M="[object Float64Array]",A="[object Int8Array]",I="[object Int16Array]",C="[object Int32Array]",k="[object Uint8Array]",O="[object Uint16Array]",P="[object Uint32Array]",R=/\b__p \+= '';/g,D=/\b(__p \+=) '' \+/g,L=/(__e\(.*?\)|\b__t\)) \+\n'';/g,z=/&(?:amp|lt|gt|quot|#39);/g,B=/[&<>"']/g,F=RegExp(z.source),j=RegExp(B.source),N=/<%-([\s\S]+?)%>/g,U=/<%([\s\S]+?)%>/g,V=/<%=([\s\S]+?)%>/g,G=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,q=/^\w*$/,W=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Z=/[\\^$.*+?()[\]{}|]/g,H=RegExp(Z.source),$=/^\s+/,X=/\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]",Te="(?:\\ud83c[\\udde6-\\uddff]){2}",Se="[\\ud800-\\udbff][\\udc00-\\udfff]",Ee="[A-Z\\xc0-\\xd6\\xd8-\\xde]",Me="(?:"+ve+"|"+xe+")",Ae="(?:"+Ee+"|"+xe+")",Ie="(?:"+_e+"|"+be+")"+"?",Ce="[\\ufe0e\\ufe0f]?"+Ie+("(?:\\u200d(?:"+[we,Te,Se].join("|")+")[\\ufe0e\\ufe0f]?"+Ie+")*"),ke="(?:"+[ye,Te,Se].join("|")+")"+Ce,Oe="(?:"+[we+_e+"?",_e,Te,Se,pe].join("|")+")",Pe=RegExp("['’]","g"),Re=RegExp(_e,"g"),De=RegExp(be+"(?="+be+")|"+Oe+Ce,"g"),Le=RegExp([Ee+"?"+ve+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[me,Ee,"$"].join("|")+")",Ae+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[me,Ee+Me,"$"].join("|")+")",Ee+"?"+Me+"+(?:['’](?:d|ll|m|re|s|t|ve))?",Ee+"+(?:['’](?: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,ke].join("|"),"g"),ze=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[E]=Ne[M]=Ne[A]=Ne[I]=Ne[C]=Ne[k]=Ne["[object Uint8ClampedArray]"]=Ne[O]=Ne[P]=!0,Ne[l]=Ne[u]=Ne[T]=Ne[c]=Ne[S]=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[T]=Ue[S]=Ue[c]=Ue[h]=Ue[E]=Ue[M]=Ue[A]=Ue[I]=Ue[C]=Ue[m]=Ue[_]=Ue[g]=Ue[y]=Ue[v]=Ue[x]=Ue[b]=Ue[k]=Ue["[object Uint8ClampedArray]"]=Ue[O]=Ue[P]=!0,Ue[d]=Ue[f]=Ue[w]=!1;var Ve={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ge=parseFloat,qe=parseInt,We="object"==typeof e&&e&&e.Object===Object&&e,Ze="object"==typeof self&&self&&self.Object===Object&&self,He=We||Ze||Function("return this")(),$e=t&&!t.nodeType&&t,Xe=$e&&"object"==typeof r&&r&&!r.nodeType&&r,Ye=Xe&&Xe.exports===$e,Ke=Ye&&We.process,Je=function(){try{var e=Xe&&Xe.require&&Xe.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 Lt(e,t){for(var n=e.length;n--&&bt(t,e[n],0)>-1;);return n}function zt(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Bt=Mt({"À":"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=Mt({"&":"&","<":"<",">":">",'"':""","'":"'"});function jt(e){return"\\"+Ve[e]}function Nt(e){return ze.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?He:Yt.defaults(He.Object(),t,Yt.pick(He,Fe))).Array,i=t.Date,X=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,Te=xe.hasOwnProperty,Se=0,Ee=(n=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",Me=xe.toString,Ae=we.call(pe),Ie=He._,Ce=me("^"+we.call(Te).replace(Z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ke=Ye?t.Buffer:void 0,Oe=t.Symbol,De=t.Uint8Array,ze=ke?ke.allocUnsafe:void 0,Ve=Vt(pe.getPrototypeOf,pe),We=pe.create,Ze=xe.propertyIsEnumerable,$e=ye.splice,Xe=Oe?Oe.isConcatSpreadable:void 0,Ke=Oe?Oe.iterator:void 0,Je=Oe?Oe.toStringTag:void 0,yt=function(){try{var e=eo(pe,"defineProperty");return e({},"",{}),e}catch(e){}}(),Mt=t.clearTimeout!==He.clearTimeout&&t.clearTimeout,Kt=i&&i.now!==He.Date.now&&i.now,Jt=t.setTimeout!==He.setTimeout&&t.setTimeout,Qt=fe.ceil,en=fe.floor,tn=pe.getOwnPropertySymbols,nn=ke?ke.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=Io(fn),wn=Io(pn),Tn=Io(mn),Sn=Io(_n),En=Io(gn),Mn=Oe?Oe.prototype:void 0,An=Mn?Mn.valueOf:void 0,In=Mn?Mn.toString:void 0;function Cn(e){if(Wa(e)&&!Da(e)&&!(e instanceof Rn)){if(e instanceof Pn)return e;if(Te.call(e,"__wrapped__"))return Co(e)}return new Pn(e)}var kn=function(){function e(){}return function(t){if(!qa(t))return{};if(We)return We(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function On(){}function Pn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function Rn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Dn(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=Da(e);if(w){if(a=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&Te.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!s)return yi(e,a)}else{var R=ro(e),D=R==f||R==p;if(Fa(e))return di(e,s);if(R==g||R==l||D&&!i){if(a=u||D?{}: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,Hn(a,e))}else{if(!Ue[R])return i?e:{};a=function(e,t,n){var r=e.constructor;switch(t){case T:return fi(e);case c:case h:return new r(+e);case S:return function(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case E:case M:case A:case I:case C:case k:case"[object Uint8ClampedArray]":case O:case P: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,An?pe(An.call(i)):{}}var i}(e,R,s)}}o||(o=new Fn);var L=o.get(e);if(L)return L;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 z=w?void 0:(d?u?Hi:Zi:u?ws:bs)(e);return st(z||e,(function(r,i){z&&(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,Ot(n))),r?(o=dt,a=!1):t.length>=200&&(o=Rt,a=!1,t=new Bn(t));e:for(;++i-1},Ln.prototype.set=function(e,t){var n=this.__data__,r=Wn(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},zn.prototype.clear=function(){this.size=0,this.__data__={hash:new Dn,map:new(pn||Ln),string:new Dn}},zn.prototype.delete=function(e){var t=Ji(this,e).delete(e);return this.size-=t?1:0,t},zn.prototype.get=function(e){return Ji(this,e).get(e)},zn.prototype.has=function(e){return Ji(this,e).has(e)},zn.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 Ln,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 Ln){var r=n.__data__;if(!pn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new zn(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=Ti(),lr=Ti(!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&&Te.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,Ot(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 Dr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)s!==e&&$e.call(s,l,1),$e.call(e,l,1);return e}function zr(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)?$e.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,Hs),e+"")}function Nr(e){return Nn(ks(e))}function Ur(e,t){var n=ks(e);return Eo(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=Rt,l=new Bn}else l=t?[]:s;e:for(;++r=r?e:Zr(e,t,n)}var hi=Mt||function(e){return He.clearTimeout(e)};function di(e,t){if(t)return e.slice();var n=e.length,r=ze?ze(n):new e.constructor(n);return e.copy(r),r}function fi(e){var t=new e.constructor(e.byteLength);return new De(t).set(new De(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 Ii(e){return Wi((function(t){var n=t.length,r=n,i=Pn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new ge(o);if(i&&!s&&"wrapper"==Xi(a))var s=new Pn([],!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 So(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 Eo(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,Xo(e,n)}));function na(e){var t=Cn(e);return t.__chain__=!0,t}function ra(e,t){return t(e)}var ia=Wi((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,i=function(t){return Xn(t,e)};return!(t>1||this.__actions__.length)&&r instanceof Rn&&so(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ra,args:[i],thisArg:void 0}),new Pn(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){Te.call(e,n)?++e[n]:$n(e,n,1)}));var aa=Ai(Ro),sa=Ai(Do);function la(e,t){return(Da(e)?st:tr)(e,Ki(t,3))}function ua(e,t){return(Da(e)?lt:nr)(e,Ki(t,3))}var ca=xi((function(e,t,n){Te.call(e,n)?e[n].push(t):$n(e,n,[t])}));var ha=jr((function(e,t,n){var i=-1,o="function"==typeof t,a=za(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){$n(e,n,t)}));function fa(e,t){return(Da(e)?ft:Ir)(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]]),Rr(e,ar(t,1),[])})),_a=Kt||function(){return He.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)})),Ta=jr((function(e,t,n){return Qn(e,as(t)||0,n)}));function Sa(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(Sa.Cache||zn),n}function Ea(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)}}Sa.Cache=zn;var Ma=ui((function(e,t){var n=(t=1==t.length&&Da(t[0])?ft(t[0],Ot(Ki())):ft(ar(t,1),Ot(Ki()))).length;return jr((function(r){for(var i=-1,o=ln(r.length,n);++i=t})),Ra=xr(function(){return arguments}())?xr:function(e){return Wa(e)&&Te.call(e,"callee")&&!Ze.call(e,"callee")},Da=r.isArray,La=Qe?Ot(Qe):function(e){return Wa(e)&&pr(e)==T};function za(e){return null!=e&&Ga(e.length)&&!Ua(e)}function Ba(e){return Wa(e)&&za(e)}var Fa=nn||al,ja=et?Ot(et):function(e){return Wa(e)&&pr(e)==h};function Na(e){if(!Wa(e))return!1;var t=pr(e);return t==d||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!$a(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 Wa(e){return null!=e&&"object"==typeof e}var Za=tt?Ot(tt):function(e){return Wa(e)&&ro(e)==m};function Ha(e){return"number"==typeof e||Wa(e)&&pr(e)==_}function $a(e){if(!Wa(e)||pr(e)!=g)return!1;var t=Ve(e);if(null===t)return!0;var n=Te.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&we.call(n)==Ae}var Xa=nt?Ot(nt):function(e){return Wa(e)&&pr(e)==y};var Ya=rt?Ot(rt):function(e){return Wa(e)&&ro(e)==v};function Ka(e){return"string"==typeof e||!Da(e)&&Wa(e)&&pr(e)==x}function Ja(e){return"symbol"==typeof e||Wa(e)&&pr(e)==b}var Qa=it?Ot(it):function(e){return Wa(e)&&Ga(e.length)&&!!Ne[pr(e)]};var es=Li(Ar),ts=Li((function(e,t){return e<=t}));function ns(e){if(!e)return[];if(za(e))return Ka(e)?Ht(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:ks)(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=kt(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)||za(t))vi(t,bs(t),e);else for(var n in t)Te.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=Wi(Xn);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,Hi(e),n),r&&(n=Kn(n,7,Gi));for(var i=t.length;i--;)ei(n,t[i]);return n}));var Ms=Wi((function(e,t){return null==e?{}:function(e,t){return Dr(e,t,(function(t,n){return gs(e,n)}))}(e,t)}));function As(e,t){if(null==e)return{};var n=ft(Hi(e),(function(e){return[e]}));return t=Ki(t),Dr(e,n,(function(e,n){return t(e,n[0])}))}var Is=ji(bs),Cs=ji(ws);function ks(e){return null==e?[]:Pt(e,bs(e))}var Os=Ei((function(e,t,n){return t=t.toLowerCase(),e+(n?Ps(t):t)}));function Ps(e){return Ns(ls(e).toLowerCase())}function Rs(e){return(e=ls(e))&&e.replace(ue,Bt).replace(Re,"")}var Ds=Ei((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ls=Ei((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),zs=Si("toLowerCase");var Bs=Ei((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Fs=Ei((function(e,t,n){return e+(n?" ":"")+Ns(t)}));var js=Ei((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Ns=Si("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(Le)||[]}(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 X(e)}})),Gs=Wi((function(e,t){return st(t,(function(t){t=Ao(t),$n(e,t,va(e[t],e))})),e}));function qs(e){return function(){return e}}var Ws=Ii(),Zs=Ii(!0);function Hs(e){return e}function $s(e){return Sr("function"==typeof e?e:Kn(e,1))}var Xs=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=Pi(ft),el=Pi(ut),tl=Pi(gt);function nl(e){return uo(e)?Et(Ao(e)):function(e){return function(t){return dr(t,e)}}(e)}var rl=Di(),il=Di(!0);function ol(){return[]}function al(){return!1}var sl=Oi((function(e,t){return e+t}),0),ll=Bi("ceil"),ul=Oi((function(e,t){return e/t}),1),cl=Bi("floor");var hl,dl=Oi((function(e,t){return e*t}),1),fl=Bi("round"),pl=Oi((function(e,t){return e-t}),0);return Cn.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)}},Cn.ary=ga,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 Da(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&&!Xa(t))&&!(t=Jr(t))&&Nt(e)?ci(Ht(e),0,n):e.split(t,n):[]},Cn.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)}))},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 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})},Cn.thru=ra,Cn.toArray=ns,Cn.toPairs=Is,Cn.toPairsIn=Cs,Cn.toPath=function(e){return Da(e)?ft(e,Ao):Ja(e)?[e]:yi(Mo(ls(e)))},Cn.toPlainObject=ss,Cn.transform=function(e,t,n){var r=Da(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)?kn(Ve(e)):{}}return(i?st:ur)(e,(function(e,r,i){return t(n,e,r,i)})),n},Cn.unary=function(e){return ga(e,1)},Cn.union=Wo,Cn.unionBy=Zo,Cn.unionWith=Ho,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=$o,Cn.unzipWith=Xo,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=ks,Cn.valuesIn=function(e){return null==e?[]:Pt(e,ws(e))},Cn.without=Yo,Cn.words=Us,Cn.wrap=function(e,t){return Aa(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=Is,Cn.entriesIn=Cs,Cn.extend=cs,Cn.extendWith=hs,Ks(Cn,Cn),Cn.add=sl,Cn.attempt=Vs,Cn.camelCase=Os,Cn.capitalize=Ps,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=Rs,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=ka,Cn.escape=function(e){return(e=ls(e))&&j.test(e)?e.replace(B,Ft):e},Cn.escapeRegExp=function(e){return(e=ls(e))&&H.test(e)?e.replace(Z,"\\$&"):e},Cn.every=function(e,t,n){var r=Da(e)?ut:rr;return n&&lo(e,t,n)&&(t=void 0),r(e,Ki(t,3))},Cn.find=aa,Cn.findIndex=Ro,Cn.findKey=function(e,t){return vt(e,Ki(t,3),ur)},Cn.findLast=sa,Cn.findLastIndex=Do,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=_s,Cn.gt=Oa,Cn.gte=Pa,Cn.has=function(e,t){return null!=e&&io(e,t,_r)},Cn.hasIn=gs,Cn.head=zo,Cn.identity=Hs,Cn.includes=function(e,t,n,r){e=za(e)?e:ks(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 Wa(e)&&ro(e)==w},Cn.isWeakSet=function(e){return Wa(e)&&"[object WeakSet]"==pr(e)},Cn.join=function(e,t){return null==e?"":on.call(e,t)},Cn.kebabCase=Ds,Cn.last=No,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,Tt,i,!0)},Cn.lowerCase=Ls,Cn.lowerFirst=zs,Cn.lt=es,Cn.lte=ts,Cn.max=function(e){return e&&e.length?ir(e,Hs,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 St(e,Hs)},Cn.meanBy=function(e,t){return St(e,Ki(t,2))},Cn.min=function(e){return e&&e.length?ir(e,Hs,Ar):void 0},Cn.minBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),Ar):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?Pr(e,is(t)):void 0},Cn.noConflict=function(){return He._===this&&(He._=Ie),this},Cn.noop=Js,Cn.now=_a,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 Ri(en(i),n)+e+Ri(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=Da(e)?mt:At,i=arguments.length<3;return r(e,Ki(t,4),n,i,tr)},Cn.reduceRight=function(e,t,n){var r=Da(e)?_t:At,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),Xa(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(z,Xt):e},Cn.uniqueId=function(e){var t=++Se;return ls(e)+t},Cn.upperCase=js,Cn.upperFirst=Ns,Cn.each=la,Cn.eachRight=ua,Cn.first=zo,Ks(Cn,(hl={},ur(Cn,(function(e,t){Te.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){Rn.prototype[e]=function(n){n=void 0===n?1:sn(is(n),0);var r=this.__filtered__&&!t?new Rn(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},Rn.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;Rn.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":"");Rn.prototype[e]=function(){return this[n](1).value()[0]}})),st(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Rn.prototype[e]=function(){return this.__filtered__?new Rn(this):this[n](1)}})),Rn.prototype.compact=function(){return this.filter(Hs)},Rn.prototype.find=function(e){return this.filter(e).head()},Rn.prototype.findLast=function(e){return this.reverse().find(e)},Rn.prototype.invokeMap=jr((function(e,t){return"function"==typeof e?new Rn(this):this.map((function(n){return vr(n,e,t)}))})),Rn.prototype.reject=function(e){return this.filter(Ea(Ki(e)))},Rn.prototype.slice=function(e,t){e=is(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Rn(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)},Rn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Rn.prototype.toArray=function(){return this.take(4294967295)},ur(Rn.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 Rn,l=a[0],u=s||Da(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 Rn(this);var m=e.apply(t,a);return m.__actions__.push({func:ra,args:[c],thisArg:void 0}),new Pn(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(Da(i)?i:[],e)}return this[n]((function(n){return t.apply(Da(n)?n:[],e)}))}})),ur(Rn.prototype,(function(e,t){var n=Cn[t];if(n){var r=n.name+"";Te.call(xn,r)||(xn[r]=[]),xn[r].push({name:t,func:n})}})),xn[Ci(void 0,2).name]=[{name:"wrapper",func:void 0}],Rn.prototype.clone=function(){var e=new Rn(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},Rn.prototype.reverse=function(){if(this.__filtered__){var e=new Rn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Rn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Da(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 On;){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 Rn){var t=e;return this.__actions__.length&&(t=new Rn(this)),(t=t.reverse()).__actions__.push({func:ra,args:[qo],thisArg:void 0}),new Pn(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}();He._=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,_=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,T=void 0!==w&&w,S=e.closeOnDocumentClick,E=void 0===S||S,M=e.repositionOnResize,A=void 0===M||M,I=e.closeOnEscape,C=void 0===I||I,k=e.on,O=void 0===k?["click"]:k,P=e.contentStyle,R=void 0===P?{}:P,D=e.arrowStyle,L=void 0===D?{}:D,z=e.overlayStyle,B=void 0===z?{}:z,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,W=void 0!==q&&q,Z=e.arrow,H=void 0===Z||Z,$=e.offsetX,X=void 0===$?0:$,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,Me(),Te(),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&&W&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},we=function(){fe&&W&&(document.getElementsByTagName("body")[0].style.overflow="auto")},Te=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 Se,Ee,Me=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,H,{offsetX:X,offsetY:K},re);if(ue.current.style.top=i.top+window.scrollY+"px",ue.current.style.left=i.left+window.scrollX+"px",H&&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=L.top)||void 0===e?void 0:e.toString())||i.arrowTop,ce.current.style.left=(null===(t=L.left)||void 0===t?void 0:t.toString())||i.arrowLeft}};Se=_e,void 0===(Ee=C)&&(Ee=!0),Object(r.useEffect)((function(){if(Ee){var e=function(e){"Escape"===e.key&&Se(e)};return document.addEventListener("keyup",e),function(){Ee&&document.removeEventListener("keyup",e)}}}),[Se,Ee]),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])}(Me,A),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,E&&!T);var Ae,Ie=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,R,{pointerEvents:"auto"}),ref:ue,onClick:function(e){e.stopPropagation()}},!G&&O.indexOf("hover")>=0&&(t.onMouseEnter=ye,t.onMouseLeave=xe),t),{key:"C",role:fe?"dialog":"tooltip",id:de.current}),H&&!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"},L)},i.a.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),ie&&"function"==typeof ie?ie(_e,ae):ie);var e,t},Ce=!(O.indexOf("hover")>=0),ke=fe?u.overlay.modal:u.overlay.tooltip,Oe=[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({},ke,B,{pointerEvents:E&&T||fe?"auto":"none"}),onClick:E&&T?_e:void 0,tabIndex:-1},fe&&Ie()),!fe&&Ie()];return i.a.createElement(i.a.Fragment,null,function(){for(var e={key:"T",ref:le,"aria-describedby":de.current},t=Array.isArray(O)?O:[O],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 zt}));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 A(e){return e instanceof T(e).HTMLElement}function I(e){return e instanceof T(e).Element}function C(e){if("undefined"==typeof ShadowRoot)return!1;return e instanceof T(e).ShadowRoot||e instanceof ShadowRoot}function k(e){const{overflow:t,overflowX:n,overflowY:r}=S(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function O(){return!/^((?!chrome|android).)*safari/i.test(M())}Math.min,Math.max;const P=Math.round;function R(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&&A(e)&&(l=e.offsetWidth>0&&P(s.width)/e.offsetWidth||1,u=e.offsetHeight>0&&P(s.height)/e.offsetHeight||1);const c=I(e)?T(e):window,h=!O()&&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 D(e){return(t=e,(t instanceof T(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function L(e){return"html"===E(e)?e:e.assignedSlot||e.parentNode||(C(e)?e.host:null)||D(e)}function z(e,t){var n;void 0===t&&(t=[]);const r=function e(t){const n=L(t);return["html","body","#document"].includes(E(n))?t.ownerDocument.body:A(n)&&k(n)?n:e(n)}(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),o=T(r),a=i?[o].concat(o.visualViewport||[],k(r)?r:[]):r,s=t.concat(a);return i?s:s.concat(z(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 W(e)?window.pageYOffset:e.scrollTop}function H(e,t){W(e)?window.scrollTo(0,t):e.scrollTop=t}function $(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function X(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=$(s+=a,i,o,n);H(e,t),sn.bottom?H(e,Math.min(t.offsetTop+t.clientHeight-e.offsetHeight+i,e.scrollHeight)):r.top-i=p)return{placement:"bottom",maxHeight:t};if(S>=p&&!a)return o&&X(l,E,160),{placement:"bottom",maxHeight:t};if(!a&&S>=r||a&&w>=r)return o&&X(l,E,160),{placement:"bottom",maxHeight:a?w-v:S-v};if("auto"===i||a){var A=t,I=a?b:T;return I>=r&&(A=Math.min(I-v-s,t)),{placement:"top",maxHeight:A}}if("bottom"===i)return o&&H(l,E),{placement:"bottom",maxHeight:t};break;case"top":if(b>=p)return{placement:"top",maxHeight:t};if(T>=p&&!a)return o&&X(l,M,160),{placement:"top",maxHeight:t};if(!a&&T>=r||a&&b>=r){var C=t;return(!a&&T>=r||a&&b>=r)&&(C=a?b-x:T-x),o&&X(l,M,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],_=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"}))},Te=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}})},Se=Te,Ee=Te,Me=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)}})))),Ae=function(e){var t=e.delay,n=e.offset;return Object(x.c)("span",{css:Object(x.b)({animation:"".concat(Me," 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"},"","")})},Ie=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,{"aria-disabled":n||void 0}),t)},Ce=["data"],ke=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))},Oe=["innerRef","isDisabled","isHidden","inputClassName"],Pe={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},Re={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"},Pe)},De=function(e){return o({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Pe)},Le=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",n,t)};var ze={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:Ie,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:ke,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,Oe);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:De(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)(Ae,{delay:0,offset:n}),Object(x.c)(Ae,{delay:160,offset:!0}),Object(x.c)(Ae,{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 T=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?[...I(e)?z(e):[],...z(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}),I(e)&&!s&&d.observe(e),d.observe(t)}let f=s?R(e):null;return s&&function t(){const r=R(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(){T()}),[T]);var S=Object(c.useCallback)((function(e){u.current=e,T()}),[T]);if(!t&&"fixed"!==s||!y)return null;var E=Object(x.c)("div",d({ref:S},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)(E,t):E)},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:Le,MultiValueLabel:Le,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=e.isAppleDevice,c=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(c(a,n),".");if("menu"===t&&u){var h=s?" disabled":"",d="".concat(l?" selected":"").concat(h);return"".concat(o).concat(d,", ").concat(c(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=e.isAppleDevice,d=l.ariaLiveMessages,f=l.getOptionLabel,p=l.inputValue,m=l.isMulti,_=l.isOptionDisabled,g=l.isSearchable,y=l.menuIsOpen,v=l.options,b=l.screenReaderStatus,w=l.tabSelectsValue,T=l.isLoading,S=l["aria-label"],E=l["aria-live"],M=Object(c.useMemo)((function(){return o(o({},Ue),d||{})}),[d]),A=Object(c.useMemo)((function(){var e,n="";if(t&&M.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?f(c):"",d=i||l||void 0,p=d?d.map(f):[],m=o({isDisabled:c&&_(c,s),label:h,labels:p},t);n=M.onChange(m)}return n}),[t,M,_,s,f]),I=Object(c.useMemo)((function(){var e="",t=n||r,o=!!(n&&s&&s.includes(n));if(t&&M.onFocus){var a={focused:t,label:f(t),isDisabled:_(t,s),isSelected:o,options:i,context:t===n?"menu":"value",selectValue:s,isAppleDevice:h};e=M.onFocus(a)}return e}),[n,r,f,_,M,i,s,h]),C=Object(c.useMemo)((function(){var e="";if(y&&v.length&&!T&&M.onFilter){var t=b({count:i.length});e=M.onFilter({inputValue:p,resultsMessage:t})}return e}),[i,p,y,M,v,b,T]),k="initial-input-focus"===(null==t?void 0:t.action),O=Object(c.useMemo)((function(){var e="";if(M.guidance){var t=r?"value":y?"menu":"input";e=M.guidance({"aria-label":S,context:t,isDisabled:n&&_(n,s),isMulti:m,isSearchable:g,tabSelectsValue:w,isInitialFocus:k})}return e}),[S,n,r,m,_,g,y,M,s,w,k]),P=Object(x.c)(c.Fragment,null,Object(x.c)("span",{id:"aria-selection"},A),Object(x.c)("span",{id:"aria-focused"},I),Object(x.c)("span",{id:"aria-results"},C),Object(x.c)("span",{id:"aria-guidance"},O));return Object(x.c)(c.Fragment,null,Object(x.c)(Ne,{id:u},k&&P),Object(x.c)(Ne,{"aria-live":E,"aria-atomic":"false","aria-relevant":"additions text",role:"log"},a&&!k&&P))},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"),We={},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.cancelable&&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(){}})};function mt(e){var t;return"undefined"!=typeof window&&null!=window.navigator&&e.test((null===(t=window.navigator.userAgentData)||void 0===t?void 0:t.platform)||window.navigator.platform)}function _t(){return mt(/^Mac/i)}function gt(){return mt(/^iPhone/i)||mt(/^iPad/i)||_t()&&navigator.maxTouchPoints>1}var yt={clearIndicator:Ee,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:Se,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)":""},Re),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 vt,xt={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}},bt={"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"},vt),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=Xe(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 wt(e,t,n,r){return{type:"option",data:t,isDisabled:kt(e,t,n),isSelected:Ot(e,t,n),label:It(e,t),value:Ct(e,t),index:r}}function Tt(e,t){return e.options.map((function(n,r){if("options"in n){var i=n.options.map((function(n,r){return wt(e,n,t,r)})).filter((function(t){return Mt(e,t)}));return i.length>0?{type:"group",data:n,options:i,index:r}:void 0}var o=wt(e,n,t,r);return Mt(e,o)?o:void 0})).filter(ne)}function St(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 Et(e,t){return e.reduce((function(e,n){return"group"===n.type?e.push.apply(e,v(n.options.map((function(e){return{data:e.data,id:"".concat(t,"-").concat(n.index,"-").concat(e.index)}})))):e.push({data:n.data,id:"".concat(t,"-").concat(n.index)}),e}),[])}function Mt(e,t){var n=e.inputValue,r=void 0===n?"":n,i=t.data,o=t.isSelected,a=t.label,s=t.value;return(!Rt(e)||!o)&&Pt(e,{label:a,value:s,data:i},r)}var At=function(e,t){var n;return(null===(n=e.find((function(e){return e.data===t})))||void 0===n?void 0:n.id)||null},It=function(e,t){return e.getOptionLabel(t)},Ct=function(e,t){return e.getOptionValue(t)};function kt(e,t,n){return"function"==typeof e.isOptionDisabled&&e.isOptionDisabled(t,n)}function Ot(e,t,n){if(n.indexOf(t)>-1)return!0;if("function"==typeof e.isOptionSelected)return e.isOptionSelected(t,n);var r=Ct(e,t);return n.some((function(t){return Ct(e,t)===r}))}function Pt(e,t,n){return!e.filterOption||e.filterOption(t,n)}var Rt=function(e){var t=e.hideSelectedOptions,n=e.isMulti;return void 0===t?n:t},Dt=1,Lt=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,focusedOptionId:null,focusableOptionsWithIds:[],focusedValue:null,inputIsHidden:!1,isFocused:!1,selectValue:[],clearFocusValueOnUpdate:!1,prevWasFocused:!1,inputIsHiddenAfterUpdate:void 0,prevProps:void 0,instancePrefix:""},t.blockOptionHover=!1,t.isComposing=!1,t.commonProps=void 0,t.initialTouchX=0,t.initialTouchY=0,t.openAfterFocus=!1,t.scrollToFocusedOptionOnUpdate=!1,t.userIsDragging=void 0,t.isAppleDevice=_t()||gt(),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.getFocusedOptionId=function(e){return At(t.state.focusableOptionsWithIds,e)},t.getFocusableOptionsWithIds=function(){return Et(Tt(t.props,t.state.selectValue),t.getElementId("option"))},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){if(!t.blockOptionHover&&t.state.focusedOption!==e){var n=t.getFocusableOptions().indexOf(e);t.setState({focusedOption:e,focusedOptionId:n>-1?t.getFocusedOptionId(e):null})}},t.shouldHideSelectedOptions=function(){return Rt(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.state.instancePrefix="react-select-"+(t.props.instanceId||++Dt),t.state.selectValue=V(e.value),e.menuIsOpen&&t.state.selectValue.length){var n=t.getFocusableOptionsWithIds(),r=t.buildFocusableOptions(),s=r.indexOf(t.state.selectValue[0]);t.state.focusableOptionsWithIds=n,t.state.focusedOption=r[s],t.state.focusedOptionId=At(n,r[s])}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=t.instancePrefix,c=e.options,h=e.value,d=e.menuIsOpen,f=e.inputValue,p=e.isMulti,m=V(h),_={};if(n&&(h!==n.value||c!==n.options||d!==n.menuIsOpen||f!==n.inputValue)){var g=d?function(e,t){return St(Tt(e,t))}(e,m):[],y=d?Et(Tt(e,m),"".concat(u,"-option")):[],v=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);_={selectValue:m,focusedOption:x,focusedOptionId:At(y,x),focusableOptionsWithIds:y,focusedValue:v,clearFocusValueOnUpdate:!1}}var b=null!=i&&e!==n?{inputIsHidden:i,inputIsHiddenAfterUpdate:void 0}:{},w=a,T=s&&l;return s&&!T&&(w={value:re(p,m,m[0]||null),options:m,action:"initial-input-focus"},T=!l),"initial-input-focus"===(null==a?void 0:a.action)&&(w=null),o(o(o({},_),b),{},{prevProps:e,ariaSelection:w,prevWasFocused:T})}}],(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],focusedOptionId:this.getFocusedOptionId(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,focusedOptionId:this.getFocusedOptionId(r[i])})}}},{key:"getTheme",value:function(){return this.props.theme?"function"==typeof this.props.theme?this.props.theme(xt):o(o({},xt),this.props.theme):xt}},{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 kt(this.props,e,t)}},{key:"isOptionSelected",value:function(e,t){return Ot(this.props,e,t)}},{key:"filterOption",value:function(e,t){return Pt(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","aria-activedescendant":this.isAppleDevice?void 0:this.state.focusedOptionId||""},l&&{"aria-controls":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,T=p.menuPosition,S=p.menuPortalTarget,E=p.menuShouldBlockScroll,M=p.menuShouldScrollIntoView,A=p.noOptionsMessage,I=p.onMenuScrollToTop,C=p.onMenuScrollToBottom;if(!b)return null;var k,O=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,role:"option","aria-selected":e.isAppleDevice?void 0:a};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())k=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 O(e,"".concat(a,"-").concat(e.index))})))}if("option"===t.type)return O(t,"".concat(t.index))}));else if(g){var P=y({inputValue:_});if(null===P)return null;k=c.createElement(s,h,P)}else{var R=A({inputValue:_});if(null===R)return null;k=c.createElement(l,h,R)}var D={minMenuHeight:v,maxMenuHeight:x,menuPlacement:w,menuPosition:T,menuShouldScrollIntoView:M},L=c.createElement(ce,d({},h,D),(function(t){var n=t.ref,r=t.placerProps,a=r.placement,s=r.maxHeight;return c.createElement(i,d({},h,D,{innerRef:n,innerProps:{onMouseDown:e.onMenuMouseDown,onMouseMove:e.onMenuMouseMove},isLoading:g,placement:a}),c.createElement(dt,{captureEnabled:m,onTopArrive:I,onBottomArrive:C,lockEnabled:E},(function(t){return c.createElement(o,d({},h,{innerRef:function(n){e.getMenuListRef(n),t(n)},innerProps:{role:"listbox","aria-multiselectable":h.isMulti,id:e.getElementId("listbox")},isLoading:g,maxHeight:s,focusedOption:f}),k)})))}));return S||"fixed"===T?c.createElement(a,d({},h,{appendTo:S,controlElement:this.controlRef,menuPlacement:w,menuPosition:T}),L):L}},{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,isAppleDevice:this.isAppleDevice}))}},{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);Lt.defaultProps=bt;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 zt=Object(c.forwardRef)((function(e,t){var n,r,i,a,s,f,p,m,_,g,y,v,x,b,w,T,S,E,M,A,I,C,k,O,P,R,D,L,z,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),T=l(Object(c.useState)(void 0!==m?m:i),2),S=T[0],E=T[1],M=l(Object(c.useState)(void 0!==_?_:s),2),A=M[0],I=M[1],C=l(Object(c.useState)(void 0!==b?b:p),2),k=C[0],O=C[1],P=Object(c.useCallback)((function(e,t){"function"==typeof g&&g(e,t),O(e)}),[g]),R=Object(c.useCallback)((function(e,t){var n;"function"==typeof y&&(n=y(e,t)),E(void 0!==n?n:e)}),[y]),D=Object(c.useCallback)((function(){"function"==typeof x&&x(),I(!0)}),[x]),L=Object(c.useCallback)((function(){"function"==typeof v&&v(),I(!1)}),[v]),z=void 0!==m?m:S,B=void 0!==_?_:A,F=void 0!==b?b:k,o(o({},w),{},{inputValue:z,menuIsOpen:B,onChange:P,onInputChange:R,onMenuClose:L,onMenuOpen:D,value:F}));return c.createElement(Lt,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)||_,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,T]=y&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[a,a],S={isOnline:()=>b,isVisible:()=>{const e=v&&document.visibilityState;return u(e)||"hidden"!==e}},E={initFocus:e=>(v&&document.addEventListener("visibilitychange",e),w("focus",e),()=>{v&&document.removeEventListener("visibilitychange",e),T("focus",e)}),initReconnect:e=>{const t=()=>{b=!0,e()},n=()=>{b=!1};return w("online",t),w("offline",n),()=>{T("online",t),T("offline",n)}}},M=!i.a.useId,A=!y||"Deno"in window,I=e=>y&&void 0!==window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1),C=A?r.useEffect:r.useLayoutEffect,k="undefined"!=typeof navigator&&navigator.connection,O=!A&&k&&(["slow-2g","2g"].includes(k.effectiveType)||k.saveData),P=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 R=0;const D=()=>++R;var L=3,z=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=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(p))}return p(n);async function p(n){const[i]=P(n);if(!i)return;const[h,p]=x(t,i),[_,g,y,v]=m.get(t),b=()=>{const e=_[i];return(c(o.revalidate)?o.revalidate(h().data,n):!1!==o.revalidate)&&(delete y[i],delete v[i],e&&e[0])?e[0](2).then(()=>h().data):h().data};if(e.length<3)return b();let w,T=r;const S=D();g[i]=[S,0];const E=!u(d),M=h(),A=M.data,I=M._c,C=u(I)?A:I;if(E&&(d=c(d)?d(C,A):d,p({data:d,_c:C})),c(T))try{T=T(C)}catch(e){w=e}if(T&&c(T.then)){if(T=await T.catch(e=>{w=e}),S!==g[i][0]){if(w)throw w;return T}w&&E&&(e=>"function"==typeof l?l(e):!1!==l)(w)&&(a=!0,p({data:C,_c:s}))}if(a&&!w)if(c(a)){const e=a(T,C);p({data:e,error:s,_c:s})}else p({data:T,error:s,_c:s});if(g[i][1]=D(),Promise.resolve(b()).then(()=>{p({_c:s})}),!w)return T;if(f)throw w}}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(E,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]),!A)){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:O?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:O?5e3:3e3,compare:(e,t)=>p(e)==p(t),isPaused:()=>!1,cache:V,mutate:G,fallback:{}},S),W=(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)({}),H=y&&window.__SWR_DEVTOOLS_USE__,$=H?window.__SWR_DEVTOOLS_USE__:[],X=e=>c(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],Y=$.concat(e=>(t,n,r)=>e(t,n&&((...e)=>{const[r]=P(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));H&&(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:W(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]),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:_,refreshWhenHidden:g,refreshWhenOffline:y,keepPreviousData:v}=n,[b,w,T,S]=m.get(i),[E,k]=P(e),O=Object(r.useRef)(!1),R=Object(r.useRef)(!1),N=Object(r.useRef)(E),U=Object(r.useRef)(t),V=Object(r.useRef)(n),G=()=>V.current,q=()=>G().isVisible()&&G().isOnline(),[W,Z,H,$]=x(i,E),X=Object(r.useRef)({}).current,Y=u(d)?n.fallback[E]:d,Q=(e,t)=>{for(const n in X){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=!!E&&!!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=W(),i=$(),o=n(r),a=r===i?o:n(i);let s=o;return[()=>{const e=n(W());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,E]),te=Object(o.useSyncExternalStore)(Object(r.useCallback)(e=>H(E,(t,n)=>{Q(n,t)||e()}),[i,E]),ee[0],ee[1]),ne=!O.current,re=b[E]&&b[E].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=!!(E&&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(!E||!t||R.current||G().isPaused())return!1;let r,i,o=!0;const l=e||{},h=!T[E]||!l.dedupe,d=()=>M?!R.current&&E===N.current&&O.current:E===N.current,f={isValidating:!1,isLoading:!1},p=()=>{Z(f)},m=()=>{const e=T[E];e&&e[1]===i&&delete T[E]},_={isValidating:!0};u(W().data)&&(_.isLoading=!0);try{if(h&&(Z(_),n.loadingTimeout&&u(W().data)&&setTimeout(()=>{o&&d()&&G().onLoadingSlow(E,n)},n.loadingTimeout),T[E]=[t(k),D()]),[r,i]=T[E],r=await r,h&&setTimeout(m,n.dedupingInterval),!T[E]||T[E][1]!==i)return h&&d()&&G().onDiscarded(E),!1;f.error=s;const e=w[E];if(!u(e)&&(i<=e[0]||i<=e[1]||0===e[1]))return p(),h&&d()&&G().onDiscarded(E),!1;const l=W().data;f.data=a(l,r)?l:r,h&&d()&&G().onSuccess(r,E,n)}catch(e){m();const t=G(),{shouldRetryOnError:n}=t;t.isPaused()||(f.error=e,h&&d()&&(t.onError(e,E,t),(!0===n||c(n)&&n(e))&&(G().revalidateOnFocus&&G().revalidateOnReconnect&&!q()||t.onErrorRetry(e,E,t,e=>{const t=b[E];t&&t[0]&&t[0](L,e)},{retryCount:(l.retryCount||0)+1,dedupe:!0}))))}return o=!1,p(),!0},[E,i]),pe=Object(r.useCallback)((...e)=>j(i,N.current,...e),[]);if(C(()=>{U.current=t,V.current=n,u(ie)||(se.current=ie)}),C(()=>{if(!E)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())}})(E,b,(n,r={})=>{if(n==z){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==L)return fe(r)}});return R.current=!1,N.current=E,O.current=!0,Z({_k:k}),ue&&(u(oe)||A?e():I(e)),()=>{R.current=!0,n()}},[E]),C(()=>{let e;function t(){const t=c(_)?_(W().data):_;t&&-1!==e&&(e=setTimeout(n,t))}function n(){W().error||!g&&!G().isVisible()||!y&&!G().isOnline()?t():fe(J).then(t)}return t(),()=>{e&&(clearTimeout(e),e=-1)}},[_,g,y,E]),Object(r.useDebugValue)(le),l&&u(oe)&&E){if(!M&&A)throw new Error("Fallback data is required when using suspense in SSR.");U.current=t,V.current=n,R.current=!1;const e=S[E];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 X.data=!0,le},get error(){return X.error=!0,ae},get isValidating(){return X.isValidating=!0,he},get isLoading(){return X.isLoading=!0,de}}},function(...e){const t=h(q,Object(r.useContext)(Z)),[n,i,o]=X(e),a=W(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 @@ -73,4 +73,4 @@ t.read=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= * * 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);var i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=r.useState,a=r.useEffect,s=r.useLayoutEffect,l=r.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=o({inst:{value:n,getSnapshot:t}}),i=r[0].inst,c=r[1];return s((function(){i.value=n,i.getSnapshot=t,u(i)&&c({inst:i})}),[e,n,t]),a((function(){return u(i)&&c({inst:i}),e((function(){u(i)&&c({inst:i})}))}),[e]),l(n),n};t.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:c},function(e,t,n){e.exports=function(){"use strict";function e(e,r,i,o,a){!function e(n,r,i,o,a){for(;o>i;){if(o-i>600){var 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(n,r,Math.max(i,Math.floor(r-l*c/s+h)),Math.min(o,Math.floor(r+(s-l)*c/s+h)),a)}var d=n[r],f=i,p=o;for(t(n,i,r),a(n[o],d)>0&&t(n,i,o);f0;)p--}0===a(n[i],d)?t(n,i,p):t(n,++p,o),p<=r&&(i=p+1),r<=p&&(o=p-1)}}(e,r,i||0,o||e.length-1,a||n)}function t(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function n(e,t){return et?1:0}var r=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function i(e,t,n){if(!n)return t.indexOf(e);for(var r=0;r=e.minX&&t.maxY>=e.minY}function p(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(t,n,r,i,o){for(var a=[n,r];a.length;)if(!((r=a.pop())-(n=a.pop())<=i)){var s=n+Math.ceil((r-n)/i/2)*i;e(t,s,n,r,o),a.push(n,s,s,r)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(e){var t=this.data,n=[];if(!f(e,t))return n;for(var r=this.toBBox,i=[];t;){for(var o=0;o=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)},r.prototype._split=function(e,t){var n=e[t],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var a=this._chooseSplitIndex(n,i,r),s=p(n.children.splice(a,n.children.length-a));s.height=n.height,s.leaf=n.leaf,o(n,this.toBBox),o(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(n,s)},r.prototype._splitRoot=function(e,t){this.data=p([e,t]),this.data.height=e.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(e,t,n){for(var r,i,o,s,l,u,h,d=1/0,f=1/0,p=t;p<=n-t;p++){var m=a(e,0,p,this.toBBox),_=a(e,p,n,this.toBBox),g=(i=m,o=_,s=Math.max(i.minX,o.minX),l=Math.max(i.minY,o.minY),u=Math.min(i.maxX,o.maxX),h=Math.min(i.maxY,o.maxY),Math.max(0,u-s)*Math.max(0,h-l)),y=c(m)+c(_);g=t;f--){var p=e.children[f];s(l,e.leaf?i(p):p),u+=h(l)}return u},r.prototype._adjustParentBBoxes=function(e,t,n){for(var r=n;r>=0;r--)s(t[r],e)},r.prototype._condense=function(e){for(var t=e.length-1,n=void 0;t>=0;t--)0===e[t].children.length?t>0?(n=e[t-1].children).splice(n.indexOf(e[t]),1):this.clear():o(e[t],this.toBBox)},r}()},function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return r}));class r{constructor(e=[],t=i){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)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 i(e,t){return et?1:0}},function(e,t,n){var r=n(94),i=n(95);e.exports=function(e,t,n,o){return t.length>0&&Array.isArray(t[0])?i(e,t,n,o):r(e,t,n,o)},e.exports.nested=i,e.exports.flat=r},function(e,t){e.exports=function(e,t,n,r){var i=e[0],o=e[1],a=!1;void 0===n&&(n=0),void 0===r&&(r=t.length);for(var s=(r-n)/2,l=0,u=s-1;lo!=f>o&&i<(d-c)*(o-h)/(f-h)+c&&(a=!a)}return a}},function(e,t){e.exports=function(e,t,n,r){var i=e[0],o=e[1],a=!1;void 0===n&&(n=0),void 0===r&&(r=t.length);for(var s=r-n,l=0,u=s-1;lo!=f>o&&i<(d-c)*(o-h)/(f-h)+c&&(a=!a)}return a}},function(e,t,n){!function(e){"use strict";const t=134217729;function n(e,t,n,r,i){let o,a,s,l,u=t[0],c=r[0],h=0,d=0;c>u==c>-u?(o=u,u=t[++h]):(o=c,c=r[++d]);let f=0;if(hu==c>-u?(s=o-((a=u+o)-u),u=t[++h]):(s=o-((a=c+o)-c),c=r[++d]),o=a,0!==s&&(i[f++]=s);hu==c>-u?(s=o-((a=o+u)-(l=a-o))+(u-l),u=t[++h]):(s=o-((a=o+c)-(l=a-o))+(c-l),c=r[++d]),o=a,0!==s&&(i[f++]=s);for(;h0!=p>0)return m;const _=Math.abs(f+p);return Math.abs(m)>=33306690738754716e-32*_?m:-function(e,r,u,c,h,d,f){let p,m,_,g,y,v,x,b,w,T,S,E,M,A,I,C,k,O;const P=e-h,R=u-h,D=r-d,L=c-d;y=(I=(b=P-(x=(v=t*P)-(v-P)))*(T=L-(w=(v=t*L)-(v-L)))-((A=P*L)-x*w-b*w-x*T))-(S=I-(k=(b=D-(x=(v=t*D)-(v-D)))*(T=R-(w=(v=t*R)-(v-R)))-((C=D*R)-x*w-b*w-x*T))),i[0]=I-(S+y)+(y-k),y=(M=A-((E=A+S)-(y=E-A))+(S-y))-(S=M-C),i[1]=M-(S+y)+(y-C),y=(O=E+S)-E,i[2]=E-(O-y)+(S-y),i[3]=O;let z=function(e,t){let n=t[0];for(let e=1;e<4;e++)n+=t[e];return n}(0,i),B=22204460492503146e-32*f;if(z>=B||-z>=B)return z;if(p=e-(P+(y=e-P))+(y-h),_=u-(R+(y=u-R))+(y-h),m=r-(D+(y=r-D))+(y-d),g=c-(L+(y=c-L))+(y-d),0===p&&0===m&&0===_&&0===g)return z;if(B=11093356479670487e-47*f+33306690738754706e-32*Math.abs(z),(z+=P*g+L*p-(D*_+R*m))>=B||-z>=B)return z;y=(I=(b=p-(x=(v=t*p)-(v-p)))*(T=L-(w=(v=t*L)-(v-L)))-((A=p*L)-x*w-b*w-x*T))-(S=I-(k=(b=m-(x=(v=t*m)-(v-m)))*(T=R-(w=(v=t*R)-(v-R)))-((C=m*R)-x*w-b*w-x*T))),l[0]=I-(S+y)+(y-k),y=(M=A-((E=A+S)-(y=E-A))+(S-y))-(S=M-C),l[1]=M-(S+y)+(y-C),y=(O=E+S)-E,l[2]=E-(O-y)+(S-y),l[3]=O;const F=n(4,i,4,l,o);y=(I=(b=P-(x=(v=t*P)-(v-P)))*(T=g-(w=(v=t*g)-(v-g)))-((A=P*g)-x*w-b*w-x*T))-(S=I-(k=(b=D-(x=(v=t*D)-(v-D)))*(T=_-(w=(v=t*_)-(v-_)))-((C=D*_)-x*w-b*w-x*T))),l[0]=I-(S+y)+(y-k),y=(M=A-((E=A+S)-(y=E-A))+(S-y))-(S=M-C),l[1]=M-(S+y)+(y-C),y=(O=E+S)-E,l[2]=E-(O-y)+(S-y),l[3]=O;const j=n(F,o,4,l,a);y=(I=(b=p-(x=(v=t*p)-(v-p)))*(T=g-(w=(v=t*g)-(v-g)))-((A=p*g)-x*w-b*w-x*T))-(S=I-(k=(b=m-(x=(v=t*m)-(v-m)))*(T=_-(w=(v=t*_)-(v-_)))-((C=m*_)-x*w-b*w-x*T))),l[0]=I-(S+y)+(y-k),y=(M=A-((E=A+S)-(y=E-A))+(S-y))-(S=M-C),l[1]=M-(S+y)+(y-C),y=(O=E+S)-E,l[2]=E-(O-y)+(S-y),l[3]=O;const N=n(j,a,4,l,s);return s[N-1]}(e,r,u,c,h,d,_)},e.orient2dfast=function(e,t,n,r,i,o){return(t-o)*(n-i)-(e-i)*(r-o)},Object.defineProperty(e,"__esModule",{value:!0})}(t)},function(e,t,n){var r=n(37),i=n(98),o=Object.hasOwnProperty,a=Object.create(null);for(var s in r)o.call(r,s)&&(a[r[s]]=s);var l=e.exports={to:{},get:{}};function u(e,t,n){return Math.min(Math.max(t,e),n)}function c(e){var t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}l.get=function(e){var t,n;switch(e.substring(0,3).toLowerCase()){case"hsl":t=l.get.hsl(e),n="hsl";break;case"hwb":t=l.get.hwb(e),n="hwb";break;default:t=l.get.rgb(e),n="rgb"}return t?{model:n,value:t}:null},l.get.rgb=function(e){if(!e)return null;var t,n,i,a=[0,0,0,1];if(t=e.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(i=t[2],t=t[1],n=0;n<3;n++){var s=2*n;a[n]=parseInt(t.slice(s,s+2),16)}i&&(a[3]=parseInt(i,16)/255)}else if(t=e.match(/^#([a-f0-9]{3,4})$/i)){for(i=(t=t[1])[3],n=0;n<3;n++)a[n]=parseInt(t[n]+t[n],16);i&&(a[3]=parseInt(i+i,16)/255)}else if(t=e.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)a[n]=parseInt(t[n+1],0);t[4]&&(t[5]?a[3]=.01*parseFloat(t[4]):a[3]=parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(t=e.match(/^(\w+)$/))?"transparent"===t[1]?[0,0,0,0]:o.call(r,t[1])?((a=r[t[1]])[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(t[n+1]));t[4]&&(t[5]?a[3]=.01*parseFloat(t[4]):a[3]=parseFloat(t[4]))}for(n=0;n<3;n++)a[n]=u(a[n],0,255);return a[3]=u(a[3],0,1),a},l.get.hsl=function(e){if(!e)return null;var t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,u(parseFloat(t[2]),0,100),u(parseFloat(t[3]),0,100),u(isNaN(n)?1:n,0,1)]}return null},l.get.hwb=function(e){if(!e)return null;var t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,u(parseFloat(t[2]),0,100),u(parseFloat(t[3]),0,100),u(isNaN(n)?1:n,0,1)]}return null},l.to.hex=function(){var e=i(arguments);return"#"+c(e[0])+c(e[1])+c(e[2])+(e[3]<1?c(Math.round(255*e[3])):"")},l.to.rgb=function(){var e=i(arguments);return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},l.to.rgb.percent=function(){var e=i(arguments),t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+n+"%, "+r+"%)":"rgba("+t+"%, "+n+"%, "+r+"%, "+e[3]+")"},l.to.hsl=function(){var e=i(arguments);return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},l.to.hwb=function(){var e=i(arguments),t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},l.to.keyword=function(e){return a[e.slice(0,3)]}},function(e,t,n){"use strict";var r=n(99),i=Array.prototype.concat,o=Array.prototype.slice,a=e.exports=function(e){for(var t=[],n=0,a=e.length;n=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&"String"!==e.constructor.name))}},function(e,t,n){const r=n(38),i=n(101),o={};Object.keys(r).forEach(e=>{o[e]={},Object.defineProperty(o[e],"channels",{value:r[e].channels}),Object.defineProperty(o[e],"labels",{value:r[e].labels});const t=i(e);Object.keys(t).forEach(n=>{const r=t[n];o[e][n]=function(e){const t=function(...t){const n=t[0];if(null==n)return n;n.length>1&&(t=n);const r=e(t);if("object"==typeof r)for(let e=r.length,t=0;t1&&(t=n),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(r)})}),e.exports=o},function(e,t,n){const r=n(38);function i(e){const t=function(){const e={},t=Object.keys(r);for(let n=t.length,r=0;r=e.length;if(a=!a&&i.a.isArray(r)?r.length:a,l)return i.a.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!s;r[a]&&i.a.isObject(r[a])||(r[a]=[]);return t(e,n,r[a],o)&&i.a.isArray(r[a])&&(r[a]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let o;for(r=0;r{t(function(e){return i.a.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null};const T={transitional:m,adapter:["xhr","http"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=i.a.isObject(e);o&&i.a.isHTMLForm(e)&&(e=new FormData(e));if(i.a.isFormData(e))return r?JSON.stringify(w(e)):e;if(i.a.isArrayBuffer(e)||i.a.isBuffer(e)||i.a.isStream(e)||i.a.isFile(e)||i.a.isBlob(e))return e;if(i.a.isArrayBufferView(e))return e.buffer;if(i.a.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Object(a.a)(e,new b.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return b.isNode&&i.a.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((s=i.a.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Object(a.a)(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(i.a.isString(e))try{return(t||JSON.parse)(e),i.a.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||T.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(e&&i.a.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw p.a.from(e,p.a.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:b.classes.FormData,Blob:b.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};i.a.forEach(["delete","get","head","post","put","patch"],e=>{T.headers[e]={}});var S=T;const E=i.a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const M=Symbol("internals");function A(e){return e&&String(e).trim().toLowerCase()}function I(e){return!1===e||null==e?e:i.a.isArray(e)?e.map(I):String(e)}function C(e,t,n,r,o){return i.a.isFunction(r)?r.call(this,t,n):(o&&(t=n),i.a.isString(t)?i.a.isString(r)?-1!==t.indexOf(r):i.a.isRegExp(r)?r.test(t):void 0:void 0)}class k{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=A(t);if(!o)throw new Error("header name must be a non-empty string");const a=i.a.findKey(r,o);(!a||void 0===r[a]||!0===n||void 0===n&&!1!==r[a])&&(r[a||t]=I(e))}const a=(e,t)=>i.a.forEach(e,(e,n)=>o(e,n,t));return i.a.isPlainObject(e)||e instanceof this.constructor?a(e,t):i.a.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?a((e=>{const t={};let n,r,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!n||t[n]&&E[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t):null!=e&&o(t,e,n),this}get(e,t){if(e=A(e)){const n=i.a.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(i.a.isFunction(t))return t.call(this,e,n);if(i.a.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=A(e)){const n=i.a.findKey(this,e);return!(!n||void 0===this[n]||t&&!C(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=A(e)){const o=i.a.findKey(n,e);!o||t&&!C(0,n[o],o,t)||(delete n[o],r=!0)}}return i.a.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];e&&!C(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return i.a.forEach(this,(r,o)=>{const a=i.a.findKey(n,o);if(a)return t[a]=I(r),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();s!==o&&delete t[o],t[s]=I(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return i.a.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&i.a.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[M]=this[M]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=A(e);t[r]||(!function(e,t){const n=i.a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[r]=!0)}return i.a.isArray(e)?e.forEach(r):r(e),this}}k.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),i.a.reduceDescriptors(k.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),i.a.freezeMethods(k);var O=k;function P(e,t){const n=this||S,r=t||n,o=O.from(r.headers);let a=r.data;return i.a.forEach(e,(function(e){a=e.call(n,a,o.normalize(),t?t.status:void 0)})),o.normalize(),a}function R(e){return!(!e||!e.__CANCEL__)}function D(e,t,n){p.a.call(this,null==e?"canceled":e,p.a.ERR_CANCELED,t,n),this.name="CanceledError"}i.a.inherits(D,p.a,{__CANCEL__:!0});var L=D,z=n(28);var B=b.hasStandardBrowserEnv?{write(e,t,n,r,o,a){const s=[e+"="+encodeURIComponent(t)];i.a.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),i.a.isString(r)&&s.push("path="+r),i.a.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function F(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var j=b.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let n;function r(n){let r=n;return e&&(t.setAttribute("href",r),r=t.href),t.setAttribute("href",r),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return n=r(window.location.href),function(e){const t=i.a.isString(e)?r(e):e;return t.protocol===n.protocol&&t.host===n.host}}():function(){return!0};var N=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i,o=0,a=0;return t=void 0!==t?t:1e3,function(s){const l=Date.now(),u=r[a];i||(i=l),n[o]=s,r[o]=l;let c=a,h=0;for(;c!==o;)h+=n[c++],c%=e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),l-i{const o=i.loaded,a=i.lengthComputable?i.total:void 0,s=o-n,l=r(s);n=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:s,rate:l||void 0,estimated:l&&a&&o<=a?(a-o)/l:void 0,event:i};u[t?"download":"upload"]=!0,e(u)}}var V="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){let r=e.data;const o=O.from(e.headers).normalize();let a,s,{responseType:l,withXSRFToken:u}=e;function c(){e.cancelToken&&e.cancelToken.unsubscribe(a),e.signal&&e.signal.removeEventListener("abort",a)}if(i.a.isFormData(r))if(b.hasStandardBrowserEnv||b.hasStandardBrowserWebWorkerEnv)o.setContentType(!1);else if(!1!==(s=o.getContentType())){const[e,...t]=s?s.split(";").map(e=>e.trim()).filter(Boolean):[];o.setContentType([e||"multipart/form-data",...t].join("; "))}let h=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",n=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(t+":"+n))}const f=F(e.baseURL,e.url);function _(){if(!h)return;const r=O.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders());!function(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new p.a("Request failed with status code "+n.status,[p.a.ERR_BAD_REQUEST,p.a.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}((function(e){t(e),c()}),(function(e){n(e),c()}),{data:l&&"text"!==l&&"json"!==l?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}if(h.open(e.method.toUpperCase(),d(f,e.params,e.paramsSerializer),!0),h.timeout=e.timeout,"onloadend"in h?h.onloadend=_:h.onreadystatechange=function(){h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))&&setTimeout(_)},h.onabort=function(){h&&(n(new p.a("Request aborted",p.a.ECONNABORTED,e,h)),h=null)},h.onerror=function(){n(new p.a("Network Error",p.a.ERR_NETWORK,e,h)),h=null},h.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const r=e.transitional||m;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new p.a(t,r.clarifyTimeoutError?p.a.ETIMEDOUT:p.a.ECONNABORTED,e,h)),h=null},b.hasStandardBrowserEnv&&(u&&i.a.isFunction(u)&&(u=u(e)),u||!1!==u&&j(f))){const t=e.xsrfHeaderName&&e.xsrfCookieName&&B.read(e.xsrfCookieName);t&&o.set(e.xsrfHeaderName,t)}void 0===r&&o.setContentType(null),"setRequestHeader"in h&&i.a.forEach(o.toJSON(),(function(e,t){h.setRequestHeader(t,e)})),i.a.isUndefined(e.withCredentials)||(h.withCredentials=!!e.withCredentials),l&&"json"!==l&&(h.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&h.addEventListener("progress",U(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",U(e.onUploadProgress)),(e.cancelToken||e.signal)&&(a=t=>{h&&(n(!t||t.type?new L(null,e,h):t),h.abort(),h=null)},e.cancelToken&&e.cancelToken.subscribe(a),e.signal&&(e.signal.aborted?a():e.signal.addEventListener("abort",a)));const g=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(f);g&&-1===b.protocols.indexOf(g)?n(new p.a("Unsupported protocol "+g+":",p.a.ERR_BAD_REQUEST,e)):h.send(r||null)}))};const G={http:z.a,xhr:V};i.a.forEach(G,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const q=e=>"- "+e,W=e=>i.a.isFunction(e)||null===e||!1===e;var Z=e=>{e=i.a.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let i=0;i`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let n=t?e.length>1?"since :\n"+e.map(q).join("\n"):" "+q(e[0]):"as no adapter specified";throw new p.a("There is no suitable adapter to dispatch the request "+n,"ERR_NOT_SUPPORT")}return r};function H(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new L(null,e)}function $(e){H(e),e.headers=O.from(e.headers),e.data=P.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Z(e.adapter||S.adapter)(e).then((function(t){return H(e),t.data=P.call(e,e.transformResponse,t),t.headers=O.from(t.headers),t}),(function(t){return R(t)||(H(e),t&&t.response&&(t.response.data=P.call(e,e.transformResponse,t.response),t.response.headers=O.from(t.response.headers))),Promise.reject(t)}))}const X=e=>e instanceof O?e.toJSON():e;function Y(e,t){t=t||{};const n={};function r(e,t,n){return i.a.isPlainObject(e)&&i.a.isPlainObject(t)?i.a.merge.call({caseless:n},e,t):i.a.isPlainObject(t)?i.a.merge({},t):i.a.isArray(t)?t.slice():t}function o(e,t,n){return i.a.isUndefined(t)?i.a.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function a(e,t){if(!i.a.isUndefined(t))return r(void 0,t)}function s(e,t){return i.a.isUndefined(t)?i.a.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function l(n,i,o){return o in t?r(n,i):o in e?r(void 0,n):void 0}const u={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l,headers:(e,t)=>o(X(e),X(t),!0)};return i.a.forEach(Object.keys(Object.assign({},e,t)),(function(r){const a=u[r]||o,s=a(e[r],t[r],r);i.a.isUndefined(s)&&a!==l||(n[r]=s)})),n}const K={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{K[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const J={};K.transitional=function(e,t,n){function r(e,t){return"[Axios v1.6.7] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,i,o)=>{if(!1===e)throw new p.a(r(i," has been removed"+(t?" in "+t:"")),p.a.ERR_DEPRECATED);return t&&!J[i]&&(J[i]=!0,console.warn(r(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,o)}};var Q={assertOptions:function(e,t,n){if("object"!=typeof e)throw new p.a("options must be an object",p.a.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const o=r[i],a=t[o];if(a){const t=e[o],n=void 0===t||a(t,o,e);if(!0!==n)throw new p.a("option "+o+" must be "+n,p.a.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new p.a("Unknown option "+o,p.a.ERR_BAD_OPTION)}},validators:K};const ee=Q.validators;class te{constructor(e){this.defaults=e,this.interceptors={request:new f,response:new f}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t;Error.captureStackTrace?Error.captureStackTrace(t={}):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Y(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&Q.assertOptions(n,{silentJSONParsing:ee.transitional(ee.boolean),forcedJSONParsing:ee.transitional(ee.boolean),clarifyTimeoutError:ee.transitional(ee.boolean)},!1),null!=r&&(i.a.isFunction(r)?t.paramsSerializer={serialize:r}:Q.assertOptions(r,{encode:ee.function,serialize:ee.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=o&&i.a.merge(o.common,o[t.method]);o&&i.a.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=O.concat(a,o);const s=[];let l=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(l=l&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const u=[];let c;this.interceptors.response.forEach((function(e){u.push(e.fulfilled,e.rejected)}));let h,d=0;if(!l){const e=[$.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,u),h=e.length,c=Promise.resolve(t);d{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,i){n.reason||(n.reason=new L(e,r,i),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new re((function(t){e=t})),cancel:e}}}var ie=re;const oe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(oe).forEach(([e,t])=>{oe[t]=e});var ae=oe;const se=function e(t){const n=new ne(t),r=Object(o.a)(ne.prototype.request,n);return i.a.extend(r,ne.prototype,n,{allOwnKeys:!0}),i.a.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Y(t,n))},r}(S);se.Axios=ne,se.CanceledError=L,se.CancelToken=ie,se.isCancel=R,se.VERSION="1.6.7",se.toFormData=a.a,se.AxiosError=p.a,se.Cancel=se.CanceledError,se.all=function(e){return Promise.all(e)},se.spread=function(e){return function(t){return e.apply(null,t)}},se.isAxiosError=function(e){return i.a.isObject(e)&&!0===e.isAxiosError},se.mergeConfig=Y,se.AxiosHeaders=O,se.formToJSON=e=>w(i.a.isHTMLForm(e)?new FormData(e):e),se.getAdapter=Z,se.HttpStatusCode=ae,se.default=se;t.a=se},function(e,t,n){"use strict";var r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let i;const o=new Uint8Array(16);function a(){if(!i&&(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!i))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(o)}const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));function l(e,t=0){return s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]}t.a=function(e,t,n){if(r.randomUUID&&!t&&!e)return r.randomUUID();const i=(e=e||{}).random||(e.rng||a)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=i[e];return t}return l(i)}}]]); \ No newline at end of file + */var r=n(0);var i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=r.useState,a=r.useEffect,s=r.useLayoutEffect,l=r.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=o({inst:{value:n,getSnapshot:t}}),i=r[0].inst,c=r[1];return s((function(){i.value=n,i.getSnapshot=t,u(i)&&c({inst:i})}),[e,n,t]),a((function(){return u(i)&&c({inst:i}),e((function(){u(i)&&c({inst:i})}))}),[e]),l(n),n};t.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:c},function(e,t,n){e.exports=function(){"use strict";function e(e,r,i,o,a){!function e(n,r,i,o,a){for(;o>i;){if(o-i>600){var 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(n,r,Math.max(i,Math.floor(r-l*c/s+h)),Math.min(o,Math.floor(r+(s-l)*c/s+h)),a)}var d=n[r],f=i,p=o;for(t(n,i,r),a(n[o],d)>0&&t(n,i,o);f0;)p--}0===a(n[i],d)?t(n,i,p):t(n,++p,o),p<=r&&(i=p+1),r<=p&&(o=p-1)}}(e,r,i||0,o||e.length-1,a||n)}function t(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function n(e,t){return et?1:0}var r=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function i(e,t,n){if(!n)return t.indexOf(e);for(var r=0;r=e.minX&&t.maxY>=e.minY}function p(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(t,n,r,i,o){for(var a=[n,r];a.length;)if(!((r=a.pop())-(n=a.pop())<=i)){var s=n+Math.ceil((r-n)/i/2)*i;e(t,s,n,r,o),a.push(n,s,s,r)}}return r.prototype.all=function(){return this._all(this.data,[])},r.prototype.search=function(e){var t=this.data,n=[];if(!f(e,t))return n;for(var r=this.toBBox,i=[];t;){for(var o=0;o=0&&i[t].children.length>this._maxEntries;)this._split(i,t),t--;this._adjustParentBBoxes(r,i,t)},r.prototype._split=function(e,t){var n=e[t],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var a=this._chooseSplitIndex(n,i,r),s=p(n.children.splice(a,n.children.length-a));s.height=n.height,s.leaf=n.leaf,o(n,this.toBBox),o(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(n,s)},r.prototype._splitRoot=function(e,t){this.data=p([e,t]),this.data.height=e.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},r.prototype._chooseSplitIndex=function(e,t,n){for(var r,i,o,s,l,u,h,d=1/0,f=1/0,p=t;p<=n-t;p++){var m=a(e,0,p,this.toBBox),_=a(e,p,n,this.toBBox),g=(i=m,o=_,s=Math.max(i.minX,o.minX),l=Math.max(i.minY,o.minY),u=Math.min(i.maxX,o.maxX),h=Math.min(i.maxY,o.maxY),Math.max(0,u-s)*Math.max(0,h-l)),y=c(m)+c(_);g=t;f--){var p=e.children[f];s(l,e.leaf?i(p):p),u+=h(l)}return u},r.prototype._adjustParentBBoxes=function(e,t,n){for(var r=n;r>=0;r--)s(t[r],e)},r.prototype._condense=function(e){for(var t=e.length-1,n=void 0;t>=0;t--)0===e[t].children.length?t>0?(n=e[t-1].children).splice(n.indexOf(e[t]),1):this.clear():o(e[t],this.toBBox)},r}()},function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return r}));class r{constructor(e=[],t=i){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)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 i(e,t){return et?1:0}},function(e,t,n){var r=n(94),i=n(95);e.exports=function(e,t,n,o){return t.length>0&&Array.isArray(t[0])?i(e,t,n,o):r(e,t,n,o)},e.exports.nested=i,e.exports.flat=r},function(e,t){e.exports=function(e,t,n,r){var i=e[0],o=e[1],a=!1;void 0===n&&(n=0),void 0===r&&(r=t.length);for(var s=(r-n)/2,l=0,u=s-1;lo!=f>o&&i<(d-c)*(o-h)/(f-h)+c&&(a=!a)}return a}},function(e,t){e.exports=function(e,t,n,r){var i=e[0],o=e[1],a=!1;void 0===n&&(n=0),void 0===r&&(r=t.length);for(var s=r-n,l=0,u=s-1;lo!=f>o&&i<(d-c)*(o-h)/(f-h)+c&&(a=!a)}return a}},function(e,t,n){!function(e){"use strict";const t=134217729;function n(e,t,n,r,i){let o,a,s,l,u=t[0],c=r[0],h=0,d=0;c>u==c>-u?(o=u,u=t[++h]):(o=c,c=r[++d]);let f=0;if(hu==c>-u?(s=o-((a=u+o)-u),u=t[++h]):(s=o-((a=c+o)-c),c=r[++d]),o=a,0!==s&&(i[f++]=s);hu==c>-u?(s=o-((a=o+u)-(l=a-o))+(u-l),u=t[++h]):(s=o-((a=o+c)-(l=a-o))+(c-l),c=r[++d]),o=a,0!==s&&(i[f++]=s);for(;h0!=p>0)return m;const _=Math.abs(f+p);return Math.abs(m)>=33306690738754716e-32*_?m:-function(e,r,u,c,h,d,f){let p,m,_,g,y,v,x,b,w,T,S,E,M,A,I,C,k,O;const P=e-h,R=u-h,D=r-d,L=c-d;y=(I=(b=P-(x=(v=t*P)-(v-P)))*(T=L-(w=(v=t*L)-(v-L)))-((A=P*L)-x*w-b*w-x*T))-(S=I-(k=(b=D-(x=(v=t*D)-(v-D)))*(T=R-(w=(v=t*R)-(v-R)))-((C=D*R)-x*w-b*w-x*T))),i[0]=I-(S+y)+(y-k),y=(M=A-((E=A+S)-(y=E-A))+(S-y))-(S=M-C),i[1]=M-(S+y)+(y-C),y=(O=E+S)-E,i[2]=E-(O-y)+(S-y),i[3]=O;let z=function(e,t){let n=t[0];for(let e=1;e<4;e++)n+=t[e];return n}(0,i),B=22204460492503146e-32*f;if(z>=B||-z>=B)return z;if(p=e-(P+(y=e-P))+(y-h),_=u-(R+(y=u-R))+(y-h),m=r-(D+(y=r-D))+(y-d),g=c-(L+(y=c-L))+(y-d),0===p&&0===m&&0===_&&0===g)return z;if(B=11093356479670487e-47*f+33306690738754706e-32*Math.abs(z),(z+=P*g+L*p-(D*_+R*m))>=B||-z>=B)return z;y=(I=(b=p-(x=(v=t*p)-(v-p)))*(T=L-(w=(v=t*L)-(v-L)))-((A=p*L)-x*w-b*w-x*T))-(S=I-(k=(b=m-(x=(v=t*m)-(v-m)))*(T=R-(w=(v=t*R)-(v-R)))-((C=m*R)-x*w-b*w-x*T))),l[0]=I-(S+y)+(y-k),y=(M=A-((E=A+S)-(y=E-A))+(S-y))-(S=M-C),l[1]=M-(S+y)+(y-C),y=(O=E+S)-E,l[2]=E-(O-y)+(S-y),l[3]=O;const F=n(4,i,4,l,o);y=(I=(b=P-(x=(v=t*P)-(v-P)))*(T=g-(w=(v=t*g)-(v-g)))-((A=P*g)-x*w-b*w-x*T))-(S=I-(k=(b=D-(x=(v=t*D)-(v-D)))*(T=_-(w=(v=t*_)-(v-_)))-((C=D*_)-x*w-b*w-x*T))),l[0]=I-(S+y)+(y-k),y=(M=A-((E=A+S)-(y=E-A))+(S-y))-(S=M-C),l[1]=M-(S+y)+(y-C),y=(O=E+S)-E,l[2]=E-(O-y)+(S-y),l[3]=O;const j=n(F,o,4,l,a);y=(I=(b=p-(x=(v=t*p)-(v-p)))*(T=g-(w=(v=t*g)-(v-g)))-((A=p*g)-x*w-b*w-x*T))-(S=I-(k=(b=m-(x=(v=t*m)-(v-m)))*(T=_-(w=(v=t*_)-(v-_)))-((C=m*_)-x*w-b*w-x*T))),l[0]=I-(S+y)+(y-k),y=(M=A-((E=A+S)-(y=E-A))+(S-y))-(S=M-C),l[1]=M-(S+y)+(y-C),y=(O=E+S)-E,l[2]=E-(O-y)+(S-y),l[3]=O;const N=n(j,a,4,l,s);return s[N-1]}(e,r,u,c,h,d,_)},e.orient2dfast=function(e,t,n,r,i,o){return(t-o)*(n-i)-(e-i)*(r-o)},Object.defineProperty(e,"__esModule",{value:!0})}(t)},function(e,t,n){var r=n(37),i=n(98),o=Object.hasOwnProperty,a=Object.create(null);for(var s in r)o.call(r,s)&&(a[r[s]]=s);var l=e.exports={to:{},get:{}};function u(e,t,n){return Math.min(Math.max(t,e),n)}function c(e){var t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}l.get=function(e){var t,n;switch(e.substring(0,3).toLowerCase()){case"hsl":t=l.get.hsl(e),n="hsl";break;case"hwb":t=l.get.hwb(e),n="hwb";break;default:t=l.get.rgb(e),n="rgb"}return t?{model:n,value:t}:null},l.get.rgb=function(e){if(!e)return null;var t,n,i,a=[0,0,0,1];if(t=e.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(i=t[2],t=t[1],n=0;n<3;n++){var s=2*n;a[n]=parseInt(t.slice(s,s+2),16)}i&&(a[3]=parseInt(i,16)/255)}else if(t=e.match(/^#([a-f0-9]{3,4})$/i)){for(i=(t=t[1])[3],n=0;n<3;n++)a[n]=parseInt(t[n]+t[n],16);i&&(a[3]=parseInt(i+i,16)/255)}else if(t=e.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)a[n]=parseInt(t[n+1],0);t[4]&&(t[5]?a[3]=.01*parseFloat(t[4]):a[3]=parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(t=e.match(/^(\w+)$/))?"transparent"===t[1]?[0,0,0,0]:o.call(r,t[1])?((a=r[t[1]])[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(t[n+1]));t[4]&&(t[5]?a[3]=.01*parseFloat(t[4]):a[3]=parseFloat(t[4]))}for(n=0;n<3;n++)a[n]=u(a[n],0,255);return a[3]=u(a[3],0,1),a},l.get.hsl=function(e){if(!e)return null;var t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,u(parseFloat(t[2]),0,100),u(parseFloat(t[3]),0,100),u(isNaN(n)?1:n,0,1)]}return null},l.get.hwb=function(e){if(!e)return null;var t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var n=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,u(parseFloat(t[2]),0,100),u(parseFloat(t[3]),0,100),u(isNaN(n)?1:n,0,1)]}return null},l.to.hex=function(){var e=i(arguments);return"#"+c(e[0])+c(e[1])+c(e[2])+(e[3]<1?c(Math.round(255*e[3])):"")},l.to.rgb=function(){var e=i(arguments);return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},l.to.rgb.percent=function(){var e=i(arguments),t=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+n+"%, "+r+"%)":"rgba("+t+"%, "+n+"%, "+r+"%, "+e[3]+")"},l.to.hsl=function(){var e=i(arguments);return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},l.to.hwb=function(){var e=i(arguments),t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},l.to.keyword=function(e){return a[e.slice(0,3)]}},function(e,t,n){"use strict";var r=n(99),i=Array.prototype.concat,o=Array.prototype.slice,a=e.exports=function(e){for(var t=[],n=0,a=e.length;n=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&"String"!==e.constructor.name))}},function(e,t,n){const r=n(38),i=n(101),o={};Object.keys(r).forEach(e=>{o[e]={},Object.defineProperty(o[e],"channels",{value:r[e].channels}),Object.defineProperty(o[e],"labels",{value:r[e].labels});const t=i(e);Object.keys(t).forEach(n=>{const r=t[n];o[e][n]=function(e){const t=function(...t){const n=t[0];if(null==n)return n;n.length>1&&(t=n);const r=e(t);if("object"==typeof r)for(let e=r.length,t=0;t1&&(t=n),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(r)})}),e.exports=o},function(e,t,n){const r=n(38);function i(e){const t=function(){const e={},t=Object.keys(r);for(let n=t.length,r=0;r=e.length;if(a=!a&&i.a.isArray(r)?r.length:a,l)return i.a.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!s;r[a]&&i.a.isObject(r[a])||(r[a]=[]);return t(e,n,r[a],o)&&i.a.isArray(r[a])&&(r[a]=function(e){const t={},n=Object.keys(e);let r;const i=n.length;let o;for(r=0;r{t(function(e){return i.a.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,n,0)}),n}return null};const T={transitional:m,adapter:["xhr","http"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,o=i.a.isObject(e);o&&i.a.isHTMLForm(e)&&(e=new FormData(e));if(i.a.isFormData(e))return r?JSON.stringify(w(e)):e;if(i.a.isArrayBuffer(e)||i.a.isBuffer(e)||i.a.isStream(e)||i.a.isFile(e)||i.a.isBlob(e))return e;if(i.a.isArrayBufferView(e))return e.buffer;if(i.a.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return Object(a.a)(e,new b.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return b.isNode&&i.a.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((s=i.a.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Object(a.a)(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return o||r?(t.setContentType("application/json",!1),function(e,t,n){if(i.a.isString(e))try{return(t||JSON.parse)(e),i.a.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||T.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(e&&i.a.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw p.a.from(e,p.a.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:b.classes.FormData,Blob:b.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};i.a.forEach(["delete","get","head","post","put","patch"],e=>{T.headers[e]={}});var S=T;const E=i.a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);const M=Symbol("internals");function A(e){return e&&String(e).trim().toLowerCase()}function I(e){return!1===e||null==e?e:i.a.isArray(e)?e.map(I):String(e)}function C(e,t,n,r,o){return i.a.isFunction(r)?r.call(this,t,n):(o&&(t=n),i.a.isString(t)?i.a.isString(r)?-1!==t.indexOf(r):i.a.isRegExp(r)?r.test(t):void 0:void 0)}class k{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function o(e,t,n){const o=A(t);if(!o)throw new Error("header name must be a non-empty string");const a=i.a.findKey(r,o);(!a||void 0===r[a]||!0===n||void 0===n&&!1!==r[a])&&(r[a||t]=I(e))}const a=(e,t)=>i.a.forEach(e,(e,n)=>o(e,n,t));return i.a.isPlainObject(e)||e instanceof this.constructor?a(e,t):i.a.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?a((e=>{const t={};let n,r,i;return e&&e.split("\n").forEach((function(e){i=e.indexOf(":"),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!n||t[n]&&E[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t):null!=e&&o(t,e,n),this}get(e,t){if(e=A(e)){const n=i.a.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(i.a.isFunction(t))return t.call(this,e,n);if(i.a.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=A(e)){const n=i.a.findKey(this,e);return!(!n||void 0===this[n]||t&&!C(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function o(e){if(e=A(e)){const o=i.a.findKey(n,e);!o||t&&!C(0,n[o],o,t)||(delete n[o],r=!0)}}return i.a.isArray(e)?e.forEach(o):o(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const i=t[n];e&&!C(0,this[i],i,e,!0)||(delete this[i],r=!0)}return r}normalize(e){const t=this,n={};return i.a.forEach(this,(r,o)=>{const a=i.a.findKey(n,o);if(a)return t[a]=I(r),void delete t[o];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}(o):String(o).trim();s!==o&&delete t[o],t[s]=I(r),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return i.a.forEach(this,(n,r)=>{null!=n&&!1!==n&&(t[r]=e&&i.a.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){const t=(this[M]=this[M]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=A(e);t[r]||(!function(e,t){const n=i.a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}(n,e),t[r]=!0)}return i.a.isArray(e)?e.forEach(r):r(e),this}}k.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),i.a.reduceDescriptors(k.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),i.a.freezeMethods(k);var O=k;function P(e,t){const n=this||S,r=t||n,o=O.from(r.headers);let a=r.data;return i.a.forEach(e,(function(e){a=e.call(n,a,o.normalize(),t?t.status:void 0)})),o.normalize(),a}function R(e){return!(!e||!e.__CANCEL__)}function D(e,t,n){p.a.call(this,null==e?"canceled":e,p.a.ERR_CANCELED,t,n),this.name="CanceledError"}i.a.inherits(D,p.a,{__CANCEL__:!0});var L=D,z=n(28);var B=b.hasStandardBrowserEnv?{write(e,t,n,r,o,a){const s=[e+"="+encodeURIComponent(t)];i.a.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),i.a.isString(r)&&s.push("path="+r),i.a.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function F(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var j=b.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let n;function r(n){let r=n;return e&&(t.setAttribute("href",r),r=t.href),t.setAttribute("href",r),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return n=r(window.location.href),function(e){const t=i.a.isString(e)?r(e):e;return t.protocol===n.protocol&&t.host===n.host}}():function(){return!0};var N=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let i,o=0,a=0;return t=void 0!==t?t:1e3,function(s){const l=Date.now(),u=r[a];i||(i=l),n[o]=s,r[o]=l;let c=a,h=0;for(;c!==o;)h+=n[c++],c%=e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),l-i{const o=i.loaded,a=i.lengthComputable?i.total:void 0,s=o-n,l=r(s);n=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:s,rate:l||void 0,estimated:l&&a&&o<=a?(a-o)/l:void 0,event:i};u[t?"download":"upload"]=!0,e(u)}}var V="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){let r=e.data;const o=O.from(e.headers).normalize();let a,s,{responseType:l,withXSRFToken:u}=e;function c(){e.cancelToken&&e.cancelToken.unsubscribe(a),e.signal&&e.signal.removeEventListener("abort",a)}if(i.a.isFormData(r))if(b.hasStandardBrowserEnv||b.hasStandardBrowserWebWorkerEnv)o.setContentType(!1);else if(!1!==(s=o.getContentType())){const[e,...t]=s?s.split(";").map(e=>e.trim()).filter(Boolean):[];o.setContentType([e||"multipart/form-data",...t].join("; "))}let h=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",n=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(t+":"+n))}const f=F(e.baseURL,e.url);function _(){if(!h)return;const r=O.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders());!function(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new p.a("Request failed with status code "+n.status,[p.a.ERR_BAD_REQUEST,p.a.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}((function(e){t(e),c()}),(function(e){n(e),c()}),{data:l&&"text"!==l&&"json"!==l?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}if(h.open(e.method.toUpperCase(),d(f,e.params,e.paramsSerializer),!0),h.timeout=e.timeout,"onloadend"in h?h.onloadend=_:h.onreadystatechange=function(){h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))&&setTimeout(_)},h.onabort=function(){h&&(n(new p.a("Request aborted",p.a.ECONNABORTED,e,h)),h=null)},h.onerror=function(){n(new p.a("Network Error",p.a.ERR_NETWORK,e,h)),h=null},h.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const r=e.transitional||m;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new p.a(t,r.clarifyTimeoutError?p.a.ETIMEDOUT:p.a.ECONNABORTED,e,h)),h=null},b.hasStandardBrowserEnv&&(u&&i.a.isFunction(u)&&(u=u(e)),u||!1!==u&&j(f))){const t=e.xsrfHeaderName&&e.xsrfCookieName&&B.read(e.xsrfCookieName);t&&o.set(e.xsrfHeaderName,t)}void 0===r&&o.setContentType(null),"setRequestHeader"in h&&i.a.forEach(o.toJSON(),(function(e,t){h.setRequestHeader(t,e)})),i.a.isUndefined(e.withCredentials)||(h.withCredentials=!!e.withCredentials),l&&"json"!==l&&(h.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&h.addEventListener("progress",U(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",U(e.onUploadProgress)),(e.cancelToken||e.signal)&&(a=t=>{h&&(n(!t||t.type?new L(null,e,h):t),h.abort(),h=null)},e.cancelToken&&e.cancelToken.subscribe(a),e.signal&&(e.signal.aborted?a():e.signal.addEventListener("abort",a)));const g=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(f);g&&-1===b.protocols.indexOf(g)?n(new p.a("Unsupported protocol "+g+":",p.a.ERR_BAD_REQUEST,e)):h.send(r||null)}))};const G={http:z.a,xhr:V};i.a.forEach(G,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const q=e=>"- "+e,W=e=>i.a.isFunction(e)||null===e||!1===e;var Z=e=>{e=i.a.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let i=0;i`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let n=t?e.length>1?"since :\n"+e.map(q).join("\n"):" "+q(e[0]):"as no adapter specified";throw new p.a("There is no suitable adapter to dispatch the request "+n,"ERR_NOT_SUPPORT")}return r};function H(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new L(null,e)}function $(e){H(e),e.headers=O.from(e.headers),e.data=P.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return Z(e.adapter||S.adapter)(e).then((function(t){return H(e),t.data=P.call(e,e.transformResponse,t),t.headers=O.from(t.headers),t}),(function(t){return R(t)||(H(e),t&&t.response&&(t.response.data=P.call(e,e.transformResponse,t.response),t.response.headers=O.from(t.response.headers))),Promise.reject(t)}))}const X=e=>e instanceof O?e.toJSON():e;function Y(e,t){t=t||{};const n={};function r(e,t,n){return i.a.isPlainObject(e)&&i.a.isPlainObject(t)?i.a.merge.call({caseless:n},e,t):i.a.isPlainObject(t)?i.a.merge({},t):i.a.isArray(t)?t.slice():t}function o(e,t,n){return i.a.isUndefined(t)?i.a.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function a(e,t){if(!i.a.isUndefined(t))return r(void 0,t)}function s(e,t){return i.a.isUndefined(t)?i.a.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function l(n,i,o){return o in t?r(n,i):o in e?r(void 0,n):void 0}const u={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:l,headers:(e,t)=>o(X(e),X(t),!0)};return i.a.forEach(Object.keys(Object.assign({},e,t)),(function(r){const a=u[r]||o,s=a(e[r],t[r],r);i.a.isUndefined(s)&&a!==l||(n[r]=s)})),n}const K={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{K[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const J={};K.transitional=function(e,t,n){function r(e,t){return"[Axios v1.6.7] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,i,o)=>{if(!1===e)throw new p.a(r(i," has been removed"+(t?" in "+t:"")),p.a.ERR_DEPRECATED);return t&&!J[i]&&(J[i]=!0,console.warn(r(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,i,o)}};var Q={assertOptions:function(e,t,n){if("object"!=typeof e)throw new p.a("options must be an object",p.a.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let i=r.length;for(;i-- >0;){const o=r[i],a=t[o];if(a){const t=e[o],n=void 0===t||a(t,o,e);if(!0!==n)throw new p.a("option "+o+" must be "+n,p.a.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new p.a("Unknown option "+o,p.a.ERR_BAD_OPTION)}},validators:K};const ee=Q.validators;class te{constructor(e){this.defaults=e,this.interceptors={request:new f,response:new f}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t;Error.captureStackTrace?Error.captureStackTrace(t={}):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Y(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:o}=t;void 0!==n&&Q.assertOptions(n,{silentJSONParsing:ee.transitional(ee.boolean),forcedJSONParsing:ee.transitional(ee.boolean),clarifyTimeoutError:ee.transitional(ee.boolean)},!1),null!=r&&(i.a.isFunction(r)?t.paramsSerializer={serialize:r}:Q.assertOptions(r,{encode:ee.function,serialize:ee.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=o&&i.a.merge(o.common,o[t.method]);o&&i.a.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),t.headers=O.concat(a,o);const s=[];let l=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(l=l&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const u=[];let c;this.interceptors.response.forEach((function(e){u.push(e.fulfilled,e.rejected)}));let h,d=0;if(!l){const e=[$.bind(this),void 0];for(e.unshift.apply(e,s),e.push.apply(e,u),h=e.length,c=Promise.resolve(t);d{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,i){n.reason||(n.reason=new L(e,r,i),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;return{token:new re((function(t){e=t})),cancel:e}}}var ie=re;const oe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(oe).forEach(([e,t])=>{oe[t]=e});var ae=oe;const se=function e(t){const n=new ne(t),r=Object(o.a)(ne.prototype.request,n);return i.a.extend(r,ne.prototype,n,{allOwnKeys:!0}),i.a.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Y(t,n))},r}(S);se.Axios=ne,se.CanceledError=L,se.CancelToken=ie,se.isCancel=R,se.VERSION="1.6.7",se.toFormData=a.a,se.AxiosError=p.a,se.Cancel=se.CanceledError,se.all=function(e){return Promise.all(e)},se.spread=function(e){return function(t){return e.apply(null,t)}},se.isAxiosError=function(e){return i.a.isObject(e)&&!0===e.isAxiosError},se.mergeConfig=Y,se.AxiosHeaders=O,se.formToJSON=e=>w(i.a.isHTMLForm(e)?new FormData(e):e),se.getAdapter=Z,se.HttpStatusCode=ae,se.default=se;t.a=se},function(e,t,n){"use strict";var r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let i;const o=new Uint8Array(16);function a(){if(!i&&(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!i))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(o)}const s=[];for(let e=0;e<256;++e)s.push((e+256).toString(16).slice(1));function l(e,t=0){return s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]}t.a=function(e,t,n){if(r.randomUUID&&!t&&!e)return r.randomUUID();const i=(e=e||{}).random||(e.rng||a)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=i[e];return t}return l(i)}}]]); \ No newline at end of file