diff --git a/assets/backend_bg.wasm b/assets/backend_bg.wasm index 58b0229..914fe11 100644 Binary files a/assets/backend_bg.wasm and b/assets/backend_bg.wasm differ diff --git a/assets/main-2a86ff11.js b/assets/main-d4d6b2f8.js similarity index 77% rename from assets/main-2a86ff11.js rename to assets/main-d4d6b2f8.js index 757728b..f0aec14 100644 --- a/assets/main-2a86ff11.js +++ b/assets/main-d4d6b2f8.js @@ -1,6 +1,6 @@ -var a_=Object.defineProperty;var l_=(m,f,_)=>f in m?a_(m,f,{enumerable:!0,configurable:!0,writable:!0,value:_}):m[f]=_;var Nn=(m,f,_)=>(l_(m,typeof f!="symbol"?f+"":f,_),_);(function(){const f=document.createElement("link").relList;if(f&&f.supports&&f.supports("modulepreload"))return;for(const E of document.querySelectorAll('link[rel="modulepreload"]'))v(E);new MutationObserver(E=>{for(const k of E)if(k.type==="childList")for(const B of k.addedNodes)B.tagName==="LINK"&&B.rel==="modulepreload"&&v(B)}).observe(document,{childList:!0,subtree:!0});function _(E){const k={};return E.integrity&&(k.integrity=E.integrity),E.referrerPolicy&&(k.referrerPolicy=E.referrerPolicy),E.crossOrigin==="use-credentials"?k.credentials="include":E.crossOrigin==="anonymous"?k.credentials="omit":k.credentials="same-origin",k}function v(E){if(E.ep)return;E.ep=!0;const k=_(E);fetch(E.href,k)}})();function Ar(){}function c_(m,f){for(const _ in f)m[_]=f[_];return m}function Np(m){return m()}function pp(){return Object.create(null)}function Ra(m){m.forEach(Np)}function Th(m){return typeof m=="function"}function Tr(m,f){return m!=m?f==f:m!==f||m&&typeof m=="object"||typeof m=="function"}function u_(m){return Object.keys(m).length===0}function Vp(m,...f){if(m==null){for(const v of f)v(void 0);return Ar}const _=m.subscribe(...f);return _.unsubscribe?()=>_.unsubscribe():_}function h_(m){let f;return Vp(m,_=>f=_)(),f}function $r(m,f,_){m.$$.on_destroy.push(Vp(f,_))}function Js(m,f,_,v){if(m){const E=Up(m,f,_,v);return m[0](E)}}function Up(m,f,_,v){return m[1]&&v?c_(_.ctx.slice(),m[1](v(f))):_.ctx}function Ys(m,f,_,v){if(m[2]&&v){const E=m[2](v(_));if(f.dirty===void 0)return E;if(typeof E=="object"){const k=[],B=Math.max(f.dirty.length,E.length);for(let s=0;s32){const f=[],_=m.ctx.length/32;for(let v=0;v<_;v++)f[v]=-1;return f}return-1}function d_(m){const f={};for(const _ in m)f[_]=!0;return f}function fp(m){return m??""}function nl(m,f,_){return m.set(_),f}function p_(m){return m&&Th(m.destroy)?m.destroy:Ar}function _i(m,f){m.appendChild(f)}function ci(m,f,_){m.insertBefore(f,_||null)}function si(m){m.parentNode&&m.parentNode.removeChild(m)}function f_(m,f){for(let _=0;_m.removeEventListener(f,_,v)}function vs(m,f,_){_==null?m.removeAttribute(f):m.getAttribute(f)!==_&&m.setAttribute(f,_)}function m_(m){return Array.from(m.childNodes)}function yh(m,f){f=""+f,m.data!==f&&(m.data=f)}function Uo(m,f){m.value=f??""}function Ic(m,f,_,v){_==null?m.style.removeProperty(f):m.style.setProperty(f,_,v?"important":"")}function mp(m,f,_){for(let v=0;v{const E=m.$$.callbacks[f];if(E){const k=g_(f,_,{cancelable:v});return E.slice().forEach(B=>{B.call(m,k)}),!k.defaultPrevented}return!0}}function qp(m,f){return zc().$$.context.set(m,f),f}function y_(m){return zc().$$.context.get(m)}function pn(m,f){const _=m.$$.callbacks[f.type];_&&_.slice().forEach(v=>v.call(this,f))}const Al=[],ea=[];let Pl=[];const vh=[],Zp=Promise.resolve();let xh=!1;function Gp(){xh||(xh=!0,Zp.then(Wp))}function v_(){return Gp(),Zp}function gu(m){Pl.push(m)}function Lc(m){vh.push(m)}const dh=new Set;let Cl=0;function Wp(){if(Cl!==0)return;const m=Pc;do{try{for(;Clm.indexOf(v)===-1?f.push(v):_.push(v)),_.forEach(v=>v()),Pl=f}const pu=new Set;let il;function rs(){il={r:0,c:[],p:il}}function ns(){il.r||Ra(il.c),il=il.p}function ft(m,f){m&&m.i&&(pu.delete(m),m.i(f))}function St(m,f,_,v){if(m&&m.o){if(pu.has(m))return;pu.add(m),il.c.push(()=>{pu.delete(m),v&&(_&&m.d(1),v())}),m.o(f)}else v&&v()}function gp(m){return(m==null?void 0:m.length)!==void 0?m:Array.from(m)}function Dc(m,f,_){const v=m.$$.props[f];v!==void 0&&(m.$$.bound[v]=_,_(m.$$.ctx[v]))}function Ri(m){m&&m.c()}function Ai(m,f,_){const{fragment:v,after_update:E}=m.$$;v&&v.m(f,_),gu(()=>{const k=m.$$.on_mount.map(Np).filter(Th);m.$$.on_destroy?m.$$.on_destroy.push(...k):Ra(k),m.$$.on_mount=[]}),E.forEach(gu)}function ki(m,f){const _=m.$$;_.fragment!==null&&(b_(_.after_update),Ra(_.on_destroy),_.fragment&&_.fragment.d(f),_.on_destroy=_.fragment=null,_.ctx=[])}function w_(m,f){m.$$.dirty[0]===-1&&(Al.push(m),Gp(),m.$$.dirty.fill(0)),m.$$.dirty[f/31|0]|=1<{const Ee=De.length?De[0]:ge;return V.ctx&&E(V.ctx[be],V.ctx[be]=Ee)&&(!V.skip_bound&&V.bound[be]&&V.bound[be](Ee),me&&w_(m,be)),ge}):[],V.update(),me=!0,Ra(V.before_update),V.fragment=v?v(V.ctx):!1,f.target){if(f.hydrate){const be=m_(f.target);V.fragment&&V.fragment.l(be),be.forEach(si)}else V.fragment&&V.fragment.c();f.intro&&ft(m.$$.fragment),Ai(m,f.target,f.anchor),Wp()}Ec(H)}class Wr{constructor(){Nn(this,"$$");Nn(this,"$$set")}$destroy(){ki(this,1),this.$destroy=Ar}$on(f,_){if(!Th(_))return Ar;const v=this.$$.callbacks[f]||(this.$$.callbacks[f]=[]);return v.push(_),()=>{const E=v.indexOf(_);E!==-1&&v.splice(E,1)}}$set(f){this.$$set&&!u_(f)&&(this.$$.skip_bound=!0,this.$$set(f),this.$$.skip_bound=!1)}}const S_="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(S_);function Hp(m,f,_){if(m!==null)for(var v,E,k,B,s,H,V,me=0,be=0,ge,De=m.type,Ee=De==="FeatureCollection",Le=De==="Feature",Ne=Ee?m.features.length:1,et=0;et_[0]&&(f[0]=_[0]),f[1]>_[1]&&(f[1]=_[1]),f[2]<_[0]&&(f[2]=_[0]),f[3]<_[1]&&(f[3]=_[1])}),f}bh.default=bh;let ui;const Xp=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Xp.decode();let gc=null;function zl(){return(gc===null||gc.byteLength===0)&&(gc=new Uint8Array(ui.memory.buffer)),gc}function rl(m,f){return m=m>>>0,Xp.decode(zl().subarray(m,m+f))}const Ws=new Array(128).fill(void 0);Ws.push(void 0,null,!0,!1);let Cc=Ws.length;function Nr(m){Cc===Ws.length&&Ws.push(Ws.length+1);const f=Cc;return Cc=Ws[f],Ws[f]=m,f}function Wt(m){return Ws[m]}let ol=0;const fu=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},T_=typeof fu.encodeInto=="function"?function(m,f){return fu.encodeInto(m,f)}:function(m,f){const _=fu.encode(m);return f.set(_),{read:m.length,written:_.length}};function ph(m,f,_){if(_===void 0){const s=fu.encode(m),H=f(s.length,1)>>>0;return zl().subarray(H,H+s.length).set(s),ol=s.length,H}let v=m.length,E=f(v,1)>>>0;const k=zl();let B=0;for(;B127)break;k[E+B]=s}if(B!==v){B!==0&&(m=m.slice(B)),E=_(E,v,v=B+m.length*3,1)>>>0;const s=zl().subarray(E+B,E+v),H=T_(m,s);B+=H.written}return ol=B,E}function mc(m){return m==null}let yc=null;function ur(){return(yc===null||yc.byteLength===0)&&(yc=new Int32Array(ui.memory.buffer)),yc}function I_(m){m<132||(Ws[m]=Cc,Cc=m)}function vc(m){const f=Wt(m);return I_(m),f}let xc=null;function E_(){return(xc===null||xc.byteLength===0)&&(xc=new Float64Array(ui.memory.buffer)),xc}let bc=null;function C_(){return(bc===null||bc.byteLength===0)&&(bc=new BigInt64Array(ui.memory.buffer)),bc}function wh(m){const f=typeof m;if(f=="number"||f=="boolean"||m==null)return`${m}`;if(f=="string")return`"${m}"`;if(f=="symbol"){const E=m.description;return E==null?"Symbol":`Symbol(${E})`}if(f=="function"){const E=m.name;return typeof E=="string"&&E.length>0?`Function(${E})`:"Function"}if(Array.isArray(m)){const E=m.length;let k="[";E>0&&(k+=wh(m[0]));for(let B=1;B1)v=_[1];else return toString.call(m);if(v=="Object")try{return"Object("+JSON.stringify(m)+")"}catch{return"Object"}return m instanceof Error?`${m.name}: ${m.message} -${m.stack}`:v}function M_(m,f){const _=f(m.length*1,1)>>>0;return zl().set(m,_/1),ol=m.length,_}function A_(m,f){return m=m>>>0,zl().subarray(m/1,m/1+f)}function fh(m,f){try{return m.apply(this,f)}catch(_){ui.__wbindgen_exn_store(Nr(_))}}class k_{__destroy_into_raw(){const f=this.__wbg_ptr;return this.__wbg_ptr=0,f}free(){const f=this.__destroy_into_raw();ui.__wbg_ltn_free(f)}constructor(f){try{const k=ui.__wbindgen_add_to_stack_pointer(-16),B=M_(f,ui.__wbindgen_malloc),s=ol;ui.ltn_new(k,B,s);var _=ur()[k/4+0],v=ur()[k/4+1],E=ur()[k/4+2];if(E)throw vc(v);return this.__wbg_ptr=_>>>0,this}finally{ui.__wbindgen_add_to_stack_pointer(16)}}render(){let f,_;try{const V=ui.__wbindgen_add_to_stack_pointer(-16);ui.ltn_render(V,this.__wbg_ptr);var v=ur()[V/4+0],E=ur()[V/4+1],k=ur()[V/4+2],B=ur()[V/4+3],s=v,H=E;if(B)throw s=0,H=0,vc(k);return f=s,_=H,rl(s,H)}finally{ui.__wbindgen_add_to_stack_pointer(16),ui.__wbindgen_free(f,_,1)}}toRouteSnapper(){try{const E=ui.__wbindgen_add_to_stack_pointer(-16);ui.ltn_toRouteSnapper(E,this.__wbg_ptr);var f=ur()[E/4+0],_=ur()[E/4+1],v=A_(f,_).slice();return ui.__wbindgen_free(f,_*1,1),v}finally{ui.__wbindgen_add_to_stack_pointer(16)}}analyzeNeighbourhood(f){let _,v;try{const me=ui.__wbindgen_add_to_stack_pointer(-16);ui.ltn_analyzeNeighbourhood(me,this.__wbg_ptr,Nr(f));var E=ur()[me/4+0],k=ur()[me/4+1],B=ur()[me/4+2],s=ur()[me/4+3],H=E,V=k;if(s)throw H=0,V=0,vc(B);return _=H,v=V,rl(H,V)}finally{ui.__wbindgen_add_to_stack_pointer(16),ui.__wbindgen_free(_,v,1)}}unsetNeighbourhood(){ui.ltn_unsetNeighbourhood(this.__wbg_ptr)}addModalFilter(f){let _,v;try{const me=ui.__wbindgen_add_to_stack_pointer(-16);ui.ltn_addModalFilter(me,this.__wbg_ptr,Nr(f));var E=ur()[me/4+0],k=ur()[me/4+1],B=ur()[me/4+2],s=ur()[me/4+3],H=E,V=k;if(s)throw H=0,V=0,vc(B);return _=H,v=V,rl(H,V)}finally{ui.__wbindgen_add_to_stack_pointer(16),ui.__wbindgen_free(_,v,1)}}}async function P_(m,f){if(typeof Response=="function"&&m instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(m,f)}catch(v){if(m.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",v);else throw v}const _=await m.arrayBuffer();return await WebAssembly.instantiate(_,f)}else{const _=await WebAssembly.instantiate(m,f);return _ instanceof WebAssembly.Instance?{instance:_,module:m}:_}}function z_(){const m={};return m.wbg={},m.wbg.__wbindgen_error_new=function(f,_){const v=new Error(rl(f,_));return Nr(v)},m.wbg.__wbindgen_string_new=function(f,_){const v=rl(f,_);return Nr(v)},m.wbg.__wbindgen_string_get=function(f,_){const v=Wt(_),E=typeof v=="string"?v:void 0;var k=mc(E)?0:ph(E,ui.__wbindgen_malloc,ui.__wbindgen_realloc),B=ol;ur()[f/4+1]=B,ur()[f/4+0]=k},m.wbg.__wbindgen_object_drop_ref=function(f){vc(f)},m.wbg.__wbindgen_boolean_get=function(f){const _=Wt(f);return typeof _=="boolean"?_?1:0:2},m.wbg.__wbindgen_is_bigint=function(f){return typeof Wt(f)=="bigint"},m.wbg.__wbindgen_bigint_from_i64=function(f){return Nr(f)},m.wbg.__wbindgen_jsval_eq=function(f,_){return Wt(f)===Wt(_)},m.wbg.__wbindgen_bigint_from_u64=function(f){const _=BigInt.asUintN(64,f);return Nr(_)},m.wbg.__wbindgen_number_get=function(f,_){const v=Wt(_),E=typeof v=="number"?v:void 0;E_()[f/8+1]=mc(E)?0:E,ur()[f/4+0]=!mc(E)},m.wbg.__wbindgen_is_object=function(f){const _=Wt(f);return typeof _=="object"&&_!==null},m.wbg.__wbindgen_in=function(f,_){return Wt(f)in Wt(_)},m.wbg.__wbindgen_is_undefined=function(f){return Wt(f)===void 0},m.wbg.__wbindgen_object_clone_ref=function(f){const _=Wt(f);return Nr(_)},m.wbg.__wbindgen_jsval_loose_eq=function(f,_){return Wt(f)==Wt(_)},m.wbg.__wbg_getwithrefkey_3b3c46ba20582127=function(f,_){const v=Wt(f)[Wt(_)];return Nr(v)},m.wbg.__wbg_debug_34c9290896ec9856=function(f){console.debug(Wt(f))},m.wbg.__wbg_error_e60eff06f24ab7a4=function(f){console.error(Wt(f))},m.wbg.__wbg_info_d7d58472d0bab115=function(f){console.info(Wt(f))},m.wbg.__wbg_log_a4530b4fe289336f=function(f){console.log(Wt(f))},m.wbg.__wbg_warn_f260f49434e45e62=function(f){console.warn(Wt(f))},m.wbg.__wbg_get_f01601b5a68d10e3=function(f,_){const v=Wt(f)[_>>>0];return Nr(v)},m.wbg.__wbg_length_1009b1af0c481d7b=function(f){return Wt(f).length},m.wbg.__wbindgen_is_function=function(f){return typeof Wt(f)=="function"},m.wbg.__wbg_next_9b877f231f476d01=function(f){const _=Wt(f).next;return Nr(_)},m.wbg.__wbg_next_6529ee0cca8d57ed=function(){return fh(function(f){const _=Wt(f).next();return Nr(_)},arguments)},m.wbg.__wbg_done_5fe336b092d60cf2=function(f){return Wt(f).done},m.wbg.__wbg_value_0c248a78fdc8e19f=function(f){const _=Wt(f).value;return Nr(_)},m.wbg.__wbg_iterator_db7ca081358d4fb2=function(){return Nr(Symbol.iterator)},m.wbg.__wbg_get_7b48513de5dc5ea4=function(){return fh(function(f,_){const v=Reflect.get(Wt(f),Wt(_));return Nr(v)},arguments)},m.wbg.__wbg_call_90c26b09837aba1c=function(){return fh(function(f,_){const v=Wt(f).call(Wt(_));return Nr(v)},arguments)},m.wbg.__wbg_isArray_74fb723e24f76012=function(f){return Array.isArray(Wt(f))},m.wbg.__wbg_instanceof_ArrayBuffer_e7d53d51371448e2=function(f){let _;try{_=Wt(f)instanceof ArrayBuffer}catch{_=!1}return _},m.wbg.__wbg_isSafeInteger_f93fde0dca9820f8=function(f){return Number.isSafeInteger(Wt(f))},m.wbg.__wbg_entries_9e2e2aa45aa5094a=function(f){const _=Object.entries(Wt(f));return Nr(_)},m.wbg.__wbg_buffer_a448f833075b71ba=function(f){const _=Wt(f).buffer;return Nr(_)},m.wbg.__wbg_new_8f67e318f15d7254=function(f){const _=new Uint8Array(Wt(f));return Nr(_)},m.wbg.__wbg_set_2357bf09366ee480=function(f,_,v){Wt(f).set(Wt(_),v>>>0)},m.wbg.__wbg_length_1d25fa9e4ac21ce7=function(f){return Wt(f).length},m.wbg.__wbg_instanceof_Uint8Array_bced6f43aed8c1aa=function(f){let _;try{_=Wt(f)instanceof Uint8Array}catch{_=!1}return _},m.wbg.__wbg_new_abda76e883ba8a5f=function(){const f=new Error;return Nr(f)},m.wbg.__wbg_stack_658279fe44541cf6=function(f,_){const v=Wt(_).stack,E=ph(v,ui.__wbindgen_malloc,ui.__wbindgen_realloc),k=ol;ur()[f/4+1]=k,ur()[f/4+0]=E},m.wbg.__wbg_error_f851667af71bcfc6=function(f,_){let v,E;try{v=f,E=_,console.error(rl(f,_))}finally{ui.__wbindgen_free(v,E,1)}},m.wbg.__wbindgen_bigint_get_as_i64=function(f,_){const v=Wt(_),E=typeof v=="bigint"?v:void 0;C_()[f/8+1]=mc(E)?BigInt(0):E,ur()[f/4+0]=!mc(E)},m.wbg.__wbindgen_debug_string=function(f,_){const v=wh(Wt(_)),E=ph(v,ui.__wbindgen_malloc,ui.__wbindgen_realloc),k=ol;ur()[f/4+1]=k,ur()[f/4+0]=E},m.wbg.__wbindgen_throw=function(f,_){throw new Error(rl(f,_))},m.wbg.__wbindgen_memory=function(){const f=ui.memory;return Nr(f)},m}function L_(m,f){return ui=m.exports,Kp.__wbindgen_wasm_module=f,bc=null,xc=null,yc=null,gc=null,ui}async function Kp(m){if(ui!==void 0)return ui;typeof m>"u"&&(m="/ltn/assets/backend_bg.wasm");const f=z_();(typeof m=="string"||typeof Request=="function"&&m instanceof Request||typeof URL=="function"&&m instanceof URL)&&(m=fetch(m));const{instance:_,module:v}=await P_(await m,f);return L_(_,v)}const Ml=[];function mh(m,f){return{subscribe:bo(m,f).subscribe}}function bo(m,f=Ar){let _;const v=new Set;function E(s){if(Tr(m,s)&&(m=s,_)){const H=!Ml.length;for(const V of v)V[1](),Ml.push(V,m);if(H){for(let V=0;V{v.delete(V),v.size===0&&_&&(_(),_=null)}}return{set:E,update:k,subscribe:B}}let D_=Date.now();function Fc(m){return`${m}-${D_++}`}const Eh=Symbol.for("svelte-maplibre");function Ll(){return y_(Eh)}function F_(m){let f=new WeakMap;return _=>{var B;let v=f.get(_.originalEvent);if(v!==void 0)return v;let k=(B=_.target.queryRenderedFeatures(_.point).find(s=>{var H;return(H=m.get(s.layer.id))==null?void 0:H.interactive}))==null?void 0:B.layer.id;return f.set(_.originalEvent,k),k}}function R_(){let m=new Map;return qp(Eh,{map:bo(null),source:mh(null),layer:mh(null),popupTarget:mh(null),cluster:bo(),loadedImages:bo(new Set),minzoom:bo(0),maxzoom:bo(24),layerEvent:bo(null),layerInfo:m,eventTopMost:F_(m)})}function yp(m){return{subscribe:m.subscribe}}function Jp({key:m,setPopupTarget:f=!1,setCluster:_=!1,setMouseEvent:v=!1}){let E=Ll(),k=bo(null),B=yp(k),s={...E,[m]:yp(k)};if(f&&(s.popupTarget=B),v){let H=bo(null);s.layerEvent=H,E.layerEvent=H}return _&&(s.cluster=bo()),qp(Eh,s),{...E,self:k}}function O_(){return Jp({key:"source",setCluster:!0})}function B_(m=!0){return Jp({key:"layer",setPopupTarget:m,setMouseEvent:m})}function N_(m){return"layerType"in m&&m.layerType==="deckgl"}var kl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yp(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var Qp={exports:{}};(function(m,f){(function(_,v){m.exports=v()})(kl,function(){var _,v,E;function k(s,H){if(!_)_=H;else if(!v)v=H;else{var V="var sharedChunk = {}; ("+_+")(sharedChunk); ("+v+")(sharedChunk);",me={};_(me),E=H(me),typeof window<"u"&&(E.workerUrl=window.URL.createObjectURL(new Blob([V],{type:"text/javascript"})))}}k(["exports"],function(s){function H(i,e,r,o){return new(r||(r=Promise))(function(l,h){function p(T){try{w(o.next(T))}catch(M){h(M)}}function y(T){try{w(o.throw(T))}catch(M){h(M)}}function w(T){var M;T.done?l(T.value):(M=T.value,M instanceof r?M:new r(function(z){z(M)})).then(p,y)}w((o=o.apply(i,e||[])).next())})}function V(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var me=be;function be(i,e){this.x=i,this.y=e}be.prototype={clone:function(){return new be(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,e){return this.clone()._rotateAround(i,e)},matMult:function(i){return this.clone()._matMult(i)},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(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var e=i.x-this.x,r=i.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult:function(i){var e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var e=Math.cos(i),r=Math.sin(i),o=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=o,this},_rotateAround:function(i,e){var r=Math.cos(i),o=Math.sin(i),l=e.y+o*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-o*(this.y-e.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},be.convert=function(i){return i instanceof be?i:Array.isArray(i)?new be(i[0],i[1]):i};var ge=V(me),De=Ee;function Ee(i,e,r,o){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(o-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=o}Ee.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,o=0;o<8;o++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?p=r:y=r,r=.5*(y-p)+p;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var Le=V(De);let Ne,et;function at(){return Ne==null&&(Ne=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),Ne}function nt(){if(et==null&&(et=!1,at())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let o=0;o<5*5;o++){const l=4*o;e.fillStyle=`rgb(${l},${l+1},${l+2})`,e.fillRect(o%5,Math.floor(o/5),1,1)}const r=e.getImageData(0,0,5,5).data;for(let o=0;o<5*5*4;o++)if(o%4!=3&&r[o]!==o){et=!0;break}}}return et||!1}function it(i,e,r,o){const l=new Le(i,e,r,o);return function(h){return l.solve(h)}}const Vt=it(.25,.1,.25,1);function ti(i,e,r){return Math.min(r,Math.max(e,i))}function Xt(i,e,r){const o=r-e,l=((i-e)%o+o)%o+e;return l===e?r:l}function Nt(i,...e){for(const r of e)for(const o in r)i[o]=r[o];return i}let Yt=1;function At(i,e,r){const o={};for(const l in i)o[l]=e.call(r||this,i[l],l,i);return o}function ke(i,e,r){const o={};for(const l in i)e.call(r||this,i[l],l,i)&&(o[l]=i[l]);return o}function Ge(i){return Array.isArray(i)?i.map(Ge):typeof i=="object"&&i?At(i,Ge):i}const Ui={};function Dt(i){Ui[i]||(typeof console<"u"&&console.warn(i),Ui[i]=!0)}function qt(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function Lt(i){let e=0;for(let r,o,l=0,h=i.length,p=h-1;l"u")throw new Error("VideoFrame not supported");const h=new VideoFrame(i,{timestamp:0});try{const p=h==null?void 0:h.format;if(!p||!p.startsWith("BGR")&&!p.startsWith("RGB"))throw new Error(`Unrecognized format ${p}`);const y=p.startsWith("BGR"),w=new Uint8ClampedArray(o*l*4);if(yield h.copyTo(w,function(T,M,z,D,N){const U=4*Math.max(-M,0),Z=(Math.max(0,z)-z)*D*4+U,$=4*D,ie=Math.max(0,M),ue=Math.max(0,z);return{rect:{x:ie,y:ue,width:Math.min(T.width,M+D)-ie,height:Math.min(T.height,z+N)-ue},layout:[{offset:Z,stride:$}]}}(i,e,r,o,l)),y)for(let T=0;TcancelAnimationFrame(e)}},getImageData(i,e=0){return this.getImageCanvasContext(i).getImageData(-e,-e,i.width+2*e,i.height+2*e)},getImageCanvasContext(i){const e=window.document.createElement("canvas"),r=e.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return e.width=i.width,e.height=i.height,r.drawImage(i,0,0,i.width,i.height),r},resolveURL:i=>(fi||(fi=document.createElement("a")),fi.href=i,fi.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(Oi==null&&(Oi=matchMedia("(prefers-reduced-motion: reduce)")),Oi.matches)}},Pt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};class He extends Error{constructor(e,r,o,l){super(`AJAXError: ${r} (${e}): ${o}`),this.status=e,this.statusText=r,this.url=o,this.body=l}}const Gt=pi()?()=>self.worker&&self.worker.referrer:()=>(window.location.protocol==="blob:"?window.parent:window).location.href,ct=i=>Pt.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))];function Zi(i,e){const r=new AbortController,o=new Request(i.url,{method:i.method||"GET",body:i.body,credentials:i.credentials,headers:i.headers,cache:i.cache,referrer:Gt(),signal:r.signal});let l=!1,h=!1;return i.type==="json"&&o.headers.set("Accept","application/json"),h||fetch(o).then(p=>p.ok?(y=>{(i.type==="arrayBuffer"||i.type==="image"?y.arrayBuffer():i.type==="json"?y.json():y.text()).then(w=>{h||(l=!0,e(null,w,y.headers.get("Cache-Control"),y.headers.get("Expires")))}).catch(w=>{h||e(new Error(w.message))})})(p):p.blob().then(y=>e(new He(p.status,p.statusText,i.url,y)))).catch(p=>{p.code!==20&&e(new Error(p.message))}),{cancel:()=>{h=!0,l||r.abort()}}}const gr=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){if(pi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e);if(!pi())return(ct(i.url)||Zi)(i,e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(Gt())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return Zi(i,e);if(pi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e,void 0,!0)}var r;return function(o,l){const h=new XMLHttpRequest;h.open(o.method||"GET",o.url,!0),o.type!=="arrayBuffer"&&o.type!=="image"||(h.responseType="arraybuffer");for(const p in o.headers)h.setRequestHeader(p,o.headers[p]);return o.type==="json"&&(h.responseType="text",h.setRequestHeader("Accept","application/json")),h.withCredentials=o.credentials==="include",h.onerror=()=>{l(new Error(h.statusText))},h.onload=()=>{if((h.status>=200&&h.status<300||h.status===0)&&h.response!==null){let p=h.response;if(o.type==="json")try{p=JSON.parse(h.response)}catch(y){return l(y)}l(null,p,h.getResponseHeader("Cache-Control"),h.getResponseHeader("Expires"))}else{const p=new Blob([h.response],{type:h.getResponseHeader("Content-Type")});l(new He(h.status,h.statusText,o.url,p))}},h.send(o.body),{cancel:()=>h.abort()}}(i,e)},Ue=function(i,e){return gr(Nt(i,{type:"arrayBuffer"}),e)};function Bi(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;const e=new URL(i),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function yr(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function hi(i,e,r){if(r&&r[i]){const o=r[i].indexOf(e);o!==-1&&r[i].splice(o,1)}}class co{constructor(e,r={}){Nt(this,r),this.type=e}}class wo extends co{constructor(e,r={}){super("error",Nt({error:e},r))}}class jo{on(e,r){return this._listeners=this._listeners||{},yr(e,r,this._listeners),this}off(e,r){return hi(e,r,this._listeners),hi(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},yr(e,r,this._oneTimeListeners),this):new Promise(o=>this.once(e,o))}fire(e,r){typeof e=="string"&&(e=new co(e,r||{}));const o=e.type;if(this.listens(o)){e.target=this;const l=this._listeners&&this._listeners[o]?this._listeners[o].slice():[];for(const y of l)y.call(this,e);const h=this._oneTimeListeners&&this._oneTimeListeners[o]?this._oneTimeListeners[o].slice():[];for(const y of h)hi(o,y,this._oneTimeListeners),y.call(this,e);const p=this._eventedParent;p&&(Nt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),p.fire(e))}else e instanceof wo&&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,r){return this._eventedParent=e,this._eventedParentData=r,this}}var Se={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const tn=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function In(i,e){const r={};for(const o in i)o!=="ref"&&(r[o]=i[o]);return tn.forEach(o=>{o in e&&(r[o]=e[o])}),r}function Ii(i,e){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let r=0;r`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const he=[rn,We,Bt,Mt,Ur,X,_n,J(It),L,F,j];function oe(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!oe(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(const r of he)if(!oe(r,e))return null}}return`Expected ${Q(i)} but found ${Q(e)} instead.`}function te(i,e){return e.some(r=>r.kind===i.kind)}function ae(i,e){return e.some(r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i)}function Te(i,e){return i.kind==="array"&&e.kind==="array"?i.itemType.kind===e.itemType.kind&&typeof i.N=="number":i.kind===e.kind}const Ie=.96422,Ce=.82521,mt=4/29,kt=6/29,ut=3*kt*kt,vt=kt*kt*kt,Ft=Math.PI/180,gi=180/Math.PI;function Ut(i){return(i%=360)<0&&(i+=360),i}function ai([i,e,r,o]){let l,h;const p=jr((.2225045*(i=ri(i))+.7168786*(e=ri(e))+.0606169*(r=ri(r)))/1);i===e&&e===r?l=h=p:(l=jr((.4360747*i+.3850649*e+.1430804*r)/Ie),h=jr((.0139322*i+.0971045*e+.7141733*r)/Ce));const y=116*p-16;return[y<0?0:y,500*(l-p),200*(p-h),o]}function ri(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function jr(i){return i>vt?Math.pow(i,1/3):i/ut+mt}function Ei([i,e,r,o]){let l=(i+16)/116,h=isNaN(e)?l:l+e/500,p=isNaN(r)?l:l-r/200;return l=1*vr(l),h=Ie*vr(h),p=Ce*vr(p),[hr(3.1338561*h-1.6168667*l-.4906146*p),hr(-.9787684*h+1.9161415*l+.033454*p),hr(.0719453*h-.2289914*l+1.4052427*p),o]}function hr(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function vr(i){return i>kt?i*i*i:ut*(i-mt)}function An(i){return parseInt(i.padEnd(2,i),16)/255}function xs(i,e){return To(e?i/100:i,0,1)}function To(i,e,r){return Math.min(Math.max(e,i),r)}function Io(i){return!i.some(Number.isNaN)}const xr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class yi{constructor(e,r,o,l=1,h=!0){this.r=e,this.g=r,this.b=o,this.a=l,h||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,r,o,l]))}static parse(e){if(e instanceof yi)return e;if(typeof e!="string")return;const r=function(o){if((o=o.toLowerCase().trim())==="transparent")return[0,0,0,0];const l=xr[o];if(l){const[p,y,w]=l;return[p/255,y/255,w/255,1]}if(o.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(o)){const p=o.length<6?1:2;let y=1;return[An(o.slice(y,y+=p)),An(o.slice(y,y+=p)),An(o.slice(y,y+=p)),An(o.slice(y,y+p)||"ff")]}if(o.startsWith("rgb")){const p=o.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(p){const[y,w,T,M,z,D,N,U,Z,$,ie,ue]=p,re=[M||" ",N||" ",$].join("");if(re===" "||re===" /"||re===",,"||re===",,,"){const pe=[T,D,Z].join(""),ye=pe==="%%%"?100:pe===""?255:0;if(ye){const Ae=[To(+w/ye,0,1),To(+z/ye,0,1),To(+U/ye,0,1),ie?xs(+ie,ue):1];if(Io(Ae))return Ae}}return}}const h=o.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(h){const[p,y,w,T,M,z,D,N,U]=h,Z=[w||" ",M||" ",D].join("");if(Z===" "||Z===" /"||Z===",,"||Z===",,,"){const $=[+y,To(+T,0,100),To(+z,0,100),N?xs(+N,U):1];if(Io($))return function([ie,ue,re,pe]){function ye(Ae){const lt=(Ae+ie/30)%12,pt=ue*Math.min(re,1-re);return re-pt*Math.max(-1,Math.min(lt-3,9-lt,1))}return ie=Ut(ie),ue/=100,re/=100,[ye(0),ye(8),ye(4),pe]}($)}}}(e);return r?new yi(...r,!1):void 0}get rgb(){const{r:e,g:r,b:o,a:l}=this,h=l||1/0;return this.overwriteGetter("rgb",[e/h,r/h,o/h,l])}get hcl(){return this.overwriteGetter("hcl",function(e){const[r,o,l,h]=ai(e),p=Math.sqrt(o*o+l*l);return[Math.round(1e4*p)?Ut(Math.atan2(l,o)*gi):NaN,p,r,h]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ai(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,o,l]=this.rgb;return`rgba(${[e,r,o].map(h=>Math.round(255*h)).join(",")},${l})`}}yi.black=new yi(0,0,0,1),yi.white=new yi(1,1,1,1),yi.transparent=new yi(0,0,0,0),yi.red=new yi(1,0,0,1);class ta{constructor(e,r,o){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=o,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class jn{constructor(e,r,o,l,h){this.text=e,this.image=r,this.scale=o,this.fontStack=l,this.textColor=h}}class ji{constructor(e){this.sections=e}static fromString(e){return new ji([new jn(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof ji?e:ji.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}}class qr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof qr)return e;if(typeof e=="number")return new qr([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const r of e)if(typeof r!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new qr(e)}}toString(){return JSON.stringify(this.values)}}const Go=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Ir{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ir)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let r=0;r=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?o===void 0||typeof o=="number"&&o>=0&&o<=1?null:`Invalid rgba value [${[i,e,r,o].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof o=="number"?[i,e,r,o]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function os(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof yi||i instanceof ta||i instanceof ji||i instanceof qr||i instanceof Ir||i instanceof Er)return!0;if(Array.isArray(i)){for(const e of i)if(!os(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!os(i[e]))return!1;return!0}return!1}function Gi(i){if(i===null)return rn;if(typeof i=="string")return Bt;if(typeof i=="boolean")return Mt;if(typeof i=="number")return We;if(i instanceof yi)return Ur;if(i instanceof ta)return Mn;if(i instanceof ji)return X;if(i instanceof qr)return L;if(i instanceof Ir)return j;if(i instanceof Er)return F;if(Array.isArray(i)){const e=i.length;let r;for(const o of i){const l=Gi(o);if(r){if(r===l)continue;r=It;break}r=l}return J(r||It,e)}return _n}function di(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof yi||i instanceof ji||i instanceof qr||i instanceof Ir||i instanceof Er?i.toString():JSON.stringify(i)}class uo{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!os(e[1]))return r.error("invalid value");const o=e[1];let l=Gi(o);const h=r.expectedType;return l.kind!=="array"||l.N!==0||!h||h.kind!=="array"||typeof h.N=="number"&&h.N!==0||(l=h),new uo(l,o)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Wi{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const bs={string:Bt,number:We,boolean:Mt,object:_n};class kn{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let o,l=1;const h=e[0];if(h==="array"){let y,w;if(e.length>2){const T=e[1];if(typeof T!="string"||!(T in bs)||T==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);y=bs[T],l++}else y=It;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);w=e[2],l++}o=J(y,w)}else{if(!bs[h])throw new Error(`Types doesn't contain name = ${h}`);o=bs[h]}const p=[];for(;le.outputDefined())}}const Na={"to-boolean":Mt,"to-color":Ur,"to-number":We,"to-string":Bt};class Eo{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const o=e[0];if(!Na[o])throw new Error(`Can't parse ${o} as it is not part of the known types`);if((o==="to-boolean"||o==="to-string")&&e.length!==2)return r.error("Expected one argument.");const l=Na[o],h=[];for(let p=1;p4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:ia(r[0],r[1],r[2],r[3]),!o))return new yi(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Wi(o||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const o of this.args){r=o.evaluate(e);const l=qr.parse(r);if(l)return l}throw new Wi(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const o of this.args){r=o.evaluate(e);const l=Ir.parse(r);if(l)return l}throw new Wi(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const o of this.args){if(r=o.evaluate(e),r===null)return 0;const l=Number(r);if(!isNaN(l))return l}throw new Wi(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return ji.fromString(di(this.args[0].evaluate(e)));case"resolvedImage":return Er.fromString(di(this.args[0].evaluate(e)));default:return di(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const ws=["Unknown","Point","LineString","Polygon"];class g{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?ws[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let r=this._parseColorCache[e];return r||(r=this._parseColorCache[e]=yi.parse(e)),r}}class I{constructor(e,r,o=[],l,h=new Zo,p=[]){this.registry=e,this.path=o,this.key=o.map(y=>`[${y}]`).join(""),this.scope=h,this.errors=p,this.expectedType=l,this._isConstant=r}parse(e,r,o,l,h={}){return r?this.concat(r,o,l)._parse(e,h):this._parse(e,h)}_parse(e,r){function o(l,h,p){return p==="assert"?new kn(h,[l]):p==="coerce"?new Eo(h,[l]):l}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=e[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[l];if(h){let p=h.parse(e,this);if(!p)return null;if(this.expectedType){const y=this.expectedType,w=p.type;if(y.kind!=="string"&&y.kind!=="number"&&y.kind!=="boolean"&&y.kind!=="object"&&y.kind!=="array"||w.kind!=="value")if(y.kind!=="color"&&y.kind!=="formatted"&&y.kind!=="resolvedImage"||w.kind!=="value"&&w.kind!=="string")if(y.kind!=="padding"||w.kind!=="value"&&w.kind!=="number"&&w.kind!=="array")if(y.kind!=="variableAnchorOffsetCollection"||w.kind!=="value"&&w.kind!=="array"){if(this.checkSubtype(y,w))return null}else p=o(p,y,r.typeAnnotation||"coerce");else p=o(p,y,r.typeAnnotation||"coerce");else p=o(p,y,r.typeAnnotation||"coerce");else p=o(p,y,r.typeAnnotation||"assert")}if(!(p instanceof uo)&&p.type.kind!=="resolvedImage"&&this._isConstant(p)){const y=new g;try{p=new uo(p.type,p.evaluate(y))}catch(w){return this.error(w.message),null}}return p}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,o){const l=typeof e=="number"?this.path.concat(e):this.path,h=o?this.scope.concat(o):this.scope;return new I(this.registry,this._isConstant,l,r||null,h,this.errors)}error(e,...r){const o=`${this.key}${r.map(l=>`[${l}]`).join("")}`;this.errors.push(new er(o,e))}checkSubtype(e,r){const o=oe(e,r);return o&&this.error(o),o}}class O{constructor(e,r,o){this.type=Mn,this.locale=o,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const o=e[1];if(typeof o!="object"||Array.isArray(o))return r.error("Collator options argument must be an object.");const l=r.parse(o["case-sensitive"]!==void 0&&o["case-sensitive"],1,Mt);if(!l)return null;const h=r.parse(o["diacritic-sensitive"]!==void 0&&o["diacritic-sensitive"],1,Mt);if(!h)return null;let p=null;return o.locale&&(p=r.parse(o.locale,1,Bt),!p)?null:new O(l,h,p)}evaluate(e){return new ta(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}const Y=8192;function ne(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function se(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function fe(i,e){const r=(180+i[0])/360,o=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,e.z);return[Math.round(r*l*Y),Math.round(o*l*Y)]}function Re(i,e,r){const o=i[0]-e[0],l=i[1]-e[1],h=i[0]-r[0],p=i[1]-r[1];return o*p-h*l==0&&o*h<=0&&l*p<=0}function Ve(i,e){let r=!1;for(let p=0,y=e.length;p(o=i)[1]!=(h=w[T+1])[1]>o[1]&&o[0]<(h[0]-l[0])*(o[1]-l[1])/(h[1]-l[1])+l[0]&&(r=!r)}}var o,l,h;return r}function rt(i,e){for(let r=0;r0&&y<0||p<0&&y>0}function Je(i,e,r){for(const T of r)for(let M=0;Mr[2]){const l=.5*o;let h=i[0]-r[0]>l?-o:r[0]-i[0]>l?o:0;h===0&&(h=i[0]-r[2]>l?-o:r[2]-i[0]>l?o:0),i[0]+=h}ne(e,i)}function _t(i,e,r,o){const l=Math.pow(2,o.z)*Y,h=[o.x*Y,o.y*Y],p=[];for(const y of i)for(const w of y){const T=[w.x+h[0],w.y+h[1]];Pe(T,e,r,l),p.push(T)}return p}function vi(i,e,r,o){const l=Math.pow(2,o.z)*Y,h=[o.x*Y,o.y*Y],p=[];for(const w of i){const T=[];for(const M of w){const z=[M.x+h[0],M.y+h[1]];ne(e,z),T.push(z)}p.push(T)}if(e[2]-e[0]<=l/2){(y=e)[0]=y[1]=1/0,y[2]=y[3]=-1/0;for(const w of p)for(const T of w)Pe(T,e,r,l)}var y;return p}class Xi{constructor(e,r){this.type=Mt,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(os(e[1])){const o=e[1];if(o.type==="FeatureCollection")for(let l=0;l!Array.isArray(T)||T.length===e.length-1);let w=null;for(const[T,M]of y){w=new I(r.registry,ra,r.path,null,r.scope);const z=[];let D=!1;for(let N=1;N{return D=z,Array.isArray(D)?`(${D.map(Q).join(", ")})`:`(${Q(D.type)}...)`;var D}).join(" | "),M=[];for(let z=1;z{r=e?r&&ra(o):r&&o instanceof uo}),!!r&&Ci(i)&&na(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Ci(i){if(i instanceof nn&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof Xi)return!1;let e=!0;return i.eachChild(r=>{e&&!Ci(r)&&(e=!1)}),e}function ss(i){if(i instanceof nn&&i.name==="feature-state")return!1;let e=!0;return i.eachChild(r=>{e&&!ss(r)&&(e=!1)}),e}function na(i,e){if(i instanceof nn&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(o=>{r&&!na(o,e)&&(r=!1)}),r}function on(i,e){const r=i.length-1;let o,l,h=0,p=r,y=0;for(;h<=p;)if(y=Math.floor((h+p)/2),o=i[y],l=i[y+1],o<=e){if(y===r||ee))throw new Wi("Input is not a number.");p=y-1}return 0}class ho{constructor(e,r,o){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[l,h]of o)this.labels.push(l),this.outputs.push(h)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const o=r.parse(e[1],1,We);if(!o)return null;const l=[];let h=null;r.expectedType&&r.expectedType.kind!=="value"&&(h=r.expectedType);for(let p=1;p=y)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',T);const z=r.parse(w,M,h);if(!z)return null;h=h||z.type,l.push([y,z])}return new ho(h,o,l)}evaluate(e){const r=this.labels,o=this.outputs;if(r.length===1)return o[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return o[0].evaluate(e);const h=r.length;return l>=r[h-1]?o[h-1].evaluate(e):o[on(r,l)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function Kt(i,e,r){return i+r*(e-i)}function Ss(i,e,r){return i.map((o,l)=>Kt(o,e[l],r))}const Hr={number:Kt,color:function(i,e,r,o="rgb"){switch(o){case"rgb":{const[l,h,p,y]=Ss(i.rgb,e.rgb,r);return new yi(l,h,p,y,!1)}case"hcl":{const[l,h,p,y]=i.hcl,[w,T,M,z]=e.hcl;let D,N;if(isNaN(l)||isNaN(w))isNaN(l)?isNaN(w)?D=NaN:(D=w,p!==1&&p!==0||(N=T)):(D=l,M!==1&&M!==0||(N=h));else{let ue=w-l;w>l&&ue>180?ue-=360:w180&&(ue+=360),D=l+r*ue}const[U,Z,$,ie]=function([ue,re,pe,ye]){return ue=isNaN(ue)?0:ue*Ft,Ei([pe,Math.cos(ue)*re,Math.sin(ue)*re,ye])}([D,N??Kt(h,T,r),Kt(p,M,r),Kt(y,z,r)]);return new yi(U,Z,$,ie,!1)}case"lab":{const[l,h,p,y]=Ei(Ss(i.lab,e.lab,r));return new yi(l,h,p,y,!1)}}},array:Ss,padding:function(i,e,r){return new qr(Ss(i.values,e.values,r))},variableAnchorOffsetCollection:function(i,e,r){const o=i.values,l=e.values;if(o.length!==l.length)throw new Wi(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${e.toString()}`);const h=[];for(let p=0;ptypeof M!="number"||M<0||M>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:T}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(h=r.parse(h,2,We),!h)return null;const y=[];let w=null;o==="interpolate-hcl"||o==="interpolate-lab"?w=Ur:r.expectedType&&r.expectedType.kind!=="value"&&(w=r.expectedType);for(let T=0;T=M)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',D);const U=r.parse(z,N,w);if(!U)return null;w=w||U.type,y.push([M,U])}return Te(w,We)||Te(w,Ur)||Te(w,L)||Te(w,j)||Te(w,J(We))?new sn(w,o,l,h,y):r.error(`Type ${Q(w)} is not interpolatable.`)}evaluate(e){const r=this.labels,o=this.outputs;if(r.length===1)return o[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return o[0].evaluate(e);const h=r.length;if(l>=r[h-1])return o[h-1].evaluate(e);const p=on(r,l),y=sn.interpolationFactor(this.interpolation,l,r[p],r[p+1]),w=o[p].evaluate(e),T=o[p+1].evaluate(e);switch(this.operator){case"interpolate":return Hr[this.type.kind](w,T,y);case"interpolate-hcl":return Hr.color(w,T,y,"hcl");case"interpolate-lab":return Hr.color(w,T,y,"lab")}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function oa(i,e,r,o){const l=o-r,h=i-r;return l===0?0:e===1?h/l:(Math.pow(e,h)-1)/(Math.pow(e,l)-1)}class sa{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let o=null;const l=r.expectedType;l&&l.kind!=="value"&&(o=l);const h=[];for(const y of e.slice(1)){const w=r.parse(y,1+h.length,o,void 0,{typeAnnotation:"omit"});if(!w)return null;o=o||w.type,h.push(w)}if(!o)throw new Error("No output type");const p=l&&h.some(y=>oe(l,y.type));return new sa(p?It:o,h)}evaluate(e){let r,o=null,l=0;for(const h of this.args)if(l++,o=h.evaluate(e),o&&o instanceof Er&&!o.available&&(r||(r=o.name),o=null,l===this.args.length&&(o=r)),o!==null)break;return o}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}class aa{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const o=[];for(let h=1;h=o.length)throw new Wi(`Array index out of bounds: ${r} > ${o.length-1}.`);if(r!==Math.floor(r))throw new Wi(`Array index must be an integer, but found ${r} instead.`);return o[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class la{constructor(e,r){this.type=Mt,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const o=r.parse(e[1],1,It),l=r.parse(e[2],2,It);return o&&l?te(o.type,[Mt,Bt,We,rn,It])?new la(o,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Q(o.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(!o)return!1;if(!ae(r,["boolean","string","number","null"]))throw new Wi(`Expected first argument to be of type boolean, string, number or null, but found ${Q(Gi(r))} instead.`);if(!ae(o,["string","array"]))throw new Wi(`Expected second argument to be of type array or string, but found ${Q(Gi(o))} instead.`);return o.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Ts{constructor(e,r,o){this.type=We,this.needle=e,this.haystack=r,this.fromIndex=o}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const o=r.parse(e[1],1,It),l=r.parse(e[2],2,It);if(!o||!l)return null;if(!te(o.type,[Mt,Bt,We,rn,It]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Q(o.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,We);return h?new Ts(o,l,h):null}return new Ts(o,l)}evaluate(e){const r=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(!ae(r,["boolean","string","number","null"]))throw new Wi(`Expected first argument to be of type boolean, string, number or null, but found ${Q(Gi(r))} instead.`);if(!ae(o,["string","array"]))throw new Wi(`Expected second argument to be of type array or string, but found ${Q(Gi(o))} instead.`);if(this.fromIndex){const l=this.fromIndex.evaluate(e);return o.indexOf(r,l)}return o.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ca{constructor(e,r,o,l,h,p){this.inputType=e,this.type=r,this.input=o,this.cases=l,this.outputs=h,this.otherwise=p}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let o,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);const h={},p=[];for(let T=2;TNumber.MAX_SAFE_INTEGER)return D.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof U=="number"&&Math.floor(U)!==U)return D.error("Numeric branch labels must be integer values.");if(o){if(D.checkSubtype(o,Gi(U)))return null}else o=Gi(U);if(h[String(U)]!==void 0)return D.error("Branch labels must be unique.");h[String(U)]=p.length}const N=r.parse(z,T,l);if(!N)return null;l=l||N.type,p.push(N)}const y=r.parse(e[1],1,It);if(!y)return null;const w=r.parse(e[e.length-1],e.length-1,l);return w?y.type.kind!=="value"&&r.concat(1).checkSubtype(o,y.type)?null:new ca(o,l,y,h,p,w):null}evaluate(e){const r=this.input.evaluate(e);return(Gi(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class Ua{constructor(e,r,o){this.type=e,this.branches=r,this.otherwise=o}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let o;r.expectedType&&r.expectedType.kind!=="value"&&(o=r.expectedType);const l=[];for(let p=1;pr.outputDefined())&&this.otherwise.outputDefined()}}class ua{constructor(e,r,o,l){this.type=e,this.input=r,this.beginIndex=o,this.endIndex=l}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const o=r.parse(e[1],1,It),l=r.parse(e[2],2,We);if(!o||!l)return null;if(!te(o.type,[J(It),Bt,It]))return r.error(`Expected first argument to be of type array or string, but found ${Q(o.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,We);return h?new ua(o.type,o,l,h):null}return new ua(o.type,o,l)}evaluate(e){const r=this.input.evaluate(e),o=this.beginIndex.evaluate(e);if(!ae(r,["string","array"]))throw new Wi(`Expected first argument to be of type array or string, but found ${Q(Gi(r))} instead.`);if(this.endIndex){const l=this.endIndex.evaluate(e);return r.slice(o,l)}return r.slice(o)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Is(i,e){return i==="=="||i==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function ha(i,e,r,o){return o.compare(e,r)===0}function Wo(i,e,r){const o=i!=="=="&&i!=="!=";return class $p{constructor(h,p,y){this.type=Mt,this.lhs=h,this.rhs=p,this.collator=y,this.hasUntypedArgument=h.type.kind==="value"||p.type.kind==="value"}static parse(h,p){if(h.length!==3&&h.length!==4)return p.error("Expected two or three arguments.");const y=h[0];let w=p.parse(h[1],1,It);if(!w)return null;if(!Is(y,w.type))return p.concat(1).error(`"${y}" comparisons are not supported for type '${Q(w.type)}'.`);let T=p.parse(h[2],2,It);if(!T)return null;if(!Is(y,T.type))return p.concat(2).error(`"${y}" comparisons are not supported for type '${Q(T.type)}'.`);if(w.type.kind!==T.type.kind&&w.type.kind!=="value"&&T.type.kind!=="value")return p.error(`Cannot compare types '${Q(w.type)}' and '${Q(T.type)}'.`);o&&(w.type.kind==="value"&&T.type.kind!=="value"?w=new kn(T.type,[w]):w.type.kind!=="value"&&T.type.kind==="value"&&(T=new kn(w.type,[T])));let M=null;if(h.length===4){if(w.type.kind!=="string"&&T.type.kind!=="string"&&w.type.kind!=="value"&&T.type.kind!=="value")return p.error("Cannot use collator to compare non-string types.");if(M=p.parse(h[3],3,Mn),!M)return null}return new $p(w,T,M)}evaluate(h){const p=this.lhs.evaluate(h),y=this.rhs.evaluate(h);if(o&&this.hasUntypedArgument){const w=Gi(p),T=Gi(y);if(w.kind!==T.kind||w.kind!=="string"&&w.kind!=="number")throw new Wi(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${w.kind}, ${T.kind}) instead.`)}if(this.collator&&!o&&this.hasUntypedArgument){const w=Gi(p),T=Gi(y);if(w.kind!=="string"||T.kind!=="string")return e(h,p,y)}return this.collator?r(h,p,y,this.collator.evaluate(h)):e(h,p,y)}eachChild(h){h(this.lhs),h(this.rhs),this.collator&&h(this.collator)}outputDefined(){return!0}}}const eo=Wo("==",function(i,e,r){return e===r},ha),al=Wo("!=",function(i,e,r){return e!==r},function(i,e,r,o){return!ha(0,e,r,o)}),ll=Wo("<",function(i,e,r){return e",function(i,e,r){return e>r},function(i,e,r,o){return o.compare(e,r)>0}),cl=Wo("<=",function(i,e,r){return e<=r},function(i,e,r,o){return o.compare(e,r)<=0}),da=Wo(">=",function(i,e,r){return e>=r},function(i,e,r,o){return o.compare(e,r)>=0});class pa{constructor(e,r,o,l,h){this.type=Bt,this.number=e,this.locale=r,this.currency=o,this.minFractionDigits=l,this.maxFractionDigits=h}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const o=r.parse(e[1],1,We);if(!o)return null;const l=e[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let h=null;if(l.locale&&(h=r.parse(l.locale,1,Bt),!h))return null;let p=null;if(l.currency&&(p=r.parse(l.currency,1,Bt),!p))return null;let y=null;if(l["min-fraction-digits"]&&(y=r.parse(l["min-fraction-digits"],1,We),!y))return null;let w=null;return l["max-fraction-digits"]&&(w=r.parse(l["max-fraction-digits"],1,We),!w)?null:new pa(o,h,p,y,w)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Es{constructor(e){this.type=X,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const o=e[1];if(!Array.isArray(o)&&typeof o=="object")return r.error("First argument must be an image or text section.");const l=[];let h=!1;for(let p=1;p<=e.length-1;++p){const y=e[p];if(h&&typeof y=="object"&&!Array.isArray(y)){h=!1;let w=null;if(y["font-scale"]&&(w=r.parse(y["font-scale"],1,We),!w))return null;let T=null;if(y["text-font"]&&(T=r.parse(y["text-font"],1,J(Bt)),!T))return null;let M=null;if(y["text-color"]&&(M=r.parse(y["text-color"],1,Ur),!M))return null;const z=l[l.length-1];z.scale=w,z.font=T,z.textColor=M}else{const w=r.parse(e[p],1,It);if(!w)return null;const T=w.type.kind;if(T!=="string"&&T!=="value"&&T!=="null"&&T!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,l.push({content:w,scale:null,font:null,textColor:null})}}return new Es(l)}evaluate(e){return new ji(this.sections.map(r=>{const o=r.content.evaluate(e);return Gi(o)===F?new jn("",o,null,null,null):new jn(di(o),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}}class ja{constructor(e){this.type=F,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const o=r.parse(e[1],1,Bt);return o?new ja(o):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),o=Er.fromString(r);return o&&e.availableImages&&(o.available=e.availableImages.indexOf(r)>-1),o}eachChild(e){e(this.input)}outputDefined(){return!1}}class po{constructor(e){this.type=We,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const o=r.parse(e[1],1);return o?o.type.kind!=="array"&&o.type.kind!=="string"&&o.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${Q(o.type)} instead.`):new po(o):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new Wi(`Expected value to be of type string or array, but found ${Q(Gi(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Ho={"==":eo,"!=":al,">":Dl,"<":ll,">=":da,"<=":cl,array:kn,at:Va,boolean:kn,case:Ua,coalesce:sa,collator:O,format:Es,image:ja,in:la,"index-of":Ts,interpolate:sn,"interpolate-hcl":sn,"interpolate-lab":sn,length:po,let:aa,literal:uo,match:ca,number:kn,"number-format":pa,object:kn,slice:ua,step:ho,string:kn,"to-boolean":Eo,"to-color":Eo,"to-number":Eo,"to-string":Eo,var:tr,within:Xi};function ul(i,[e,r,o,l]){e=e.evaluate(i),r=r.evaluate(i),o=o.evaluate(i);const h=l?l.evaluate(i):1,p=ia(e,r,o,h);if(p)throw new Wi(p);return new yi(e/255,r/255,o/255,h,!1)}function hl(i,e){return i in e}function Cs(i,e){const r=e[i];return r===void 0?null:r}function qn(i){return{type:i}}function fa(i){return{result:"success",value:i}}function to(i){return{result:"error",value:i}}function Co(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function as(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function qa(i){return!!i.expression&&i.expression.interpolated}function mi(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function Ki(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Fl(i){return i}function Qt(i,e){const r=e.type==="color",o=i.stops&&typeof i.stops[0][0]=="object",l=o||!(o||i.property!==void 0),h=i.type||(qa(e)?"exponential":"interval");if(r||e.type==="padding"){const M=r?yi.parse:qr.parse;(i=mn({},i)).stops&&(i.stops=i.stops.map(z=>[z[0],M(z[1])])),i.default=M(i.default?i.default:e.default)}if(i.colorSpace&&(p=i.colorSpace)!=="rgb"&&p!=="hcl"&&p!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var p;let y,w,T;if(h==="exponential")y=gn;else if(h==="interval")y=xi;else if(h==="categorical"){y=Ni,w=Object.create(null);for(const M of i.stops)w[M[0]]=M[1];T=typeof i.stops[0][0]}else{if(h!=="identity")throw new Error(`Unknown function type "${h}"`);y=Ao}if(o){const M={},z=[];for(let U=0;UU[0]),evaluate:({zoom:U},Z)=>gn({stops:D,base:i.base},e,U).evaluate(U,Z)}}if(l){const M=h==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:M,interpolationFactor:sn.interpolationFactor.bind(void 0,M),zoomStops:i.stops.map(z=>z[0]),evaluate:({zoom:z})=>y(i,e,z,w,T)}}return{kind:"source",evaluate(M,z){const D=z&&z.properties?z.properties[i.property]:void 0;return D===void 0?Mo(i.default,e.default):y(i,e,D,w,T)}}}function Mo(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function Ni(i,e,r,o,l){return Mo(typeof r===l?o[r]:void 0,i.default,e.default)}function xi(i,e,r){if(mi(r)!=="number")return Mo(i.default,e.default);const o=i.stops.length;if(o===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[o-1][0])return i.stops[o-1][1];const l=on(i.stops.map(h=>h[0]),r);return i.stops[l][1]}function gn(i,e,r){const o=i.base!==void 0?i.base:1;if(mi(r)!=="number")return Mo(i.default,e.default);const l=i.stops.length;if(l===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[l-1][0])return i.stops[l-1][1];const h=on(i.stops.map(M=>M[0]),r),p=function(M,z,D,N){const U=N-D,Z=M-D;return U===0?0:z===1?Z/U:(Math.pow(z,Z)-1)/(Math.pow(z,U)-1)}(r,o,i.stops[h][0],i.stops[h+1][0]),y=i.stops[h][1],w=i.stops[h+1][1],T=Hr[e.type]||Fl;return typeof y.evaluate=="function"?{evaluate(...M){const z=y.evaluate.apply(void 0,M),D=w.evaluate.apply(void 0,M);if(z!==void 0&&D!==void 0)return T(z,D,p,i.colorSpace)}}:T(y,w,p,i.colorSpace)}function Ao(i,e,r){switch(e.type){case"color":r=yi.parse(r);break;case"formatted":r=ji.fromString(r.toString());break;case"resolvedImage":r=Er.fromString(r.toString());break;case"padding":r=qr.parse(r);break;default:mi(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return Mo(r,i.default,e.default)}nn.register(Ho,{error:[{kind:"error"},[Bt],(i,[e])=>{throw new Wi(e.evaluate(i))}],typeof:[Bt,[It],(i,[e])=>Q(Gi(e.evaluate(i)))],"to-rgba":[J(We,4),[Ur],(i,[e])=>{const[r,o,l,h]=e.evaluate(i).rgb;return[255*r,255*o,255*l,h]}],rgb:[Ur,[We,We,We],ul],rgba:[Ur,[We,We,We,We],ul],has:{type:Mt,overloads:[[[Bt],(i,[e])=>hl(e.evaluate(i),i.properties())],[[Bt,_n],(i,[e,r])=>hl(e.evaluate(i),r.evaluate(i))]]},get:{type:It,overloads:[[[Bt],(i,[e])=>Cs(e.evaluate(i),i.properties())],[[Bt,_n],(i,[e,r])=>Cs(e.evaluate(i),r.evaluate(i))]]},"feature-state":[It,[Bt],(i,[e])=>Cs(e.evaluate(i),i.featureState||{})],properties:[_n,[],i=>i.properties()],"geometry-type":[Bt,[],i=>i.geometryType()],id:[It,[],i=>i.id()],zoom:[We,[],i=>i.globals.zoom],"heatmap-density":[We,[],i=>i.globals.heatmapDensity||0],"line-progress":[We,[],i=>i.globals.lineProgress||0],accumulated:[It,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[We,qn(We),(i,e)=>{let r=0;for(const o of e)r+=o.evaluate(i);return r}],"*":[We,qn(We),(i,e)=>{let r=1;for(const o of e)r*=o.evaluate(i);return r}],"-":{type:We,overloads:[[[We,We],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[We],(i,[e])=>-e.evaluate(i)]]},"/":[We,[We,We],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[We,[We,We],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[We,[],()=>Math.LN2],pi:[We,[],()=>Math.PI],e:[We,[],()=>Math.E],"^":[We,[We,We],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[We,[We],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[We,[We],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[We,[We],(i,[e])=>Math.log(e.evaluate(i))],log2:[We,[We],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[We,[We],(i,[e])=>Math.sin(e.evaluate(i))],cos:[We,[We],(i,[e])=>Math.cos(e.evaluate(i))],tan:[We,[We],(i,[e])=>Math.tan(e.evaluate(i))],asin:[We,[We],(i,[e])=>Math.asin(e.evaluate(i))],acos:[We,[We],(i,[e])=>Math.acos(e.evaluate(i))],atan:[We,[We],(i,[e])=>Math.atan(e.evaluate(i))],min:[We,qn(We),(i,e)=>Math.min(...e.map(r=>r.evaluate(i)))],max:[We,qn(We),(i,e)=>Math.max(...e.map(r=>r.evaluate(i)))],abs:[We,[We],(i,[e])=>Math.abs(e.evaluate(i))],round:[We,[We],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[We,[We],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[We,[We],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[Mt,[Bt,It],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[Mt,[It],(i,[e])=>i.id()===e.value],"filter-type-==":[Mt,[Bt],(i,[e])=>i.geometryType()===e.value],"filter-<":[Mt,[Bt,It],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o{const r=i.id(),o=e.value;return typeof r==typeof o&&r":[Mt,[Bt,It],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o>l}],"filter-id->":[Mt,[It],(i,[e])=>{const r=i.id(),o=e.value;return typeof r==typeof o&&r>o}],"filter-<=":[Mt,[Bt,It],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o<=l}],"filter-id-<=":[Mt,[It],(i,[e])=>{const r=i.id(),o=e.value;return typeof r==typeof o&&r<=o}],"filter->=":[Mt,[Bt,It],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o>=l}],"filter-id->=":[Mt,[It],(i,[e])=>{const r=i.id(),o=e.value;return typeof r==typeof o&&r>=o}],"filter-has":[Mt,[It],(i,[e])=>e.value in i.properties()],"filter-has-id":[Mt,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Mt,[J(Bt)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[Mt,[J(It)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[Mt,[Bt,J(It)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[Mt,[Bt,J(It)],(i,[e,r])=>function(o,l,h,p){for(;h<=p;){const y=h+p>>1;if(l[y]===o)return!0;l[y]>o?p=y-1:h=y+1}return!1}(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Mt,overloads:[[[Mt,Mt],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[qn(Mt),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Mt,overloads:[[[Mt,Mt],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[qn(Mt),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[Mt,[Mt],(i,[e])=>!e.evaluate(i)],"is-supported-script":[Mt,[Bt],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[Bt,[Bt],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[Bt,[Bt],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[Bt,qn(It),(i,e)=>e.map(r=>di(r.evaluate(i))).join("")],"resolved-locale":[Bt,[Mn],(i,[e])=>e.evaluate(i).resolvedLocale()]});class ls{constructor(e,r){var o;this.expression=e,this._warningHistory={},this._evaluator=new g,this._defaultValue=r?(o=r).type==="color"&&Ki(o.default)?new yi(0,0,0,0):o.type==="color"?yi.parse(o.default)||null:o.type==="padding"?qr.parse(o.default)||null:o.type==="variableAnchorOffsetCollection"?Ir.parse(o.default)||null:o.default===void 0?null:o.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,o,l,h,p){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=o,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(e,r,o,l,h,p){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=o||null,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=p||null;try{const y=this.expression.evaluate(this._evaluator);if(y==null||typeof y=="number"&&y!=y)return this._defaultValue;if(this._enumValues&&!(y in this._enumValues))throw new Wi(`Expected value to be one of ${Object.keys(this._enumValues).map(w=>JSON.stringify(w)).join(", ")}, but found ${JSON.stringify(y)} instead.`);return y}catch(y){return this._warningHistory[y.message]||(this._warningHistory[y.message]=!0,typeof console<"u"&&console.warn(y.message)),this._defaultValue}}}function Zn(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in Ho}function ma(i,e){const r=new I(Ho,ra,[],e?function(l){const h={color:Ur,string:Bt,number:We,enum:Bt,boolean:Mt,formatted:X,padding:L,resolvedImage:F,variableAnchorOffsetCollection:j};return l.type==="array"?J(h[l.value]||It,l.length):h[l.type]}(e):void 0),o=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return o?fa(new ls(o,e)):to(r.errors)}class cs{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!ss(r.expression)}evaluateWithoutErrorHandling(e,r,o,l,h,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,o,l,h,p)}evaluate(e,r,o,l,h,p){return this._styleExpression.evaluate(e,r,o,l,h,p)}}class ko{constructor(e,r,o,l){this.kind=e,this.zoomStops=o,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!ss(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(e,r,o,l,h,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,o,l,h,p)}evaluate(e,r,o,l,h,p){return this._styleExpression.evaluate(e,r,o,l,h,p)}interpolationFactor(e,r,o){return this.interpolationType?sn.interpolationFactor(this.interpolationType,e,r,o):0}}function _a(i,e){const r=ma(i,e);if(r.result==="error")return r;const o=r.value.expression,l=Ci(o);if(!l&&!Co(e))return to([new er("","data expressions not supported")]);const h=na(o,["zoom"]);if(!h&&!as(e))return to([new er("","zoom expressions not supported")]);const p=Ms(o);return p||h?p instanceof er?to([p]):p instanceof sn&&!qa(e)?to([new er("",'"interpolate" expressions cannot be used with this property')]):fa(p?new ko(l?"camera":"composite",r.value,p.labels,p instanceof sn?p.interpolation:void 0):new cs(l?"constant":"source",r.value)):to([new er("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class us{constructor(e,r){this._parameters=e,this._specification=r,mn(this,Qt(this._parameters,this._specification))}static deserialize(e){return new us(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Ms(i){let e=null;if(i instanceof aa)e=Ms(i.result);else if(i instanceof sa){for(const r of i.args)if(e=Ms(r),e)break}else(i instanceof ho||i instanceof sn)&&i.input instanceof nn&&i.input.name==="zoom"&&(e=i);return e instanceof er||i.eachChild(r=>{const o=Ms(r);o instanceof er?e=o:!e&&o?e=new er("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&o&&e!==o&&(e=new er("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function As(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const e of i.slice(1))if(!As(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const dl={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ga(i){if(i==null)return{filter:()=>!0,needGeometry:!1};As(i)||(i=va(i));const e=ma(i,dl);if(e.result==="error")throw new Error(e.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,o,l)=>e.value.evaluate(r,o,{},l),needGeometry:Xo(i)}}function ya(i,e){return ie?1:0}function Xo(i){if(!Array.isArray(i))return!1;if(i[0]==="within")return!0;for(let e=1;e"||e==="<="||e===">="?io(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(va))):e==="all"?["all"].concat(i.slice(1).map(va)):e==="none"?["all"].concat(i.slice(1).map(va).map(hs)):e==="in"?pl(i[1],i.slice(2)):e==="!in"?hs(pl(i[1],i.slice(2))):e==="has"?Po(i[1]):e==="!has"?hs(Po(i[1])):e!=="within"||i;var r}function io(i,e,r){switch(i){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,i,e]}}function pl(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",i,["literal",e.sort(ya)]]:["filter-in-small",i,["literal",e]]}}function Po(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function hs(i){return["!",i]}function xa(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(const h of i)l+=`${xa(h)},`;return`${l}]`}const r=Object.keys(i).sort();let o="{";for(let l=0;lo.maximum?[new qe(e,r,`${r} is greater than the maximum value ${o.maximum}`)]:[]}function wa(i){const e=i.valueSpec,r=Ji(i.value.type);let o,l,h,p={};const y=r!=="categorical"&&i.value.property===void 0,w=!y,T=mi(i.value.stops)==="array"&&mi(i.value.stops[0])==="array"&&mi(i.value.stops[0][0])==="object",M=Xr({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(N){if(r==="identity")return[new qe(N.key,N.value,'identity function may not have a "stops" property')];let U=[];const Z=N.value;return U=U.concat(ro({key:N.key,value:Z,valueSpec:N.valueSpec,validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec,arrayElementValidator:z})),mi(Z)==="array"&&Z.length===0&&U.push(new qe(N.key,Z,"array must have at least one stop")),U},default:function(N){return N.validateSpec({key:N.key,value:N.value,valueSpec:e,validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec})}}});return r==="identity"&&y&&M.push(new qe(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||M.push(new qe(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!qa(i.valueSpec)&&M.push(new qe(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(w&&!Co(i.valueSpec)?M.push(new qe(i.key,i.value,"property functions not supported")):y&&!as(i.valueSpec)&&M.push(new qe(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!T||i.value.property!==void 0||M.push(new qe(i.key,i.value,'"property" property is required')),M;function z(N){let U=[];const Z=N.value,$=N.key;if(mi(Z)!=="array")return[new qe($,Z,`array expected, ${mi(Z)} found`)];if(Z.length!==2)return[new qe($,Z,`array length 2 expected, length ${Z.length} found`)];if(T){if(mi(Z[0])!=="object")return[new qe($,Z,`object expected, ${mi(Z[0])} found`)];if(Z[0].zoom===void 0)return[new qe($,Z,"object stop key must have zoom")];if(Z[0].value===void 0)return[new qe($,Z,"object stop key must have value")];if(h&&h>Ji(Z[0].zoom))return[new qe($,Z[0].zoom,"stop zoom values must appear in ascending order")];Ji(Z[0].zoom)!==h&&(h=Ji(Z[0].zoom),l=void 0,p={}),U=U.concat(Xr({key:`${$}[0]`,value:Z[0],valueSpec:{zoom:{}},validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec,objectElementValidators:{zoom:ds,value:D}}))}else U=U.concat(D({key:`${$}[0]`,value:Z[0],valueSpec:{},validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec},Z));return Zn(zo(Z[1]))?U.concat([new qe(`${$}[1]`,Z[1],"expressions are not allowed in function stops.")]):U.concat(N.validateSpec({key:`${$}[1]`,value:Z[1],valueSpec:e,validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec}))}function D(N,U){const Z=mi(N.value),$=Ji(N.value),ie=N.value!==null?N.value:U;if(o){if(Z!==o)return[new qe(N.key,ie,`${Z} stop domain type must match previous stop domain type ${o}`)]}else o=Z;if(Z!=="number"&&Z!=="string"&&Z!=="boolean")return[new qe(N.key,ie,"stop domain value must be a number, string, or boolean")];if(Z!=="number"&&r!=="categorical"){let ue=`number expected, ${Z} found`;return Co(e)&&r===void 0&&(ue+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new qe(N.key,ie,ue)]}return r!=="categorical"||Z!=="number"||isFinite($)&&Math.floor($)===$?r!=="categorical"&&Z==="number"&&l!==void 0&&$new qe(`${i.key}${o.key}`,i.value,o.message));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new qe(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!ss(r))return[new qe(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!ss(r))return[new qe(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!na(r,["zoom","feature-state"]))return[new qe(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!Ci(r))return[new qe(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function we(i){const e=i.key,r=i.value,o=i.valueSpec,l=[];return Array.isArray(o.values)?o.values.indexOf(Ji(r))===-1&&l.push(new qe(e,r,`expected one of [${o.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(o.values).indexOf(Ji(r))===-1&&l.push(new qe(e,r,`expected one of [${Object.keys(o.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function Ye(i){return As(zo(i.value))?de(mn({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):wt(i)}function wt(i){const e=i.value,r=i.key;if(mi(e)!=="array")return[new qe(r,e,`array expected, ${mi(e)} found`)];const o=i.styleSpec;let l,h=[];if(e.length<1)return[new qe(r,e,"filter array must have at least 1 element")];switch(h=h.concat(we({key:`${r}[0]`,value:e[0],valueSpec:o.filter_operator,style:i.style,styleSpec:i.styleSpec})),Ji(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Ji(e[1])==="$type"&&h.push(new qe(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&h.push(new qe(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(l=mi(e[1]),l!=="string"&&h.push(new qe(`${r}[1]`,e[1],`string expected, ${l} found`)));for(let p=2;p{T in r&&e.push(new qe(o,r[T],`"${T}" is prohibited for ref layers`))}),l.layers.forEach(T=>{Ji(T.id)===y&&(w=T)}),w?w.ref?e.push(new qe(o,r.ref,"ref cannot reference another ref layer")):p=Ji(w.type):e.push(new qe(o,r.ref,`ref layer "${y}" not found`))}else if(p!=="background")if(r.source){const w=l.sources&&l.sources[r.source],T=w&&Ji(w.type);w?T==="vector"&&p==="raster"?e.push(new qe(o,r.source,`layer "${r.id}" requires a raster source`)):T!=="raster-dem"&&p==="hillshade"?e.push(new qe(o,r.source,`layer "${r.id}" requires a raster-dem source`)):T==="raster"&&p!=="raster"?e.push(new qe(o,r.source,`layer "${r.id}" requires a vector source`)):T!=="vector"||r["source-layer"]?T==="raster-dem"&&p!=="hillshade"?e.push(new qe(o,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):p!=="line"||!r.paint||!r.paint["line-gradient"]||T==="geojson"&&w.lineMetrics||e.push(new qe(o,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new qe(o,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new qe(o,r.source,`source "${r.source}" not found`))}else e.push(new qe(o,r,'missing required property "source"'));return e=e.concat(Xr({key:o,value:r,valueSpec:h.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${o}.type`,value:r.type,valueSpec:h.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:Ye,layout:w=>Xr({layer:r,key:w.key,value:w.value,style:w.style,styleSpec:w.styleSpec,validateSpec:w.validateSpec,objectElementValidators:{"*":T=>ir(mn({layerType:p},T))}}),paint:w=>Xr({layer:r,key:w.key,value:w.value,style:w.style,styleSpec:w.styleSpec,validateSpec:w.validateSpec,objectElementValidators:{"*":T=>ni(mn({layerType:p},T))}})}})),e}function dr(i){const e=i.value,r=i.key,o=mi(e);return o!=="string"?[new qe(r,e,`string expected, ${o} found`)]:[]}const rr={promoteId:function({key:i,value:e}){if(mi(e)==="string")return dr({key:i,value:e});{const r=[];for(const o in e)r.push(...dr({key:`${i}.${o}`,value:e[o]}));return r}}};function bi(i){const e=i.value,r=i.key,o=i.styleSpec,l=i.style,h=i.validateSpec;if(!e.type)return[new qe(r,e,'"type" is required')];const p=Ji(e.type);let y;switch(p){case"vector":case"raster":return y=Xr({key:r,value:e,valueSpec:o[`source_${p.replace("-","_")}`],style:i.style,styleSpec:o,objectElementValidators:rr,validateSpec:h}),y;case"raster-dem":return y=function(w){var T;const M=(T=w.sourceName)!==null&&T!==void 0?T:"",z=w.value,D=w.styleSpec,N=D.source_raster_dem,U=w.style;let Z=[];const $=mi(z);if(z===void 0)return Z;if($!=="object")return Z.push(new qe("source_raster_dem",z,`object expected, ${$} found`)),Z;const ie=Ji(z.encoding)==="custom",ue=["redFactor","greenFactor","blueFactor","baseShift"],re=w.value.encoding?`"${w.value.encoding}"`:"Default";for(const pe in z)!ie&&ue.includes(pe)?Z.push(new qe(pe,z[pe],`In "${M}": "${pe}" is only valid when "encoding" is set to "custom". ${re} encoding found`)):N[pe]?Z=Z.concat(w.validateSpec({key:pe,value:z[pe],valueSpec:N[pe],validateSpec:w.validateSpec,style:U,styleSpec:D})):Z.push(new qe(pe,z[pe],`unknown property "${pe}"`));return Z}({sourceName:r,value:e,style:i.style,styleSpec:o,validateSpec:h}),y;case"geojson":if(y=Xr({key:r,value:e,valueSpec:o.source_geojson,style:l,styleSpec:o,validateSpec:h,objectElementValidators:rr}),e.cluster)for(const w in e.clusterProperties){const[T,M]=e.clusterProperties[w],z=typeof T=="string"?[T,["accumulated"],["get",w]]:T;y.push(...de({key:`${r}.${w}.map`,value:M,validateSpec:h,expressionContext:"cluster-map"})),y.push(...de({key:`${r}.${w}.reduce`,value:z,validateSpec:h,expressionContext:"cluster-reduce"}))}return y;case"video":return Xr({key:r,value:e,valueSpec:o.source_video,style:l,validateSpec:h,styleSpec:o});case"image":return Xr({key:r,value:e,valueSpec:o.source_image,style:l,validateSpec:h,styleSpec:o});case"canvas":return[new qe(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return we({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:l,validateSpec:h,styleSpec:o})}}function an(i){const e=i.value,r=i.styleSpec,o=r.light,l=i.style;let h=[];const p=mi(e);if(e===void 0)return h;if(p!=="object")return h=h.concat([new qe("light",e,`object expected, ${p} found`)]),h;for(const y in e){const w=y.match(/^(.*)-transition$/);h=h.concat(w&&o[w[1]]&&o[w[1]].transition?i.validateSpec({key:y,value:e[y],valueSpec:r.transition,validateSpec:i.validateSpec,style:l,styleSpec:r}):o[y]?i.validateSpec({key:y,value:e[y],valueSpec:o[y],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new qe(y,e[y],`unknown property "${y}"`)])}return h}function no(i){const e=i.value,r=i.styleSpec,o=r.terrain,l=i.style;let h=[];const p=mi(e);if(e===void 0)return h;if(p!=="object")return h=h.concat([new qe("terrain",e,`object expected, ${p} found`)]),h;for(const y in e)h=h.concat(o[y]?i.validateSpec({key:y,value:e[y],valueSpec:o[y],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new qe(y,e[y],`unknown property "${y}"`)]);return h}function Zr(i){let e=[];const r=i.value,o=i.key;if(Array.isArray(r)){const l=[],h=[];for(const p in r)r[p].id&&l.includes(r[p].id)&&e.push(new qe(o,r,`all the sprites' ids must be unique, but ${r[p].id} is duplicated`)),l.push(r[p].id),r[p].url&&h.includes(r[p].url)&&e.push(new qe(o,r,`all the sprites' URLs must be unique, but ${r[p].url} is duplicated`)),h.push(r[p].url),e=e.concat(Xr({key:`${o}[${p}]`,value:r[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return dr({key:o,value:r})}const oo={"*":()=>[],array:ro,boolean:function(i){const e=i.value,r=i.key,o=mi(e);return o!=="boolean"?[new qe(r,e,`boolean expected, ${o} found`)]:[]},number:ds,color:function(i){const e=i.key,r=i.value,o=mi(r);return o!=="string"?[new qe(e,r,`color expected, ${o} found`)]:yi.parse(String(r))?[]:[new qe(e,r,`color expected, "${r}" found`)]},constants:ba,enum:we,filter:Ye,function:wa,layer:lr,object:Xr,source:bi,light:an,terrain:no,string:dr,formatted:function(i){return dr(i).length===0?[]:de(i)},resolvedImage:function(i){return dr(i).length===0?[]:de(i)},padding:function(i){const e=i.key,r=i.value;if(mi(r)==="array"){if(r.length<1||r.length>4)return[new qe(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const o={type:"number"};let l=[];for(let h=0;h[]}})),i.constants&&(r=r.concat(ba({key:"constants",value:i.constants,style:i,styleSpec:e,validateSpec:ln}))),Ps(r)}function yn(i){return function(e){return i({...e,validateSpec:ln})}}function Ps(i){return[].concat(i).sort((e,r)=>e.line-r.line)}function fo(i){return function(...e){return Ps(i.apply(this,e))}}kr.source=fo(yn(bi)),kr.sprite=fo(yn(Zr)),kr.glyphs=fo(yn(ks)),kr.light=fo(yn(an)),kr.terrain=fo(yn(no)),kr.layer=fo(yn(lr)),kr.filter=fo(yn(Ye)),kr.paintProperty=fo(yn(ni)),kr.layoutProperty=fo(yn(ir));const mo=kr,Li=mo.light,wi=mo.paintProperty,zs=mo.layoutProperty;function Gn(i,e){let r=!1;if(e&&e.length)for(const o of e)i.fire(new wo(new Error(o.message))),r=!0;return r}class Lo{constructor(e,r,o){const l=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const p=new Int32Array(this.arrayBuffer);e=p[0],this.d=(r=p[1])+2*(o=p[2]);for(let w=0;w=z[U+0]&&l>=z[U+1])?(y[N]=!0,p.push(M[N])):y[N]=!1}}}}_forEachCell(e,r,o,l,h,p,y,w){const T=this._convertToCellCoord(e),M=this._convertToCellCoord(r),z=this._convertToCellCoord(o),D=this._convertToCellCoord(l);for(let N=T;N<=z;N++)for(let U=M;U<=D;U++){const Z=this.d*U+N;if((!w||w(this._convertFromCellCoord(N),this._convertFromCellCoord(U),this._convertFromCellCoord(N+1),this._convertFromCellCoord(U+1)))&&h.call(this,e,r,o,l,Z,p,y,w))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,r=3+this.cells.length+1+1;let o=0;for(let p=0;p=0)continue;const p=i[h];l[h]=pr[o].shallow.indexOf(h)>=0?p:Pn(p,e)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return o!=="Object"&&(l.$name=o),l}throw new Error("can't serialize object of type "+typeof i)}function _o(i){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob||Wn(i)||en(i)||ArrayBuffer.isView(i)||i instanceof ImageData)return i;if(Array.isArray(i))return i.map(_o);if(typeof i=="object"){const e=i.$name||"Object";if(!pr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=pr[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const o=Object.create(r.prototype);for(const l of Object.keys(i)){if(l==="$name")continue;const h=i[l];o[l]=pr[e].shallow.indexOf(l)>=0?h:_o(h)}return o}throw new Error("can't deserialize object of type "+typeof i)}class Jo{constructor(){this.first=!0}update(e,r){const o=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=o,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=o,!0):(this.lastFloorZoom>o?(this.lastIntegerZoom=o+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=128&&i<=255,Arabic:i=>i>=1536&&i<=1791,"Arabic Supplement":i=>i>=1872&&i<=1919,"Arabic Extended-A":i=>i>=2208&&i<=2303,"Hangul Jamo":i=>i>=4352&&i<=4607,"Unified Canadian Aboriginal Syllabics":i=>i>=5120&&i<=5759,Khmer:i=>i>=6016&&i<=6143,"Unified Canadian Aboriginal Syllabics Extended":i=>i>=6320&&i<=6399,"General Punctuation":i=>i>=8192&&i<=8303,"Letterlike Symbols":i=>i>=8448&&i<=8527,"Number Forms":i=>i>=8528&&i<=8591,"Miscellaneous Technical":i=>i>=8960&&i<=9215,"Control Pictures":i=>i>=9216&&i<=9279,"Optical Character Recognition":i=>i>=9280&&i<=9311,"Enclosed Alphanumerics":i=>i>=9312&&i<=9471,"Geometric Shapes":i=>i>=9632&&i<=9727,"Miscellaneous Symbols":i=>i>=9728&&i<=9983,"Miscellaneous Symbols and Arrows":i=>i>=11008&&i<=11263,"CJK Radicals Supplement":i=>i>=11904&&i<=12031,"Kangxi Radicals":i=>i>=12032&&i<=12255,"Ideographic Description Characters":i=>i>=12272&&i<=12287,"CJK Symbols and Punctuation":i=>i>=12288&&i<=12351,Hiragana:i=>i>=12352&&i<=12447,Katakana:i=>i>=12448&&i<=12543,Bopomofo:i=>i>=12544&&i<=12591,"Hangul Compatibility Jamo":i=>i>=12592&&i<=12687,Kanbun:i=>i>=12688&&i<=12703,"Bopomofo Extended":i=>i>=12704&&i<=12735,"CJK Strokes":i=>i>=12736&&i<=12783,"Katakana Phonetic Extensions":i=>i>=12784&&i<=12799,"Enclosed CJK Letters and Months":i=>i>=12800&&i<=13055,"CJK Compatibility":i=>i>=13056&&i<=13311,"CJK Unified Ideographs Extension A":i=>i>=13312&&i<=19903,"Yijing Hexagram Symbols":i=>i>=19904&&i<=19967,"CJK Unified Ideographs":i=>i>=19968&&i<=40959,"Yi Syllables":i=>i>=40960&&i<=42127,"Yi Radicals":i=>i>=42128&&i<=42191,"Hangul Jamo Extended-A":i=>i>=43360&&i<=43391,"Hangul Syllables":i=>i>=44032&&i<=55215,"Hangul Jamo Extended-B":i=>i>=55216&&i<=55295,"Private Use Area":i=>i>=57344&&i<=63743,"CJK Compatibility Ideographs":i=>i>=63744&&i<=64255,"Arabic Presentation Forms-A":i=>i>=64336&&i<=65023,"Vertical Forms":i=>i>=65040&&i<=65055,"CJK Compatibility Forms":i=>i>=65072&&i<=65103,"Small Form Variants":i=>i>=65104&&i<=65135,"Arabic Presentation Forms-B":i=>i>=65136&&i<=65279,"Halfwidth and Fullwidth Forms":i=>i>=65280&&i<=65519};function Sa(i){for(const e of i)if(fs(e.charCodeAt(0)))return!0;return!1}function ps(i){for(const e of i)if(!Za(e.charCodeAt(0)))return!1;return!0}function Za(i){return!(Xe.Arabic(i)||Xe["Arabic Supplement"](i)||Xe["Arabic Extended-A"](i)||Xe["Arabic Presentation Forms-A"](i)||Xe["Arabic Presentation Forms-B"](i))}function fs(i){return!(i!==746&&i!==747&&(i<4352||!(Xe["Bopomofo Extended"](i)||Xe.Bopomofo(i)||Xe["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||Xe["CJK Compatibility Ideographs"](i)||Xe["CJK Compatibility"](i)||Xe["CJK Radicals Supplement"](i)||Xe["CJK Strokes"](i)||!(!Xe["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||Xe["CJK Unified Ideographs Extension A"](i)||Xe["CJK Unified Ideographs"](i)||Xe["Enclosed CJK Letters and Months"](i)||Xe["Hangul Compatibility Jamo"](i)||Xe["Hangul Jamo Extended-A"](i)||Xe["Hangul Jamo Extended-B"](i)||Xe["Hangul Jamo"](i)||Xe["Hangul Syllables"](i)||Xe.Hiragana(i)||Xe["Ideographic Description Characters"](i)||Xe.Kanbun(i)||Xe["Kangxi Radicals"](i)||Xe["Katakana Phonetic Extensions"](i)||Xe.Katakana(i)&&i!==12540||!(!Xe["Halfwidth and Fullwidth Forms"](i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!Xe["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||Xe["Unified Canadian Aboriginal Syllabics"](i)||Xe["Unified Canadian Aboriginal Syllabics Extended"](i)||Xe["Vertical Forms"](i)||Xe["Yijing Hexagram Symbols"](i)||Xe["Yi Syllables"](i)||Xe["Yi Radicals"](i))))}function Ls(i){return!(fs(i)||function(e){return!!(Xe["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Xe["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Xe["Letterlike Symbols"](e)||Xe["Number Forms"](e)||Xe["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Xe["Control Pictures"](e)&&e!==9251||Xe["Optical Character Recognition"](e)||Xe["Enclosed Alphanumerics"](e)||Xe["Geometric Shapes"](e)||Xe["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Xe["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Xe["CJK Symbols and Punctuation"](e)||Xe.Katakana(e)||Xe["Private Use Area"](e)||Xe["CJK Compatibility Forms"](e)||Xe["Small Form Variants"](e)||Xe["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(i))}function Ga(i){return i>=1424&&i<=2303||Xe["Arabic Presentation Forms-A"](i)||Xe["Arabic Presentation Forms-B"](i)}function Ds(i,e){return!(!e&&Ga(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||Xe.Khmer(i))}function Ta(i){for(const e of i)if(Ga(e.charCodeAt(0)))return!0;return!1}const Rl="deferred",Ol="loading",Bl="loaded";let Nl=null,zn="unavailable",ms=null;const Wa=function(i){i&&typeof i=="string"&&i.indexOf("NetworkError")>-1&&(zn="error"),Nl&&Nl(i)};function Vl(){Ha.fire(new co("pluginStateChange",{pluginStatus:zn,pluginURL:ms}))}const Ha=new jo,Ul=function(){return zn},Oc=function(){if(zn!==Rl||!ms)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");zn=Ol,Vl(),ms&&Ue({url:ms},i=>{i?Wa(i):(zn=Bl,Vl())})},Hn={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>zn===Bl||Hn.applyArabicShaping!=null,isLoading:()=>zn===Ol,setState(i){if(!pi())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");zn=i.pluginStatus,ms=i.pluginURL},isParsed(){if(!pi())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return Hn.applyArabicShaping!=null&&Hn.processBidirectionalText!=null&&Hn.processStyledBidirectionalText!=null},getPluginURL(){if(!pi())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return ms}};class Yi{constructor(e,r){this.zoom=e,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Jo,this.transition={})}isSupportedScript(e){return function(r,o){for(const l of r)if(!Ds(l.charCodeAt(0),o))return!1;return!0}(e,Hn.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),o=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*o}:{fromScale:.5,toScale:1,t:1-(1-o)*r}}}class fl{constructor(e,r){this.property=e,this.value=r,this.expression=function(o,l){if(Ki(o))return new us(o,l);if(Zn(o)){const h=_a(o,l);if(h.result==="error")throw new Error(h.value.map(p=>`${p.key}: ${p.message}`).join(", "));return h.value}{let h=o;return l.type==="color"&&typeof o=="string"?h=yi.parse(o):l.type!=="padding"||typeof o!="number"&&!Array.isArray(o)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(o)&&(h=Ir.parse(o)):h=qr.parse(o),{kind:"constant",evaluate:()=>h}}}(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,o){return this.property.possiblyEvaluate(this,e,r,o)}}class jl{constructor(e){this.property=e,this.value=new fl(e,void 0)}transitioned(e,r){return new Nc(this.property,this.value,r,Nt({},e.transition,this.transition),e.now)}untransitioned(){return new Nc(this.property,this.value,null,{},0)}}class Bc{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Ge(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new jl(this._values[e].property)),this._values[e].value=new fl(this._values[e].property,r===null?void 0:Ge(r))}getTransition(e){return Ge(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new jl(this._values[e].property)),this._values[e].transition=Ge(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const o=this.getValue(r);o!==void 0&&(e[r]=o);const l=this.getTransition(r);l!==void 0&&(e[`${r}-transition`]=l)}return e}transitioned(e,r){const o=new Vc(this._properties);for(const l of Object.keys(this._values))o._values[l]=this._values[l].transitioned(e,r._values[l]);return o}untransitioned(){const e=new Vc(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Nc{constructor(e,r,o,l,h){this.property=e,this.value=r,this.begin=h+l.delay||0,this.end=this.begin+l.duration||0,e.specification.transition&&(l.delay||l.duration)&&(this.prior=o)}possiblyEvaluate(e,r,o){const l=e.now||0,h=this.value.possiblyEvaluate(e,r,o),p=this.prior;if(p){if(l>this.end)return this.prior=null,h;if(this.value.isDataDriven())return this.prior=null,h;if(l=1)return 1;const T=w*w,M=T*w;return 4*(w<.5?M:3*(w-T)+M-.75)}(y))}}return h}}class Vc{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,o){const l=new ml(this._properties);for(const h of Object.keys(this._values))l._values[h]=this._values[h].possiblyEvaluate(e,r,o);return l}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class bu{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return Ge(this._values[e].value)}setValue(e,r){this._values[e]=new fl(this._values[e].property,r===null?void 0:Ge(r))}serialize(){const e={};for(const r of Object.keys(this._values)){const o=this.getValue(r);o!==void 0&&(e[r]=o)}return e}possiblyEvaluate(e,r,o){const l=new ml(this._properties);for(const h of Object.keys(this._values))l._values[h]=this._values[h].possiblyEvaluate(e,r,o);return l}}class vn{constructor(e,r,o){this.property=e,this.value=r,this.parameters=o}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,o,l){return this.property.evaluate(this.value,this.parameters,e,r,o,l)}}class ml{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class xt{constructor(e){this.specification=e}possiblyEvaluate(e,r){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(r)}interpolate(e,r,o){const l=Hr[this.specification.type];return l?l(e,r,o):e}}class Et{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,o,l){return new vn(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},o,l)}:e.expression,r)}interpolate(e,r,o){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new vn(this,{kind:"constant",value:void 0},e.parameters);const l=Hr[this.specification.type];if(l){const h=l(e.value.value,r.value.value,o);return new vn(this,{kind:"constant",value:h},e.parameters)}return e}evaluate(e,r,o,l,h,p){return e.kind==="constant"?e.value:e.evaluate(r,o,l,h,p)}}class Xa extends Et{possiblyEvaluate(e,r,o,l){if(e.value===void 0)return new vn(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const h=e.expression.evaluate(r,null,{},o,l),p=e.property.specification.type==="resolvedImage"&&typeof h!="string"?h.name:h,y=this._calculate(p,p,p,r);return new vn(this,{kind:"constant",value:y},r)}if(e.expression.kind==="camera"){const h=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new vn(this,{kind:"constant",value:h},r)}return new vn(this,e.expression,r)}evaluate(e,r,o,l,h,p){if(e.kind==="source"){const y=e.evaluate(r,o,l,h,p);return this._calculate(y,y,y,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},o,l),e.evaluate({zoom:Math.floor(r.zoom)},o,l),e.evaluate({zoom:Math.floor(r.zoom)+1},o,l),r):e.value}_calculate(e,r,o,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:o,to:r}}interpolate(e){return e}}class ql{constructor(e){this.specification=e}possiblyEvaluate(e,r,o,l){if(e.value!==void 0){if(e.expression.kind==="constant"){const h=e.expression.evaluate(r,null,{},o,l);return this._calculate(h,h,h,r)}return this._calculate(e.expression.evaluate(new Yi(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Yi(Math.floor(r.zoom),r)),e.expression.evaluate(new Yi(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,o,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:o,to:r}}interpolate(e){return e}}class Zl{constructor(e){this.specification=e}possiblyEvaluate(e,r,o,l){return!!e.expression.evaluate(r,null,{},o,l)}interpolate(){return!1}}class br{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const o=e[r];o.specification.overridable&&this.overridableProperties.push(r);const l=this.defaultPropertyValues[r]=new fl(o,void 0),h=this.defaultTransitionablePropertyValues[r]=new jl(o);this.defaultTransitioningPropertyValues[r]=h.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}tt("DataDrivenProperty",Et),tt("DataConstantProperty",xt),tt("CrossFadedDataDrivenProperty",Xa),tt("CrossFadedProperty",ql),tt("ColorRampProperty",Zl);const Gl="-transition";class so extends jo{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new bu(r.layout)),r.paint)){this._transitionablePaint=new Bc(r.paint);for(const o in e.paint)this.setPaintProperty(o,e.paint[o],{validate:!1});for(const o in e.layout)this.setLayoutProperty(o,e.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ml(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,o={}){r!=null&&this._validate(zs,`layers.${this.id}.layout.${e}`,e,r,o)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(Gl)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,o={}){if(r!=null&&this._validate(wi,`layers.${this.id}.paint.${e}`,e,r,o))return!1;if(e.endsWith(Gl))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const l=this._transitionablePaint._values[e],h=l.property.specification["property-type"]==="cross-faded-data-driven",p=l.value.isDataDriven(),y=l.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const w=this._transitionablePaint._values[e].value;return w.isDataDriven()||p||h||this._handleOverridablePaintPropertyUpdate(e,y,w)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,o){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),ke(e,(r,o)=>!(r===void 0||o==="layout"&&!Object.keys(r).length||o==="paint"&&!Object.keys(r).length))}_validate(e,r,o,l,h={}){return(!h||h.validate!==!1)&&Gn(this,e.call(mo,{key:r,layerType:this.type,objectKey:o,value:l,styleSpec:Se,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof vn&&Co(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const Uc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Fs{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class cr{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_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 r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function or(i,e=1){let r=0,o=0;return{members:i.map(l=>{const h=Uc[l.type].BYTES_PER_ELEMENT,p=r=Ia(r,Math.max(e,h)),y=l.components||1;return o=Math.max(o,h),r+=h*y,{name:l.name,type:l.type,components:y,offset:p}}),size:Ia(r,Math.max(o,e)),alignment:e}}function Ia(i,e){return Math.ceil(i/e)*e}class Ka extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,r)}emplace(e,r,o){const l=2*e;return this.int16[l+0]=r,this.int16[l+1]=o,e}}Ka.prototype.bytesPerElement=4,tt("StructArrayLayout2i4",Ka);class Ja extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.int16[h+0]=r,this.int16[h+1]=o,this.int16[h+2]=l,e}}Ja.prototype.bytesPerElement=6,tt("StructArrayLayout3i6",Ja);class Rs extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,o,l)}emplace(e,r,o,l,h){const p=4*e;return this.int16[p+0]=r,this.int16[p+1]=o,this.int16[p+2]=l,this.int16[p+3]=h,e}}Rs.prototype.bytesPerElement=8,tt("StructArrayLayout4i8",Rs);class Wl extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,o,l,h,p)}emplace(e,r,o,l,h,p,y){const w=6*e;return this.int16[w+0]=r,this.int16[w+1]=o,this.int16[w+2]=l,this.int16[w+3]=h,this.int16[w+4]=p,this.int16[w+5]=y,e}}Wl.prototype.bytesPerElement=12,tt("StructArrayLayout2i4i12",Wl);class Hl extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,o,l,h,p)}emplace(e,r,o,l,h,p,y){const w=4*e,T=8*e;return this.int16[w+0]=r,this.int16[w+1]=o,this.uint8[T+4]=l,this.uint8[T+5]=h,this.uint8[T+6]=p,this.uint8[T+7]=y,e}}Hl.prototype.bytesPerElement=8,tt("StructArrayLayout2i4ub8",Hl);class Ea extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,r)}emplace(e,r,o){const l=2*e;return this.float32[l+0]=r,this.float32[l+1]=o,e}}Ea.prototype.bytesPerElement=8,tt("StructArrayLayout2f8",Ea);class Xl extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T,M){const z=this.length;return this.resize(z+1),this.emplace(z,e,r,o,l,h,p,y,w,T,M)}emplace(e,r,o,l,h,p,y,w,T,M,z){const D=10*e;return this.uint16[D+0]=r,this.uint16[D+1]=o,this.uint16[D+2]=l,this.uint16[D+3]=h,this.uint16[D+4]=p,this.uint16[D+5]=y,this.uint16[D+6]=w,this.uint16[D+7]=T,this.uint16[D+8]=M,this.uint16[D+9]=z,e}}Xl.prototype.bytesPerElement=20,tt("StructArrayLayout10ui20",Xl);class Kl extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T,M,z,D){const N=this.length;return this.resize(N+1),this.emplace(N,e,r,o,l,h,p,y,w,T,M,z,D)}emplace(e,r,o,l,h,p,y,w,T,M,z,D,N){const U=12*e;return this.int16[U+0]=r,this.int16[U+1]=o,this.int16[U+2]=l,this.int16[U+3]=h,this.uint16[U+4]=p,this.uint16[U+5]=y,this.uint16[U+6]=w,this.uint16[U+7]=T,this.int16[U+8]=M,this.int16[U+9]=z,this.int16[U+10]=D,this.int16[U+11]=N,e}}Kl.prototype.bytesPerElement=24,tt("StructArrayLayout4i4ui4i24",Kl);class Si extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.float32[h+0]=r,this.float32[h+1]=o,this.float32[h+2]=l,e}}Si.prototype.bytesPerElement=12,tt("StructArrayLayout3f12",Si);class u extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}u.prototype.bytesPerElement=4,tt("StructArrayLayout1ul4",u);class t extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T){const M=this.length;return this.resize(M+1),this.emplace(M,e,r,o,l,h,p,y,w,T)}emplace(e,r,o,l,h,p,y,w,T,M){const z=10*e,D=5*e;return this.int16[z+0]=r,this.int16[z+1]=o,this.int16[z+2]=l,this.int16[z+3]=h,this.int16[z+4]=p,this.int16[z+5]=y,this.uint32[D+3]=w,this.uint16[z+8]=T,this.uint16[z+9]=M,e}}t.prototype.bytesPerElement=20,tt("StructArrayLayout6i1ul2ui20",t);class n extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,o,l,h,p)}emplace(e,r,o,l,h,p,y){const w=6*e;return this.int16[w+0]=r,this.int16[w+1]=o,this.int16[w+2]=l,this.int16[w+3]=h,this.int16[w+4]=p,this.int16[w+5]=y,e}}n.prototype.bytesPerElement=12,tt("StructArrayLayout2i2i2i12",n);class a extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,r,o,l,h)}emplace(e,r,o,l,h,p){const y=4*e,w=8*e;return this.float32[y+0]=r,this.float32[y+1]=o,this.float32[y+2]=l,this.int16[w+6]=h,this.int16[w+7]=p,e}}a.prototype.bytesPerElement=16,tt("StructArrayLayout2f1f2i16",a);class c extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,o,l)}emplace(e,r,o,l,h){const p=12*e,y=3*e;return this.uint8[p+0]=r,this.uint8[p+1]=o,this.float32[y+1]=l,this.float32[y+2]=h,e}}c.prototype.bytesPerElement=12,tt("StructArrayLayout2ub2f12",c);class d extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.uint16[h+0]=r,this.uint16[h+1]=o,this.uint16[h+2]=l,e}}d.prototype.bytesPerElement=6,tt("StructArrayLayout3ui6",d);class x extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T,M,z,D,N,U,Z,$,ie){const ue=this.length;return this.resize(ue+1),this.emplace(ue,e,r,o,l,h,p,y,w,T,M,z,D,N,U,Z,$,ie)}emplace(e,r,o,l,h,p,y,w,T,M,z,D,N,U,Z,$,ie,ue){const re=24*e,pe=12*e,ye=48*e;return this.int16[re+0]=r,this.int16[re+1]=o,this.uint16[re+2]=l,this.uint16[re+3]=h,this.uint32[pe+2]=p,this.uint32[pe+3]=y,this.uint32[pe+4]=w,this.uint16[re+10]=T,this.uint16[re+11]=M,this.uint16[re+12]=z,this.float32[pe+7]=D,this.float32[pe+8]=N,this.uint8[ye+36]=U,this.uint8[ye+37]=Z,this.uint8[ye+38]=$,this.uint32[pe+10]=ie,this.int16[re+22]=ue,e}}x.prototype.bytesPerElement=48,tt("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",x);class b extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T,M,z,D,N,U,Z,$,ie,ue,re,pe,ye,Ae,lt,pt,st,$e,Ze,ht){const Ke=this.length;return this.resize(Ke+1),this.emplace(Ke,e,r,o,l,h,p,y,w,T,M,z,D,N,U,Z,$,ie,ue,re,pe,ye,Ae,lt,pt,st,$e,Ze,ht)}emplace(e,r,o,l,h,p,y,w,T,M,z,D,N,U,Z,$,ie,ue,re,pe,ye,Ae,lt,pt,st,$e,Ze,ht,Ke){const Be=32*e,bt=16*e;return this.int16[Be+0]=r,this.int16[Be+1]=o,this.int16[Be+2]=l,this.int16[Be+3]=h,this.int16[Be+4]=p,this.int16[Be+5]=y,this.int16[Be+6]=w,this.int16[Be+7]=T,this.uint16[Be+8]=M,this.uint16[Be+9]=z,this.uint16[Be+10]=D,this.uint16[Be+11]=N,this.uint16[Be+12]=U,this.uint16[Be+13]=Z,this.uint16[Be+14]=$,this.uint16[Be+15]=ie,this.uint16[Be+16]=ue,this.uint16[Be+17]=re,this.uint16[Be+18]=pe,this.uint16[Be+19]=ye,this.uint16[Be+20]=Ae,this.uint16[Be+21]=lt,this.uint16[Be+22]=pt,this.uint32[bt+12]=st,this.float32[bt+13]=$e,this.float32[bt+14]=Ze,this.uint16[Be+30]=ht,this.uint16[Be+31]=Ke,e}}b.prototype.bytesPerElement=64,tt("StructArrayLayout8i15ui1ul2f2ui64",b);class S extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}S.prototype.bytesPerElement=4,tt("StructArrayLayout1f4",S);class C extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.uint16[6*e+0]=r,this.float32[h+1]=o,this.float32[h+2]=l,e}}C.prototype.bytesPerElement=12,tt("StructArrayLayout1ui2f12",C);class A extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=4*e;return this.uint32[2*e+0]=r,this.uint16[h+2]=o,this.uint16[h+3]=l,e}}A.prototype.bytesPerElement=8,tt("StructArrayLayout1ul2ui8",A);class P extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,r)}emplace(e,r,o){const l=2*e;return this.uint16[l+0]=r,this.uint16[l+1]=o,e}}P.prototype.bytesPerElement=4,tt("StructArrayLayout2ui4",P);class R extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}R.prototype.bytesPerElement=2,tt("StructArrayLayout1ui2",R);class W extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,o,l)}emplace(e,r,o,l,h){const p=4*e;return this.float32[p+0]=r,this.float32[p+1]=o,this.float32[p+2]=l,this.float32[p+3]=h,e}}W.prototype.bytesPerElement=16,tt("StructArrayLayout4f16",W);class G extends Fs{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new ge(this.anchorPointX,this.anchorPointY)}}G.prototype.size=20;class K extends t{get(e){return new G(this,e)}}tt("CollisionBoxArray",K);class q extends Fs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}q.prototype.size=48;class le extends x{get(e){return new q(this,e)}}tt("PlacedSymbolArray",le);class _e extends Fs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}_e.prototype.size=64;class ee extends b{get(e){return new _e(this,e)}}tt("SymbolInstanceArray",ee);class ce extends S{getoffsetX(e){return this.float32[1*e+0]}}tt("GlyphOffsetArray",ce);class ve extends Ja{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}tt("SymbolLineVertexArray",ve);class xe extends Fs{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}xe.prototype.size=12;class Me extends C{get(e){return new xe(this,e)}}tt("TextAnchorOffsetArray",Me);class Oe extends Fs{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]}}Oe.prototype.size=8;class ze extends A{get(e){return new Oe(this,e)}}tt("FeatureIndexArray",ze);class je extends Ka{}class dt extends Ka{}class $t extends Ka{}class Qe extends Wl{}class Ct extends Hl{}class gt extends Ea{}class Mi extends Xl{}class Jt extends Kl{}class jt extends Si{}class ei extends u{}class fr extends n{}class qi extends c{}class Kr extends d{}class Pr extends P{}const wr=or([{name:"a_pos",components:2,type:"Int16"}],4),{members:Xn}=wr;class Qi{constructor(e=[]){this.segments=e}prepareSegment(e,r,o,l){let h=this.segments[this.segments.length-1];return e>Qi.MAX_VERTEX_ARRAY_LENGTH&&Dt(`Max vertices per segment is ${Qi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!h||h.vertexLength+e>Qi.MAX_VERTEX_ARRAY_LENGTH||h.sortKey!==l)&&(h={vertexOffset:r.length,primitiveOffset:o.length,vertexLength:0,primitiveLength:0},l!==void 0&&(h.sortKey=l),this.segments.push(h)),h}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,o,l){return new Qi([{vertexOffset:e,primitiveOffset:r,vertexLength:o,primitiveLength:l,vaos:{},sortKey:0}])}}function Do(i,e){return 256*(i=ti(Math.floor(i),0,255))+ti(Math.floor(e),0,255)}Qi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,tt("SegmentVector",Qi);const Fo=or([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var _s={exports:{}},Os={exports:{}};Os.exports=function(i,e){var r,o,l,h,p,y,w,T;for(o=i.length-(r=3&i.length),l=e,p=3432918353,y=461845907,T=0;T>>16)*p&65535)<<16)&4294967295)<<15|w>>>17))*y+(((w>>>16)*y&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(h>>>16)&65535)<<16);switch(w=0,r){case 3:w^=(255&i.charCodeAt(T+2))<<16;case 2:w^=(255&i.charCodeAt(T+1))<<8;case 1:l^=w=(65535&(w=(w=(65535&(w^=255&i.charCodeAt(T)))*p+(((w>>>16)*p&65535)<<16)&4294967295)<<15|w>>>17))*y+(((w>>>16)*y&65535)<<16)&4294967295}return l^=i.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0};var Ca=Os.exports,cn={exports:{}};cn.exports=function(i,e){for(var r,o=i.length,l=e^o,h=0;o>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(h)|(255&i.charCodeAt(++h))<<8|(255&i.charCodeAt(++h))<<16|(255&i.charCodeAt(++h))<<24))+((1540483477*(r>>>16)&65535)<<16),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),o-=4,++h;switch(o){case 3:l^=(255&i.charCodeAt(h+2))<<16;case 2:l^=(255&i.charCodeAt(h+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(h)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var Jr=Ca,xn=cn.exports;_s.exports=Jr,_s.exports.murmur3=Jr,_s.exports.murmur2=xn;var Bs=V(_s.exports);class mr{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,o,l){this.ids.push(zr(e)),this.positions.push(r,o,l)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=zr(e);let o=0,l=this.ids.length-1;for(;o>1;this.ids[p]>=r?l=p:o=p+1}const h=[];for(;this.ids[o]===r;)h.push({index:this.positions[3*o],start:this.positions[3*o+1],end:this.positions[3*o+2]}),o++;return h}static serialize(e,r){const o=new Float64Array(e.ids),l=new Uint32Array(e.positions);return Ln(o,l,0,o.length-1),r&&r.push(o.buffer,l.buffer),{ids:o,positions:l}}static deserialize(e){const r=new mr;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function zr(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Bs(String(i))}function Ln(i,e,r,o){for(;r>1];let h=r-1,p=o+1;for(;;){do h++;while(i[h]l);if(h>=p)break;_r(i,h,p),_r(e,3*h,3*p),_r(e,3*h+1,3*p+1),_r(e,3*h+2,3*p+2)}p-r`u_${l}`),this.type=o}setUniform(e,r,o){e.set(o.constantOr(this.value))}getBinding(e,r,o){return this.type==="color"?new qc(e,r):new _l(e,r)}}class Vs{constructor(e,r){this.uniformNames=r.map(o=>`u_${o}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setUniform(e,r,o,l){const h=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;h&&e.set(h)}getBinding(e,r,o){return o.substr(0,9)==="u_pattern"?new jc(e,r):new _l(e,r)}}class Oo{constructor(e,r,o,l){this.expression=e,this.type=o,this.maxValue=0,this.paintVertexAttributes=r.map(h=>({name:`a_${h}`,type:"Float32",components:o==="color"?2:1,offset:0})),this.paintVertexArray=new l}populatePaintArray(e,r,o,l,h){const p=this.paintVertexArray.length,y=this.expression.evaluate(new Yi(0),r,{},l,[],h);this.paintVertexArray.resize(e),this._setPaintValue(p,e,y)}updatePaintArray(e,r,o,l){const h=this.expression.evaluate({zoom:0},o,l);this._setPaintValue(e,r,h)}_setPaintValue(e,r,o){if(this.type==="color"){const l=Jl(o);for(let h=e;h`u_${y}_t`),this.type=o,this.useIntegerZoom=l,this.zoom=h,this.maxValue=0,this.paintVertexAttributes=r.map(y=>({name:`a_${y}`,type:"Float32",components:o==="color"?4:2,offset:0})),this.paintVertexArray=new p}populatePaintArray(e,r,o,l,h){const p=this.expression.evaluate(new Yi(this.zoom),r,{},l,[],h),y=this.expression.evaluate(new Yi(this.zoom+1),r,{},l,[],h),w=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(w,e,p,y)}updatePaintArray(e,r,o,l){const h=this.expression.evaluate({zoom:this.zoom},o,l),p=this.expression.evaluate({zoom:this.zoom+1},o,l);this._setPaintValue(e,r,h,p)}_setPaintValue(e,r,o,l){if(this.type==="color"){const h=Jl(o),p=Jl(l);for(let y=e;y`#define HAS_UNIFORM_${l}`))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const o=this.binders[r];if(o instanceof Oo||o instanceof ao)for(let l=0;l!0){this.programConfigurations={};for(const l of e)this.programConfigurations[l.id]=new Yl(l,r,o);this.needsUpload=!1,this._featureMap=new mr,this._bufferOffset=0}populatePaintArrays(e,r,o,l,h,p){for(const y in this.programConfigurations)this.programConfigurations[y].populatePaintArrays(e,r,l,h,p);r.id!==void 0&&this._featureMap.add(r.id,o,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,o,l){for(const h of o)this.needsUpload=this.programConfigurations[h.id].updatePaintArrays(e,this._featureMap,r,h,l)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function pf(i,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}function Lh(i,e,r){const o={color:{source:Ea,composite:W},number:{source:S,composite:Ea}},l=function(h){return{"line-pattern":{source:Mi,composite:Mi},"fill-pattern":{source:Mi,composite:Mi},"fill-extrusion-pattern":{source:Mi,composite:Mi}}[h]}(i);return l&&l[r]||o[e][r]}tt("ConstantBinder",Ro),tt("CrossFadedConstantBinder",Vs),tt("SourceExpressionBinder",Oo),tt("CrossFadedCompositeBinder",Bo),tt("CompositeExpressionBinder",ao),tt("ProgramConfiguration",Yl,{omit:["_buffers"]}),tt("ProgramConfigurationSet",Yo);const Cr=8192,Su=Math.pow(2,14)-1,Dh=-Su-1;function Ya(i){const e=Cr/i.extent,r=i.loadGeometry();for(let o=0;op.x+1||wp.y+1)&&Dt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function Qa(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?Ya(i):[]}}function Zc(i,e,r,o,l){i.emplaceBack(2*e+(o+1)/2,2*r+(l+1)/2)}class Tu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new dt,this.indexArray=new Kr,this.segments=new Qi,this.programConfigurations=new Yo(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){const l=this.layers[0],h=[];let p=null,y=!1;l.type==="circle"&&(p=l.layout.get("circle-sort-key"),y=!p.isConstant());for(const{feature:w,id:T,index:M,sourceLayerIndex:z}of e){const D=this.layers[0]._featureFilter.needGeometry,N=Qa(w,D);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom),N,o))continue;const U=y?p.evaluate(N,{},o):void 0,Z={id:T,properties:w.properties,type:w.type,sourceLayerIndex:z,index:M,geometry:D?N.geometry:Ya(w),patterns:{},sortKey:U};h.push(Z)}y&&h.sort((w,T)=>w.sortKey-T.sortKey);for(const w of h){const{geometry:T,index:M,sourceLayerIndex:z}=w,D=e[M].feature;this.addFeature(w,T,M,o),r.featureIndex.insert(D,T,M,z,this.index)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Xn),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,o,l){for(const h of r)for(const p of h){const y=p.x,w=p.y;if(y<0||y>=Cr||w<0||w>=Cr)continue;const T=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),M=T.vertexLength;Zc(this.layoutVertexArray,y,w,-1,-1),Zc(this.layoutVertexArray,y,w,1,-1),Zc(this.layoutVertexArray,y,w,1,1),Zc(this.layoutVertexArray,y,w,-1,1),this.indexArray.emplaceBack(M,M+1,M+2),this.indexArray.emplaceBack(M,M+3,M+2),T.vertexLength+=4,T.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,{},l)}}function Fh(i,e){for(let r=0;r1){if(Iu(i,e))return!0;for(let o=0;o1?r:r.sub(e)._mult(l)._add(e))}function Bh(i,e){let r,o,l,h=!1;for(let p=0;pe.y!=l.y>e.y&&e.x<(l.x-o.x)*(e.y-o.y)/(l.y-o.y)+o.x&&(h=!h)}return h}function gl(i,e){let r=!1;for(let o=0,l=i.length-1;oe.y!=p.y>e.y&&e.x<(p.x-h.x)*(e.y-h.y)/(p.y-h.y)+h.x&&(r=!r)}return r}function gf(i,e,r){const o=r[0],l=r[2];if(i.xl.x&&e.x>l.x||i.yl.y&&e.y>l.y)return!1;const h=qt(i,e,r[0]);return h!==qt(i,e,r[1])||h!==qt(i,e,r[2])||h!==qt(i,e,r[3])}function Ql(i,e,r){const o=e.paint.get(i).value;return o.kind==="constant"?o.value:r.programConfigurations.get(e.id).getMaxValue(i)}function Gc(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Wc(i,e,r,o,l){if(!e[0]&&!e[1])return i;const h=ge.convert(e)._mult(l);r==="viewport"&&h._rotate(-o);const p=[];for(let y=0;yjh($,Z))}(T,w),N=z?M*y:M;for(const U of l)for(const Z of U){const $=z?Z:jh(Z,w);let ie=N;const ue=Hc([],[Z.x,Z.y,0,1],w);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?ie*=ue[3]/p.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(ie*=p.cameraToCenterDistance/ue[3]),ff(D,$,ie))return!0}return!1}}function jh(i,e){const r=Hc([],[i.x,i.y,0,1],e);return new ge(r[0]/r[3],r[1]/r[3])}class qh extends Tu{}let Zh;tt("HeatmapBucket",qh,{omit:["layers"]});var bf={get paint(){return Zh=Zh||new br({"heatmap-radius":new Et(Se.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Et(Se.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new xt(Se.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Zl(Se.paint_heatmap["heatmap-color"]),"heatmap-opacity":new xt(Se.paint_heatmap["heatmap-opacity"])})}};function Mu(i,{width:e,height:r},o,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==e*r*o)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${e*r*o}`)}else l=new Uint8Array(e*r*o);return i.width=e,i.height=r,i.data=l,i}function Gh(i,{width:e,height:r},o){if(e===i.width&&r===i.height)return;const l=Mu({},{width:e,height:r},o);Au(i,l,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},o),i.width=e,i.height=r,i.data=l.data}function Au(i,e,r,o,l,h){if(l.width===0||l.height===0)return e;if(l.width>i.width||l.height>i.height||r.x>i.width-l.width||r.y>i.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>e.width||l.height>e.height||o.x>e.width-l.width||o.y>e.height-l.height)throw new RangeError("out of range destination coordinates for image copy");const p=i.data,y=e.data;if(p===y)throw new Error("srcData equals dstData, so image is already copied");for(let w=0;w{e[i.evaluationKey]=w;const T=i.expression.evaluate(e);l.data[p+y+0]=Math.floor(255*T.r/T.a),l.data[p+y+1]=Math.floor(255*T.g/T.a),l.data[p+y+2]=Math.floor(255*T.b/T.a),l.data[p+y+3]=Math.floor(255*T.a)};if(i.clips)for(let p=0,y=0;p80*r){o=h=i[0],l=p=i[1];for(var U=r;Uh&&(h=y),w>p&&(p=w);T=(T=Math.max(h-o,p-l))!==0?32767/T:0}return tc(D,N,r,o,l,T,0),N}function Xh(i,e,r,o,l){var h,p;if(l===Lu(i,e,r,o)>0)for(h=e;h=e;h-=o)p=Yh(h,i[h],i[h+1],p);return p&&Kc(p,p.next)&&(rc(p),p=p.next),p}function $a(i,e){if(!i)return i;e||(e=i);var r,o=i;do if(r=!1,o.steiner||!Kc(o,o.next)&&Sr(o.prev,o,o.next)!==0)o=o.next;else{if(rc(o),(o=e=o.prev)===o.next)break;r=!0}while(r||o!==e);return e}function tc(i,e,r,o,l,h,p){if(i){!p&&h&&function(M,z,D,N){var U=M;do U.z===0&&(U.z=Pu(U.x,U.y,z,D,N)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==M);U.prevZ.nextZ=null,U.prevZ=null,function(Z){var $,ie,ue,re,pe,ye,Ae,lt,pt=1;do{for(ie=Z,Z=null,pe=null,ye=0;ie;){for(ye++,ue=ie,Ae=0,$=0;$0||lt>0&&ue;)Ae!==0&&(lt===0||!ue||ie.z<=ue.z)?(re=ie,ie=ie.nextZ,Ae--):(re=ue,ue=ue.nextZ,lt--),pe?pe.nextZ=re:Z=re,re.prevZ=pe,pe=re;ie=ue}pe.nextZ=null,pt*=2}while(ye>1)}(U)}(i,o,l,h);for(var y,w,T=i;i.prev!==i.next;)if(y=i.prev,w=i.next,h?Mf(i,o,l,h):Cf(i))e.push(y.i/r|0),e.push(i.i/r|0),e.push(w.i/r|0),rc(i),i=w.next,T=w.next;else if((i=w)===T){p?p===1?tc(i=Af($a(i),e,r),e,r,o,l,h,2):p===2&&kf(i,e,r,o,l,h):tc($a(i),e,r,o,l,h,1);break}}}function Cf(i){var e=i.prev,r=i,o=i.next;if(Sr(e,r,o)>=0)return!1;for(var l=e.x,h=r.x,p=o.x,y=e.y,w=r.y,T=o.y,M=lh?l>p?l:p:h>p?h:p,N=y>w?y>T?y:T:w>T?w:T,U=o.next;U!==e;){if(U.x>=M&&U.x<=D&&U.y>=z&&U.y<=N&&vl(l,y,h,w,p,T,U.x,U.y)&&Sr(U.prev,U,U.next)>=0)return!1;U=U.next}return!0}function Mf(i,e,r,o){var l=i.prev,h=i,p=i.next;if(Sr(l,h,p)>=0)return!1;for(var y=l.x,w=h.x,T=p.x,M=l.y,z=h.y,D=p.y,N=yw?y>T?y:T:w>T?w:T,$=M>z?M>D?M:D:z>D?z:D,ie=Pu(N,U,e,r,o),ue=Pu(Z,$,e,r,o),re=i.prevZ,pe=i.nextZ;re&&re.z>=ie&&pe&&pe.z<=ue;){if(re.x>=N&&re.x<=Z&&re.y>=U&&re.y<=$&&re!==l&&re!==p&&vl(y,M,w,z,T,D,re.x,re.y)&&Sr(re.prev,re,re.next)>=0||(re=re.prevZ,pe.x>=N&&pe.x<=Z&&pe.y>=U&&pe.y<=$&&pe!==l&&pe!==p&&vl(y,M,w,z,T,D,pe.x,pe.y)&&Sr(pe.prev,pe,pe.next)>=0))return!1;pe=pe.nextZ}for(;re&&re.z>=ie;){if(re.x>=N&&re.x<=Z&&re.y>=U&&re.y<=$&&re!==l&&re!==p&&vl(y,M,w,z,T,D,re.x,re.y)&&Sr(re.prev,re,re.next)>=0)return!1;re=re.prevZ}for(;pe&&pe.z<=ue;){if(pe.x>=N&&pe.x<=Z&&pe.y>=U&&pe.y<=$&&pe!==l&&pe!==p&&vl(y,M,w,z,T,D,pe.x,pe.y)&&Sr(pe.prev,pe,pe.next)>=0)return!1;pe=pe.nextZ}return!0}function Af(i,e,r){var o=i;do{var l=o.prev,h=o.next.next;!Kc(l,h)&&Kh(l,o,o.next,h)&&ic(l,h)&&ic(h,l)&&(e.push(l.i/r|0),e.push(o.i/r|0),e.push(h.i/r|0),rc(o),rc(o.next),o=i=h),o=o.next}while(o!==i);return $a(o)}function kf(i,e,r,o,l,h){var p=i;do{for(var y=p.next.next;y!==p.prev;){if(p.i!==y.i&&Ff(p,y)){var w=Jh(p,y);return p=$a(p,p.next),w=$a(w,w.next),tc(p,e,r,o,l,h,0),void tc(w,e,r,o,l,h,0)}y=y.next}p=p.next}while(p!==i)}function Pf(i,e){return i.x-e.x}function zf(i,e){var r=function(l,h){var p,y=h,w=l.x,T=l.y,M=-1/0;do{if(T<=y.y&&T>=y.next.y&&y.next.y!==y.y){var z=y.x+(T-y.y)*(y.next.x-y.x)/(y.next.y-y.y);if(z<=w&&z>M&&(M=z,p=y.x=y.x&&y.x>=U&&w!==y.x&&vl(Tp.x||y.x===p.x&&Lf(p,y)))&&(p=y,$=D)),y=y.next;while(y!==N);return p}(i,e);if(!r)return e;var o=Jh(r,i);return $a(o,o.next),$a(r,r.next)}function Lf(i,e){return Sr(i.prev,i,e.prev)<0&&Sr(e.next,i,i.next)<0}function Pu(i,e,r,o,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-o)*l|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Df(i){var e=i,r=i;do(e.x=(i-p)*(h-y)&&(i-p)*(o-y)>=(r-p)*(e-y)&&(r-p)*(h-y)>=(l-p)*(o-y)}function Ff(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!function(r,o){var l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==o.i&&l.next.i!==o.i&&Kh(l,l.next,r,o))return!0;l=l.next}while(l!==r);return!1}(i,e)&&(ic(i,e)&&ic(e,i)&&function(r,o){var l=r,h=!1,p=(r.x+o.x)/2,y=(r.y+o.y)/2;do l.y>y!=l.next.y>y&&l.next.y!==l.y&&p<(l.next.x-l.x)*(y-l.y)/(l.next.y-l.y)+l.x&&(h=!h),l=l.next;while(l!==r);return h}(i,e)&&(Sr(i.prev,i,e.prev)||Sr(i,e.prev,e))||Kc(i,e)&&Sr(i.prev,i,i.next)>0&&Sr(e.prev,e,e.next)>0)}function Sr(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function Kc(i,e){return i.x===e.x&&i.y===e.y}function Kh(i,e,r,o){var l=Yc(Sr(i,e,r)),h=Yc(Sr(i,e,o)),p=Yc(Sr(r,o,i)),y=Yc(Sr(r,o,e));return l!==h&&p!==y||!(l!==0||!Jc(i,r,e))||!(h!==0||!Jc(i,o,e))||!(p!==0||!Jc(r,i,o))||!(y!==0||!Jc(r,e,o))}function Jc(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function Yc(i){return i>0?1:i<0?-1:0}function ic(i,e){return Sr(i.prev,i,i.next)<0?Sr(i,e,i.next)>=0&&Sr(i,i.prev,e)>=0:Sr(i,e,i.prev)<0||Sr(i,i.next,e)<0}function Jh(i,e){var r=new zu(i.i,i.x,i.y),o=new zu(e.i,e.x,e.y),l=i.next,h=e.prev;return i.next=e,e.prev=i,r.next=l,l.prev=r,o.next=r,r.prev=o,h.next=o,o.prev=h,o}function Yh(i,e,r,o){var l=new zu(i,e,r);return o?(l.next=o.next,l.prev=o,o.next.prev=l,o.next=l):(l.prev=l,l.next=l),l}function rc(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function zu(i,e,r){this.i=i,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Lu(i,e,r,o){for(var l=0,h=e,p=r-o;h0&&r.holes.push(o+=i[l-1].length)}return r};var Qh=V(ku.exports);function Rf(i,e,r,o,l){$h(i,e,r||0,o||i.length-1,l||Of)}function $h(i,e,r,o,l){for(;o>r;){if(o-r>600){var h=o-r+1,p=e-r+1,y=Math.log(h),w=.5*Math.exp(2*y/3),T=.5*Math.sqrt(y*w*(h-w)/h)*(p-h/2<0?-1:1);$h(i,e,Math.max(r,Math.floor(e-p*w/h+T)),Math.min(o,Math.floor(e+(h-p)*w/h+T)),l)}var M=i[e],z=r,D=o;for(nc(i,r,e),l(i[o],M)>0&&nc(i,r,o);z0;)D--}l(i[r],M)===0?nc(i,r,D):nc(i,++D,o),D<=e&&(r=D+1),e<=D&&(o=D-1)}}function nc(i,e,r){var o=i[e];i[e]=i[r],i[r]=o}function Of(i,e){return ie?1:0}function Du(i,e){const r=i.length;if(r<=1)return[i];const o=[];let l,h;for(let p=0;p1)for(let p=0;pr.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $t,this.indexArray=new Kr,this.indexArray2=new Pr,this.programConfigurations=new Yo(e.layers,e.zoom),this.segments=new Qi,this.segments2=new Qi,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){this.hasPattern=Fu("fill",this.layers,r);const l=this.layers[0].layout.get("fill-sort-key"),h=!l.isConstant(),p=[];for(const{feature:y,id:w,index:T,sourceLayerIndex:M}of e){const z=this.layers[0]._featureFilter.needGeometry,D=Qa(y,z);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom),D,o))continue;const N=h?l.evaluate(D,{},o,r.availableImages):void 0,U={id:w,properties:y.properties,type:y.type,sourceLayerIndex:M,index:T,geometry:z?D.geometry:Ya(y),patterns:{},sortKey:N};p.push(U)}h&&p.sort((y,w)=>y.sortKey-w.sortKey);for(const y of p){const{geometry:w,index:T,sourceLayerIndex:M}=y;if(this.hasPattern){const z=Ru("fill",this.layers,y,this.zoom,r);this.patternFeatures.push(z)}else this.addFeature(y,w,T,o,{});r.featureIndex.insert(e[T].feature,w,T,M,this.index)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}addFeatures(e,r,o){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,o)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ef),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,r,o,l,h){for(const p of Du(r,500)){let y=0;for(const N of p)y+=N.length;const w=this.segments.prepareSegment(y,this.layoutVertexArray,this.indexArray),T=w.vertexLength,M=[],z=[];for(const N of p){if(N.length===0)continue;N!==p[0]&&z.push(M.length/2);const U=this.segments2.prepareSegment(N.length,this.layoutVertexArray,this.indexArray2),Z=U.vertexLength;this.layoutVertexArray.emplaceBack(N[0].x,N[0].y),this.indexArray2.emplaceBack(Z+N.length-1,Z),M.push(N[0].x),M.push(N[0].y);for(let $=1;$>3}if(l--,o===1||o===2)h+=i.readSVarint(),p+=i.readSVarint(),o===1&&(e&&y.push(e),e=[]),e.push(new Zf(h,p));else{if(o!==7)throw new Error("unknown command "+o);e&&e.push(e[0].clone())}}return e&&y.push(e),y},xl.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,o=0,l=0,h=0,p=1/0,y=-1/0,w=1/0,T=-1/0;i.pos>3}if(o--,r===1||r===2)(l+=i.readSVarint())y&&(y=l),(h+=i.readSVarint())T&&(T=h);else if(r!==7)throw new Error("unknown command "+r)}return[p,w,y,T]},xl.prototype.toGeoJSON=function(i,e,r){var o,l,h=this.extent*Math.pow(2,r),p=this.extent*i,y=this.extent*e,w=this.loadGeometry(),T=xl.types[this.type];function M(N){for(var U=0;U>3;l=p===1?o.readString():p===2?o.readFloat():p===3?o.readDouble():p===4?o.readVarint64():p===5?o.readVarint():p===6?o.readSVarint():p===7?o.readBoolean():null}return l}(r))}nd.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var e=this._pbf.readVarint()+this._pbf.pos;return new Hf(this._pbf,e,this.extent,this._keys,this._values)};var Kf=rd;function Jf(i,e,r){if(i===3){var o=new Kf(r,r.readVarint()+r.pos);o.length&&(e[o.name]=o)}}Ma.VectorTile=function(i,e){this.layers=i.readFields(Jf,{},e)},Ma.VectorTileFeature=id,Ma.VectorTileLayer=rd;const Yf=Ma.VectorTileFeature.types,Bu=Math.pow(2,13);function oc(i,e,r,o,l,h,p,y){i.emplaceBack(e,r,2*Math.floor(o*Bu)+p,l*Bu*2,h*Bu*2,Math.round(y))}class Nu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Qe,this.centroidVertexArray=new je,this.indexArray=new Kr,this.programConfigurations=new Yo(e.layers,e.zoom),this.segments=new Qi,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){this.features=[],this.hasPattern=Fu("fill-extrusion",this.layers,r);for(const{feature:l,id:h,index:p,sourceLayerIndex:y}of e){const w=this.layers[0]._featureFilter.needGeometry,T=Qa(l,w);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom),T,o))continue;const M={id:h,sourceLayerIndex:y,index:p,geometry:w?T.geometry:Ya(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(Ru("fill-extrusion",this.layers,M,this.zoom,r)):this.addFeature(M,M.geometry,p,o,{}),r.featureIndex.insert(l,M.geometry,p,y,this.index,!0)}}addFeatures(e,r,o){for(const l of this.features){const{geometry:h}=l;this.addFeature(l,h,l.index,r,o)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,qf),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,jf.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,r,o,l,h){const p={x:0,y:0,vertexCount:0};for(const y of Du(r,500)){let w=0;for(const U of y)w+=U.length;let T=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const U of y){if(U.length===0||$f(U))continue;let Z=0;for(let $=0;$=1){const ue=U[$-1];if(!Qf(ie,ue)){T.vertexLength+4>Qi.MAX_VERTEX_ARRAY_LENGTH&&(T=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const re=ie.sub(ue)._perp()._unit(),pe=ue.dist(ie);Z+pe>32768&&(Z=0),oc(this.layoutVertexArray,ie.x,ie.y,re.x,re.y,0,0,Z),oc(this.layoutVertexArray,ie.x,ie.y,re.x,re.y,0,1,Z),p.x+=2*ie.x,p.y+=2*ie.y,p.vertexCount+=2,Z+=pe,oc(this.layoutVertexArray,ue.x,ue.y,re.x,re.y,0,0,Z),oc(this.layoutVertexArray,ue.x,ue.y,re.x,re.y,0,1,Z),p.x+=2*ue.x,p.y+=2*ue.y,p.vertexCount+=2;const ye=T.vertexLength;this.indexArray.emplaceBack(ye,ye+2,ye+1),this.indexArray.emplaceBack(ye+1,ye+2,ye+3),T.vertexLength+=4,T.primitiveLength+=2}}}}if(T.vertexLength+w>Qi.MAX_VERTEX_ARRAY_LENGTH&&(T=this.segments.prepareSegment(w,this.layoutVertexArray,this.indexArray)),Yf[e.type]!=="Polygon")continue;const M=[],z=[],D=T.vertexLength;for(const U of y)if(U.length!==0){U!==y[0]&&z.push(M.length/2);for(let Z=0;ZCr)||i.y===e.y&&(i.y<0||i.y>Cr)}function $f(i){return i.every(e=>e.x<0)||i.every(e=>e.x>Cr)||i.every(e=>e.y<0)||i.every(e=>e.y>Cr)}let od;tt("FillExtrusionBucket",Nu,{omit:["layers","features"]});var em={get paint(){return od=od||new br({"fill-extrusion-opacity":new xt(Se["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Et(Se["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new xt(Se["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new xt(Se["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Xa(Se["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Et(Se["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Et(Se["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new xt(Se["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class tm extends so{constructor(e){super(e,em)}createBucket(e){return new Nu(e)}queryRadius(){return Gc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(e,r,o,l,h,p,y,w){const T=Wc(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),p.angle,y),M=this.paint.get("fill-extrusion-height").evaluate(r,o),z=this.paint.get("fill-extrusion-base").evaluate(r,o),D=function(U,Z,$,ie){const ue=[];for(const re of U){const pe=[re.x,re.y,0,1];Hc(pe,pe,Z),ue.push(new ge(pe[0]/pe[3],pe[1]/pe[3]))}return ue}(T,w),N=function(U,Z,$,ie){const ue=[],re=[],pe=ie[8]*Z,ye=ie[9]*Z,Ae=ie[10]*Z,lt=ie[11]*Z,pt=ie[8]*$,st=ie[9]*$,$e=ie[10]*$,Ze=ie[11]*$;for(const ht of U){const Ke=[],Be=[];for(const bt of ht){const yt=bt.x,Ht=bt.y,$i=ie[0]*yt+ie[4]*Ht+ie[12],nr=ie[1]*yt+ie[5]*Ht+ie[13],Dr=ie[2]*yt+ie[6]*Ht+ie[14],lo=ie[3]*yt+ie[7]*Ht+ie[15],Fn=Dr+Ae,Mr=lo+lt,Yr=$i+pt,hn=nr+st,Rn=Dr+$e,On=lo+Ze,Fr=new ge(($i+pe)/Mr,(nr+ye)/Mr);Fr.z=Fn/Mr,Ke.push(Fr);const Rr=new ge(Yr/On,hn/On);Rr.z=Rn/On,Be.push(Rr)}ue.push(Ke),re.push(Be)}return[ue,re]}(l,z,M,w);return function(U,Z,$){let ie=1/0;Rh($,Z)&&(ie=sd($,Z[0]));for(let ue=0;uer.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new Ct,this.layoutVertexArray2=new gt,this.indexArray=new Kr,this.programConfigurations=new Yo(e.layers,e.zoom),this.segments=new Qi,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){this.hasPattern=Fu("line",this.layers,r);const l=this.layers[0].layout.get("line-sort-key"),h=!l.isConstant(),p=[];for(const{feature:y,id:w,index:T,sourceLayerIndex:M}of e){const z=this.layers[0]._featureFilter.needGeometry,D=Qa(y,z);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom),D,o))continue;const N=h?l.evaluate(D,{},o):void 0,U={id:w,properties:y.properties,type:y.type,sourceLayerIndex:M,index:T,geometry:z?D.geometry:Ya(y),patterns:{},sortKey:N};p.push(U)}h&&p.sort((y,w)=>y.sortKey-w.sortKey);for(const y of p){const{geometry:w,index:T,sourceLayerIndex:M}=y;if(this.hasPattern){const z=Ru("line",this.layers,y,this.zoom,r);this.patternFeatures.push(z)}else this.addFeature(y,w,T,o,{});r.featureIndex.insert(e[T].feature,w,T,M,this.index)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}addFeatures(e,r,o){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,o)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,om)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,rm),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,o,l,h){const p=this.layers[0].layout,y=p.get("line-join").evaluate(e,{}),w=p.get("line-cap"),T=p.get("line-miter-limit"),M=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const z of r)this.addLine(z,e,y,w,T,M);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,h,l)}addLine(e,r,o,l,h,p){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let ie=0;ie=2&&e[w-1].equals(e[w-2]);)w--;let T=0;for(;T0;if(lt&&ie>T){const Ze=D.dist(N);if(Ze>2*M){const ht=D.sub(D.sub(N)._mult(M/Ze)._round());this.updateDistance(N,ht),this.addCurrentVertex(ht,Z,0,0,z),N=ht}}const st=N&&U;let $e=st?o:y?"butt":l;if(st&&$e==="round"&&(yeh&&($e="bevel"),$e==="bevel"&&(ye>2&&($e="flipbevel"),ye100)ue=$.mult(-1);else{const Ze=ye*Z.add($).mag()/Z.sub($).mag();ue._perp()._mult(Ze*(pt?-1:1))}this.addCurrentVertex(D,ue,0,0,z),this.addCurrentVertex(D,ue.mult(-1),0,0,z)}else if($e==="bevel"||$e==="fakeround"){const Ze=-Math.sqrt(ye*ye-1),ht=pt?Ze:0,Ke=pt?0:Ze;if(N&&this.addCurrentVertex(D,Z,ht,Ke,z),$e==="fakeround"){const Be=Math.round(180*Ae/Math.PI/20);for(let bt=1;bt2*M){const ht=D.add(U.sub(D)._mult(M/Ze)._round());this.updateDistance(D,ht),this.addCurrentVertex(ht,$,0,0,z),D=ht}}}}addCurrentVertex(e,r,o,l,h,p=!1){const y=r.y*l-r.x,w=-r.y-r.x*l;this.addHalfVertex(e,r.x+r.y*o,r.y-r.x*o,p,!1,o,h),this.addHalfVertex(e,y,w,p,!0,-l,h),this.distance>ad/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,o,l,h,p))}addHalfVertex({x:e,y:r},o,l,h,p,y,w){const T=.5*(this.lineClips?this.scaledDistance*(ad-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(h?1:0),(r<<1)+(p?1:0),Math.round(63*o)+128,Math.round(63*l)+128,1+(y===0?0:y<0?-1:1)|(63&T)<<2,T>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const M=w.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,M),w.primitiveLength++),p?this.e2=M:this.e1=M}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}let ld,cd;tt("LineBucket",Vu,{omit:["layers","patternFeatures"]});var ud={get paint(){return cd=cd||new br({"line-opacity":new Et(Se.paint_line["line-opacity"]),"line-color":new Et(Se.paint_line["line-color"]),"line-translate":new xt(Se.paint_line["line-translate"]),"line-translate-anchor":new xt(Se.paint_line["line-translate-anchor"]),"line-width":new Et(Se.paint_line["line-width"]),"line-gap-width":new Et(Se.paint_line["line-gap-width"]),"line-offset":new Et(Se.paint_line["line-offset"]),"line-blur":new Et(Se.paint_line["line-blur"]),"line-dasharray":new ql(Se.paint_line["line-dasharray"]),"line-pattern":new Xa(Se.paint_line["line-pattern"]),"line-gradient":new Zl(Se.paint_line["line-gradient"])})},get layout(){return ld=ld||new br({"line-cap":new xt(Se.layout_line["line-cap"]),"line-join":new Et(Se.layout_line["line-join"]),"line-miter-limit":new xt(Se.layout_line["line-miter-limit"]),"line-round-limit":new xt(Se.layout_line["line-round-limit"]),"line-sort-key":new Et(Se.layout_line["line-sort-key"])})}};class lm extends Et{possiblyEvaluate(e,r){return r=new Yi(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,o,l){return r=Nt({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,o,l)}}let Qc;class cm extends so{constructor(e){super(e,ud),this.gradientVersion=0,Qc||(Qc=new lm(ud.paint.properties["line-width"].specification),Qc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!function(o){return o._styleExpression!==void 0}(r)&&r._styleExpression.expression instanceof ho,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values["line-floorwidth"]=Qc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Vu(e)}queryRadius(e){const r=e,o=hd(Ql("line-width",this,r),Ql("line-gap-width",this,r)),l=Ql("line-offset",this,r);return o/2+Math.abs(l)+Gc(this.paint.get("line-translate"))}queryIntersectsFeature(e,r,o,l,h,p,y){const w=Wc(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),p.angle,y),T=y/2*hd(this.paint.get("line-width").evaluate(r,o),this.paint.get("line-gap-width").evaluate(r,o)),M=this.paint.get("line-offset").evaluate(r,o);return M&&(l=function(z,D){const N=[];for(let U=0;U=3){for(let $=0;$0?e+2*i:i}const um=or([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),hm=or([{name:"a_projected_pos",components:3,type:"Float32"}],4);or([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const dm=or([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);or([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const dd=or([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),pm=or([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function fm(i,e,r){return i.sections.forEach(o=>{o.text=function(l,h,p){const y=h.layout.get("text-transform").evaluate(p,{});return y==="uppercase"?l=l.toLocaleUpperCase():y==="lowercase"&&(l=l.toLocaleLowerCase()),Hn.applyArabicShaping&&(l=Hn.applyArabicShaping(l)),l}(o.text,e,r)}),i}or([{name:"triangle",components:3,type:"Uint16"}]),or([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),or([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),or([{type:"Float32",name:"offsetX"}]),or([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),or([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const ac={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Lr=24,pd=Di,fd=function(i,e,r,o,l){var h,p,y=8*l-o-1,w=(1<>1,M=-7,z=r?l-1:0,D=r?-1:1,N=i[e+z];for(z+=D,h=N&(1<<-M)-1,N>>=-M,M+=y;M>0;h=256*h+i[e+z],z+=D,M-=8);for(p=h&(1<<-M)-1,h>>=-M,M+=o;M>0;p=256*p+i[e+z],z+=D,M-=8);if(h===0)h=1-T;else{if(h===w)return p?NaN:1/0*(N?-1:1);p+=Math.pow(2,o),h-=T}return(N?-1:1)*p*Math.pow(2,h-o)},md=function(i,e,r,o,l,h){var p,y,w,T=8*h-l-1,M=(1<>1,D=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=o?0:h-1,U=o?1:-1,Z=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(y=isNaN(e)?1:0,p=M):(p=Math.floor(Math.log(e)/Math.LN2),e*(w=Math.pow(2,-p))<1&&(p--,w*=2),(e+=p+z>=1?D/w:D*Math.pow(2,1-z))*w>=2&&(p++,w/=2),p+z>=M?(y=0,p=M):p+z>=1?(y=(e*w-1)*Math.pow(2,l),p+=z):(y=e*Math.pow(2,z-1)*Math.pow(2,l),p=0));l>=8;i[r+N]=255&y,N+=U,y/=256,l-=8);for(p=p<0;i[r+N]=255&p,N+=U,p/=256,T-=8);i[r+N-U]|=128*Z};function Di(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}Di.Varint=0,Di.Fixed64=1,Di.Bytes=2,Di.Fixed32=5;var Uu=4294967296,_d=1/Uu,gd=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function Us(i){return i.type===Di.Bytes?i.readVarint()+i.pos:i.pos+1}function bl(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function yd(i,e,r){var o=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(o);for(var l=r.pos-1;l>=i;l--)r.buf[l+o]=r.buf[l]}function mm(i,e){for(var r=0;r>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function vd(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+(i[e+3]<<24)}Di.prototype={destroy:function(){this.buf=null},readFields:function(i,e,r){for(r=r||this.length;this.pos>3,h=this.pos;this.type=7&o,i(l,e,this),this.pos===h&&this.skip(o)}return e},readMessage:function(i,e){return this.readFields(i,e,this.readVarint()+this.pos)},readFixed32:function(){var i=$c(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=vd(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=$c(this.buf,this.pos)+$c(this.buf,this.pos+4)*Uu;return this.pos+=8,i},readSFixed64:function(){var i=$c(this.buf,this.pos)+vd(this.buf,this.pos+4)*Uu;return this.pos+=8,i},readFloat:function(){var i=fd(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=fd(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var e,r,o=this.buf;return e=127&(r=o[this.pos++]),r<128?e:(e|=(127&(r=o[this.pos++]))<<7,r<128?e:(e|=(127&(r=o[this.pos++]))<<14,r<128?e:(e|=(127&(r=o[this.pos++]))<<21,r<128?e:function(l,h,p){var y,w,T=p.buf;if(y=(112&(w=T[p.pos++]))>>4,w<128||(y|=(127&(w=T[p.pos++]))<<3,w<128)||(y|=(127&(w=T[p.pos++]))<<10,w<128)||(y|=(127&(w=T[p.pos++]))<<17,w<128)||(y|=(127&(w=T[p.pos++]))<<24,w<128)||(y|=(1&(w=T[p.pos++]))<<31,w<128))return bl(l,y,h);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,e=this.pos;return this.pos=i,i-e>=12&&gd?function(r,o,l){return gd.decode(r.subarray(o,l))}(this.buf,e,i):function(r,o,l){for(var h="",p=o;p239?4:M>223?3:M>191?2:1;if(p+D>l)break;D===1?M<128&&(z=M):D===2?(192&(y=r[p+1]))==128&&(z=(31&M)<<6|63&y)<=127&&(z=null):D===3?(w=r[p+2],(192&(y=r[p+1]))==128&&(192&w)==128&&((z=(15&M)<<12|(63&y)<<6|63&w)<=2047||z>=55296&&z<=57343)&&(z=null)):D===4&&(w=r[p+2],T=r[p+3],(192&(y=r[p+1]))==128&&(192&w)==128&&(192&T)==128&&((z=(15&M)<<18|(63&y)<<12|(63&w)<<6|63&T)<=65535||z>=1114112)&&(z=null)),z===null?(z=65533,D=1):z>65535&&(z-=65536,h+=String.fromCharCode(z>>>10&1023|55296),z=56320|1023&z),h+=String.fromCharCode(z),p+=D}return h}(this.buf,e,i)},readBytes:function(){var i=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,i);return this.pos=i,e},readPackedVarint:function(i,e){if(this.type!==Di.Bytes)return i.push(this.readVarint(e));var r=Us(this);for(i=i||[];this.pos127;);else if(e===Di.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Di.Fixed32)this.pos+=4;else{if(e!==Di.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(i,e){this.writeVarint(i<<3|e)},realloc:function(i){for(var e=this.length||16;e268435455||i<0?function(e,r){var o,l;if(e>=0?(o=e%4294967296|0,l=e/4294967296|0):(l=~(-e/4294967296),4294967295^(o=~(-e%4294967296))?o=o+1|0:(o=0,l=l+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(h,p,y){y.buf[y.pos++]=127&h|128,h>>>=7,y.buf[y.pos++]=127&h|128,h>>>=7,y.buf[y.pos++]=127&h|128,h>>>=7,y.buf[y.pos++]=127&h|128,y.buf[y.pos]=127&(h>>>=7)}(o,0,r),function(h,p){var y=(7&h)<<4;p.buf[p.pos++]|=y|((h>>>=3)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h)))))}(l,r)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var e=this.pos;this.pos=function(o,l,h){for(var p,y,w=0;w55295&&p<57344){if(!y){p>56319||w+1===l.length?(o[h++]=239,o[h++]=191,o[h++]=189):y=p;continue}if(p<56320){o[h++]=239,o[h++]=191,o[h++]=189,y=p;continue}p=y-55296<<10|p-56320|65536,y=null}else y&&(o[h++]=239,o[h++]=191,o[h++]=189,y=null);p<128?o[h++]=p:(p<2048?o[h++]=p>>6|192:(p<65536?o[h++]=p>>12|224:(o[h++]=p>>18|240,o[h++]=p>>12&63|128),o[h++]=p>>6&63|128),o[h++]=63&p|128)}return h}(this.buf,i,this.pos);var r=this.pos-e;r>=128&&yd(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),md(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),md(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var e=i.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&yd(r,o,this),this.pos=r-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,e,r){this.writeTag(i,Di.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(i,e){e.length&&this.writeMessage(i,mm,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,_m,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,vm,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,gm,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,ym,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,xm,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,bm,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,wm,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,Sm,e)},writeBytesField:function(i,e){this.writeTag(i,Di.Bytes),this.writeBytes(e)},writeFixed32Field:function(i,e){this.writeTag(i,Di.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(i,e){this.writeTag(i,Di.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(i,e){this.writeTag(i,Di.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(i,e){this.writeTag(i,Di.Fixed64),this.writeSFixed64(e)},writeVarintField:function(i,e){this.writeTag(i,Di.Varint),this.writeVarint(e)},writeSVarintField:function(i,e){this.writeTag(i,Di.Varint),this.writeSVarint(e)},writeStringField:function(i,e){this.writeTag(i,Di.Bytes),this.writeString(e)},writeFloatField:function(i,e){this.writeTag(i,Di.Fixed32),this.writeFloat(e)},writeDoubleField:function(i,e){this.writeTag(i,Di.Fixed64),this.writeDouble(e)},writeBooleanField:function(i,e){this.writeVarintField(i,!!e)}};var ju=V(pd);const qu=3;function Tm(i,e,r){i===1&&r.readMessage(Im,e)}function Im(i,e,r){if(i===3){const{id:o,bitmap:l,width:h,height:p,left:y,top:w,advance:T}=r.readMessage(Em,{});e.push({id:o,bitmap:new ec({width:h+2*qu,height:p+2*qu},l),metrics:{width:h,height:p,left:y,top:w,advance:T}})}}function Em(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}const xd=qu;function bd(i){let e=0,r=0;for(const p of i)e+=p.w*p.h,r=Math.max(r,p.w);i.sort((p,y)=>y.h-p.h);const o=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let l=0,h=0;for(const p of i)for(let y=o.length-1;y>=0;y--){const w=o[y];if(!(p.w>w.w||p.h>w.h)){if(p.x=w.x,p.y=w.y,h=Math.max(h,p.y+p.h),l=Math.max(l,p.x+p.w),p.w===w.w&&p.h===w.h){const T=o.pop();y=0&&o>=e&&tu[this.text.charCodeAt(o)];o--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const o=new Sl;return o.text=this.text.substring(e,r),o.sectionIndex=this.sectionIndex.slice(e,r),o.sections=this.sections,o}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(cc.forText(e.scale,e.fontStack||r));const o=this.sections.length-1;for(let l=0;l=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function eu(i,e,r,o,l,h,p,y,w,T,M,z,D,N,U,Z){const $=Sl.fromFeature(i,l);let ie;z===s.ai.vertical&&$.verticalizePunctuation();const{processBidirectionalText:ue,processStyledBidirectionalText:re}=Hn;if(ue&&$.sections.length===1){ie=[];const Ae=ue($.toString(),Gu($,T,h,e,o,N,U));for(const lt of Ae){const pt=new Sl;pt.text=lt,pt.sections=$.sections;for(let st=0;st0&&qs>Jn&&(Jn=qs)}else{const vo=pt[oi.fontStack],Qn=vo&&vo[dn];if(Qn&&Qn.rect)Qo=Qn.rect,No=Qn.metrics;else{const qs=lt[oi.fontStack],fc=qs&&qs[dn];if(!fc)continue;No=fc.metrics}Br=(Rr-oi.scale)*Lr}Vo?(Ae.verticalizable=!0,wn.push({glyph:dn,imageName:$o,x:$i,y:nr+Br,vertical:Vo,scale:oi.scale,fontStack:oi.fontStack,sectionIndex:Sn,metrics:No,rect:Qo}),$i+=js*oi.scale+bt):(wn.push({glyph:dn,imageName:$o,x:$i,y:nr+Br,vertical:Vo,scale:oi.scale,fontStack:oi.fontStack,sectionIndex:Sn,metrics:No,rect:Qo}),$i+=No.advance*oi.scale+bt)}wn.length!==0&&(Dr=Math.max($i-bt,Dr),Am(wn,0,wn.length-1,Fn,Jn)),$i=0;const Yn=Ze*Rr+Jn;Bn.lineOffset=Math.max(Jn,bn),nr+=Yn,lo=Math.max(Yn,lo),++Mr}var Yr;const hn=nr-lc,{horizontalAlign:Rn,verticalAlign:On}=Wu(ht);(function(Fr,Rr,bn,Bn,wn,Jn,Yn,Or,oi){const Sn=(Rr-bn)*wn;let dn=0;dn=Jn!==Yn?-Or*Bn-lc:(-Bn*oi+.5)*Yn;for(const Br of Fr)for(const No of Br.positionedGlyphs)No.x+=Sn,No.y+=dn})(Ae.positionedLines,Fn,Rn,On,Dr,lo,Ze,hn,$e.length),Ae.top+=-On*hn,Ae.bottom=Ae.top+hn,Ae.left+=-Rn*Dr,Ae.right=Ae.left+Dr}(ye,e,r,o,ie,p,y,w,z,T,D,Z),!function(Ae){for(const lt of Ae)if(lt.positionedGlyphs.length!==0)return!1;return!0}(pe)&&ye}const tu={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Cm={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Sd(i,e,r,o,l,h){if(e.imageName){const p=o[e.imageName];return p?p.displaySize[0]*e.scale*Lr/h+l:0}{const p=r[e.fontStack],y=p&&p[i];return y?y.metrics.advance*e.scale+l:0}}function Td(i,e,r,o){const l=Math.pow(i-e,2);return o?i=0;let M=0;for(let D=0;Dp.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Cu([]),this.placementViewportMatrix=Cu([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Md(this.zoom,r["text-size"]),this.iconSizeData=Md(this.zoom,r["icon-size"]);const o=this.layers[0].layout,l=o.get("symbol-sort-key"),h=o.get("symbol-z-order");this.canOverlap=Hu(o,"text-overlap","text-allow-overlap")!=="never"||Hu(o,"icon-overlap","icon-allow-overlap")!=="never"||o.get("text-ignore-placement")||o.get("icon-ignore-placement"),this.sortFeaturesByKey=h!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(h==="viewport-y"||h==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,o.get("symbol-placement")==="point"&&(this.writingModes=o.get("text-writing-mode").map(p=>s.ai[p])),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.sourceID=e.sourceID}createArrays(){this.text=new Ku(new Yo(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Ku(new Yo(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new ce,this.lineVertexArray=new ve,this.symbolInstances=new ee,this.textAnchorOffsets=new Me}calculateGlyphDependencies(e,r,o,l,h){for(let p=0;p0)&&(p.value.kind!=="constant"||p.value.value.length>0),M=w.value.kind!=="constant"||!!w.value.value||Object.keys(w.parameters).length>0,z=h.get("symbol-sort-key");if(this.features=[],!T&&!M)return;const D=r.iconDependencies,N=r.glyphDependencies,U=r.availableImages,Z=new Yi(this.zoom);for(const{feature:$,id:ie,index:ue,sourceLayerIndex:re}of e){const pe=l._featureFilter.needGeometry,ye=Qa($,pe);if(!l._featureFilter.filter(Z,ye,o))continue;let Ae,lt;if(pe||(ye.geometry=Ya($)),T){const st=l.getValueAndResolveTokens("text-field",ye,o,U),$e=ji.factory(st);Lm($e)&&(this.hasRTLText=!0),(!this.hasRTLText||Ul()==="unavailable"||this.hasRTLText&&Hn.isParsed())&&(Ae=fm($e,l,ye))}if(M){const st=l.getValueAndResolveTokens("icon-image",ye,o,U);lt=st instanceof Er?st:Er.fromString(st)}if(!Ae&&!lt)continue;const pt=this.sortFeaturesByKey?z.evaluate(ye,{},o):void 0;if(this.features.push({id:ie,text:Ae,icon:lt,index:ue,sourceLayerIndex:re,geometry:ye.geometry,properties:$.properties,type:Pm[$.type],sortKey:pt}),lt&&(D[lt.name]=!0),Ae){const st=p.evaluate(ye,{},o).join(","),$e=h.get("text-rotation-alignment")!=="viewport"&&h.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(s.ai.vertical)>=0;for(const Ze of Ae.sections)if(Ze.image)D[Ze.image.name]=!0;else{const ht=Sa(Ae.toString()),Ke=Ze.fontStack||st,Be=N[Ke]=N[Ke]||{};this.calculateGlyphDependencies(Ze.text,Be,$e,this.allowVerticalPlacement,ht)}}}h.get("symbol-placement")==="line"&&(this.features=function($){const ie={},ue={},re=[];let pe=0;function ye(st){re.push($[st]),pe++}function Ae(st,$e,Ze){const ht=ue[st];return delete ue[st],ue[$e]=ht,re[ht].geometry[0].pop(),re[ht].geometry[0]=re[ht].geometry[0].concat(Ze[0]),ht}function lt(st,$e,Ze){const ht=ie[$e];return delete ie[$e],ie[st]=ht,re[ht].geometry[0].shift(),re[ht].geometry[0]=Ze[0].concat(re[ht].geometry[0]),ht}function pt(st,$e,Ze){const ht=Ze?$e[0][$e[0].length-1]:$e[0][0];return`${st}:${ht.x}:${ht.y}`}for(let st=0;st<$.length;st++){const $e=$[st],Ze=$e.geometry,ht=$e.text?$e.text.toString():null;if(!ht){ye(st);continue}const Ke=pt(ht,Ze),Be=pt(ht,Ze,!0);if(Ke in ue&&Be in ie&&ue[Ke]!==ie[Be]){const bt=lt(Ke,Be,Ze),yt=Ae(Ke,Be,re[bt].geometry);delete ie[Ke],delete ue[Be],ue[pt(ht,re[yt].geometry,!0)]=yt,re[bt].geometry=null}else Ke in ue?Ae(Ke,Be,Ze):Be in ie?lt(Ke,Be,Ze):(ye(st),ie[Ke]=pe-1,ue[Be]=pe-1)}return re.filter(st=>st.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort(($,ie)=>$.sortKey-ie.sortKey)}update(e,r,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,o),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,o))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const o=this.lineVertexArray.length;if(e.segment!==void 0){let l=e.dist(r[e.segment+1]),h=e.dist(r[e.segment]);const p={};for(let y=e.segment+1;y=0;y--)p[y]={x:r[y].x,y:r[y].y,tileUnitDistanceFromAnchor:h},y>0&&(h+=r[y-1].dist(r[y]));for(let y=0;y0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){const o=e.placedSymbolArray.get(r),l=o.vertexStartIndex+4*o.numGlyphs;for(let h=o.vertexStartIndex;hl[y]-l[w]||h[w]-h[y]),p}addToSortKeyRanges(e,r){const o=this.sortKeyRanges[this.sortKeyRanges.length-1];o&&o.sortKey===r?o.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,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 r of this.symbolInstanceIndexes){const o=this.symbolInstances.get(r);this.featureSortOrder.push(o.featureIndex),[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((l,h,p)=>{l>=0&&p.indexOf(l)===h&&this.addIndicesForPlacedSymbol(this.text,l)}),o.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,o.verticalPlacedTextSymbolIndex),o.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,o.placedIconSymbolIndex),o.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,o.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Ad,kd;tt("SymbolBucket",Tl,{omit:["layers","collisionBoxArray","features","compareText"]}),Tl.MAX_GLYPHS=65535,Tl.addDynamicAttributes=Xu;var Yu={get paint(){return kd=kd||new br({"icon-opacity":new Et(Se.paint_symbol["icon-opacity"]),"icon-color":new Et(Se.paint_symbol["icon-color"]),"icon-halo-color":new Et(Se.paint_symbol["icon-halo-color"]),"icon-halo-width":new Et(Se.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Et(Se.paint_symbol["icon-halo-blur"]),"icon-translate":new xt(Se.paint_symbol["icon-translate"]),"icon-translate-anchor":new xt(Se.paint_symbol["icon-translate-anchor"]),"text-opacity":new Et(Se.paint_symbol["text-opacity"]),"text-color":new Et(Se.paint_symbol["text-color"],{runtimeType:Ur,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Et(Se.paint_symbol["text-halo-color"]),"text-halo-width":new Et(Se.paint_symbol["text-halo-width"]),"text-halo-blur":new Et(Se.paint_symbol["text-halo-blur"]),"text-translate":new xt(Se.paint_symbol["text-translate"]),"text-translate-anchor":new xt(Se.paint_symbol["text-translate-anchor"])})},get layout(){return Ad=Ad||new br({"symbol-placement":new xt(Se.layout_symbol["symbol-placement"]),"symbol-spacing":new xt(Se.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new xt(Se.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Et(Se.layout_symbol["symbol-sort-key"]),"symbol-z-order":new xt(Se.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new xt(Se.layout_symbol["icon-allow-overlap"]),"icon-overlap":new xt(Se.layout_symbol["icon-overlap"]),"icon-ignore-placement":new xt(Se.layout_symbol["icon-ignore-placement"]),"icon-optional":new xt(Se.layout_symbol["icon-optional"]),"icon-rotation-alignment":new xt(Se.layout_symbol["icon-rotation-alignment"]),"icon-size":new Et(Se.layout_symbol["icon-size"]),"icon-text-fit":new xt(Se.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new xt(Se.layout_symbol["icon-text-fit-padding"]),"icon-image":new Et(Se.layout_symbol["icon-image"]),"icon-rotate":new Et(Se.layout_symbol["icon-rotate"]),"icon-padding":new Et(Se.layout_symbol["icon-padding"]),"icon-keep-upright":new xt(Se.layout_symbol["icon-keep-upright"]),"icon-offset":new Et(Se.layout_symbol["icon-offset"]),"icon-anchor":new Et(Se.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new xt(Se.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new xt(Se.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new xt(Se.layout_symbol["text-rotation-alignment"]),"text-field":new Et(Se.layout_symbol["text-field"]),"text-font":new Et(Se.layout_symbol["text-font"]),"text-size":new Et(Se.layout_symbol["text-size"]),"text-max-width":new Et(Se.layout_symbol["text-max-width"]),"text-line-height":new xt(Se.layout_symbol["text-line-height"]),"text-letter-spacing":new Et(Se.layout_symbol["text-letter-spacing"]),"text-justify":new Et(Se.layout_symbol["text-justify"]),"text-radial-offset":new Et(Se.layout_symbol["text-radial-offset"]),"text-variable-anchor":new xt(Se.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Et(Se.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Et(Se.layout_symbol["text-anchor"]),"text-max-angle":new xt(Se.layout_symbol["text-max-angle"]),"text-writing-mode":new xt(Se.layout_symbol["text-writing-mode"]),"text-rotate":new Et(Se.layout_symbol["text-rotate"]),"text-padding":new xt(Se.layout_symbol["text-padding"]),"text-keep-upright":new xt(Se.layout_symbol["text-keep-upright"]),"text-transform":new Et(Se.layout_symbol["text-transform"]),"text-offset":new Et(Se.layout_symbol["text-offset"]),"text-allow-overlap":new xt(Se.layout_symbol["text-allow-overlap"]),"text-overlap":new xt(Se.layout_symbol["text-overlap"]),"text-ignore-placement":new xt(Se.layout_symbol["text-ignore-placement"]),"text-optional":new xt(Se.layout_symbol["text-optional"])})}};class Pd{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:rn,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.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}}tt("FormatSectionOverride",Pd,{omit:["defaultValue"]});class ru extends so{constructor(e){super(e,Yu)}recalculate(e,r){if(super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const o=this.layout.get("text-writing-mode");if(o){const l=[];for(const h of o)l.indexOf(h)<0&&l.push(h);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,o,l){const h=this.layout.get(e).evaluate(r,{},o,l),p=this._unevaluatedLayout._values[e];return p.isDataDriven()||Zn(p.value)||!h?h:function(y,w){return w.replace(/{([^{}]+)}/g,(T,M)=>y&&M in y?String(y[M]):"")}(r.properties,h)}createBucket(e){return new Tl(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Yu.paint.overridableProperties){if(!ru.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),o=new Pd(r),l=new ls(o,r.property.specification);let h=null;h=r.value.kind==="constant"||r.value.kind==="source"?new cs("source",l):new ko("composite",l,r.value.zoomStops),this.paint._values[e]=new vn(r.property,h,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,o){return!(!this.layout||r.isDataDriven()||o.isDataDriven())&&ru.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const o=e.get("text-field"),l=Yu.paint.properties[r];let h=!1;const p=y=>{for(const w of y)if(l.overrides&&l.overrides.hasOverride(w))return void(h=!0)};if(o.value.kind==="constant"&&o.value.value instanceof ji)p(o.value.value.sections);else if(o.value.kind==="source"){const y=T=>{h||(T instanceof uo&&Gi(T.value)===X?p(T.value.sections):T instanceof Es?p(T.sections):T.eachChild(y))},w=o.value;w._styleExpression&&y(w._styleExpression.expression)}return h}}let zd;var Dm={get paint(){return zd=zd||new br({"background-color":new xt(Se.paint_background["background-color"]),"background-pattern":new ql(Se.paint_background["background-pattern"]),"background-opacity":new xt(Se.paint_background["background-opacity"])})}};class Fm extends so{constructor(e){super(e,Dm)}}let Ld;var Rm={get paint(){return Ld=Ld||new br({"raster-opacity":new xt(Se.paint_raster["raster-opacity"]),"raster-hue-rotate":new xt(Se.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new xt(Se.paint_raster["raster-brightness-min"]),"raster-brightness-max":new xt(Se.paint_raster["raster-brightness-max"]),"raster-saturation":new xt(Se.paint_raster["raster-saturation"]),"raster-contrast":new xt(Se.paint_raster["raster-contrast"]),"raster-resampling":new xt(Se.paint_raster["raster-resampling"]),"raster-fade-duration":new xt(Se.paint_raster["raster-fade-duration"])})}};class Om extends so{constructor(e){super(e,Rm)}}class Bm extends so{constructor(e){super(e,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Nm{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}const Qu=63710088e-1;class Pa{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Pa(Xt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,o=this.lat*r,l=e.lat*r,h=Math.sin(o)*Math.sin(l)+Math.cos(o)*Math.cos(l)*Math.cos((e.lng-this.lng)*r);return Qu*Math.acos(Math.min(h,1))}static convert(e){if(e instanceof Pa)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Pa(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Pa(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 [, ]")}}const Dd=2*Math.PI*Qu;function Fd(i){return Dd*Math.cos(i*Math.PI/180)}function Rd(i){return(180+i)/360}function Od(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Bd(i,e){return i/Fd(e)}function Nd(i){return 360*i-180}function $u(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class nu{constructor(e,r,o=0){this.x=+e,this.y=+r,this.z=+o}static fromLngLat(e,r=0){const o=Pa.convert(e);return new nu(Rd(o.lng),Od(o.lat),Bd(r,o.lat))}toLngLat(){return new Pa(Nd(this.x),$u(this.y))}toAltitude(){return this.z*Fd($u(this.y))}meterInMercatorCoordinateUnits(){return 1/Dd*(e=$u(this.y),1/Math.cos(e*Math.PI/180));var e}}function Vd(i,e,r){var o=2*Math.PI*6378137/256/Math.pow(2,r);return[i*o-2*Math.PI*6378137/2,e*o-2*Math.PI*6378137/2]}class eh{constructor(e,r,o){if(e<0||e>25||o<0||o>=Math.pow(2,e)||r<0||r>=Math.pow(2,e))throw new Error(`x=${r}, y=${o}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=o,this.key=hc(0,e,e,r,o)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,o){const l=(p=this.y,y=this.z,w=Vd(256*(h=this.x),256*(p=Math.pow(2,y)-p-1),y),T=Vd(256*(h+1),256*(p+1),y),w[0]+","+w[1]+","+T[0]+","+T[1]);var h,p,y,w,T;const M=function(z,D,N){let U,Z="";for(let $=z;$>0;$--)U=1<<$-1,Z+=(D&U?1:0)+(N&U?2:0);return Z}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(o==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,M).replace(/{bbox-epsg-3857}/g,l)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new ge((e.x*r-this.x)*Cr,(e.y*r-this.y)*Cr)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Ud{constructor(e,r){this.wrap=e,this.canonical=r,this.key=hc(e,r.z,r.z,r.x,r.y)}}class yo{constructor(e,r,o,l,h){if(e= z; overscaledZ = ${e}; z = ${o}`);this.overscaledZ=e,this.wrap=r,this.canonical=new eh(o,+l,+h),this.key=hc(r,e,o,l,h)}clone(){return new yo(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?new yo(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new yo(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const o=this.canonical.z-e;return e>this.canonical.z?hc(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):hc(this.wrap*+r,e,e,this.canonical.x>>o,this.canonical.y>>o)}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new yo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,o=2*this.canonical.x,l=2*this.canonical.y;return[new yo(r,this.wrap,r,o,l),new yo(r,this.wrap,r,o+1,l),new yo(r,this.wrap,r,o,l+1),new yo(r,this.wrap,r,o+1,l+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ythis.max&&(this.max=z),z=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}unpack(e,r,o){return e*this.redFactor+r*this.greenFactor+o*this.blueFactor-this.baseShift}getPixels(){return new go({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,o){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,h=r*this.dim+this.dim,p=o*this.dim,y=o*this.dim+this.dim;switch(r){case-1:l=h-1;break;case 1:h=l+1}switch(o){case-1:p=y-1;break;case 1:y=p+1}const w=-r*this.dim,T=-o*this.dim;for(let M=p;M=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Zd{constructor(e,r,o,l,h){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=o,e._y=l,this.properties=e.properties,this.id=h}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(e[r]=this[r]);return e}}class Gd{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Lo(Cr,16,0),this.grid3D=new Lo(Cr,16,0),this.featureIndexArray=new ze,this.promoteId=r}insert(e,r,o,l,h,p){const y=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(o,l,h);const w=p?this.grid3D:this.grid;for(let T=0;T=0&&z[3]>=0&&w.insert(y,z[0],z[1],z[2],z[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ma.VectorTile(new ju(this.rawTileData)).layers,this.sourceLayerCoder=new qd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,o,l){this.loadVTLayers();const h=e.params||{},p=Cr/e.tileSize/e.scale,y=ga(h.filter),w=e.queryGeometry,T=e.queryPadding*p,M=Hd(w),z=this.grid.query(M.minX-T,M.minY-T,M.maxX+T,M.maxY+T),D=Hd(e.cameraQueryGeometry),N=this.grid3D.query(D.minX-T,D.minY-T,D.maxX+T,D.maxY+T,($,ie,ue,re)=>function(pe,ye,Ae,lt,pt){for(const $e of pe)if(ye<=$e.x&&Ae<=$e.y&<>=$e.x&&pt>=$e.y)return!0;const st=[new ge(ye,Ae),new ge(ye,pt),new ge(lt,pt),new ge(lt,Ae)];if(pe.length>2){for(const $e of st)if(gl(pe,$e))return!0}for(let $e=0;$e(re||(re=Ya(pe)),ye.queryIntersectsFeature(w,pe,Ae,re,this.z,e.transform,p,e.pixelPosMatrix)))}return U}loadMatchingFeature(e,r,o,l,h,p,y,w,T,M,z){const D=this.bucketLayerIDs[r];if(p&&!function($,ie){for(let ue=0;ue<$.length;ue++)if(ie.indexOf($[ue])>=0)return!0;return!1}(p,D))return;const N=this.sourceLayerCoder.decode(o),U=this.vtLayers[N].feature(l);if(h.needGeometry){const $=Qa(U,!0);if(!h.filter(new Yi(this.tileID.overscaledZ),$,this.tileID.canonical))return}else if(!h.filter(new Yi(this.tileID.overscaledZ),U))return;const Z=this.getId(U,N);for(let $=0;${const y=e instanceof ml?e.get(p):null;return y&&y.evaluate?y.evaluate(r,o,l):y})}function Hd(i){let e=1/0,r=1/0,o=-1/0,l=-1/0;for(const h of i)e=Math.min(e,h.x),r=Math.min(r,h.y),o=Math.max(o,h.x),l=Math.max(l,h.y);return{minX:e,minY:r,maxX:o,maxY:l}}function Vm(i,e){return e-i}function Xd(i,e,r,o,l){const h=[];for(let p=0;p=o&&z.x>=o||(M.x>=o?M=new ge(o,M.y+(o-M.x)/(z.x-M.x)*(z.y-M.y))._round():z.x>=o&&(z=new ge(o,M.y+(o-M.x)/(z.x-M.x)*(z.y-M.y))._round()),M.y>=l&&z.y>=l||(M.y>=l?M=new ge(M.x+(l-M.y)/(z.y-M.y)*(z.x-M.x),l)._round():z.y>=l&&(z=new ge(M.x+(l-M.y)/(z.y-M.y)*(z.x-M.x),l)._round()),w&&M.equals(w[w.length-1])||(w=[M],h.push(w)),w.push(z)))))}}return h}tt("FeatureIndex",Gd,{omit:["rawTileData","sourceLayerCoder"]});class za extends ge{constructor(e,r,o,l){super(e,r),this.angle=o,l!==void 0&&(this.segment=l)}clone(){return new za(this.x,this.y,this.angle,this.segment)}}function Kd(i,e,r,o,l){if(e.segment===void 0||r===0)return!0;let h=e,p=e.segment+1,y=0;for(;y>-r/2;){if(p--,p<0)return!1;y-=i[p].dist(h),h=i[p]}y+=i[p].dist(i[p+1]),p++;const w=[];let T=0;for(;yo;)T-=w.shift().angleDelta;if(T>l)return!1;p++,y+=M.dist(z)}return!0}function Jd(i){let e=0;for(let r=0;rT){const U=(T-w)/N,Z=Hr.number(z.x,D.x,U),$=Hr.number(z.y,D.y,U),ie=new za(Z,$,D.angleTo(z),M);return ie._round(),!p||Kd(i,ie,y,p,e)?ie:void 0}w+=N}}function jm(i,e,r,o,l,h,p,y,w){const T=Yd(o,h,p),M=Qd(o,l),z=M*p,D=i[0].x===0||i[0].x===w||i[0].y===0||i[0].y===w;return e-z=0&&pe=0&&ye=0&&D+T<=M){const Ae=new za(pe,ye,ue,U);Ae._round(),o&&!Kd(i,Ae,h,o,l)||N.push(Ae)}}z+=ie}return y||N.length||p||(N=$d(i,z/2,r,o,l,h,p,!0,w)),N}tt("Anchor",za);const Il=Kn;function ep(i,e,r,o){const l=[],h=i.image,p=h.pixelRatio,y=h.paddedRect.w-2*Il,w=h.paddedRect.h-2*Il,T=i.right-i.left,M=i.bottom-i.top,z=h.stretchX||[[0,y]],D=h.stretchY||[[0,w]],N=(Ze,ht)=>Ze+ht[1]-ht[0],U=z.reduce(N,0),Z=D.reduce(N,0),$=y-U,ie=w-Z;let ue=0,re=U,pe=0,ye=Z,Ae=0,lt=$,pt=0,st=ie;if(h.content&&o){const Ze=h.content;ue=ou(z,0,Ze[0]),pe=ou(D,0,Ze[1]),re=ou(z,Ze[0],Ze[2]),ye=ou(D,Ze[1],Ze[3]),Ae=Ze[0]-ue,pt=Ze[1]-pe,lt=Ze[2]-Ze[0]-re,st=Ze[3]-Ze[1]-ye}const $e=(Ze,ht,Ke,Be)=>{const bt=su(Ze.stretch-ue,re,T,i.left),yt=au(Ze.fixed-Ae,lt,Ze.stretch,U),Ht=su(ht.stretch-pe,ye,M,i.top),$i=au(ht.fixed-pt,st,ht.stretch,Z),nr=su(Ke.stretch-ue,re,T,i.left),Dr=au(Ke.fixed-Ae,lt,Ke.stretch,U),lo=su(Be.stretch-pe,ye,M,i.top),Fn=au(Be.fixed-pt,st,Be.stretch,Z),Mr=new ge(bt,Ht),Yr=new ge(nr,Ht),hn=new ge(nr,lo),Rn=new ge(bt,lo),On=new ge(yt/p,$i/p),Fr=new ge(Dr/p,Fn/p),Rr=e*Math.PI/180;if(Rr){const wn=Math.sin(Rr),Jn=Math.cos(Rr),Yn=[Jn,-wn,wn,Jn];Mr._matMult(Yn),Yr._matMult(Yn),Rn._matMult(Yn),hn._matMult(Yn)}const bn=Ze.stretch+Ze.fixed,Bn=ht.stretch+ht.fixed;return{tl:Mr,tr:Yr,bl:Rn,br:hn,tex:{x:h.paddedRect.x+Il+bn,y:h.paddedRect.y+Il+Bn,w:Ke.stretch+Ke.fixed-bn,h:Be.stretch+Be.fixed-Bn},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:On,pixelOffsetBR:Fr,minFontScaleX:lt/p/T,minFontScaleY:st/p/M,isSDF:r}};if(o&&(h.stretchX||h.stretchY)){const Ze=tp(z,$,U),ht=tp(D,ie,Z);for(let Ke=0;Ke0&&(U=Math.max(10,U),this.circleDiameter=U)}else{let z=p.top*y-w[0],D=p.bottom*y+w[2],N=p.left*y-w[3],U=p.right*y+w[1];const Z=p.collisionPadding;if(Z&&(N-=Z[0]*y,z-=Z[1]*y,U+=Z[2]*y,D+=Z[3]*y),M){const $=new ge(N,z),ie=new ge(U,z),ue=new ge(N,D),re=new ge(U,D),pe=M*Math.PI/180;$._rotate(pe),ie._rotate(pe),ue._rotate(pe),re._rotate(pe),N=Math.min($.x,ie.x,ue.x,re.x),U=Math.max($.x,ie.x,ue.x,re.x),z=Math.min($.y,ie.y,ue.y,re.y),D=Math.max($.y,ie.y,ue.y,re.y)}e.emplaceBack(r.x,r.y,N,z,U,D,o,l,h)}this.boxEndIndex=e.length}}class qm{constructor(e=[],r=Zm){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let o=(this.length>>1)-1;o>=0;o--)this._down(o)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:o}=this,l=r[e];for(;e>0;){const h=e-1>>1,p=r[h];if(o(l,p)>=0)break;r[e]=p,e=h}r[e]=l}_down(e){const{data:r,compare:o}=this,l=this.length>>1,h=r[e];for(;e=0)break;r[e]=y,e=p}r[e]=h}}function Zm(i,e){return ie?1:0}function Gm(i,e=1,r=!1){let o=1/0,l=1/0,h=-1/0,p=-1/0;const y=i[0];for(let N=0;Nh)&&(h=U.x),(!N||U.y>p)&&(p=U.y)}const w=Math.min(h-o,p-l);let T=w/2;const M=new qm([],Wm);if(w===0)return new ge(o,l);for(let N=o;Nz.d||!z.d)&&(z=N,r&&console.log("found best %d after %d probes",Math.round(1e4*N.d)/1e4,D)),N.max-z.d<=e||(T=N.h/2,M.push(new El(N.p.x-T,N.p.y-T,T,i)),M.push(new El(N.p.x+T,N.p.y-T,T,i)),M.push(new El(N.p.x-T,N.p.y+T,T,i)),M.push(new El(N.p.x+T,N.p.y+T,T,i)),D+=4)}return r&&(console.log(`num probes: ${D}`),console.log(`best distance: ${z.d}`)),z.p}function Wm(i,e){return e.max-i.max}function El(i,e,r,o){this.p=new ge(i,e),this.h=r,this.d=function(l,h){let p=!1,y=1/0;for(let w=0;wl.y!=U.y>l.y&&l.x<(U.x-N.x)*(l.y-N.y)/(U.y-N.y)+N.x&&(p=!p),y=Math.min(y,Oh(l,N,U))}}return(p?1:-1)*Math.sqrt(y)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}var un;s.aq=void 0,(un=s.aq||(s.aq={}))[un.center=1]="center",un[un.left=2]="left",un[un.right=3]="right",un[un.top=4]="top",un[un.bottom=5]="bottom",un[un["top-left"]=6]="top-left",un[un["top-right"]=7]="top-right",un[un["bottom-left"]=8]="bottom-left",un[un["bottom-right"]=9]="bottom-right";const La=7,th=Number.POSITIVE_INFINITY;function ip(i,e){return e[1]!==th?function(r,o,l){let h=0,p=0;switch(o=Math.abs(o),l=Math.abs(l),r){case"top-right":case"top-left":case"top":p=l-La;break;case"bottom-right":case"bottom-left":case"bottom":p=-l+La}switch(r){case"top-right":case"bottom-right":case"right":h=-o;break;case"top-left":case"bottom-left":case"left":h=o}return[h,p]}(i,e[0],e[1]):function(r,o){let l=0,h=0;o<0&&(o=0);const p=o/Math.SQRT2;switch(r){case"top-right":case"top-left":h=p-La;break;case"bottom-right":case"bottom-left":h=-p+La;break;case"bottom":h=-o+La;break;case"top":h=o-La}switch(r){case"top-right":case"bottom-right":l=-p;break;case"top-left":case"bottom-left":l=p;break;case"left":l=o;break;case"right":l=-o}return[l,h]}(i,e[0])}function rp(i,e,r){var o;const l=i.layout,h=(o=l.get("text-variable-anchor-offset"))===null||o===void 0?void 0:o.evaluate(e,{},r);if(h){const y=h.values,w=[];for(let T=0;TD*Lr);M.startsWith("top")?z[1]-=La:M.startsWith("bottom")&&(z[1]+=La),w[T+1]=z}return new Ir(w)}const p=l.get("text-variable-anchor");if(p){let y;y=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(e,{},r)*Lr,th]:l.get("text-offset").evaluate(e,{},r).map(T=>T*Lr);const w=[];for(const T of p)w.push(T,ip(T,y));return new Ir(w)}return null}function ih(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Hm(i,e,r,o,l,h,p,y,w,T,M){let z=h.textMaxSize.evaluate(e,{});z===void 0&&(z=p);const D=i.layers[0].layout,N=D.get("icon-offset").evaluate(e,{},M),U=op(r.horizontal),Z=p/24,$=i.tilePixelRatio*Z,ie=i.tilePixelRatio*z/24,ue=i.tilePixelRatio*y,re=i.tilePixelRatio*D.get("symbol-spacing"),pe=D.get("text-padding")*i.tilePixelRatio,ye=function(Be,bt,yt,Ht=1){const $i=Be.get("icon-padding").evaluate(bt,{},yt),nr=$i&&$i.values;return[nr[0]*Ht,nr[1]*Ht,nr[2]*Ht,nr[3]*Ht]}(D,e,M,i.tilePixelRatio),Ae=D.get("text-max-angle")/180*Math.PI,lt=D.get("text-rotation-alignment")!=="viewport"&&D.get("symbol-placement")!=="point",pt=D.get("icon-rotation-alignment")==="map"&&D.get("symbol-placement")!=="point",st=D.get("symbol-placement"),$e=re/2,Ze=D.get("icon-text-fit");let ht;o&&Ze!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(ht=Cd(o,r.vertical,Ze,D.get("icon-text-fit-padding"),N,Z)),U&&(o=Cd(o,U,Ze,D.get("icon-text-fit-padding"),N,Z)));const Ke=(Be,bt)=>{bt.x<0||bt.x>=Cr||bt.y<0||bt.y>=Cr||function(yt,Ht,$i,nr,Dr,lo,Fn,Mr,Yr,hn,Rn,On,Fr,Rr,bn,Bn,wn,Jn,Yn,Or,oi,Sn,dn,Br,No){const Qo=yt.addToLineVertexArray(Ht,$i);let $o,js,Vo,vo,Qn=0,qs=0,fc=0,cp=0,uh=-1,hh=-1;const Zs={};let up=Bs("");if(yt.allowVerticalPlacement&&nr.vertical){const Tn=Mr.layout.get("text-rotate").evaluate(oi,{},Br)+90;Vo=new lu(Yr,Ht,hn,Rn,On,nr.vertical,Fr,Rr,bn,Tn),Fn&&(vo=new lu(Yr,Ht,hn,Rn,On,Fn,wn,Jn,bn,Tn))}if(Dr){const Tn=Mr.layout.get("icon-rotate").evaluate(oi,{}),xo=Mr.layout.get("icon-text-fit")!=="none",el=ep(Dr,Tn,dn,xo),ts=Fn?ep(Fn,Tn,dn,xo):void 0;js=new lu(Yr,Ht,hn,Rn,On,Dr,wn,Jn,!1,Tn),Qn=4*el.length;const tl=yt.iconSizeData;let ys=null;tl.kind==="source"?(ys=[gs*Mr.layout.get("icon-size").evaluate(oi,{})],ys[0]>ka&&Dt(`${yt.layerIds[0]}: Value for "icon-size" is >= ${uc}. Reduce your "icon-size".`)):tl.kind==="composite"&&(ys=[gs*Sn.compositeIconSizes[0].evaluate(oi,{},Br),gs*Sn.compositeIconSizes[1].evaluate(oi,{},Br)],(ys[0]>ka||ys[1]>ka)&&Dt(`${yt.layerIds[0]}: Value for "icon-size" is >= ${uc}. Reduce your "icon-size".`)),yt.addSymbols(yt.icon,el,ys,Or,Yn,oi,s.ai.none,Ht,Qo.lineStartIndex,Qo.lineLength,-1,Br),uh=yt.icon.placedSymbolArray.length-1,ts&&(qs=4*ts.length,yt.addSymbols(yt.icon,ts,ys,Or,Yn,oi,s.ai.vertical,Ht,Qo.lineStartIndex,Qo.lineLength,-1,Br),hh=yt.icon.placedSymbolArray.length-1)}const hp=Object.keys(nr.horizontal);for(const Tn of hp){const xo=nr.horizontal[Tn];if(!$o){up=Bs(xo.text);const ts=Mr.layout.get("text-rotate").evaluate(oi,{},Br);$o=new lu(Yr,Ht,hn,Rn,On,xo,Fr,Rr,bn,ts)}const el=xo.positionedLines.length===1;if(fc+=np(yt,Ht,xo,lo,Mr,bn,oi,Bn,Qo,nr.vertical?s.ai.horizontal:s.ai.horizontalOnly,el?hp:[Tn],Zs,uh,Sn,Br),el)break}nr.vertical&&(cp+=np(yt,Ht,nr.vertical,lo,Mr,bn,oi,Bn,Qo,s.ai.vertical,["vertical"],Zs,hh,Sn,Br));const Jm=$o?$o.boxStartIndex:yt.collisionBoxArray.length,Ym=$o?$o.boxEndIndex:yt.collisionBoxArray.length,Qm=Vo?Vo.boxStartIndex:yt.collisionBoxArray.length,$m=Vo?Vo.boxEndIndex:yt.collisionBoxArray.length,e_=js?js.boxStartIndex:yt.collisionBoxArray.length,t_=js?js.boxEndIndex:yt.collisionBoxArray.length,i_=vo?vo.boxStartIndex:yt.collisionBoxArray.length,r_=vo?vo.boxEndIndex:yt.collisionBoxArray.length;let es=-1;const uu=(Tn,xo)=>Tn&&Tn.circleDiameter?Math.max(Tn.circleDiameter,xo):xo;es=uu($o,es),es=uu(Vo,es),es=uu(js,es),es=uu(vo,es);const dp=es>-1?1:0;dp&&(es*=No/Lr),yt.glyphOffsetArray.length>=Tl.MAX_GLYPHS&&Dt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),oi.sortKey!==void 0&&yt.addToSortKeyRanges(yt.symbolInstances.length,oi.sortKey);const n_=rp(Mr,oi,Br),[o_,s_]=function(Tn,xo){const el=Tn.length,ts=xo==null?void 0:xo.values;if((ts==null?void 0:ts.length)>0)for(let tl=0;tl=0?Zs.right:-1,Zs.center>=0?Zs.center:-1,Zs.left>=0?Zs.left:-1,Zs.vertical||-1,uh,hh,up,Jm,Ym,Qm,$m,e_,t_,i_,r_,hn,fc,cp,Qn,qs,dp,0,Fr,es,o_,s_)}(i,bt,Be,r,o,l,ht,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,$,[pe,pe,pe,pe],lt,w,ue,ye,pt,N,e,h,T,M,p)};if(st==="line")for(const Be of Xd(e.geometry,0,0,Cr,Cr)){const bt=jm(Be,re,Ae,r.vertical||U,o,24,ie,i.overscaling,Cr);for(const yt of bt)U&&Xm(i,U.text,$e,yt)||Ke(Be,yt)}else if(st==="line-center"){for(const Be of e.geometry)if(Be.length>1){const bt=Um(Be,Ae,r.vertical||U,o,24,ie);bt&&Ke(Be,bt)}}else if(e.type==="Polygon")for(const Be of Du(e.geometry,0)){const bt=Gm(Be,16);Ke(Be[0],new za(bt.x,bt.y,0))}else if(e.type==="LineString")for(const Be of e.geometry)Ke(Be,new za(Be[0].x,Be[0].y,0));else if(e.type==="Point")for(const Be of e.geometry)for(const bt of Be)Ke([bt],new za(bt.x,bt.y,0))}function np(i,e,r,o,l,h,p,y,w,T,M,z,D,N,U){const Z=function(ue,re,pe,ye,Ae,lt,pt,st){const $e=ye.layout.get("text-rotate").evaluate(lt,{})*Math.PI/180,Ze=[];for(const ht of re.positionedLines)for(const Ke of ht.positionedGlyphs){if(!Ke.rect)continue;const Be=Ke.rect||{};let bt=xd+1,yt=!0,Ht=1,$i=0;const nr=(Ae||st)&&Ke.vertical,Dr=Ke.metrics.advance*Ke.scale/2;if(st&&re.verticalizable&&($i=ht.lineOffset/2-(Ke.imageName?-(Lr-Ke.metrics.width*Ke.scale)/2:(Ke.scale-1)*Lr)),Ke.imageName){const Or=pt[Ke.imageName];yt=Or.sdf,Ht=Or.pixelRatio,bt=Kn/Ht}const lo=Ae?[Ke.x+Dr,Ke.y]:[0,0];let Fn=Ae?[0,0]:[Ke.x+Dr+pe[0],Ke.y+pe[1]-$i],Mr=[0,0];nr&&(Mr=Fn,Fn=[0,0]);const Yr=Ke.metrics.isDoubleResolution?2:1,hn=(Ke.metrics.left-bt)*Ke.scale-Dr+Fn[0],Rn=(-Ke.metrics.top-bt)*Ke.scale+Fn[1],On=hn+Be.w/Yr*Ke.scale/Ht,Fr=Rn+Be.h/Yr*Ke.scale/Ht,Rr=new ge(hn,Rn),bn=new ge(On,Rn),Bn=new ge(hn,Fr),wn=new ge(On,Fr);if(nr){const Or=new ge(-Dr,Dr-lc),oi=-Math.PI/2,Sn=Lr/2-Dr,dn=new ge(5-lc-Sn,-(Ke.imageName?Sn:0)),Br=new ge(...Mr);Rr._rotateAround(oi,Or)._add(dn)._add(Br),bn._rotateAround(oi,Or)._add(dn)._add(Br),Bn._rotateAround(oi,Or)._add(dn)._add(Br),wn._rotateAround(oi,Or)._add(dn)._add(Br)}if($e){const Or=Math.sin($e),oi=Math.cos($e),Sn=[oi,-Or,Or,oi];Rr._matMult(Sn),bn._matMult(Sn),Bn._matMult(Sn),wn._matMult(Sn)}const Jn=new ge(0,0),Yn=new ge(0,0);Ze.push({tl:Rr,tr:bn,bl:Bn,br:wn,tex:Be,writingMode:re.writingMode,glyphOffset:lo,sectionIndex:Ke.sectionIndex,isSDF:yt,pixelOffsetTL:Jn,pixelOffsetBR:Yn,minFontScaleX:0,minFontScaleY:0})}return Ze}(0,r,y,l,h,p,o,i.allowVerticalPlacement),$=i.textSizeData;let ie=null;$.kind==="source"?(ie=[gs*l.layout.get("text-size").evaluate(p,{})],ie[0]>ka&&Dt(`${i.layerIds[0]}: Value for "text-size" is >= ${uc}. Reduce your "text-size".`)):$.kind==="composite"&&(ie=[gs*N.compositeTextSizes[0].evaluate(p,{},U),gs*N.compositeTextSizes[1].evaluate(p,{},U)],(ie[0]>ka||ie[1]>ka)&&Dt(`${i.layerIds[0]}: Value for "text-size" is >= ${uc}. Reduce your "text-size".`)),i.addSymbols(i.text,Z,ie,y,h,p,T,e,w.lineStartIndex,w.lineLength,D,U);for(const ue of M)z[ue]=i.text.placedSymbolArray.length-1;return 4*Z.length}function op(i){for(const e in i)return i[e];return null}function Xm(i,e,r,o){const l=i.compareText;if(e in l){const h=l[e];for(let p=h.length-1;p>=0;p--)if(o.dist(h[p])>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);const h=sp[15&o];if(!h)throw new Error("Unrecognized array type.");const[p]=new Uint16Array(e,2,1),[y]=new Uint32Array(e,4,1);return new rh(y,p,h,e)}constructor(e,r=64,o=Float64Array,l){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=o,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const h=sp.indexOf(this.ArrayType),p=2*e*this.ArrayType.BYTES_PER_ELEMENT,y=e*this.IndexArrayType.BYTES_PER_ELEMENT,w=(8-y%8)%8;if(h<0)throw new Error(`Unexpected typed array class: ${o}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+y+w,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+p+y+w),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+y+w,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+h]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const o=this._pos>>1;return this.ids[o]=o,this.coords[this._pos++]=e,this.coords[this._pos++]=r,o}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return nh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,o,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:h,coords:p,nodeSize:y}=this,w=[0,h.length-1,0],T=[];for(;w.length;){const M=w.pop()||0,z=w.pop()||0,D=w.pop()||0;if(z-D<=y){for(let $=D;$<=z;$++){const ie=p[2*$],ue=p[2*$+1];ie>=e&&ie<=o&&ue>=r&&ue<=l&&T.push(h[$])}continue}const N=D+z>>1,U=p[2*N],Z=p[2*N+1];U>=e&&U<=o&&Z>=r&&Z<=l&&T.push(h[N]),(M===0?e<=U:r<=Z)&&(w.push(D),w.push(N-1),w.push(1-M)),(M===0?o>=U:l>=Z)&&(w.push(N+1),w.push(z),w.push(1-M))}return T}within(e,r,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:h,nodeSize:p}=this,y=[0,l.length-1,0],w=[],T=o*o;for(;y.length;){const M=y.pop()||0,z=y.pop()||0,D=y.pop()||0;if(z-D<=p){for(let $=D;$<=z;$++)lp(h[2*$],h[2*$+1],e,r)<=T&&w.push(l[$]);continue}const N=D+z>>1,U=h[2*N],Z=h[2*N+1];lp(U,Z,e,r)<=T&&w.push(l[N]),(M===0?e-o<=U:r-o<=Z)&&(y.push(D),y.push(N-1),y.push(1-M)),(M===0?e+o>=U:r+o>=Z)&&(y.push(N+1),y.push(z),y.push(1-M))}return w}}function nh(i,e,r,o,l,h){if(l-o<=r)return;const p=o+l>>1;ap(i,e,p,o,l,h),nh(i,e,r,o,p-1,1-h),nh(i,e,r,p+1,l,1-h)}function ap(i,e,r,o,l,h){for(;l>o;){if(l-o>600){const T=l-o+1,M=r-o+1,z=Math.log(T),D=.5*Math.exp(2*z/3),N=.5*Math.sqrt(z*D*(T-D)/T)*(M-T/2<0?-1:1);ap(i,e,r,Math.max(o,Math.floor(r-M*D/T+N)),Math.min(l,Math.floor(r+(T-M)*D/T+N)),h)}const p=e[2*r+h];let y=o,w=l;for(dc(i,e,o,r),e[2*l+h]>p&&dc(i,e,o,l);yp;)w--}e[2*o+h]===p?dc(i,e,o,w):(w++,dc(i,e,w,l)),w<=r&&(o=w+1),r<=w&&(l=w-1)}}function dc(i,e,r,o){oh(i,r,o),oh(e,2*r,2*o),oh(e,2*r+1,2*o+1)}function oh(i,e,r){const o=i[e];i[e]=i[r],i[r]=o}function lp(i,e,r,o){const l=i-r,h=e-o;return l*l+h*h}var sh;s.bh=void 0,(sh=s.bh||(s.bh={})).create="create",sh.load="load",sh.fullLoad="fullLoad";let cu=null,pc=[];const ah=1e3/60,lh="loadTime",ch="fullLoadTime",Km={mark(i){performance.mark(i)},frame(i){const e=i;cu!=null&&pc.push(e-cu),cu=e},clearMetrics(){cu=null,pc=[],performance.clearMeasures(lh),performance.clearMeasures(ch);for(const i in s.bh)performance.clearMarks(s.bh[i])},getPerformanceMetrics(){performance.measure(lh,s.bh.create,s.bh.load),performance.measure(ch,s.bh.create,s.bh.fullLoad);const i=performance.getEntriesByName(lh)[0].duration,e=performance.getEntriesByName(ch)[0].duration,r=pc.length,o=1/(pc.reduce((h,p)=>h+p,0)/r/1e3),l=pc.filter(h=>h>ah).reduce((h,p)=>h+(p-ah)/ah,0);return{loadTime:i,fullLoadTime:e,fps:o,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};s.$=function(i,e,r){var o,l,h,p,y,w,T,M,z,D,N,U,Z=r[0],$=r[1],ie=r[2];return e===i?(i[12]=e[0]*Z+e[4]*$+e[8]*ie+e[12],i[13]=e[1]*Z+e[5]*$+e[9]*ie+e[13],i[14]=e[2]*Z+e[6]*$+e[10]*ie+e[14],i[15]=e[3]*Z+e[7]*$+e[11]*ie+e[15]):(l=e[1],h=e[2],p=e[3],y=e[4],w=e[5],T=e[6],M=e[7],z=e[8],D=e[9],N=e[10],U=e[11],i[0]=o=e[0],i[1]=l,i[2]=h,i[3]=p,i[4]=y,i[5]=w,i[6]=T,i[7]=M,i[8]=z,i[9]=D,i[10]=N,i[11]=U,i[12]=o*Z+y*$+z*ie+e[12],i[13]=l*Z+w*$+D*ie+e[13],i[14]=h*Z+T*$+N*ie+e[14],i[15]=p*Z+M*$+U*ie+e[15]),i},s.A=yl,s.B=Hr,s.C=class{constructor(i,e,r){this.receive=o=>{const l=o.data,h=l.id;if(h&&(!l.targetMapId||this.mapId===l.targetMapId))if(l.type===""){delete this.tasks[h];const p=this.cancelCallbacks[h];delete this.cancelCallbacks[h],p&&p()}else pi()||l.mustQueue?(this.tasks[h]=l,this.taskQueue.push(h),this.invoker.trigger()):this.processTask(h,l)},this.process=()=>{if(!this.taskQueue.length)return;const o=this.taskQueue.shift(),l=this.tasks[o];delete this.tasks[o],this.taskQueue.length&&this.invoker.trigger(),l&&this.processTask(o,l)},this.target=i,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},this.invoker=new Nm(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=pi()?i:window}send(i,e,r,o,l=!1){const h=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(this.callbacks[h]=r);const p=[],y={id:h,type:i,hasCallback:!!r,targetMapId:o,mustQueue:l,sourceMapId:this.mapId,data:Pn(e,p)};return this.target.postMessage(y,{transfer:p}),{cancel:()=>{r&&delete this.callbacks[h],this.target.postMessage({id:h,type:"",targetMapId:o,sourceMapId:this.mapId})}}}processTask(i,e){if(e.type===""){const r=this.callbacks[i];delete this.callbacks[i],r&&(e.error?r(_o(e.error)):r(null,_o(e.data)))}else{let r=!1;const o=[],l=e.hasCallback?(y,w)=>{r=!0,delete this.cancelCallbacks[i];const T={id:i,type:"",sourceMapId:this.mapId,error:y?Pn(y):null,data:Pn(w,o)};this.target.postMessage(T,{transfer:o})}:y=>{r=!0};let h=null;const p=_o(e.data);if(this.parent[e.type])h=this.parent[e.type](e.sourceMapId,p,l);else if("getWorkerSource"in this.parent){const y=e.type.split(".");h=this.parent.getWorkerSource(e.sourceMapId,y[0],p.source)[y[1]](p,l)}else l(new Error(`Could not find function ${e.type}`));!r&&h&&h.cancel&&(this.cancelCallbacks[i]=h.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},s.D=xt,s.E=jo,s.F=function(i,e){const r={};for(let o=0;o{}}},s.Y=qe,s.Z=function(){var i=new yl(16);return yl!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},s._=H,s.a=en,s.a$=class extends R{},s.a0=function(i,e,r){var o=r[0],l=r[1],h=r[2];return i[0]=e[0]*o,i[1]=e[1]*o,i[2]=e[2]*o,i[3]=e[3]*o,i[4]=e[4]*l,i[5]=e[5]*l,i[6]=e[6]*l,i[7]=e[7]*l,i[8]=e[8]*h,i[9]=e[9]*h,i[10]=e[10]*h,i[11]=e[11]*h,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},s.a1=Uh,s.a2=function(){return Yt++},s.a3=K,s.a4=Tl,s.a5=function(){Hn.isLoading()||Hn.isLoaded()||Ul()!=="deferred"||Oc()},s.a6=ga,s.a7=Qa,s.a8=Yi,s.a9=Zd,s.aA=Wa,s.aB=function(i){i=i.slice();const e=Object.create(null);for(let r=0;r{o[p.source]?r.push({command:ii.removeLayer,args:[p.id]}):h.push(p)}),r=r.concat(l),function(p,y,w){y=y||[];const T=(p=p||[]).map(Cn),M=y.map(Cn),z=p.reduce($n,{}),D=y.reduce($n,{}),N=T.slice(),U=Object.create(null);let Z,$,ie,ue,re,pe,ye;for(Z=0,$=0;Z@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,o,l,h)=>{const p=l||h;return e[o]=!p||p.toLowerCase(),""}),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},s.ab=function(i,e){const r=[];for(const o in i)o in e||r.push(o);return r},s.ac=function(i){if(Pi==null){const e=i.navigator?i.navigator.userAgent:null;Pi=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Pi},s.ad=ti,s.ae=function(i,e,r){var o=Math.sin(r),l=Math.cos(r),h=e[0],p=e[1],y=e[2],w=e[3],T=e[4],M=e[5],z=e[6],D=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=h*l+T*o,i[1]=p*l+M*o,i[2]=y*l+z*o,i[3]=w*l+D*o,i[4]=T*l-h*o,i[5]=M*l-p*o,i[6]=z*l-y*o,i[7]=D*l-w*o,i},s.af=function(i){var e=new yl(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},s.ag=Hc,s.ah=function(i,e){let r=0,o=0;if(i.kind==="constant")o=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:l,minZoom:h,maxZoom:p}=i,y=l?ti(sn.interpolationFactor(l,e,h,p),0,1):0;i.kind==="camera"?o=Hr.number(i.minSize,i.maxSize,y):r=y}return{uSizeT:r,uSize:o}},s.aj=function(i,{uSize:e,uSizeT:r},{lowerSize:o,upperSize:l}){return i.kind==="source"?o/gs:i.kind==="composite"?Hr.number(o/gs,l/gs,r):e},s.ak=Xu,s.al=function(i,e,r,o){const l=e.y-i.y,h=e.x-i.x,p=o.y-r.y,y=o.x-r.x,w=p*h-y*l;if(w===0)return null;const T=(y*(i.y-r.y)-p*(i.x-r.x))/w;return new ge(i.x+T*h,i.y+T*l)},s.am=Xd,s.an=Fh,s.ao=Cu,s.ap=Lr,s.ar=Hu,s.as=function(i,e){var r=e[0],o=e[1],l=e[2],h=e[3],p=e[4],y=e[5],w=e[6],T=e[7],M=e[8],z=e[9],D=e[10],N=e[11],U=e[12],Z=e[13],$=e[14],ie=e[15],ue=r*y-o*p,re=r*w-l*p,pe=r*T-h*p,ye=o*w-l*y,Ae=o*T-h*y,lt=l*T-h*w,pt=M*Z-z*U,st=M*$-D*U,$e=M*ie-N*U,Ze=z*$-D*Z,ht=z*ie-N*Z,Ke=D*ie-N*$,Be=ue*Ke-re*ht+pe*Ze+ye*$e-Ae*st+lt*pt;return Be?(i[0]=(y*Ke-w*ht+T*Ze)*(Be=1/Be),i[1]=(l*ht-o*Ke-h*Ze)*Be,i[2]=(Z*lt-$*Ae+ie*ye)*Be,i[3]=(D*Ae-z*lt-N*ye)*Be,i[4]=(w*$e-p*Ke-T*st)*Be,i[5]=(r*Ke-l*$e+h*st)*Be,i[6]=($*pe-U*lt-ie*re)*Be,i[7]=(M*lt-D*pe+N*re)*Be,i[8]=(p*ht-y*$e+T*pt)*Be,i[9]=(o*$e-r*ht-h*pt)*Be,i[10]=(U*Ae-Z*pe+ie*ue)*Be,i[11]=(z*pe-M*Ae-N*ue)*Be,i[12]=(y*st-p*Ze-w*pt)*Be,i[13]=(r*Ze-o*st+l*pt)*Be,i[14]=(Z*re-U*ye-$*ue)*Be,i[15]=(M*ye-z*re+D*ue)*Be,i):null},s.at=ih,s.au=Wu,s.av=rh,s.aw=function(){const i={},e=Se.$version;for(const r in Se.$root){const o=Se.$root[r];if(o.required){let l=null;l=r==="version"?e:o.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},s.ax=ii,s.ay=Jo,s.az=Gt,s.b=function(i,e){const r=new Blob([new Uint8Array(i)],{type:"image/png"});createImageBitmap(r).then(o=>{e(null,o)}).catch(o=>{e(new Error(`Could not load image because of ${o.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})},s.b0=Kr,s.b1=function(i,e){var r=i[0],o=i[1],l=i[2],h=i[3],p=i[4],y=i[5],w=i[6],T=i[7],M=i[8],z=i[9],D=i[10],N=i[11],U=i[12],Z=i[13],$=i[14],ie=i[15],ue=e[0],re=e[1],pe=e[2],ye=e[3],Ae=e[4],lt=e[5],pt=e[6],st=e[7],$e=e[8],Ze=e[9],ht=e[10],Ke=e[11],Be=e[12],bt=e[13],yt=e[14],Ht=e[15];return Math.abs(r-ue)<=Dn*Math.max(1,Math.abs(r),Math.abs(ue))&&Math.abs(o-re)<=Dn*Math.max(1,Math.abs(o),Math.abs(re))&&Math.abs(l-pe)<=Dn*Math.max(1,Math.abs(l),Math.abs(pe))&&Math.abs(h-ye)<=Dn*Math.max(1,Math.abs(h),Math.abs(ye))&&Math.abs(p-Ae)<=Dn*Math.max(1,Math.abs(p),Math.abs(Ae))&&Math.abs(y-lt)<=Dn*Math.max(1,Math.abs(y),Math.abs(lt))&&Math.abs(w-pt)<=Dn*Math.max(1,Math.abs(w),Math.abs(pt))&&Math.abs(T-st)<=Dn*Math.max(1,Math.abs(T),Math.abs(st))&&Math.abs(M-$e)<=Dn*Math.max(1,Math.abs(M),Math.abs($e))&&Math.abs(z-Ze)<=Dn*Math.max(1,Math.abs(z),Math.abs(Ze))&&Math.abs(D-ht)<=Dn*Math.max(1,Math.abs(D),Math.abs(ht))&&Math.abs(N-Ke)<=Dn*Math.max(1,Math.abs(N),Math.abs(Ke))&&Math.abs(U-Be)<=Dn*Math.max(1,Math.abs(U),Math.abs(Be))&&Math.abs(Z-bt)<=Dn*Math.max(1,Math.abs(Z),Math.abs(bt))&&Math.abs($-yt)<=Dn*Math.max(1,Math.abs($),Math.abs(yt))&&Math.abs(ie-Ht)<=Dn*Math.max(1,Math.abs(ie),Math.abs(Ht))},s.b2=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},s.b3=function(i,e,r){return i[0]=e[0]*r[0],i[1]=e[1]*r[1],i[2]=e[2]*r[2],i[3]=e[3]*r[3],i},s.b4=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]*e[3]},s.b5=Xt,s.b6=Ud,s.b7=Bd,s.b8=function(i,e,r,o,l){var h,p=1/Math.tan(e/2);return i[0]=p/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=p,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,l!=null&&l!==1/0?(i[10]=(l+o)*(h=1/(o-l)),i[14]=2*l*o*h):(i[10]=-1,i[14]=-2*o),i},s.b9=function(i,e,r){var o=Math.sin(r),l=Math.cos(r),h=e[4],p=e[5],y=e[6],w=e[7],T=e[8],M=e[9],z=e[10],D=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=h*l+T*o,i[5]=p*l+M*o,i[6]=y*l+z*o,i[7]=w*l+D*o,i[8]=T*l-h*o,i[9]=M*l-p*o,i[10]=z*l-y*o,i[11]=D*l-w*o,i},s.bA=me,s.bB=pd,s.bC=ma,s.bD=Hn,s.ba=it,s.bb=Vt,s.bc=function(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},s.bd=class extends Ja{},s.be=Qu,s.bf=Nd,s.bg=Km,s.bi=He,s.bj=function(i,e,r=!1){if(zn===Rl||zn===Ol||zn===Bl)throw new Error("setRTLTextPlugin cannot be called multiple times.");ms=Fe.resolveURL(i),zn=Rl,Nl=e,Vl(),r||Oc()},s.bk=Ul,s.bl=function(i,e){const r={};for(let l=0;lBe*Lr)}let st=p?"center":r.get("text-justify").evaluate(T,{},i.canonical);const $e=r.get("symbol-placement"),Ze=$e==="point"?r.get("text-max-width").evaluate(T,{},i.canonical)*Lr:0,ht=()=>{i.bucket.allowVerticalPlacement&&Sa(pe)&&(U.vertical=eu(Z,i.glyphMap,i.glyphPositions,i.imagePositions,M,Ze,h,lt,"left",Ae,ie,s.ai.vertical,!0,$e,D,z))};if(!p&&pt){const Ke=new Set;if(st==="auto")for(let bt=0;bt{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>{r.src=Vr})},r.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new Blob([new Uint8Array(i)],{type:"image/png"});r.src=i.byteLength?URL.createObjectURL(o):Vr},s.e=Nt,s.f=function(i,e){return gr(Nt(i,{type:"json"}),e)},s.g=ct,s.h=Fe,s.i=pi,s.j=wo,s.k=co,s.l=Ue,s.m=gr,s.n=function(i){return new ju(i).readFields(Tm,[])},s.o=function(i,e,r){if(!i.length)return r(null,[]);let o=i.length;const l=new Array(i.length);let h=null;i.forEach((p,y)=>{e(p,(w,T)=>{w&&(h=w),l[y]=T,--o==0&&r(h,l)})})},s.p=bd,s.q=ec,s.r=br,s.s=Bi,s.t=Li,s.u=Xe,s.v=Se,s.w=Dt,s.x=Gn,s.y=mo,s.z=function([i,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(e)*Math.sin(r),y:i*Math.sin(e)*Math.sin(r),z:i*Math.cos(r)}}}),k(["./shared"],function(s){class H{constructor(L){this.keyCache={},L&&this.replace(L)}replace(L){this._layerConfigs={},this._layers={},this.update(L,[])}update(L,F){for(const J of L){this._layerConfigs[J.id]=J;const Q=this._layers[J.id]=s.aC(J);Q._featureFilter=s.a6(Q.filter),this.keyCache[J.id]&&delete this.keyCache[J.id]}for(const J of F)delete this.keyCache[J],delete this._layerConfigs[J],delete this._layers[J];this.familiesBySource={};const j=s.bl(Object.values(this._layerConfigs),this.keyCache);for(const J of j){const Q=J.map(Ie=>this._layers[Ie.id]),he=Q[0];if(he.visibility==="none")continue;const oe=he.source||"";let te=this.familiesBySource[oe];te||(te=this.familiesBySource[oe]={});const ae=he.sourceLayer||"_geojsonTileLayer";let Te=te[ae];Te||(Te=te[ae]=[]),Te.push(Q)}}}class V{constructor(L){const F={},j=[];for(const oe in L){const te=L[oe],ae=F[oe]={};for(const Te in te){const Ie=te[+Te];if(!Ie||Ie.bitmap.width===0||Ie.bitmap.height===0)continue;const Ce={x:0,y:0,w:Ie.bitmap.width+2,h:Ie.bitmap.height+2};j.push(Ce),ae[Te]={rect:Ce,metrics:Ie.metrics}}}const{w:J,h:Q}=s.p(j),he=new s.q({width:J||1,height:Q||1});for(const oe in L){const te=L[oe];for(const ae in te){const Te=te[+ae];if(!Te||Te.bitmap.width===0||Te.bitmap.height===0)continue;const Ie=F[oe][ae].rect;s.q.copy(Te.bitmap,he,{x:0,y:0},{x:Ie.x+1,y:Ie.y+1},Te.bitmap)}}this.image=he,this.positions=F}}s.bm("GlyphAtlas",V);class me{constructor(L){this.tileID=new s.O(L.tileID.overscaledZ,L.tileID.wrap,L.tileID.canonical.z,L.tileID.canonical.x,L.tileID.canonical.y),this.uid=L.uid,this.zoom=L.zoom,this.pixelRatio=L.pixelRatio,this.tileSize=L.tileSize,this.source=L.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=L.showCollisionBoxes,this.collectResourceTiming=!!L.collectResourceTiming,this.returnDependencies=!!L.returnDependencies,this.promoteId=L.promoteId,this.inFlightDependencies=[],this.dependencySentinel=-1}parse(L,F,j,J,Q){this.status="parsing",this.data=L,this.collisionBoxArray=new s.a3;const he=new s.bn(Object.keys(L.layers).sort()),oe=new s.bo(this.tileID,this.promoteId);oe.bucketLayerIDs=[];const te={},ae={featureIndex:oe,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:j},Te=F.familiesBySource[this.source];for(const ai in Te){const ri=L.layers[ai];if(!ri)continue;ri.version===1&&s.w(`Vector tile source "${this.source}" layer "${ai}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const jr=he.encode(ai),Ei=[];for(let hr=0;hr=vr.maxzoom||vr.visibility!=="none"&&(be(hr,this.zoom,j),(te[vr.id]=vr.createBucket({index:oe.bucketLayerIDs.length,layers:hr,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:jr,sourceID:this.source})).populate(Ei,ae,this.tileID.canonical),oe.bucketLayerIDs.push(hr.map(An=>An.id)))}}let Ie,Ce,mt,kt;const ut=s.aH(ae.glyphDependencies,ai=>Object.keys(ai).map(Number));this.inFlightDependencies.forEach(ai=>ai==null?void 0:ai.cancel()),this.inFlightDependencies=[];const vt=++this.dependencySentinel;Object.keys(ut).length?this.inFlightDependencies.push(J.send("getGlyphs",{uid:this.uid,stacks:ut,source:this.source,tileID:this.tileID,type:"glyphs"},(ai,ri)=>{vt===this.dependencySentinel&&(Ie||(Ie=ai,Ce=ri,Ut.call(this)))})):Ce={};const Ft=Object.keys(ae.iconDependencies);Ft.length?this.inFlightDependencies.push(J.send("getImages",{icons:Ft,source:this.source,tileID:this.tileID,type:"icons"},(ai,ri)=>{vt===this.dependencySentinel&&(Ie||(Ie=ai,mt=ri,Ut.call(this)))})):mt={};const gi=Object.keys(ae.patternDependencies);function Ut(){if(Ie)return Q(Ie);if(Ce&&mt&&kt){const ai=new V(Ce),ri=new s.bp(mt,kt);for(const jr in te){const Ei=te[jr];Ei instanceof s.a4?(be(Ei.layers,this.zoom,j),s.bq({bucket:Ei,glyphMap:Ce,glyphPositions:ai.positions,imageMap:mt,imagePositions:ri.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):Ei.hasPattern&&(Ei instanceof s.br||Ei instanceof s.bs||Ei instanceof s.bt)&&(be(Ei.layers,this.zoom,j),Ei.addFeatures(ae,this.tileID.canonical,ri.patternPositions))}this.status="done",Q(null,{buckets:Object.values(te).filter(jr=>!jr.isEmpty()),featureIndex:oe,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ai.image,imageAtlas:ri,glyphMap:this.returnDependencies?Ce:null,iconMap:this.returnDependencies?mt:null,glyphPositions:this.returnDependencies?ai.positions:null})}}gi.length?this.inFlightDependencies.push(J.send("getImages",{icons:gi,source:this.source,tileID:this.tileID,type:"patterns"},(ai,ri)=>{vt===this.dependencySentinel&&(Ie||(Ie=ai,kt=ri,Ut.call(this)))})):kt={},Ut.call(this)}}function be(X,L,F){const j=new s.a8(L);for(const J of X)J.recalculate(j,F)}function ge(X,L){const F=s.l(X.request,(j,J,Q,he)=>{if(j)L(j);else if(J)try{const oe=new s.bw.VectorTile(new s.bv(J));L(null,{vectorTile:oe,rawData:J,cacheControl:Q,expires:he})}catch(oe){const te=new Uint8Array(J);let ae=`Unable to parse the tile at ${X.request.url}, `;ae+=te[0]===31&&te[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${oe.messge}`,L(new Error(ae))}});return()=>{F.cancel(),L()}}class De{constructor(L,F,j,J){this.actor=L,this.layerIndex=F,this.availableImages=j,this.loadVectorData=J||ge,this.fetching={},this.loading={},this.loaded={}}loadTile(L,F){const j=L.uid;this.loading||(this.loading={});const J=!!(L&&L.request&&L.request.collectResourceTiming)&&new s.bu(L.request),Q=this.loading[j]=new me(L);Q.abort=this.loadVectorData(L,(he,oe)=>{if(delete this.loading[j],he||!oe)return Q.status="done",this.loaded[j]=Q,F(he);const te=oe.rawData,ae={};oe.expires&&(ae.expires=oe.expires),oe.cacheControl&&(ae.cacheControl=oe.cacheControl);const Te={};if(J){const Ie=J.finish();Ie&&(Te.resourceTiming=JSON.parse(JSON.stringify(Ie)))}Q.vectorTile=oe.vectorTile,Q.parse(oe.vectorTile,this.layerIndex,this.availableImages,this.actor,(Ie,Ce)=>{if(delete this.fetching[j],Ie||!Ce)return F(Ie);F(null,s.e({rawTileData:te.slice(0)},Ce,ae,Te))}),this.loaded=this.loaded||{},this.loaded[j]=Q,this.fetching[j]={rawTileData:te,cacheControl:ae,resourceTiming:Te}})}reloadTile(L,F){const j=this.loaded,J=L.uid;if(j&&j[J]){const Q=j[J];Q.showCollisionBoxes=L.showCollisionBoxes,Q.status==="parsing"?Q.parse(Q.vectorTile,this.layerIndex,this.availableImages,this.actor,(he,oe)=>{if(he||!oe)return F(he,oe);let te;if(this.fetching[J]){const{rawTileData:ae,cacheControl:Te,resourceTiming:Ie}=this.fetching[J];delete this.fetching[J],te=s.e({rawTileData:ae.slice(0)},oe,Te,Ie)}else te=oe;F(null,te)}):Q.status==="done"&&(Q.vectorTile?Q.parse(Q.vectorTile,this.layerIndex,this.availableImages,this.actor,F):F())}}abortTile(L,F){const j=this.loading,J=L.uid;j&&j[J]&&j[J].abort&&(j[J].abort(),delete j[J]),F()}removeTile(L,F){const j=this.loaded,J=L.uid;j&&j[J]&&delete j[J],F()}}class Ee{constructor(){this.loaded={}}loadTile(L,F){return s._(this,void 0,void 0,function*(){const{uid:j,encoding:J,rawImageData:Q,redFactor:he,greenFactor:oe,blueFactor:te,baseShift:ae}=L,Te=Q.width+2,Ie=Q.height+2,Ce=s.a(Q)?new s.R({width:Te,height:Ie},yield s.bx(Q,-1,-1,Te,Ie)):Q,mt=new s.by(j,Ce,J,he,oe,te,ae);this.loaded=this.loaded||{},this.loaded[j]=mt,F(null,mt)})}removeTile(L){const F=this.loaded,j=L.uid;F&&F[j]&&delete F[j]}}function Le(X,L){if(X.length!==0){Ne(X[0],L);for(var F=1;F=Math.abs(oe)?F-te+oe:oe-te+F,F=te}F+j>=0!=!!L&&X.reverse()}var et=s.bz(function X(L,F){var j,J=L&&L.type;if(J==="FeatureCollection")for(j=0;j>31}function pi(X,L){for(var F=X.loadGeometry(),j=X.type,J=0,Q=0,he=F.length,oe=0;oeX},zi=Math.fround||(Ti=new Float32Array(1),X=>(Ti[0]=+X,Ti[0]));var Ti;const Tt=3,fi=5,Oi=6;class Fe{constructor(L){this.options=Object.assign(Object.create(Vr),L),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(L){const{log:F,minZoom:j,maxZoom:J}=this.options;F&&console.time("total time");const Q=`prepare ${L.length} points`;F&&console.time(Q),this.points=L;const he=[];for(let te=0;te=j;te--){const ae=+Date.now();oe=this.trees[te]=this._createTree(this._cluster(oe,te)),F&&console.log("z%d: %d clusters in %dms",te,oe.numItems,+Date.now()-ae)}return F&&console.timeEnd("total time"),this}getClusters(L,F){let j=((L[0]+180)%360+360)%360-180;const J=Math.max(-90,Math.min(90,L[1]));let Q=L[2]===180?180:((L[2]+180)%360+360)%360-180;const he=Math.max(-90,Math.min(90,L[3]));if(L[2]-L[0]>=360)j=-180,Q=180;else if(j>Q){const Ie=this.getClusters([j,J,180,he],F),Ce=this.getClusters([-180,J,Q,he],F);return Ie.concat(Ce)}const oe=this.trees[this._limitZoom(F)],te=oe.range(Gt(j),ct(he),Gt(Q),ct(J)),ae=oe.data,Te=[];for(const Ie of te){const Ce=this.stride*Ie;Te.push(ae[Ce+fi]>1?Pt(ae,Ce,this.clusterProps):this.points[ae[Ce+Tt]])}return Te}getChildren(L){const F=this._getOriginId(L),j=this._getOriginZoom(L),J="No cluster with the specified id.",Q=this.trees[j];if(!Q)throw new Error(J);const he=Q.data;if(F*this.stride>=he.length)throw new Error(J);const oe=this.options.radius/(this.options.extent*Math.pow(2,j-1)),te=Q.within(he[F*this.stride],he[F*this.stride+1],oe),ae=[];for(const Te of te){const Ie=Te*this.stride;he[Ie+4]===L&&ae.push(he[Ie+fi]>1?Pt(he,Ie,this.clusterProps):this.points[he[Ie+Tt]])}if(ae.length===0)throw new Error(J);return ae}getLeaves(L,F,j){const J=[];return this._appendLeaves(J,L,F=F||10,j=j||0,0),J}getTile(L,F,j){const J=this.trees[this._limitZoom(L)],Q=Math.pow(2,L),{extent:he,radius:oe}=this.options,te=oe/he,ae=(j-te)/Q,Te=(j+1+te)/Q,Ie={features:[]};return this._addTileFeatures(J.range((F-te)/Q,ae,(F+1+te)/Q,Te),J.data,F,j,Q,Ie),F===0&&this._addTileFeatures(J.range(1-te/Q,ae,1,Te),J.data,Q,j,Q,Ie),F===Q-1&&this._addTileFeatures(J.range(0,ae,te/Q,Te),J.data,-1,j,Q,Ie),Ie.features.length?Ie:null}getClusterExpansionZoom(L){let F=this._getOriginZoom(L)-1;for(;F<=this.options.maxZoom;){const j=this.getChildren(L);if(F++,j.length!==1)break;L=j[0].properties.cluster_id}return F}_appendLeaves(L,F,j,J,Q){const he=this.getChildren(F);for(const oe of he){const te=oe.properties;if(te&&te.cluster?Q+te.point_count<=J?Q+=te.point_count:Q=this._appendLeaves(L,te.cluster_id,j,J,Q):Q1;let Te,Ie,Ce;if(ae)Te=He(F,te,this.clusterProps),Ie=F[te],Ce=F[te+1];else{const ut=this.points[F[te+Tt]];Te=ut.properties;const[vt,Ft]=ut.geometry.coordinates;Ie=Gt(vt),Ce=ct(Ft)}const mt={type:1,geometry:[[Math.round(this.options.extent*(Ie*Q-j)),Math.round(this.options.extent*(Ce*Q-J))]],tags:Te};let kt;kt=ae||this.options.generateId?F[te+Tt]:this.points[F[te+Tt]].id,kt!==void 0&&(mt.id=kt),he.features.push(mt)}}_limitZoom(L){return Math.max(this.options.minZoom,Math.min(Math.floor(+L),this.options.maxZoom+1))}_cluster(L,F){const{radius:j,extent:J,reduce:Q,minPoints:he}=this.options,oe=j/(J*Math.pow(2,F)),te=L.data,ae=[],Te=this.stride;for(let Ie=0;IeF&&(vt+=te[gi+fi])}if(vt>ut&&vt>=he){let Ft,gi=Ce*ut,Ut=mt*ut,ai=-1;const ri=((Ie/Te|0)<<5)+(F+1)+this.points.length;for(const jr of kt){const Ei=jr*Te;if(te[Ei+2]<=F)continue;te[Ei+2]=F;const hr=te[Ei+fi];gi+=te[Ei]*hr,Ut+=te[Ei+1]*hr,te[Ei+4]=ri,Q&&(Ft||(Ft=this._map(te,Ie,!0),ai=this.clusterProps.length,this.clusterProps.push(Ft)),Q(Ft,this._map(te,Ei)))}te[Ie+4]=ri,ae.push(gi/vt,Ut/vt,1/0,ri,-1,vt),Q&&ae.push(ai)}else{for(let Ft=0;Ft1)for(const Ft of kt){const gi=Ft*Te;if(!(te[gi+2]<=F)){te[gi+2]=F;for(let Ut=0;Ut>5}_getOriginZoom(L){return(L-this.points.length)%32}_map(L,F,j){if(L[F+fi]>1){const he=this.clusterProps[L[F+Oi]];return j?Object.assign({},he):he}const J=this.points[L[F+Tt]].properties,Q=this.options.map(J);return j&&Q===J?Object.assign({},Q):Q}}function Pt(X,L,F){return{type:"Feature",id:X[L+Tt],properties:He(X,L,F),geometry:{type:"Point",coordinates:[(j=X[L],360*(j-.5)),Zi(X[L+1])]}};var j}function He(X,L,F){const j=X[L+fi],J=j>=1e4?`${Math.round(j/1e3)}k`:j>=1e3?Math.round(j/100)/10+"k":j,Q=X[L+Oi],he=Q===-1?{}:Object.assign({},F[Q]);return Object.assign(he,{cluster:!0,cluster_id:X[L+Tt],point_count:j,point_count_abbreviated:J})}function Gt(X){return X/360+.5}function ct(X){const L=Math.sin(X*Math.PI/180),F=.5-.25*Math.log((1+L)/(1-L))/Math.PI;return F<0?0:F>1?1:F}function Zi(X){const L=(180-360*X)*Math.PI/180;return 360*Math.atan(Math.exp(L))/Math.PI-90}function gr(X,L,F,j){for(var J,Q=j,he=F-L>>1,oe=F-L,te=X[L],ae=X[L+1],Te=X[F],Ie=X[F+1],Ce=L+3;CeQ)J=Ce,Q=mt;else if(mt===Q){var kt=Math.abs(Ce-he);ktj&&(J-L>3&&gr(X,L,J,j),X[J+2]=Q,F-J>3&&gr(X,J,F,j))}function Ue(X,L,F,j,J,Q){var he=J-F,oe=Q-j;if(he!==0||oe!==0){var te=((X-F)*he+(L-j)*oe)/(he*he+oe*oe);te>1?(F=J,j=Q):te>0&&(F+=he*te,j+=oe*te)}return(he=X-F)*he+(oe=L-j)*oe}function Bi(X,L,F,j){var J={id:X===void 0?null:X,type:L,geometry:F,tags:j,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Q){var he=Q.geometry,oe=Q.type;if(oe==="Point"||oe==="MultiPoint"||oe==="LineString")yr(Q,he);else if(oe==="Polygon"||oe==="MultiLineString")for(var te=0;te0&&(he+=j?(J*ae-te*Q)/2:Math.sqrt(Math.pow(te-J,2)+Math.pow(ae-Q,2))),J=te,Q=ae}var Te=L.length-3;L[2]=1,gr(L,0,Te,F),L[Te+2]=1,L.size=Math.abs(he),L.start=0,L.end=L.size}function jo(X,L,F,j){for(var J=0;J1?1:F}function In(X,L,F,j,J,Q,he,oe){if(j/=L,Q>=(F/=L)&&he=j)return null;for(var te=[],ae=0;ae=F&&kt=j)){var ut=[];if(Ce==="Point"||Ce==="MultiPoint")Ii(Ie,ut,F,j,J);else if(Ce==="LineString")ii(Ie,ut,F,j,J,!1,oe.lineMetrics);else if(Ce==="MultiLineString")En(Ie,ut,F,j,J,!1);else if(Ce==="Polygon")En(Ie,ut,F,j,J,!0);else if(Ce==="MultiPolygon")for(var vt=0;vt=F&&he<=j&&(L.push(X[Q]),L.push(X[Q+1]),L.push(X[Q+2]))}}function ii(X,L,F,j,J,Q,he){for(var oe,te,ae=Vn(X),Te=J===0?qo:So,Ie=X.start,Ce=0;CeF&&(te=Te(ae,mt,kt,vt,Ft,F),he&&(ae.start=Ie+oe*te)):gi>j?Ut=F&&(te=Te(ae,mt,kt,vt,Ft,F),ai=!0),Ut>j&&gi<=j&&(te=Te(ae,mt,kt,vt,Ft,j),ai=!0),!Q&&ai&&(he&&(ae.end=Ie+oe*te),L.push(ae),ae=Vn(X)),he&&(Ie+=oe)}var ri=X.length-3;mt=X[ri],kt=X[ri+1],ut=X[ri+2],(gi=J===0?mt:kt)>=F&&gi<=j&&Un(ae,mt,kt,ut),ri=ae.length-3,Q&&ri>=3&&(ae[ri]!==ae[0]||ae[ri+1]!==ae[1])&&Un(ae,ae[0],ae[1],ae[2]),ae.length&&L.push(ae)}function Vn(X){var L=[];return L.size=X.size,L.start=X.start,L.end=X.end,L}function En(X,L,F,j,J,Q){for(var he=0;hehe.maxX&&(he.maxX=Te),Ie>he.maxY&&(he.maxY=Ie)}return he}function Zo(X,L,F,j){var J=L.geometry,Q=L.type,he=[];if(Q==="Point"||Q==="MultiPoint")for(var oe=0;oe0&&L.size<(J?he:j))F.numPoints+=L.length/3;else{for(var oe=[],te=0;tehe)&&(F.numSimplified++,oe.push(L[te]),oe.push(L[te+1])),F.numPoints++;J&&function(ae,Te){for(var Ie=0,Ce=0,mt=ae.length,kt=mt-2;Ce0===Te)for(Ce=0,mt=ae.length;Ce24)throw new Error("maxZoom should be in the 0-24 range");if(L.promoteId&&L.generateId)throw new Error("promoteId and generateId cannot be used together.");var j=function(J,Q){var he=[];if(J.type==="FeatureCollection")for(var oe=0;oe1&&console.time("creation"),Ce=this.tiles[Ie]=er(X,L,F,j,te),this.tileCoords.push({z:L,x:F,y:j}),ae)){ae>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",L,F,j,Ce.numFeatures,Ce.numPoints,Ce.numSimplified),console.timeEnd("creation"));var mt="z"+L;this.stats[mt]=(this.stats[mt]||0)+1,this.total++}if(Ce.source=X,J){if(L===te.maxZoom||L===J)continue;var kt=1<1&&console.time("clipping");var ut,vt,Ft,gi,Ut,ai,ri=.5*te.buffer/te.extent,jr=.5-ri,Ei=.5+ri,hr=1+ri;ut=vt=Ft=gi=null,Ut=In(X,Te,F-ri,F+Ei,0,Ce.minX,Ce.maxX,te),ai=In(X,Te,F+jr,F+hr,0,Ce.minX,Ce.maxX,te),X=null,Ut&&(ut=In(Ut,Te,j-ri,j+Ei,1,Ce.minY,Ce.maxY,te),vt=In(Ut,Te,j+jr,j+hr,1,Ce.minY,Ce.maxY,te),Ut=null),ai&&(Ft=In(ai,Te,j-ri,j+Ei,1,Ce.minY,Ce.maxY,te),gi=In(ai,Te,j+jr,j+hr,1,Ce.minY,Ce.maxY,te),ai=null),ae>1&&console.timeEnd("clipping"),oe.push(ut||[],L+1,2*F,2*j),oe.push(vt||[],L+1,2*F,2*j+1),oe.push(Ft||[],L+1,2*F+1,2*j),oe.push(gi||[],L+1,2*F+1,2*j+1)}}},We.prototype.getTile=function(X,L,F){var j=this.options,J=j.extent,Q=j.debug;if(X<0||X>24)return null;var he=1<1&&console.log("drilling down to z%d-%d-%d",X,L,F);for(var te,ae=X,Te=L,Ie=F;!te&&ae>0;)ae--,Te=Math.floor(Te/2),Ie=Math.floor(Ie/2),te=this.tiles[Bt(ae,Te,Ie)];return te&&te.source?(Q>1&&console.log("found parent tile z%d-%d-%d",ae,Te,Ie),Q>1&&console.time("drilling down"),this.splitTile(te.source,ae,Te,Ie,X,L,F),Q>1&&console.timeEnd("drilling down"),this.tiles[oe]?qe(this.tiles[oe],J):null):null};class It extends De{constructor(L,F,j,J){super(L,F,j),this._dataUpdateable=new Map,this.loadGeoJSON=(Q,he)=>{const{promoteId:oe}=Q;if(Q.request)return s.f(Q.request,(te,ae,Te,Ie)=>{this._dataUpdateable=Ur(ae,oe)?_n(ae,oe):void 0,he(te,ae,Te,Ie)});if(typeof Q.data=="string")try{const te=JSON.parse(Q.data);this._dataUpdateable=Ur(te,oe)?_n(te,oe):void 0,he(null,te)}catch{he(new Error(`Input data given to '${Q.source}' is not a valid GeoJSON object.`))}else Q.dataDiff?this._dataUpdateable?(function(te,ae,Te){var Ie,Ce,mt,kt;if(ae.removeAll&&te.clear(),ae.remove)for(const ut of ae.remove)te.delete(ut);if(ae.add)for(const ut of ae.add){const vt=Mt(ut,Te);vt!=null&&te.set(vt,ut)}if(ae.update)for(const ut of ae.update){let vt=te.get(ut.id);if(vt==null)continue;const Ft=!ut.removeAllProperties&&(((Ie=ut.removeProperties)===null||Ie===void 0?void 0:Ie.length)>0||((Ce=ut.addOrUpdateProperties)===null||Ce===void 0?void 0:Ce.length)>0);if((ut.newGeometry||ut.removeAllProperties||Ft)&&(vt=Object.assign({},vt),te.set(ut.id,vt),Ft&&(vt.properties=Object.assign({},vt.properties))),ut.newGeometry&&(vt.geometry=ut.newGeometry),ut.removeAllProperties)vt.properties={};else if(((mt=ut.removeProperties)===null||mt===void 0?void 0:mt.length)>0)for(const gi of ut.removeProperties)Object.prototype.hasOwnProperty.call(vt.properties,gi)&&delete vt.properties[gi];if(((kt=ut.addOrUpdateProperties)===null||kt===void 0?void 0:kt.length)>0)for(const{key:gi,value:Ut}of ut.addOrUpdateProperties)vt.properties[gi]=Ut}}(this._dataUpdateable,Q.dataDiff,oe),he(null,{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())})):he(new Error(`Cannot update existing geojson data in ${Q.source}`)):he(new Error(`Input data given to '${Q.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}},this.loadVectorData=this.loadGeoJSONTile,J&&(this.loadGeoJSON=J)}loadGeoJSONTile(L,F){const j=L.tileID.canonical;if(!this._geoJSONIndex)return F(null,null);const J=this._geoJSONIndex.getTile(j.z,j.x,j.y);if(!J)return F(null,null);const Q=new class{constructor(oe){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=s.N,this.length=oe.length,this._features=oe}feature(oe){return new class{constructor(te){this._feature=te,this.extent=s.N,this.type=te.type,this.properties=te.tags,"id"in te&&!isNaN(te.id)&&(this.id=parseInt(te.id,10))}loadGeometry(){if(this._feature.type===1){const te=[];for(const ae of this._feature.geometry)te.push([new s.P(ae[0],ae[1])]);return te}{const te=[];for(const ae of this._feature.geometry){const Te=[];for(const Ie of ae)Te.push(new s.P(Ie[0],Ie[1]));te.push(Te)}return te}}toGeoJSON(te,ae,Te){return at.call(this,te,ae,Te)}}(this._features[oe])}}(J.features);let he=en(Q);he.byteOffset===0&&he.byteLength===he.buffer.byteLength||(he=new Uint8Array(he)),F(null,{vectorTile:Q,rawData:he.buffer})}loadData(L,F){var j;(j=this._pendingRequest)===null||j===void 0||j.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const J=!!(L&&L.request&&L.request.collectResourceTiming)&&new s.bu(L.request);this._pendingCallback=F,this._pendingRequest=this.loadGeoJSON(L,(Q,he)=>{if(delete this._pendingCallback,delete this._pendingRequest,Q||!he)return F(Q);if(typeof he!="object")return F(new Error(`Input data given to '${L.source}' is not a valid GeoJSON object.`));{et(he,!0);try{if(L.filter){const te=s.bC(L.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(te.result==="error")throw new Error(te.value.map(Te=>`${Te.key}: ${Te.message}`).join(", "));he={type:"FeatureCollection",features:he.features.filter(Te=>te.value.evaluate({zoom:0},Te))}}this._geoJSONIndex=L.cluster?new Fe(function({superclusterOptions:te,clusterProperties:ae}){if(!ae||!te)return te;const Te={},Ie={},Ce={accumulated:null,zoom:0},mt={properties:null},kt=Object.keys(ae);for(const ut of kt){const[vt,Ft]=ae[ut],gi=s.bC(Ft),Ut=s.bC(typeof vt=="string"?[vt,["accumulated"],["get",ut]]:vt);Te[ut]=gi.value,Ie[ut]=Ut.value}return te.map=ut=>{mt.properties=ut;const vt={};for(const Ft of kt)vt[Ft]=Te[Ft].evaluate(Ce,mt);return vt},te.reduce=(ut,vt)=>{mt.properties=vt;for(const Ft of kt)Ce.accumulated=ut[Ft],ut[Ft]=Ie[Ft].evaluate(Ce,mt)},te}(L)).load(he.features):function(te,ae){return new We(te,ae)}(he,L.geojsonVtOptions)}catch(te){return F(te)}this.loaded={};const oe={};if(J){const te=J.finish();te&&(oe.resourceTiming={},oe.resourceTiming[L.source]=JSON.parse(JSON.stringify(te)))}F(null,oe)}})}reloadTile(L,F){const j=this.loaded;return j&&j[L.uid]?super.reloadTile(L,F):this.loadTile(L,F)}removeSource(L,F){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),F()}getClusterExpansionZoom(L,F){try{F(null,this._geoJSONIndex.getClusterExpansionZoom(L.clusterId))}catch(j){F(j)}}getClusterChildren(L,F){try{F(null,this._geoJSONIndex.getChildren(L.clusterId))}catch(j){F(j)}}getClusterLeaves(L,F){try{F(null,this._geoJSONIndex.getLeaves(L.clusterId,L.limit,L.offset))}catch(j){F(j)}}}class Mn{constructor(L){this.self=L,this.actor=new s.C(L,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:De,geojson:It},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(F,j)=>{if(this.workerSourceTypes[F])throw new Error(`Worker source with name "${F}" already registered.`);this.workerSourceTypes[F]=j},this.self.registerRTLTextPlugin=F=>{if(s.bD.isParsed())throw new Error("RTL text plugin already registered.");s.bD.applyArabicShaping=F.applyArabicShaping,s.bD.processBidirectionalText=F.processBidirectionalText,s.bD.processStyledBidirectionalText=F.processStyledBidirectionalText}}setReferrer(L,F){this.referrer=F}setImages(L,F,j){this.availableImages[L]=F;for(const J in this.workerSources[L]){const Q=this.workerSources[L][J];for(const he in Q)Q[he].availableImages=F}j()}setLayers(L,F,j){this.getLayerIndex(L).replace(F),j()}updateLayers(L,F,j){this.getLayerIndex(L).update(F.layers,F.removedIds),j()}loadTile(L,F,j){this.getWorkerSource(L,F.type,F.source).loadTile(F,j)}loadDEMTile(L,F,j){this.getDEMWorkerSource(L,F.source).loadTile(F,j)}reloadTile(L,F,j){this.getWorkerSource(L,F.type,F.source).reloadTile(F,j)}abortTile(L,F,j){this.getWorkerSource(L,F.type,F.source).abortTile(F,j)}removeTile(L,F,j){this.getWorkerSource(L,F.type,F.source).removeTile(F,j)}removeDEMTile(L,F){this.getDEMWorkerSource(L,F.source).removeTile(F)}removeSource(L,F,j){if(!this.workerSources[L]||!this.workerSources[L][F.type]||!this.workerSources[L][F.type][F.source])return;const J=this.workerSources[L][F.type][F.source];delete this.workerSources[L][F.type][F.source],J.removeSource!==void 0?J.removeSource(F,j):j()}loadWorkerSource(L,F,j){try{this.self.importScripts(F.url),j()}catch(J){j(J.toString())}}syncRTLPluginState(L,F,j){try{s.bD.setState(F);const J=s.bD.getPluginURL();if(s.bD.isLoaded()&&!s.bD.isParsed()&&J!=null){this.self.importScripts(J);const Q=s.bD.isParsed();j(Q?void 0:new Error(`RTL Text Plugin failed to import scripts from ${J}`),Q)}}catch(J){j(J.toString())}}getAvailableImages(L){let F=this.availableImages[L];return F||(F=[]),F}getLayerIndex(L){let F=this.layerIndexes[L];return F||(F=this.layerIndexes[L]=new H),F}getWorkerSource(L,F,j){return this.workerSources[L]||(this.workerSources[L]={}),this.workerSources[L][F]||(this.workerSources[L][F]={}),this.workerSources[L][F][j]||(this.workerSources[L][F][j]=new this.workerSourceTypes[F]({send:(J,Q,he)=>{this.actor.send(J,Q,he,L)}},this.getLayerIndex(L),this.getAvailableImages(L))),this.workerSources[L][F][j]}getDEMWorkerSource(L,F){return this.demWorkerSources[L]||(this.demWorkerSources[L]={}),this.demWorkerSources[L][F]||(this.demWorkerSources[L][F]=new Ee),this.demWorkerSources[L][F]}}return s.i()&&(self.worker=new Mn(self)),Mn}),k(["./shared"],function(s){var H="3.6.2";class V{static testProp(t){if(!V.docStyle)return t[0];for(let n=0;n{window.removeEventListener("click",V.suppressClickInternal,!0)},0)}static mousePos(t,n){const a=t.getBoundingClientRect();return new s.P(n.clientX-a.left-t.clientLeft,n.clientY-a.top-t.clientTop)}static touchPos(t,n){const a=t.getBoundingClientRect(),c=[];for(let d=0;d{t=[],n=0,a=0,c={}},u.addThrottleControl=C=>{const A=a++;return c[A]=C,A},u.removeThrottleControl=C=>{delete c[C],b()},u.getImage=(C,A,P=!0)=>{me.supported&&(C.headers||(C.headers={}),C.headers.accept="image/webp,*/*");const R={requestParameters:C,supportImageRefresh:P,callback:A,cancelled:!1,completed:!1,cancel:()=>{R.completed||R.cancelled||(R.cancelled=!0,R.innerRequest&&(R.innerRequest.cancel(),n--),b())}};return t.push(R),b(),R};const d=C=>{const{requestParameters:A,supportImageRefresh:P,callback:R}=C;return s.e(A,{type:"image"}),(P!==!1||s.i()||s.g(A.url)||A.headers&&!Object.keys(A.headers).reduce((W,G)=>W&&G==="accept",!0)?s.m:S)(A,(W,G,K,q)=>{x(C,R,W,G,K,q)})},x=(C,A,P,R,W,G)=>{P?A(P):R instanceof HTMLImageElement||s.a(R)?A(null,R):R&&((K,q)=>{typeof createImageBitmap=="function"?s.b(K,q):s.d(K,q)})(R,(K,q)=>{K!=null?A(K):q!=null&&A(null,q,{cacheControl:W,expires:G})}),C.cancelled||(C.completed=!0,n--,b())},b=()=>{const C=(()=>{const A=Object.keys(c);let P=!1;if(A.length>0){for(const R of A)if(P=c[R](),P)break}return P})()?s.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:s.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let A=n;A0;A++){const P=t.shift();if(P.cancelled){A--;continue}const R=d(P);n++,P.innerRequest=R}},S=(C,A)=>{const P=new Image,R=C.url;let W=!1;const G=C.credentials;return G&&G==="include"?P.crossOrigin="use-credentials":(G&&G==="same-origin"||!s.s(R))&&(P.crossOrigin="anonymous"),P.fetchPriority="high",P.onload=()=>{A(null,P),P.onerror=P.onload=null},P.onerror=()=>{W||A(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.")),P.onerror=P.onload=null},P.src=R,{cancel:()=>{W=!0,P.src=""}}}}(Ne||(Ne={})),Ne.resetRequestQueue(),function(u){u.Glyphs="Glyphs",u.Image="Image",u.Source="Source",u.SpriteImage="SpriteImage",u.SpriteJSON="SpriteJSON",u.Style="Style",u.Tile="Tile",u.Unknown="Unknown"}(et||(et={}));class at{constructor(t){this._transformRequestFn=t}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}normalizeSpriteURL(t,n,a){const c=function(d){const x=d.match(nt);if(!x)throw new Error(`Unable to parse URL "${d}"`);return{protocol:x[1],authority:x[2],path:x[3]||"/",params:x[4]?x[4].split("&"):[]}}(t);return c.path+=`${n}${a}`,function(d){const x=d.params.length?`?${d.params.join("&")}`:"";return`${d.protocol}://${d.authority}${d.path}${x}`}(c)}setTransformRequest(t){this._transformRequestFn=t}}const nt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function it(u){var t=new s.A(3);return t[0]=u[0],t[1]=u[1],t[2]=u[2],t}var Vt,ti=function(u,t,n){return u[0]=t[0]-n[0],u[1]=t[1]-n[1],u[2]=t[2]-n[2],u};Vt=new s.A(3),s.A!=Float32Array&&(Vt[0]=0,Vt[1]=0,Vt[2]=0);var Xt=function(u){var t=u[0],n=u[1];return t*t+n*n};function Nt(u){const t=[];if(typeof u=="string")t.push({id:"default",url:u});else if(u&&u.length>0){const n=[];for(const{id:a,url:c}of u){const d=`${a}${c}`;n.indexOf(d)===-1&&(n.push(d),t.push({id:a,url:c}))}}return t}function Yt(u,t,n,a,c){if(a)return void u(a);if(c!==Object.values(t).length||c!==Object.values(n).length)return;const d={};for(const x in t){d[x]={};const b=s.h.getImageCanvasContext(n[x]),S=t[x];for(const C in S){const{width:A,height:P,x:R,y:W,sdf:G,pixelRatio:K,stretchX:q,stretchY:le,content:_e}=S[C];d[x][C]={data:null,pixelRatio:K,sdf:G,stretchX:q,stretchY:le,content:_e,spriteData:{width:A,height:P,x:R,y:W,context:b}}}}u(null,d)}(function(){var u=new s.A(2);s.A!=Float32Array&&(u[0]=0,u[1]=0)})();class At{constructor(t,n,a,c){this.context=t,this.format=a,this.texture=t.gl.createTexture(),this.update(n,c)}update(t,n,a){const{width:c,height:d}=t,x=!(this.size&&this.size[0]===c&&this.size[1]===d||a),{context:b}=this,{gl:S}=b;if(this.useMipmap=!!(n&&n.useMipmap),S.bindTexture(S.TEXTURE_2D,this.texture),b.pixelStoreUnpackFlipY.set(!1),b.pixelStoreUnpack.set(1),b.pixelStoreUnpackPremultiplyAlpha.set(this.format===S.RGBA&&(!n||n.premultiply!==!1)),x)this.size=[c,d],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||s.a(t)?S.texImage2D(S.TEXTURE_2D,0,this.format,this.format,S.UNSIGNED_BYTE,t):S.texImage2D(S.TEXTURE_2D,0,this.format,c,d,0,this.format,S.UNSIGNED_BYTE,t.data);else{const{x:C,y:A}=a||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||s.a(t)?S.texSubImage2D(S.TEXTURE_2D,0,C,A,S.RGBA,S.UNSIGNED_BYTE,t):S.texSubImage2D(S.TEXTURE_2D,0,C,A,c,d,S.RGBA,S.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&S.generateMipmap(S.TEXTURE_2D)}bind(t,n,a){const{context:c}=this,{gl:d}=c;d.bindTexture(d.TEXTURE_2D,this.texture),a!==d.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(a=d.LINEAR),t!==this.filter&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,t),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,a||t),this.filter=t),n!==this.wrap&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,n),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function ke(u){const{userImage:t}=u;return!!(t&&t.render&&t.render())&&(u.data.replace(new Uint8Array(t.data.buffer)),!0)}class Ge extends s.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new s.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,callback:a}of this.requestors)this._notify(n,a);this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const a=n.spriteData;n.data=new s.R({width:a.width,height:a.height},a.context.getImageData(a.x,a.y,a.width,a.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let a=!0;const c=n.data||n.spriteData;return this._validateStretch(n.stretchX,c&&c.width)||(this.fire(new s.j(new Error(`Image "${t}" has invalid "stretchX" value`))),a=!1),this._validateStretch(n.stretchY,c&&c.height)||(this.fire(new s.j(new Error(`Image "${t}" has invalid "stretchY" value`))),a=!1),this._validateContent(n.content,n)||(this.fire(new s.j(new Error(`Image "${t}" has invalid "content" value`))),a=!1),a}_validateStretch(t,n){if(!t)return!0;let a=0;for(const c of t){if(c[0]-1);S++,d[S]=b,x[S]=C,x[S+1]=Ui}for(let b=0,S=0;b{let b=this.entries[c];b||(b=this.entries[c]={glyphs:{},requests:{},ranges:{}});let S=b.glyphs[d];if(S!==void 0)return void x(null,{stack:c,id:d,glyph:S});if(S=this._tinySDF(b,c,d),S)return b.glyphs[d]=S,void x(null,{stack:c,id:d,glyph:S});const C=Math.floor(d/256);if(256*C>65535)return void x(new Error("glyphs > 65535 not supported"));if(b.ranges[C])return void x(null,{stack:c,id:d,glyph:S});if(!this.url)return void x(new Error("glyphsUrl is not set"));let A=b.requests[C];A||(A=b.requests[C]=[],Lt.loadGlyphRange(c,C,this.url,this.requestManager,(P,R)=>{if(R){for(const W in R)this._doesCharSupportLocalGlyph(+W)||(b.glyphs[+W]=R[+W]);b.ranges[C]=!0}for(const W of A)W(P,R);delete b.requests[C]})),A.push((P,R)=>{P?x(P):R&&x(null,{stack:c,id:d,glyph:R[d]||null})})},(c,d)=>{if(c)n(c);else if(d){const x={};for(const{stack:b,id:S,glyph:C}of d)(x[b]||(x[b]={}))[S]=C&&{id:C.id,bitmap:C.bitmap.clone(),metrics:C.metrics};n(null,x)}})}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(s.u["CJK Unified Ideographs"](t)||s.u["Hangul Syllables"](t)||s.u.Hiragana(t)||s.u.Katakana(t))}_tinySDF(t,n,a){const c=this.localIdeographFontFamily;if(!c||!this._doesCharSupportLocalGlyph(a))return;let d=t.tinySDF;if(!d){let b="400";/bold/i.test(n)?b="900":/medium/i.test(n)?b="500":/light/i.test(n)&&(b="200"),d=t.tinySDF=new Lt.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:c,fontWeight:b})}const x=d.draw(String.fromCharCode(a));return{id:a,bitmap:new s.q({width:x.width||60,height:x.height||60},x.data),metrics:{width:x.glyphWidth/2||24,height:x.glyphHeight/2||24,left:x.glyphLeft/2+.5||0,top:x.glyphTop/2-27.5||-8,advance:x.glyphAdvance/2||24,isDoubleResolution:!0}}}}Lt.loadGlyphRange=function(u,t,n,a,c){const d=256*t,x=d+255,b=a.transformRequest(n.replace("{fontstack}",u).replace("{range}",`${d}-${x}`),et.Glyphs);s.l(b,(S,C)=>{if(S)c(S);else if(C){const A={};for(const P of s.n(C))A[P.id]=P;c(null,A)}})},Lt.TinySDF=class{constructor({fontSize:u=24,buffer:t=3,radius:n=8,cutoff:a=.25,fontFamily:c="sans-serif",fontWeight:d="normal",fontStyle:x="normal"}={}){this.buffer=t,this.cutoff=a,this.radius=n;const b=this.size=u+4*t,S=this._createCanvas(b),C=this.ctx=S.getContext("2d",{willReadFrequently:!0});C.font=`${x} ${d} ${u}px ${c}`,C.textBaseline="alphabetic",C.textAlign="left",C.fillStyle="black",this.gridOuter=new Float64Array(b*b),this.gridInner=new Float64Array(b*b),this.f=new Float64Array(b),this.z=new Float64Array(b+1),this.v=new Uint16Array(b)}_createCanvas(u){const t=document.createElement("canvas");return t.width=t.height=u,t}draw(u){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:a,actualBoundingBoxLeft:c,actualBoundingBoxRight:d}=this.ctx.measureText(u),x=Math.ceil(n),b=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(d-c))),S=Math.min(this.size-this.buffer,x+Math.ceil(a)),C=b+2*this.buffer,A=S+2*this.buffer,P=Math.max(C*A,0),R=new Uint8ClampedArray(P),W={data:R,width:C,height:A,glyphWidth:b,glyphHeight:S,glyphTop:x,glyphLeft:0,glyphAdvance:t};if(b===0||S===0)return W;const{ctx:G,buffer:K,gridInner:q,gridOuter:le}=this;G.clearRect(K,K,b,S),G.fillText(u,K,K+x);const _e=G.getImageData(K,K,b,S);le.fill(Ui,0,P),q.fill(0,0,P);for(let ee=0;ee0?Me*Me:0,q[xe]=Me<0?Me*Me:0}}Dt(le,0,0,C,A,C,this.f,this.v,this.z),Dt(q,K,K,b,S,C,this.f,this.v,this.z);for(let ee=0;ee1&&(S=t[++b]);const A=Math.abs(C-S.left),P=Math.abs(C-S.right),R=Math.min(A,P);let W;const G=d/a*(c+1);if(S.isDash){const K=c-Math.abs(G);W=Math.sqrt(R*R+K*K)}else W=c-Math.sqrt(R*R+G*G);this.data[x+C]=Math.max(0,Math.min(255,W+128))}}}addRegularDash(t){for(let b=t.length-1;b>=0;--b){const S=t[b],C=t[b+1];S.zeroLength?t.splice(b,1):C&&C.isDash===S.isDash&&(C.left=S.left,t.splice(b,1))}const n=t[0],a=t[t.length-1];n.isDash===a.isDash&&(n.left=a.left-this.width,a.right=n.right+this.width);const c=this.width*this.nextRow;let d=0,x=t[d];for(let b=0;b1&&(x=t[++d]);const S=Math.abs(b-x.left),C=Math.abs(b-x.right),A=Math.min(S,C);this.data[c+b]=Math.max(0,Math.min(255,(x.isDash?A:-A)+128))}}addDash(t,n){const a=n?7:0,c=2*a+1;if(this.nextRow+c>this.height)return s.w("LineAtlas out of space"),null;let d=0;for(let b=0;b{c.send(t,n,d)},a=a||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach(n=>{n.remove()}),this.actors=[],t&&this.workerPool.release(this.id)}}function Ti(u,t,n){const a=function(c,d){if(c)return n(c);if(d){const x=s.F(s.e(d,u),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);d.vector_layers&&(x.vectorLayers=d.vector_layers,x.vectorLayerIds=x.vectorLayers.map(b=>b.id)),n(null,x)}};return u.url?s.f(t.transformRequest(u.url,et.Source),a):s.h.frame(()=>a(null,u))}class Tt{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof s.L?new s.L(t.lng,t.lat):s.L.convert(t),this}setSouthWest(t){return this._sw=t instanceof s.L?new s.L(t.lng,t.lat):s.L.convert(t),this}extend(t){const n=this._sw,a=this._ne;let c,d;if(t instanceof s.L)c=t,d=t;else{if(!(t instanceof Tt))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Tt.convert(t)):this.extend(s.L.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(s.L.convert(t)):this;if(c=t._sw,d=t._ne,!c||!d)return this}return n||a?(n.lng=Math.min(c.lng,n.lng),n.lat=Math.min(c.lat,n.lat),a.lng=Math.max(d.lng,a.lng),a.lat=Math.max(d.lat,a.lat)):(this._sw=new s.L(c.lng,c.lat),this._ne=new s.L(d.lng,d.lat)),this}getCenter(){return new s.L((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 s.L(this.getWest(),this.getNorth())}getSouthEast(){return new s.L(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:n,lat:a}=s.L.convert(t);let c=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&c}static convert(t){return t instanceof Tt?t:t&&new Tt(t)}static fromLngLat(t,n=0){const a=360*n/40075017,c=a/Math.cos(Math.PI/180*t.lat);return new Tt(new s.L(t.lng-c,t.lat-a),new s.L(t.lng+c,t.lat+a))}}class fi{constructor(t,n,a){this.bounds=Tt.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=a||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),a=Math.floor(s.G(this.bounds.getWest())*n),c=Math.floor(s.H(this.bounds.getNorth())*n),d=Math.ceil(s.G(this.bounds.getEast())*n),x=Math.ceil(s.H(this.bounds.getSouth())*n);return t.x>=a&&t.x=c&&t.y{this._loaded=!1,this.fire(new s.k("dataloading",{dataType:"source"})),this._tileJSONRequest=Ti(this._options,this.map._requestManager,(d,x)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),d?this.fire(new s.j(d)):x&&(s.e(this,x),x.bounds&&(this.tileBounds=new fi(x.bounds,this.minzoom,this.maxzoom)),this.fire(new s.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.k("data",{dataType:"source",sourceDataType:"content"})))})},this.serialize=()=>s.e({},this._options),this.id=t,this.dispatcher=a,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,s.e(this,s.F(n,["url","scheme","tileSize","promoteId"])),this._options=s.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(c)}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}loadTile(t,n){const a=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),c={request:this.map._requestManager.transformRequest(a,et.Tile),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function d(x,b){return delete t.request,t.aborted?n(null):x&&x.status!==404?n(x):(b&&b.resourceTiming&&(t.resourceTiming=b.resourceTiming),this.map._refreshExpiredTiles&&b&&t.setExpiryData(b),t.loadVectorData(b,this.map.painter),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}c.request.collectResourceTiming=this._collectResourceTiming,t.actor&&t.state!=="expired"?t.state==="loading"?t.reloadCallback=n:t.request=t.actor.send("reloadTile",c,d.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",c,d.bind(this)))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class Fe extends s.E{constructor(t,n,a,c){super(),this.id=t,this.dispatcher=a,this.setEventedParent(c),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=s.e({type:"raster"},n),s.e(this,s.F(n,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new s.k("dataloading",{dataType:"source"})),this._tileJSONRequest=Ti(this._options,this.map._requestManager,(t,n)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new s.j(t)):n&&(s.e(this,n),n.bounds&&(this.tileBounds=new fi(n.bounds,this.minzoom,this.maxzoom)),this.fire(new s.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.k("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}serialize(){return s.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,n){const a=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.request=Ne.getImage(this.map._requestManager.transformRequest(a,et.Tile),(c,d,x)=>{if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(c)t.state="errored",n(c);else if(d){this.map._refreshExpiredTiles&&x&&t.setExpiryData(x);const b=this.map.painter.context,S=b.gl;t.texture=this.map.painter.getTileTexture(d.width),t.texture?t.texture.update(d,{useMipmap:!0}):(t.texture=new At(b,d,S.RGBA,{useMipmap:!0}),t.texture.bind(S.LINEAR,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),b.extTextureFilterAnisotropic&&S.texParameterf(S.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax)),t.state="loaded",n(null)}},this.map._refreshExpiredTiles)}abortTile(t,n){t.request&&(t.request.cancel(),delete t.request),n()}unloadTile(t,n){t.texture&&this.map.painter.saveTileTexture(t.texture),n()}hasTransition(){return!1}}class Pt extends Fe{constructor(t,n,a,c){super(t,n,a,c),this.type="raster-dem",this.maxzoom=22,this._options=s.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(t,n){const a=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),c=this.map._requestManager.transformRequest(a,et.Tile);function d(x,b){x&&(t.state="errored",n(x)),b&&(t.dem=b,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded",n(null))}t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.request=Ne.getImage(c,(x,b,S)=>s._(this,void 0,void 0,function*(){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(x)t.state="errored",n(x);else if(b){this.map._refreshExpiredTiles&&t.setExpiryData(S);const C=s.a(b)&&s.J()?b:yield function(P){return s._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&s.K()){const R=P.width+2,W=P.height+2;try{return new s.R({width:R,height:W},yield s.M(P,-1,-1,R,W))}catch{}}return s.h.getImageData(P,1)})}(b),A={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:C,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};t.actor&&t.state!=="expired"||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",A,d))}}),this.map._refreshExpiredTiles)}_getNeighboringTiles(t){const n=t.canonical,a=Math.pow(2,n.z),c=(n.x-1+a)%a,d=n.x===0?t.wrap-1:t.wrap,x=(n.x+1+a)%a,b=n.x+1===a?t.wrap+1:t.wrap,S={};return S[new s.O(t.overscaledZ,d,n.z,c,n.y).key]={backfilled:!1},S[new s.O(t.overscaledZ,b,n.z,x,n.y).key]={backfilled:!1},n.y>0&&(S[new s.O(t.overscaledZ,d,n.z,c,n.y-1).key]={backfilled:!1},S[new s.O(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},S[new s.O(t.overscaledZ,b,n.z,x,n.y-1).key]={backfilled:!1}),n.y+1{this._updateWorkerData()},this.serialize=()=>s.e({},this._options,{type:this.type,data:this._data}),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=a.getActor(),this.setEventedParent(c),this._data=n.data,this._options=s.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId;const d=s.N/this.tileSize;this.workerOptions=s.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:(n.buffer!==void 0?n.buffer:128)*d,tolerance:(n.tolerance!==void 0?n.tolerance:.375)*d,extent:s.N,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:n.clusterMaxZoom!==void 0?n.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,n.clusterMinPoints||2),extent:s.N,radius:(n.clusterRadius||50)*d,log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=t.clusterRadius),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t,n){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},n),this}getClusterChildren(t,n){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},n),this}getClusterLeaves(t,n,a,c){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:n,offset:a},c),this}_updateWorkerData(t){const n=s.e({},this.workerOptions);t?n.dataDiff=t:typeof this._data=="string"?(n.request=this.map._requestManager.transformRequest(s.h.resolveURL(this._data),et.Source),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new s.k("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,n,(a,c)=>{if(this._pendingLoads--,this._removed||c&&c.abandoned)return void this.fire(new s.k("dataabort",{dataType:"source"}));let d=null;if(c&&c.resourceTiming&&c.resourceTiming[this.id]&&(d=c.resourceTiming[this.id].slice(0)),a)return void this.fire(new s.j(a));const x={dataType:"source"};this._collectResourceTiming&&d&&d.length>0&&s.e(x,{resourceTiming:d}),this.fire(new s.k("data",Object.assign(Object.assign({},x),{sourceDataType:"metadata"}))),this.fire(new s.k("data",Object.assign(Object.assign({},x),{sourceDataType:"content"})))})}loaded(){return this._pendingLoads===0}loadTile(t,n){const a=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const c={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.request=this.actor.send(a,c,(d,x)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):d?n(d):(t.loadVectorData(x,this.map.painter,a==="reloadTile"),n(null))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}hasTransition(){return!1}}var Gt=s.Q([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class ct extends s.E{constructor(t,n,a,c){super(),this.load=(d,x)=>{this._loaded=!1,this.fire(new s.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=Ne.getImage(this.map._requestManager.transformRequest(this.url,et.Image),(b,S)=>{this._request=null,this._loaded=!0,b?this.fire(new s.j(b)):S&&(this.image=S,d&&(this.coordinates=d),x&&x(),this._finishLoading())})},this.prepare=()=>{if(Object.keys(this.tiles).length===0||!this.image)return;const d=this.map.painter.context,x=d.gl;this.boundsBuffer||(this.boundsBuffer=d.createVertexBuffer(this._boundsArray,Gt.members)),this.boundsSegments||(this.boundsSegments=s.S.simpleSegment(0,0,4,2)),this.texture||(this.texture=new At(d,this.image,x.RGBA),this.texture.bind(x.LINEAR,x.CLAMP_TO_EDGE));let b=!1;for(const S in this.tiles){const C=this.tiles[S];C.state!=="loaded"&&(C.state="loaded",C.texture=this.texture,b=!0)}b&&this.fire(new s.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"image",url:this.options.url,coordinates:this.coordinates}),this.id=t,this.dispatcher=a,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(c),this.options=n}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.cancel(),this._request=null),this.options.url=t.url,this.load(t.coordinates,()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new s.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.cancel(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(s.U.fromLngLat);this.tileID=function(c){let d=1/0,x=1/0,b=-1/0,S=-1/0;for(const R of c)d=Math.min(d,R.x),x=Math.min(x,R.y),b=Math.max(b,R.x),S=Math.max(S,R.y);const C=Math.max(b-d,S-x),A=Math.max(0,Math.floor(-Math.log(C)/Math.LN2)),P=Math.pow(2,A);return new s.W(A,Math.floor((d+b)/2*P),Math.floor((x+S)/2*P))}(n),this.minzoom=this.maxzoom=this.tileID.z;const a=n.map(c=>this.tileID.getTilePoint(c)._round());return this._boundsArray=new s.V,this._boundsArray.emplaceBack(a[0].x,a[0].y,0,0),this._boundsArray.emplaceBack(a[1].x,a[1].y,s.N,0),this._boundsArray.emplaceBack(a[3].x,a[3].y,0,s.N),this._boundsArray.emplaceBack(a[2].x,a[2].y,s.N,s.N),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new s.k("data",{dataType:"source",sourceDataType:"content"})),this}loadTile(t,n){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},n(null)):(t.state="errored",n(null))}hasTransition(){return!1}}class Zi extends ct{constructor(t,n,a,c){super(t,n,a,c),this.load=()=>{this._loaded=!1;const d=this.options;this.urls=[];for(const x of d.urls)this.urls.push(this.map._requestManager.transformRequest(x,et.Source).url);s.X(this.urls,(x,b)=>{this._loaded=!0,x?this.fire(new s.j(x)):b&&(this.video=b,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})},this.prepare=()=>{if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const d=this.map.painter.context,x=d.gl;this.boundsBuffer||(this.boundsBuffer=d.createVertexBuffer(this._boundsArray,Gt.members)),this.boundsSegments||(this.boundsSegments=s.S.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(x.LINEAR,x.CLAMP_TO_EDGE),x.texSubImage2D(x.TEXTURE_2D,0,0,0,x.RGBA,x.UNSIGNED_BYTE,this.video)):(this.texture=new At(d,this.video,x.RGBA),this.texture.bind(x.LINEAR,x.CLAMP_TO_EDGE));let b=!1;for(const S in this.tiles){const C=this.tiles[S];C.state!=="loaded"&&(C.state="loaded",C.texture=this.texture,b=!0)}b&&this.fire(new s.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"video",urls:this.urls,coordinates:this.coordinates}),this.roundZoom=!0,this.type="video",this.options=n}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;tn.end(0)?this.fire(new s.j(new s.Y(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}hasTransition(){return this.video&&!this.video.paused}}class gr extends ct{constructor(t,n,a,c){super(t,n,a,c),this.load=()=>{this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new s.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())},this.prepare=()=>{let d=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,d=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,d=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const x=this.map.painter.context,b=x.gl;this.boundsBuffer||(this.boundsBuffer=x.createVertexBuffer(this._boundsArray,Gt.members)),this.boundsSegments||(this.boundsSegments=s.S.simpleSegment(0,0,4,2)),this.texture?(d||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new At(x,this.canvas,b.RGBA,{premultiply:!0});let S=!1;for(const C in this.tiles){const A=this.tiles[C];A.state!=="loaded"&&(A.state="loaded",A.texture=this.texture,S=!0)}S&&this.fire(new s.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"canvas",coordinates:this.coordinates}),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(x=>typeof x!="number"))||this.fire(new s.j(new s.Y(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new s.j(new s.Y(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new s.j(new s.Y(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new s.j(new s.Y(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new s.j(new s.Y(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const Ue={},Bi=u=>{switch(u){case"geojson":return He;case"image":return ct;case"raster":return Fe;case"raster-dem":return Pt;case"vector":return Oi;case"video":return Zi;case"canvas":return gr}return Ue[u]};function yr(u,t){const n=s.Z();return s.$(n,n,[1,1,0]),s.a0(n,n,[.5*u.width,.5*u.height,1]),s.a1(n,n,u.calculatePosMatrix(t.toUnwrapped()))}function hi(u,t,n,a,c,d){const x=function(P,R,W){if(P)for(const G of P){const K=R[G];if(K&&K.source===W&&K.type==="fill-extrusion")return!0}else for(const G in R){const K=R[G];if(K.source===W&&K.type==="fill-extrusion")return!0}return!1}(c&&c.layers,t,u.id),b=d.maxPitchScaleFactor(),S=u.tilesIn(a,b,x);S.sort(co);const C=[];for(const P of S)C.push({wrappedTileID:P.tileID.wrapped().key,queryResults:P.tile.queryRenderedFeatures(t,n,u._state,P.queryGeometry,P.cameraQueryGeometry,P.scale,c,d,b,yr(u.transform,P.tileID))});const A=function(P){const R={},W={};for(const G of P){const K=G.queryResults,q=G.wrappedTileID,le=W[q]=W[q]||{};for(const _e in K){const ee=K[_e],ce=le[_e]=le[_e]||{},ve=R[_e]=R[_e]||[];for(const xe of ee)ce[xe.featureIndex]||(ce[xe.featureIndex]=!0,ve.push(xe))}}return R}(C);for(const P in A)A[P].forEach(R=>{const W=R.feature,G=u.getFeatureState(W.layer["source-layer"],W.id);W.source=W.layer.source,W.layer["source-layer"]&&(W.sourceLayer=W.layer["source-layer"]),W.state=G});return A}function co(u,t){const n=u.tileID,a=t.tileID;return n.overscaledZ-a.overscaledZ||n.canonical.y-a.canonical.y||n.wrap-a.wrap||n.canonical.x-a.canonical.x}class wo{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=s.a2(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const n=t+this.timeAdded;nd.getLayer(C)).filter(Boolean);if(S.length!==0){b.layers=S,b.stateDependentLayerIds&&(b.stateDependentLayers=b.stateDependentLayerIds.map(C=>S.filter(A=>A.id===C)[0]));for(const C of S)x[C.id]=b}}return x}(t.buckets,n.style),this.hasSymbolBuckets=!1;for(const c in this.buckets){const d=this.buckets[c];if(d instanceof s.a4){if(this.hasSymbolBuckets=!0,!a)break;d.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const c in this.buckets){const d=this.buckets[c];if(d instanceof s.a4&&d.hasRTLText){this.hasRTLText=!0,s.a5();break}}this.queryPadding=0;for(const c in this.buckets){const d=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(c).queryRadius(d))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new s.a3}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const a in this.buckets){const c=this.buckets[a];c.uploadPending()&&c.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new At(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new At(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,a,c,d,x,b,S,C,A){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:c,cameraQueryGeometry:d,scale:x,tileSize:this.tileSize,pixelPosMatrix:A,transform:S,params:b,queryPadding:this.queryPadding*C},t,n,a):{}}querySourceFeatures(t,n){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const c=a.loadVTLayers(),d=n&&n.sourceLayer?n.sourceLayer:"",x=c._geojsonTileLayer||c[d];if(!x)return;const b=s.a6(n&&n.filter),{z:S,x:C,y:A}=this.tileID.canonical,P={z:S,x:C,y:A};for(let R=0;Ra)c=!1;else if(n)if(this.expirationTime{this.remove(t,d)},a)),this.data[c].push(d),this.order.push(c),this.order.length>this.max){const x=this._getAndRemoveByKey(this.order[0]);x&&this.onRemove(x)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const n=this.data[t].shift();return n.timeout&&clearTimeout(n.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),n.value}getByKey(t){const n=this.data[t];return n?n[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,n){if(!this.has(t))return this;const a=t.wrapped().key,c=n===void 0?0:this.data[a].indexOf(n),d=this.data[a][c];return this.data[a].splice(c,1),d.timeout&&clearTimeout(d.timeout),this.data[a].length===0&&delete this.data[a],this.onRemove(d.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(t){const n=[];for(const a in this.data)for(const c of this.data[a])t(c.value)||n.push(c);for(const a of n)this.remove(a.value.tileID,a)}}class Se{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,a){const c=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][c]=this.stateChanges[t][c]||{},s.e(this.stateChanges[t][c],a),this.deletedStates[t]===null){this.deletedStates[t]={};for(const d in this.state[t])d!==c&&(this.deletedStates[t][d]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][c]===null){this.deletedStates[t][c]={};for(const d in this.state[t][c])a[d]||(this.deletedStates[t][c][d]=null)}else for(const d in a)this.deletedStates[t]&&this.deletedStates[t][c]&&this.deletedStates[t][c][d]===null&&delete this.deletedStates[t][c][d]}removeFeatureState(t,n,a){if(this.deletedStates[t]===null)return;const c=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},a&&n!==void 0)this.deletedStates[t][c]!==null&&(this.deletedStates[t][c]=this.deletedStates[t][c]||{},this.deletedStates[t][c][a]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][c])for(a in this.deletedStates[t][c]={},this.stateChanges[t][c])this.deletedStates[t][c][a]=null;else this.deletedStates[t][c]=null;else this.deletedStates[t]=null}getState(t,n){const a=String(n),c=s.e({},(this.state[t]||{})[a],(this.stateChanges[t]||{})[a]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const d=this.deletedStates[t][n];if(d===null)return{};for(const x in d)delete c[x]}return c}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const a={};for(const c in this.stateChanges){this.state[c]=this.state[c]||{};const d={};for(const x in this.stateChanges[c])this.state[c][x]||(this.state[c][x]={}),s.e(this.state[c][x],this.stateChanges[c][x]),d[x]=this.state[c][x];a[c]=d}for(const c in this.deletedStates){this.state[c]=this.state[c]||{};const d={};if(this.deletedStates[c]===null)for(const x in this.state[c])d[x]={},this.state[c][x]={};else for(const x in this.deletedStates[c]){if(this.deletedStates[c][x]===null)this.state[c][x]={};else for(const b of Object.keys(this.deletedStates[c][x]))delete this.state[c][x][b];d[x]=this.state[c][x]}a[c]=a[c]||{},s.e(a[c],d)}if(this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0)for(const c in t)t[c].setFeatureState(a,n)}}class tn extends s.E{constructor(t,n,a){super(),this.id=t,this.dispatcher=a,this.on("data",c=>{c.dataType==="source"&&c.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&c.dataType==="source"&&c.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((c,d,x,b)=>{const S=new(Bi(d.type))(c,d,x,b);if(S.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${S.id}`);return S})(t,n,a,this),this._tiles={},this._cache=new jo(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Se,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t in this._tiles){const n=this._tiles[t];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n){return this._source.loadTile(t,n)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,()=>{})}_abortTile(t){this._source.abortTile&&this._source.abortTile(t,()=>{}),this._source.fire(new s.k("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const a=this._tiles[n];a.upload(t),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(In).map(t=>t.key)}getRenderableIds(t){const n=[];for(const a in this._tiles)this._isIdRenderable(a,t)&&n.push(this._tiles[a]);return t?n.sort((a,c)=>{const d=a.tileID,x=c.tileID,b=new s.P(d.canonical.x,d.canonical.y)._rotate(this.transform.angle),S=new s.P(x.canonical.x,x.canonical.y)._rotate(this.transform.angle);return d.overscaledZ-x.overscaledZ||S.y-b.y||S.x-b.x}).map(a=>a.tileID.key):n.map(a=>a.tileID).sort(In).map(a=>a.key)}hasRenderableParent(t){const n=this.findLoadedParent(t,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(t,n){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(n||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(t,"reloading")}}_reloadTile(t,n){const a=this._tiles[t];a&&(a.state!=="loading"&&(a.state=n),this._loadTile(a,this._tileLoaded.bind(this,a,t,n)))}_tileLoaded(t,n,a,c){if(c)return t.state="errored",void(c.status!==404?this._source.fire(new s.j(c,{tile:t})):this.update(this.transform,this.terrain));t.timeAdded=s.h.now(),a==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new s.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const n=this.getRenderableIds();for(let c=0;c1||(Math.abs(x)>1&&(Math.abs(x+S)===1?x+=S:Math.abs(x-S)===1&&(x-=S)),d.dem&&c.dem&&(c.dem.backfillBorder(d.dem,x,b),c.neighboringTiles&&c.neighboringTiles[C]&&(c.neighboringTiles[C].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,n,a,c){for(const d in this._tiles){let x=this._tiles[d];if(c[d]||!x.hasData()||x.tileID.overscaledZ<=n||x.tileID.overscaledZ>a)continue;let b=x.tileID;for(;x&&x.tileID.overscaledZ>n+1;){const C=x.tileID.scaledTo(x.tileID.overscaledZ-1);x=this._tiles[C.key],x&&x.hasData()&&(b=C)}let S=b;for(;S.overscaledZ>n;)if(S=S.scaledTo(S.overscaledZ-1),t[S.key]){c[b.key]=b;break}}}findLoadedParent(t,n){if(t.key in this._loadedParentTiles){const a=this._loadedParentTiles[t.key];return a&&a.tileID.overscaledZ>=n?a:null}for(let a=t.overscaledZ-1;a>=n;a--){const c=t.scaledTo(a),d=this._getLoadedTile(c);if(d)return d}}_getLoadedTile(t){const n=this._tiles[t.key];return n&&n.hasData()?n:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,a=Math.ceil(t.height/this._source.tileSize)+1,c=Math.floor(n*a*(this._maxTileCacheZoomLevels===null?s.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),d=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,c):c;this._cache.setMaxSize(d)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,n){const a={};for(const c in this._tiles){const d=this._tiles[c];d.tileID=d.tileID.unwrapTo(d.tileID.wrap+n),a[d.tileID.key]=d}this._tiles=a;for(const c in this._timers)clearTimeout(this._timers[c]),delete this._timers[c];for(const c in this._tiles)this._setTileReloadTimer(c,this._tiles[c])}}update(t,n){if(this.transform=t,this.terrain=n,!this._sourceLoaded||this._paused)return;let a;this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(A=>new s.O(A.canonical.z,A.wrap,A.canonical.z,A.canonical.x,A.canonical.y)):(a=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n}),this._source.hasTile&&(a=a.filter(A=>this._source.hasTile(A)))):a=[];const c=t.coveringZoomLevel(this._source),d=Math.max(c-tn.maxOverzooming,this._source.minzoom),x=Math.max(c+tn.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const A={};for(const P of a)if(P.canonical.z>this._source.minzoom){const R=P.scaledTo(P.canonical.z-1);A[R.key]=R;const W=P.scaledTo(Math.max(this._source.minzoom,Math.min(P.canonical.z,5)));A[W.key]=W}a=a.concat(Object.values(A))}const b=a.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,b&&this.fire(new s.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const S=this._updateRetainedTiles(a,c);if(Ii(this._source.type)){const A={},P={},R=Object.keys(S),W=s.h.now();for(const G of R){const K=S[G],q=this._tiles[G];if(!q||q.fadeEndTime!==0&&q.fadeEndTime<=W)continue;const le=this.findLoadedParent(K,d);le&&(this._addTile(le.tileID),A[le.tileID.key]=le.tileID),P[G]=K}this._retainLoadedChildren(P,c,x,S);for(const G in A)S[G]||(this._coveredTiles[G]=!0,S[G]=A[G]);if(n){const G={},K={};for(const q of a)this._tiles[q.key].hasData()?G[q.key]=q:K[q.key]=q;for(const q in K){const le=K[q].children(this._source.maxzoom);this._tiles[le[0].key]&&this._tiles[le[1].key]&&this._tiles[le[2].key]&&this._tiles[le[3].key]&&(G[le[0].key]=S[le[0].key]=le[0],G[le[1].key]=S[le[1].key]=le[1],G[le[2].key]=S[le[2].key]=le[2],G[le[3].key]=S[le[3].key]=le[3],delete K[q])}for(const q in K){const le=this.findLoadedParent(K[q],this._source.minzoom);if(le){G[le.tileID.key]=S[le.tileID.key]=le.tileID;for(const _e in G)G[_e].isChildOf(le.tileID)&&delete G[_e]}}for(const q in this._tiles)G[q]||(this._coveredTiles[q]=!0)}}for(const A in S)this._tiles[A].clearFadeHold();const C=s.ab(this._tiles,S);for(const A of C){const P=this._tiles[A];P.hasSymbolBuckets&&!P.holdingForFade()?P.setHoldDuration(this.map._fadeDuration):P.hasSymbolBuckets&&!P.symbolFadeFinished()||this._removeTile(A)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){const a={},c={},d=Math.max(n-tn.maxOverzooming,this._source.minzoom),x=Math.max(n+tn.maxUnderzooming,this._source.minzoom),b={};for(const S of t){const C=this._addTile(S);a[S.key]=S,C.hasData()||nthis._source.maxzoom){const P=S.children(this._source.maxzoom)[0],R=this.getTile(P);if(R&&R.hasData()){a[P.key]=P;continue}}else{const P=S.children(this._source.maxzoom);if(a[P[0].key]&&a[P[1].key]&&a[P[2].key]&&a[P[3].key])continue}let A=C.wasRequested();for(let P=S.overscaledZ-1;P>=d;--P){const R=S.scaledTo(P);if(c[R.key])break;if(c[R.key]=!0,C=this.getTile(R),!C&&A&&(C=this._addTile(R)),C){const W=C.hasData();if((A||W)&&(a[R.key]=R),A=C.wasRequested(),W)break}}}return a}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const n=[];let a,c=this._tiles[t].tileID;for(;c.overscaledZ>0;){if(c.key in this._loadedParentTiles){a=this._loadedParentTiles[c.key];break}n.push(c.key);const d=c.scaledTo(c.overscaledZ-1);if(a=this._getLoadedTile(d),a)break;c=d}for(const d of n)this._loadedParentTiles[d]=a}}_addTile(t){let n=this._tiles[t.key];if(n)return n;n=this._cache.getAndRemove(t),n&&(this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,n)));const a=n;return n||(n=new wo(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,this._tileLoaded.bind(this,n,t.key,n.state))),n.uses++,this._tiles[t.key]=n,a||this._source.fire(new s.k("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const a=n.getExpiryTimeout();a&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},a))}_removeTile(t){const n=this._tiles[t];n&&(n.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,n,a){const c=[],d=this.transform;if(!d)return c;const x=a?d.getCameraQueryGeometry(t):t,b=t.map(G=>d.pointCoordinate(G,this.terrain)),S=x.map(G=>d.pointCoordinate(G,this.terrain)),C=this.getIds();let A=1/0,P=1/0,R=-1/0,W=-1/0;for(const G of S)A=Math.min(A,G.x),P=Math.min(P,G.y),R=Math.max(R,G.x),W=Math.max(W,G.y);for(let G=0;G=0&&ee[1].y+_e>=0){const ce=b.map(xe=>q.getTilePoint(xe)),ve=S.map(xe=>q.getTilePoint(xe));c.push({tile:K,tileID:q,queryGeometry:ce,cameraQueryGeometry:ve,scale:le})}}return c}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map(a=>this._tiles[a].tileID);for(const a of n)a.posMatrix=this.transform.calculatePosMatrix(a.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(Ii(this._source.type)){const t=s.h.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=t)return!0}return!1}setFeatureState(t,n,a){this._state.updateState(t=t||"_geojsonTileLayer",n,a)}removeFeatureState(t,n,a){this._state.removeFeatureState(t=t||"_geojsonTileLayer",n,a)}getFeatureState(t,n){return this._state.getState(t=t||"_geojsonTileLayer",n)}setDependencies(t,n,a){const c=this._tiles[t];c&&c.setDependencies(n,a)}reloadTilesForDependencies(t,n){for(const a in this._tiles)this._tiles[a].hasDependency(t,n)&&this._reloadTile(a,"reloading");this._cache.filter(a=>!a.hasDependency(t,n))}}function In(u,t){const n=Math.abs(2*u.wrap)-+(u.wrap<0),a=Math.abs(2*t.wrap)-+(t.wrap<0);return u.overscaledZ-t.overscaledZ||a-n||t.canonical.y-u.canonical.y||t.canonical.x-u.canonical.x}function Ii(u){return u==="raster"||u==="image"||u==="video"}tn.maxOverzooming=10,tn.maxUnderzooming=3;const ii="mapboxgl_preloaded_worker_pool";class Vn{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[ii]}numActive(){return Object.keys(this.active).length}}const En=Math.floor(s.h.hardwareConcurrency/2);let Un;function qo(){return Un||(Un=new Vn),Un}Vn.workerCount=s.ac(globalThis)?Math.max(Math.min(En,3),1):1;class So{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let a=1;a0?(c-x)/b:0;return this.points[d].mult(1-S).add(this.points[n].mult(S))}}function Cn(u,t){let n=!0;return u==="always"||u!=="never"&&t!=="never"||(n=!1),n}class $n{constructor(t,n,a){const c=this.boxCells=[],d=this.circleCells=[];this.xCellCount=Math.ceil(t/a),this.yCellCount=Math.ceil(n/a);for(let x=0;xthis.width||c<0||n>this.height)return[];const S=[];if(t<=0&&n<=0&&this.width<=a&&this.height<=c){if(d)return[{key:null,x1:t,y1:n,x2:a,y2:c}];for(let C=0;C0}hitTestCircle(t,n,a,c,d){const x=t-a,b=t+a,S=n-a,C=n+a;if(b<0||x>this.width||C<0||S>this.height)return!1;const A=[];return this._forEachCell(x,S,b,C,this._queryCellCircle,A,{hitTest:!0,overlapMode:c,circle:{x:t,y:n,radius:a},seenUids:{box:{},circle:{}}},d),A.length>0}_queryCell(t,n,a,c,d,x,b,S){const{seenUids:C,hitTest:A,overlapMode:P}=b,R=this.boxCells[d];if(R!==null){const G=this.bboxes;for(const K of R)if(!C.box[K]){C.box[K]=!0;const q=4*K,le=this.boxKeys[K];if(t<=G[q+2]&&n<=G[q+3]&&a>=G[q+0]&&c>=G[q+1]&&(!S||S(le))&&(!A||!Cn(P,le.overlapMode))&&(x.push({key:le,x1:G[q],y1:G[q+1],x2:G[q+2],y2:G[q+3]}),A))return!0}}const W=this.circleCells[d];if(W!==null){const G=this.circles;for(const K of W)if(!C.circle[K]){C.circle[K]=!0;const q=3*K,le=this.circleKeys[K];if(this._circleAndRectCollide(G[q],G[q+1],G[q+2],t,n,a,c)&&(!S||S(le))&&(!A||!Cn(P,le.overlapMode))){const _e=G[q],ee=G[q+1],ce=G[q+2];if(x.push({key:le,x1:_e-ce,y1:ee-ce,x2:_e+ce,y2:ee+ce}),A)return!0}}}return!1}_queryCellCircle(t,n,a,c,d,x,b,S){const{circle:C,seenUids:A,overlapMode:P}=b,R=this.boxCells[d];if(R!==null){const G=this.bboxes;for(const K of R)if(!A.box[K]){A.box[K]=!0;const q=4*K,le=this.boxKeys[K];if(this._circleAndRectCollide(C.x,C.y,C.radius,G[q+0],G[q+1],G[q+2],G[q+3])&&(!S||S(le))&&!Cn(P,le.overlapMode))return x.push(!0),!0}}const W=this.circleCells[d];if(W!==null){const G=this.circles;for(const K of W)if(!A.circle[K]){A.circle[K]=!0;const q=3*K,le=this.circleKeys[K];if(this._circlesCollide(G[q],G[q+1],G[q+2],C.x,C.y,C.radius)&&(!S||S(le))&&!Cn(P,le.overlapMode))return x.push(!0),!0}}}_forEachCell(t,n,a,c,d,x,b,S){const C=this._convertToXCellCoord(t),A=this._convertToYCellCoord(n),P=this._convertToXCellCoord(a),R=this._convertToYCellCoord(c);for(let W=C;W<=P;W++)for(let G=A;G<=R;G++)if(d.call(this,t,n,a,c,this.xCellCount*G+W,x,b,S))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,a,c,d,x){const b=c-t,S=d-n,C=a+x;return C*C>b*b+S*S}_circleAndRectCollide(t,n,a,c,d,x,b){const S=(x-c)/2,C=Math.abs(t-(c+S));if(C>S+a)return!1;const A=(b-d)/2,P=Math.abs(n-(d+A));if(P>A+a)return!1;if(C<=S||P<=A)return!0;const R=C-S,W=P-A;return R*R+W*W<=a*a}}function qe(u,t,n,a,c){const d=s.Z();return t?(s.a0(d,d,[1/c,1/c,1]),n||s.ae(d,d,a.angle)):s.a1(d,a.labelPlaneMatrix,u),d}function mn(u,t,n,a,c){if(t){const d=s.af(u);return s.a0(d,d,[c,c,1]),n||s.ae(d,d,-a.angle),d}return a.glCoordMatrix}function er(u,t,n){let a;n?(a=[u.x,u.y,n(u.x,u.y),1],s.ag(a,a,t)):(a=[u.x,u.y,0,1],J(a,a,t));const c=a[3];return{point:new s.P(a[0]/c,a[1]/c),signedDistanceFromCamera:c}}function Zo(u,t){return .5+u/t*.5}function rn(u,t){const n=u[0]/u[3],a=u[1]/u[3];return n>=-t[0]&&n<=t[0]&&a>=-t[1]&&a<=t[1]}function We(u,t,n,a,c,d,x,b,S,C){const A=a?u.textSizeData:u.iconSizeData,P=s.ah(A,n.transform.zoom),R=[256/n.width*2+1,256/n.height*2+1],W=a?u.text.dynamicLayoutVertexArray:u.icon.dynamicLayoutVertexArray;W.clear();const G=u.lineVertexArray,K=a?u.text.placedSymbolArray:u.icon.placedSymbolArray,q=n.transform.width/n.transform.height;let le=!1;for(let _e=0;_eMath.abs(n.x-t.x)*a?{useVertical:!0}:(u===s.ai.vertical?t.yn.x)?{needsFlipping:!0}:null}function Ur(u,t,n,a,c,d,x,b,S,C,A,P,R,W,G,K){const q=t/24,le=u.lineOffsetX*q,_e=u.lineOffsetY*q;let ee;if(u.numGlyphs>1){const ce=u.glyphStartIndex+u.numGlyphs,ve=u.lineStartIndex,xe=u.lineStartIndex+u.lineLength,Me=Bt(q,b,le,_e,n,A,P,u,S,d,R,G,K);if(!Me)return{notEnoughRoom:!0};const Oe=er(Me.first.point,x,K).point,ze=er(Me.last.point,x,K).point;if(a&&!n){const je=Mt(u.writingMode,Oe,ze,W);if(je)return je}ee=[Me.first];for(let je=u.glyphStartIndex+1;je0?Oe.point:_n(P,Me,ve,1,c,K),je=Mt(u.writingMode,ve,ze,W);if(je)return je}const ce=L(q*b.getoffsetX(u.glyphStartIndex),le,_e,n,A,P,u.segment,u.lineStartIndex,u.lineStartIndex+u.lineLength,S,d,R,G,K);if(!ce)return{notEnoughRoom:!0};ee=[ce]}for(const ce of ee)s.ak(C,ce.point,ce.angle);return{}}function _n(u,t,n,a,c,d){const x=er(u.add(u.sub(t)._unit()),c,d).point,b=n.sub(x);return n.add(b._mult(a/b.mag()))}function It(u,t){const{projectionCache:n,lineVertexArray:a,labelPlaneMatrix:c,tileAnchorPoint:d,distanceFromAnchor:x,getElevation:b,previousVertex:S,direction:C,absOffsetX:A}=t;if(n.projections[u])return n.projections[u];const P=new s.P(a.getx(u),a.gety(u)),R=er(P,c,b);if(R.signedDistanceFromCamera>0)return n.projections[u]=R.point,R.point;const W=u-C;return _n(x===0?d:new s.P(a.getx(W),a.gety(W)),P,S,A-x+1,c,b)}function Mn(u,t,n){return u._unit()._perp()._mult(t*n)}function X(u,t,n,a,c,d,x,b){const{projectionCache:S,direction:C}=b;if(S.offsets[u])return S.offsets[u];const A=n.add(t);if(u+C=c)return S.offsets[u]=A,A;const P=It(u+C,b),R=Mn(P.sub(n),x,C),W=n.add(R),G=P.add(R);return S.offsets[u]=s.al(d,A,W,G)||A,S.offsets[u]}function L(u,t,n,a,c,d,x,b,S,C,A,P,R,W){const G=a?u-t:u+t;let K=G>0?1:-1,q=0;a&&(K*=-1,q=Math.PI),K<0&&(q+=Math.PI);let le,_e,ee=K>0?b+x:b+x+1,ce=c,ve=c,xe=0,Me=0;const Oe=Math.abs(G),ze=[];let je;for(;xe+Me<=Oe;){if(ee+=K,ee=S)return null;xe+=Me,ve=ce,_e=le;const Qe={projectionCache:P,lineVertexArray:C,labelPlaneMatrix:A,tileAnchorPoint:d,distanceFromAnchor:xe,getElevation:W,previousVertex:ve,direction:K,absOffsetX:Oe};if(ce=It(ee,Qe),n===0)ze.push(ve),je=ce.sub(ve);else{let Ct;const gt=ce.sub(ve);Ct=gt.mag()===0?Mn(It(ee+K,Qe).sub(ce),n,K):Mn(gt,n,K),_e||(_e=ve.add(Ct)),le=X(ee,Ct,ce,b,S,_e,n,Qe),ze.push(_e),je=le.sub(_e)}Me=je.mag()}const dt=je._mult((Oe-xe)/Me)._add(_e||ve),$t=q+Math.atan2(ce.y-ve.y,ce.x-ve.x);return ze.push(dt),{point:dt,angle:R?$t:0,path:ze}}const F=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function j(u,t){for(let n=0;n=1;jt--)gt.push(Qe.path[jt]);for(let jt=1;jter(ei,S,G));gt=jt.some(ei=>ei.signedDistanceFromCamera<=0)?[]:jt.map(ei=>ei.point)}let Jt=[];if(gt.length>0){const jt=gt[0].clone(),ei=gt[0].clone();for(let fr=1;fr=je.x&&ei.x<=dt.x&&jt.y>=je.y&&ei.y<=dt.y?[gt]:ei.xdt.x||ei.ydt.y?[]:s.am([gt],je.x,je.y,dt.x,dt.y)}for(const jt of Jt){$t.reset(jt,.25*ze);let ei=0;ei=$t.length<=.5*ze?1:Math.ceil($t.paddedLength/Mi)+1;for(let fr=0;fr=this.screenRightBoundary||cthis.screenBottomBoundary}isInsideGrid(t,n,a,c){return a>=0&&t=0&&na.collisionGroupID===n}}return this.collisionGroups[t]}}function kt(u,t,n,a,c){const{horizontalAlign:d,verticalAlign:x}=s.au(u);return new s.P(-(d-.5)*t+a[0]*c,-(x-.5)*n+a[1]*c)}function ut(u,t,n,a,c,d){const{x1:x,x2:b,y1:S,y2:C,anchorPointX:A,anchorPointY:P}=u,R=new s.P(t,n);return a&&R._rotate(c?d:-d),{x1:x+R.x,y1:S+R.y,x2:b+R.x,y2:C+R.y,anchorPointX:A,anchorPointY:P}}class vt{constructor(t,n,a,c,d){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new he(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new mt(c),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,a,c){const d=a.getBucket(n),x=a.latestFeatureIndex;if(!d||!x||n.id!==d.layerIds[0])return;const b=a.collisionBoxArray,S=d.layers[0].layout,C=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),A=a.tileSize/s.N,P=this.transform.calculatePosMatrix(a.tileID.toUnwrapped()),R=S.get("text-pitch-alignment")==="map",W=S.get("text-rotation-alignment")==="map",G=oe(a,1,this.transform.zoom),K=qe(P,R,W,this.transform,G);let q=null;if(R){const _e=mn(P,R,W,this.transform,G);q=s.a1([],this.transform.labelPlaneMatrix,_e)}this.retainedQueryData[d.bucketInstanceId]=new Ce(d.bucketInstanceId,x,d.sourceLayerIndex,d.index,a.tileID);const le={bucket:d,layout:S,posMatrix:P,textLabelPlaneMatrix:K,labelToScreenMatrix:q,scale:C,textPixelRatio:A,holdingForFade:a.holdingForFade(),collisionBoxArray:b,partiallyEvaluatedTextSize:s.ah(d.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(d.sourceID)};if(c)for(const _e of d.sortKeyRanges){const{sortKey:ee,symbolInstanceStart:ce,symbolInstanceEnd:ve}=_e;t.push({sortKey:ee,symbolInstanceStart:ce,symbolInstanceEnd:ve,parameters:le})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:d.symbolInstances.length,parameters:le})}attemptAnchorPlacement(t,n,a,c,d,x,b,S,C,A,P,R,W,G,K,q){const le=s.aq[t.textAnchor],_e=[t.textOffset0,t.textOffset1],ee=kt(le,a,c,_e,d),ce=this.collisionIndex.placeCollisionBox(ut(n,ee.x,ee.y,x,b,this.transform.angle),P,S,C,A.predicate,q);if((!K||this.collisionIndex.placeCollisionBox(ut(K,ee.x,ee.y,x,b,this.transform.angle),P,S,C,A.predicate,q).box.length!==0)&&ce.box.length>0){let ve;if(this.prevPlacement&&this.prevPlacement.variableOffsets[R.crossTileID]&&this.prevPlacement.placements[R.crossTileID]&&this.prevPlacement.placements[R.crossTileID].text&&(ve=this.prevPlacement.variableOffsets[R.crossTileID].anchor),R.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[R.crossTileID]={textOffset:_e,width:a,height:c,anchor:le,textBoxScale:d,prevAnchor:ve},this.markUsedJustification(W,le,R,G),W.allowVerticalPlacement&&(this.markUsedOrientation(W,G,R),this.placedOrientations[R.crossTileID]=G),{shift:ee,placedGlyphBoxes:ce}}}placeLayerBucketPart(t,n,a){const{bucket:c,layout:d,posMatrix:x,textLabelPlaneMatrix:b,labelToScreenMatrix:S,textPixelRatio:C,holdingForFade:A,collisionBoxArray:P,partiallyEvaluatedTextSize:R,collisionGroup:W}=t.parameters,G=d.get("text-optional"),K=d.get("icon-optional"),q=s.ar(d,"text-overlap","text-allow-overlap"),le=q==="always",_e=s.ar(d,"icon-overlap","icon-allow-overlap"),ee=_e==="always",ce=d.get("text-rotation-alignment")==="map",ve=d.get("text-pitch-alignment")==="map",xe=d.get("icon-text-fit")!=="none",Me=d.get("symbol-z-order")==="viewport-y",Oe=le&&(ee||!c.hasIconData()||K),ze=ee&&(le||!c.hasTextData()||G);!c.collisionArrays&&P&&c.deserializeCollisionBoxes(P);const je=this.retainedQueryData[c.bucketInstanceId].tileID,dt=this.terrain?(Qe,Ct)=>this.terrain.getElevation(je,Qe,Ct):null,$t=(Qe,Ct)=>{var gt,Mi;if(n[Qe.crossTileID])return;if(A)return void(this.placements[Qe.crossTileID]=new Te(!1,!1,!1));let Jt=!1,jt=!1,ei=!0,fr=null,qi={box:null,offscreen:null},Kr={box:null,offscreen:null},Pr=null,wr=null,Xn=null,Qi=0,Do=0,Fo=0;Ct.textFeatureIndex?Qi=Ct.textFeatureIndex:Qe.useRuntimeCollisionCircles&&(Qi=Qe.featureIndex),Ct.verticalTextFeatureIndex&&(Do=Ct.verticalTextFeatureIndex);const _s=Ct.textBox;if(_s){const cn=mr=>{let zr=s.ai.horizontal;if(c.allowVerticalPlacement&&!mr&&this.prevPlacement){const Ln=this.prevPlacement.placedOrientations[Qe.crossTileID];Ln&&(this.placedOrientations[Qe.crossTileID]=Ln,zr=Ln,this.markUsedOrientation(c,zr,Qe))}return zr},Jr=(mr,zr)=>{if(c.allowVerticalPlacement&&Qe.numVerticalGlyphVertices>0&&Ct.verticalTextBox){for(const Ln of c.writingModes)if(Ln===s.ai.vertical?(qi=zr(),Kr=qi):qi=mr(),qi&&qi.box&&qi.box.length)break}else qi=mr()},xn=Qe.textAnchorOffsetStartIndex,Bs=Qe.textAnchorOffsetEndIndex;if(Bs===xn){const mr=(zr,Ln)=>{const _r=this.collisionIndex.placeCollisionBox(zr,q,C,x,W.predicate,dt);return _r&&_r.box&&_r.box.length&&(this.markUsedOrientation(c,Ln,Qe),this.placedOrientations[Qe.crossTileID]=Ln),_r};Jr(()=>mr(_s,s.ai.horizontal),()=>{const zr=Ct.verticalTextBox;return c.allowVerticalPlacement&&Qe.numVerticalGlyphVertices>0&&zr?mr(zr,s.ai.vertical):{box:null,offscreen:null}}),cn(qi&&qi.box&&qi.box.length)}else{let mr=s.aq[(Mi=(gt=this.prevPlacement)===null||gt===void 0?void 0:gt.variableOffsets[Qe.crossTileID])===null||Mi===void 0?void 0:Mi.anchor];const zr=(_r,Ns,_l)=>{const jc=_r.x2-_r.x1,qc=_r.y2-_r.y1,wu=Qe.textBoxScale,Jl=xe&&_e==="never"?Ns:null;let Ro={box:[],offscreen:!1},Vs=q==="never"?1:2,Oo="never";mr&&Vs++;for(let ao=0;aozr(_s,Ct.iconBox,s.ai.horizontal),()=>{const _r=Ct.verticalTextBox;return c.allowVerticalPlacement&&!(qi&&qi.box&&qi.box.length)&&Qe.numVerticalGlyphVertices>0&&_r?zr(_r,Ct.verticalIconBox,s.ai.vertical):{box:null,offscreen:null}}),qi&&(Jt=qi.box,ei=qi.offscreen);const Ln=cn(qi&&qi.box);if(!Jt&&this.prevPlacement){const _r=this.prevPlacement.variableOffsets[Qe.crossTileID];_r&&(this.variableOffsets[Qe.crossTileID]=_r,this.markUsedJustification(c,_r.anchor,Qe,Ln))}}}if(Pr=qi,Jt=Pr&&Pr.box&&Pr.box.length>0,ei=Pr&&Pr.offscreen,Qe.useRuntimeCollisionCircles){const cn=c.text.placedSymbolArray.get(Qe.centerJustifiedTextSymbolIndex),Jr=s.aj(c.textSizeData,R,cn),xn=d.get("text-padding");wr=this.collisionIndex.placeCollisionCircles(q,cn,c.lineVertexArray,c.glyphOffsetArray,Jr,x,b,S,a,ve,W.predicate,Qe.collisionCircleDiameter,xn,dt),wr.circles.length&&wr.collisionDetected&&!a&&s.w("Collisions detected, but collision boxes are not shown"),Jt=le||wr.circles.length>0&&!wr.collisionDetected,ei=ei&&wr.offscreen}if(Ct.iconFeatureIndex&&(Fo=Ct.iconFeatureIndex),Ct.iconBox){const cn=Jr=>{const xn=xe&&fr?ut(Jr,fr.x,fr.y,ce,ve,this.transform.angle):Jr;return this.collisionIndex.placeCollisionBox(xn,_e,C,x,W.predicate,dt)};Kr&&Kr.box&&Kr.box.length&&Ct.verticalIconBox?(Xn=cn(Ct.verticalIconBox),jt=Xn.box.length>0):(Xn=cn(Ct.iconBox),jt=Xn.box.length>0),ei=ei&&Xn.offscreen}const Os=G||Qe.numHorizontalGlyphVertices===0&&Qe.numVerticalGlyphVertices===0,Ca=K||Qe.numIconVertices===0;if(Os||Ca?Ca?Os||(jt=jt&&Jt):Jt=jt&&Jt:jt=Jt=jt&&Jt,Jt&&Pr&&Pr.box&&this.collisionIndex.insertCollisionBox(Pr.box,q,d.get("text-ignore-placement"),c.bucketInstanceId,Kr&&Kr.box&&Do?Do:Qi,W.ID),jt&&Xn&&this.collisionIndex.insertCollisionBox(Xn.box,_e,d.get("icon-ignore-placement"),c.bucketInstanceId,Fo,W.ID),wr&&(Jt&&this.collisionIndex.insertCollisionCircles(wr.circles,q,d.get("text-ignore-placement"),c.bucketInstanceId,Qi,W.ID),a)){const cn=c.bucketInstanceId;let Jr=this.collisionCircleArrays[cn];Jr===void 0&&(Jr=this.collisionCircleArrays[cn]=new Ie);for(let xn=0;xn=0;--Ct){const gt=Qe[Ct];$t(c.symbolInstances.get(gt),c.collisionArrays[gt])}}else for(let Qe=t.symbolInstanceStart;Qe=0&&(t.text.placedSymbolArray.get(b).crossTileID=d>=0&&b!==d?0:a.crossTileID)}markUsedOrientation(t,n,a){const c=n===s.ai.horizontal||n===s.ai.horizontalOnly?n:0,d=n===s.ai.vertical?n:0,x=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const b of x)t.text.placedSymbolArray.get(b).placedOrientation=c;a.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=d)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let a=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const c=n?n.symbolFadeChange(t):1,d=n?n.opacities:{},x=n?n.variableOffsets:{},b=n?n.placedOrientations:{};for(const S in this.placements){const C=this.placements[S],A=d[S];A?(this.opacities[S]=new ae(A,c,C.text,C.icon),a=a||C.text!==A.text.placed||C.icon!==A.icon.placed):(this.opacities[S]=new ae(null,c,C.text,C.icon,C.skipFade),a=a||C.text||C.icon)}for(const S in d){const C=d[S];if(!this.opacities[S]){const A=new ae(C,c,!1,!1);A.isHidden()||(this.opacities[S]=A,a=a||C.text.placed||C.icon.placed)}}for(const S in x)this.variableOffsets[S]||!this.opacities[S]||this.opacities[S].isHidden()||(this.variableOffsets[S]=x[S]);for(const S in b)this.placedOrientations[S]||!this.opacities[S]||this.opacities[S].isHidden()||(this.placedOrientations[S]=b[S]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const a={};for(const c of n){const d=c.getBucket(t);d&&c.latestFeatureIndex&&t.id===d.layerIds[0]&&this.updateBucketOpacities(d,a,c.collisionBoxArray)}}updateBucketOpacities(t,n,a){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0],d=c.layout,x=new ae(null,0,!1,!1,!0),b=d.get("text-allow-overlap"),S=d.get("icon-allow-overlap"),C=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),A=d.get("text-rotation-alignment")==="map",P=d.get("text-pitch-alignment")==="map",R=d.get("icon-text-fit")!=="none",W=new ae(null,0,b&&(S||!t.hasIconData()||d.get("icon-optional")),S&&(b||!t.hasTextData()||d.get("text-optional")),!0);!t.collisionArrays&&a&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(a);const G=(K,q,le)=>{for(let _e=0;_e0,xe=this.placedOrientations[q.crossTileID],Me=xe===s.ai.vertical,Oe=xe===s.ai.horizontal||xe===s.ai.horizontalOnly;if(le>0||_e>0){const ze=vr(ce.text);G(t.text,le,Me?An:ze),G(t.text,_e,Oe?An:ze);const je=ce.text.isHidden();[q.rightJustifiedTextSymbolIndex,q.centerJustifiedTextSymbolIndex,q.leftJustifiedTextSymbolIndex].forEach(Qe=>{Qe>=0&&(t.text.placedSymbolArray.get(Qe).hidden=je||Me?1:0)}),q.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(q.verticalPlacedTextSymbolIndex).hidden=je||Oe?1:0);const dt=this.variableOffsets[q.crossTileID];dt&&this.markUsedJustification(t,dt.anchor,q,xe);const $t=this.placedOrientations[q.crossTileID];$t&&(this.markUsedJustification(t,"left",q,$t),this.markUsedOrientation(t,$t,q))}if(ve){const ze=vr(ce.icon),je=!(R&&q.verticalPlacedIconSymbolIndex&&Me);q.placedIconSymbolIndex>=0&&(G(t.icon,q.numIconVertices,je?ze:An),t.icon.placedSymbolArray.get(q.placedIconSymbolIndex).hidden=ce.icon.isHidden()),q.verticalPlacedIconSymbolIndex>=0&&(G(t.icon,q.numVerticalIconVertices,je?An:ze),t.icon.placedSymbolArray.get(q.verticalPlacedIconSymbolIndex).hidden=ce.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const ze=t.collisionArrays[K];if(ze){let je=new s.P(0,0);if(ze.textBox||ze.verticalTextBox){let $t=!0;if(C){const Qe=this.variableOffsets[ee];Qe?(je=kt(Qe.anchor,Qe.width,Qe.height,Qe.textOffset,Qe.textBoxScale),A&&je._rotate(P?this.transform.angle:-this.transform.angle)):$t=!1}ze.textBox&&Ft(t.textCollisionBox.collisionVertexArray,ce.text.placed,!$t||Me,je.x,je.y),ze.verticalTextBox&&Ft(t.textCollisionBox.collisionVertexArray,ce.text.placed,!$t||Oe,je.x,je.y)}const dt=!!(!Oe&&ze.verticalIconBox);ze.iconBox&&Ft(t.iconCollisionBox.collisionVertexArray,ce.icon.placed,dt,R?je.x:0,R?je.y:0),ze.verticalIconBox&&Ft(t.iconCollisionBox.collisionVertexArray,ce.icon.placed,!dt,R?je.x:0,R?je.y:0)}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const K=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=K.invProjMatrix,t.placementViewportMatrix=K.viewportMatrix,t.collisionCircleArray=K.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function Ft(u,t,n,a,c){u.emplaceBack(t?1:0,n?1:0,a||0,c||0),u.emplaceBack(t?1:0,n?1:0,a||0,c||0),u.emplaceBack(t?1:0,n?1:0,a||0,c||0),u.emplaceBack(t?1:0,n?1:0,a||0,c||0)}const gi=Math.pow(2,25),Ut=Math.pow(2,24),ai=Math.pow(2,17),ri=Math.pow(2,16),jr=Math.pow(2,9),Ei=Math.pow(2,8),hr=Math.pow(2,1);function vr(u){if(u.opacity===0&&!u.placed)return 0;if(u.opacity===1&&u.placed)return 4294967295;const t=u.placed?1:0,n=Math.floor(127*u.opacity);return n*gi+t*Ut+n*ai+t*ri+n*jr+t*Ei+n*hr+t}const An=0;class xs{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,a,c,d){const x=this._bucketParts;for(;this._currentTileIndexb.sortKey-S.sortKey));this._currentPartIndex!this._forceFullPlacement&&s.h.now()-c>2;for(;this._currentPlacementIndex>=0;){const x=n[t[this._currentPlacementIndex]],b=this.placement.collisionIndex.transform.zoom;if(x.type==="symbol"&&(!x.minzoom||x.minzoom<=b)&&(!x.maxzoom||x.maxzoom>b)){if(this._inProgressLayer||(this._inProgressLayer=new xs(x)),this._inProgressLayer.continuePlacement(a[x.source],this.placement,this._showCollisionBoxes,x,d))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Io=512/s.N/2;class xr{constructor(t,n,a){this.tileID=t,this.bucketInstanceId=a,this._symbolsByKey={};const c=new Map;for(let d=0;d({x:Math.floor(S.anchorX*Io),y:Math.floor(S.anchorY*Io)})),crossTileIDs:x.map(S=>S.crossTileID)};if(b.positions.length>128){const S=new s.av(b.positions.length,16,Uint16Array);for(const{x:C,y:A}of b.positions)S.add(C,A);S.finish(),delete b.positions,b.index=S}this._symbolsByKey[d]=b}}getScaledCoordinates(t,n){const{x:a,y:c,z:d}=this.tileID.canonical,{x,y:b,z:S}=n.canonical,C=Io/Math.pow(2,S-d),A=(b*s.N+t.anchorY)*C,P=c*s.N*Io;return{x:Math.floor((x*s.N+t.anchorX)*C-a*s.N*Io),y:Math.floor(A-P)}}findMatches(t,n,a){const c=this.tileID.canonical.zt)}}class yi{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ta{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const a in this.indexes){const c=this.indexes[a],d={};for(const x in c){const b=c[x];b.tileID=b.tileID.unwrapTo(b.tileID.wrap+n),d[b.tileID.key]=b}this.indexes[a]=d}this.lng=t}addBucket(t,n,a){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let d=0;dt.overscaledZ)for(const b in x){const S=x[b];S.tileID.isChildOf(t)&&S.findMatches(n.symbolInstances,t,c)}else{const b=x[t.scaledTo(Number(d)).key];b&&b.findMatches(n.symbolInstances,t,c)}}for(let d=0;d{n[a]=!0});for(const a in this.layerIndexes)n[a]||delete this.layerIndexes[a]}}const ji=(u,t)=>s.x(u,t&&t.filter(n=>n.identifier!=="source.canvas")),qr=s.F(s.ax,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setGlyphs","setSprite"]),Go=s.F(s.ax,["setCenter","setZoom","setBearing","setPitch"]),Ir=s.aw();class Er extends s.E{constructor(t,n={}){super(),this.map=t,this.dispatcher=new zi(qo(),this,t._getMapId()),this.imageManager=new Ge,this.imageManager.setEventedParent(this),this.glyphManager=new Lt(t._requestManager,n.localIdeographFontFamily),this.lineAtlas=new Vr(256,512),this.crossTileSymbolIndex=new jn,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new s.ay,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",s.az());const a=this;this._rtlTextPluginCallback=Er.registerForPluginStateChange(c=>{a.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:c.pluginStatus,pluginURL:c.pluginURL},(d,x)=>{if(s.aA(d),x&&x.every(b=>b))for(const b in a.sourceCaches){const S=a.sourceCaches[b].getSource().type;S!=="vector"&&S!=="geojson"||a.sourceCaches[b].reload()}})}),this.on("data",c=>{if(c.dataType!=="source"||c.sourceDataType!=="metadata")return;const d=this.sourceCaches[c.sourceId];if(!d)return;const x=d.getSource();if(x&&x.vectorLayerIds)for(const b in this._layers){const S=this._layers[b];S.source===x.id&&this._validateLayer(S)}})}loadURL(t,n={},a){this.fire(new s.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const c=this.map._requestManager.transformRequest(t,et.Style);this._request=s.f(c,(d,x)=>{this._request=null,d?this.fire(new s.j(d)):x&&this._load(x,n,a)})}loadJSON(t,n={},a){this.fire(new s.k("dataloading",{dataType:"style"})),this._request=s.h.frame(()=>{this._request=null,n.validate=n.validate!==!1,this._load(t,n,a)})}loadEmpty(){this.fire(new s.k("dataloading",{dataType:"style"})),this._load(Ir,{validate:!1})}_load(t,n,a){var c;const d=n.transformStyle?n.transformStyle(a,t):t;if(!n.validate||!ji(this,s.y(d))){this._loaded=!0,this.stylesheet=d;for(const x in d.sources)this.addSource(x,d.sources[x],{validate:!1});d.sprite?this._loadSprite(d.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(d.glyphs),this._createLayers(),this.light=new en(this.stylesheet.light),this.map.setTerrain((c=this.stylesheet.terrain)!==null&&c!==void 0?c:null),this.fire(new s.k("data",{dataType:"style"})),this.fire(new s.k("style.load"))}}_createLayers(){const t=s.aB(this.stylesheet.layers);this.dispatcher.broadcast("setLayers",t),this._order=t.map(n=>n.id),this._layers={},this._serializedLayers=null;for(const n of t){const a=s.aC(n);a.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=a}}_loadSprite(t,n=!1,a=void 0){this.imageManager.setLoaded(!1),this._spriteRequest=function(c,d,x,b){const S=Nt(c),C=S.length,A=x>1?"@2x":"",P={},R={},W={};for(const{id:G,url:K}of S){const q=d.transformRequest(d.normalizeSpriteURL(K,A,".json"),et.SpriteJSON),le=`${G}_${q.url}`;P[le]=s.f(q,(ce,ve)=>{delete P[le],R[G]=ve,Yt(b,R,W,ce,C)});const _e=d.transformRequest(d.normalizeSpriteURL(K,A,".png"),et.SpriteImage),ee=`${G}_${_e.url}`;P[ee]=Ne.getImage(_e,(ce,ve)=>{delete P[ee],W[G]=ve,Yt(b,R,W,ce,C)})}return{cancel(){for(const G of Object.values(P))G.cancel()}}}(t,this.map._requestManager,this.map.getPixelRatio(),(c,d)=>{if(this._spriteRequest=null,c)this.fire(new s.j(c));else if(d)for(const x in d){this._spritesImagesIds[x]=[];const b=this._spritesImagesIds[x]?this._spritesImagesIds[x].filter(S=>!(S in d)):[];for(const S of b)this.imageManager.removeImage(S),this._changedImages[S]=!0;for(const S in d[x]){const C=x==="default"?S:`${x}:${S}`;this._spritesImagesIds[x].push(C),C in this.imageManager.images?this.imageManager.updateImage(C,d[x][S],!1):this.imageManager.addImage(C,d[x][S]),n&&(this._changedImages[C]=!0)}}this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.k("data",{dataType:"style"})),a&&a(c)})}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.k("data",{dataType:"style"}))}_validateLayer(t){const n=this.sourceCaches[t.source];if(!n)return;const a=t.sourceLayer;if(!a)return;const c=n.getSource();(c.type==="geojson"||c.vectorLayerIds&&c.vectorLayerIds.indexOf(a)===-1)&&this.fire(new s.j(new Error(`Source layer "${a}" does not exist on source "${c.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t){const n=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n);const a=[];for(const c of t)n[c]&&a.push(n[c]);return a}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const n=Object.keys(this._layers);for(const a of n){const c=this._layers[a];c.type!=="custom"&&(t[a]=c.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const c=Object.keys(this._updatedLayers),d=Object.keys(this._removedLayers);(c.length||d.length)&&this._updateWorkerLayers(c,d);for(const x in this._updatedSources){const b=this._updatedSources[x];if(b==="reload")this._reloadSource(x);else{if(b!=="clear")throw new Error(`Invalid action ${b}`);this._clearSource(x)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const x in this._updatedPaintProps)this._layers[x].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const a={};for(const c in this.sourceCaches){const d=this.sourceCaches[c];a[c]=d.used,d.used=!1}for(const c of this._order){const d=this._layers[c];d.recalculate(t,this._availableImages),!d.isHidden(t.zoom)&&d.source&&(this.sourceCaches[d.source].used=!0)}for(const c in a){const d=this.sourceCaches[c];a[c]!==d.used&&d.fire(new s.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:c}))}this.light.recalculate(t),this.z=t.zoom,n&&this.fire(new s.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("updateLayers",{layers:this._serializeByIds(t),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){this._checkLoaded();const a=this.serialize();if(t=n.transformStyle?n.transformStyle(a,t):t,ji(this,s.y(t)))return!1;(t=s.aD(t)).layers=s.aB(t.layers);const c=s.aE(a,t).filter(x=>!(x.command in Go));if(c.length===0)return!1;const d=c.filter(x=>!(x.command in qr));if(d.length>0)throw new Error(`Unimplemented: ${d.map(x=>x.command).join(", ")}.`);for(const x of c)x.command!=="setTransition"&&this[x.command].apply(this,x.args);return this.stylesheet=t,this._serializedLayers=null,!0}addImage(t,n){if(this.getImage(t))return this.fire(new s.j(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new s.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,a={}){if(this._checkLoaded(),this.sourceCaches[t]!==void 0)throw new Error(`Source "${t}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(s.y.source,`sources.${t}`,n,null,a))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const c=this.sourceCaches[t]=new tn(t,n,this.dispatcher);c.style=this,c.setEventedParent(this,()=>({isSourceLoaded:c.loaded(),source:c.serialize(),sourceId:t})),c.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error("There is no source with this ID");for(const a in this._layers)if(this._layers[a].source===t)return this.fire(new s.j(new Error(`Source "${t}" cannot be removed while layer "${a}" is using it.`)));const n=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],n.fire(new s.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const a=this.sourceCaches[t].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(n),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,n,a={}){this._checkLoaded();const c=t.id;if(this.getLayer(c))return void this.fire(new s.j(new Error(`Layer "${c}" already exists on this map.`)));let d;if(t.type==="custom"){if(ji(this,s.aF(t)))return;d=s.aC(t)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(c,t.source),t=s.aD(t),t=s.e(t,{source:c})),this._validate(s.y.layer,`layers.${c}`,t,{arrayIndex:-1},a))return;d=s.aC(t),this._validateLayer(d),d.setEventedParent(this,{layer:{id:c}})}const x=n?this._order.indexOf(n):this._order.length;if(n&&x===-1)this.fire(new s.j(new Error(`Cannot add layer "${c}" before non-existing layer "${n}".`)));else{if(this._order.splice(x,0,c),this._layerOrderChanged=!0,this._layers[c]=d,this._removedLayers[c]&&d.source&&d.type!=="custom"){const b=this._removedLayers[c];delete this._removedLayers[c],b.type!==d.type?this._updatedSources[d.source]="clear":(this._updatedSources[d.source]="reload",this.sourceCaches[d.source].pause())}this._updateLayer(d),d.onAdd&&d.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new s.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const a=this._order.indexOf(t);this._order.splice(a,1);const c=n?this._order.indexOf(n):this._order.length;n&&c===-1?this.fire(new s.j(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(c,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new s.j(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const a=this._order.indexOf(t);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,a){this._checkLoaded();const c=this.getLayer(t);c?c.minzoom===n&&c.maxzoom===a||(n!=null&&(c.minzoom=n),a!=null&&(c.maxzoom=a),this._updateLayer(c)):this.fire(new s.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,a={}){this._checkLoaded();const c=this.getLayer(t);if(c){if(!s.aG(c.filter,n))return n==null?(c.filter=void 0,void this._updateLayer(c)):void(this._validate(s.y.filter,`layers.${c.id}.filter`,n,null,a)||(c.filter=s.aD(n),this._updateLayer(c)))}else this.fire(new s.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return s.aD(this.getLayer(t).filter)}setLayoutProperty(t,n,a,c={}){this._checkLoaded();const d=this.getLayer(t);d?s.aG(d.getLayoutProperty(n),a)||(d.setLayoutProperty(n,a,c),this._updateLayer(d)):this.fire(new s.j(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const a=this.getLayer(t);if(a)return a.getLayoutProperty(n);this.fire(new s.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,a,c={}){this._checkLoaded();const d=this.getLayer(t);d?s.aG(d.getPaintProperty(n),a)||(d.setPaintProperty(n,a,c)&&this._updateLayer(d),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new s.j(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const a=t.source,c=t.sourceLayer,d=this.sourceCaches[a];if(d===void 0)return void this.fire(new s.j(new Error(`The source '${a}' does not exist in the map's style.`)));const x=d.getSource().type;x==="geojson"&&c?this.fire(new s.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):x!=="vector"||c?(t.id===void 0&&this.fire(new s.j(new Error("The feature id parameter must be provided."))),d.setFeatureState(c,t.id,n)):this.fire(new s.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const a=t.source,c=this.sourceCaches[a];if(c===void 0)return void this.fire(new s.j(new Error(`The source '${a}' does not exist in the map's style.`)));const d=c.getSource().type,x=d==="vector"?t.sourceLayer:void 0;d!=="vector"||x?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new s.j(new Error("A feature id is required to remove its specific state property."))):c.removeFeatureState(x,t.id,n):this.fire(new s.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,a=t.sourceLayer,c=this.sourceCaches[n];if(c!==void 0)return c.getSource().type!=="vector"||a?(t.id===void 0&&this.fire(new s.j(new Error("The feature id parameter must be provided."))),c.getFeatureState(a,t.id)):void this.fire(new s.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new s.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return s.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=s.aH(this.sourceCaches,d=>d.serialize()),n=this._serializeByIds(this._order),a=this.map.getTerrain()||void 0,c=this.stylesheet;return s.aI({version:c.version,name:c.name,metadata:c.metadata,light:c.light,center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,sprite:c.sprite,glyphs:c.glyphs,transition:c.transition,sources:t,layers:n,terrain:a},d=>d!==void 0)}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.sourceCaches[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=x=>this._layers[x].type==="fill-extrusion",a={},c=[];for(let x=this._order.length-1;x>=0;x--){const b=this._order[x];if(n(b)){a[b]=x;for(const S of t){const C=S[b];if(C)for(const A of C)c.push(A)}}}c.sort((x,b)=>b.intersectionZ-x.intersectionZ);const d=[];for(let x=this._order.length-1;x>=0;x--){const b=this._order[x];if(n(b))for(let S=c.length-1;S>=0;S--){const C=c[S].feature;if(a[C.layer.id]{const Oe=le.featureSortOrder;if(Oe){const ze=Oe.indexOf(xe.featureIndex);return Oe.indexOf(Me.featureIndex)-ze}return Me.featureIndex-xe.featureIndex});for(const xe of ve)ce.push(xe)}}for(const le in G)G[le].forEach(_e=>{const ee=_e.feature,ce=C[b[le].source].getFeatureState(ee.layer["source-layer"],ee.id);ee.source=ee.layer.source,ee.layer["source-layer"]&&(ee.sourceLayer=ee.layer["source-layer"]),ee.state=ce});return G}(this._layers,x,this.sourceCaches,t,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(d)}querySourceFeatures(t,n){n&&n.filter&&this._validate(s.y.filter,"querySourceFeatures.filter",n.filter,null,n);const a=this.sourceCaches[t];return a?function(c,d){const x=c.getRenderableIds().map(C=>c.getTileByID(C)),b=[],S={};for(let C=0;C{Ue[c]=d})(t,n),n.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:n.workerSourceURL},a):a(null,null))}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const a=this.light.getLight();let c=!1;for(const x in t)if(!s.aG(t[x],a[x])){c=!0;break}if(!c)return;const d={now:s.h.now(),transition:s.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(d)}_validate(t,n,a,c,d={}){return(!d||d.validate!==!1)&&ji(this,t.call(s.y,s.e({key:n,style:this.serialize(),value:a,styleSpec:s.v},c)))}_remove(t=!0){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),s.aJ.off("pluginStateChange",this._rtlTextPluginCallback);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.sourceCaches){const a=this.sourceCaches[n];a.setEventedParent(null),a.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove(t)}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const n in this.sourceCaches)this.sourceCaches[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,n,a,c,d=!1){let x=!1,b=!1;const S={};for(const C of this._order){const A=this._layers[C];if(A.type!=="symbol")continue;if(!S[A.source]){const R=this.sourceCaches[A.source];S[A.source]=R.getRenderableIds(!0).map(W=>R.getTileByID(W)).sort((W,G)=>G.tileID.overscaledZ-W.tileID.overscaledZ||(W.tileID.isLessThan(G.tileID)?-1:1))}const P=this.crossTileSymbolIndex.addLayer(A,S[A.source],t.center.lng);x=x||P}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((d=d||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.h.now(),t.zoom))&&(this.pauseablePlacement=new To(t,this.map.terrain,this._order,d,n,a,c,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,S),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.h.now()),b=!0),x&&this.pauseablePlacement.placement.setStale()),b||x)for(const C of this._order){const A=this._layers[C];A.type==="symbol"&&this.placement.updateLayerOpacities(A,S[A.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.h.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,n,a){this.imageManager.getImages(n.icons,a),this._updateTilesForChangedImages();const c=this.sourceCaches[n.source];c&&c.setDependencies(n.tileID.key,n.type,n.icons)}getGlyphs(t,n,a){this.glyphManager.getGlyphs(n.stacks,a);const c=this.sourceCaches[n.source];c&&c.setDependencies(n.tileID.key,n.type,[""])}getResource(t,n,a){return s.m(n,a)}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(s.y.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,n,a={},c){this._checkLoaded();const d=[{id:t,url:n}],x=[...Nt(this.stylesheet.sprite),...d];this._validate(s.y.sprite,"sprite",x,null,a)||(this.stylesheet.sprite=x,this._loadSprite(d,!0,c))}removeSprite(t){this._checkLoaded();const n=Nt(this.stylesheet.sprite);if(n.find(a=>a.id===t)){if(this._spritesImagesIds[t])for(const a of this._spritesImagesIds[t])this.imageManager.removeImage(a),this._changedImages[a]=!0;n.splice(n.findIndex(a=>a.id===t),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.k("data",{dataType:"style"}))}else this.fire(new s.j(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return Nt(this.stylesheet.sprite)}setSprite(t,n={},a){this._checkLoaded(),t&&this._validate(s.y.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,a):(this._unloadSprite(),a&&a(null)))}}Er.registerForPluginStateChange=s.aK;var ia=s.Q([{name:"a_pos",type:"Int16",components:2}]),os="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";const Gi={prelude:di(`#ifdef GL_ES +var a_=Object.defineProperty;var l_=(m,f,_)=>f in m?a_(m,f,{enumerable:!0,configurable:!0,writable:!0,value:_}):m[f]=_;var Nn=(m,f,_)=>(l_(m,typeof f!="symbol"?f+"":f,_),_);(function(){const f=document.createElement("link").relList;if(f&&f.supports&&f.supports("modulepreload"))return;for(const E of document.querySelectorAll('link[rel="modulepreload"]'))v(E);new MutationObserver(E=>{for(const k of E)if(k.type==="childList")for(const F of k.addedNodes)F.tagName==="LINK"&&F.rel==="modulepreload"&&v(F)}).observe(document,{childList:!0,subtree:!0});function _(E){const k={};return E.integrity&&(k.integrity=E.integrity),E.referrerPolicy&&(k.referrerPolicy=E.referrerPolicy),E.crossOrigin==="use-credentials"?k.credentials="include":E.crossOrigin==="anonymous"?k.credentials="omit":k.credentials="same-origin",k}function v(E){if(E.ep)return;E.ep=!0;const k=_(E);fetch(E.href,k)}})();function Nr(){}function c_(m,f){for(const _ in f)m[_]=f[_];return m}function Np(m){return m()}function pp(){return Object.create(null)}function Oa(m){m.forEach(Np)}function Th(m){return typeof m=="function"}function Tr(m,f){return m!=m?f==f:m!==f||m&&typeof m=="object"||typeof m=="function"}function u_(m){return Object.keys(m).length===0}function Vp(m,...f){if(m==null){for(const v of f)v(void 0);return Nr}const _=m.subscribe(...f);return _.unsubscribe?()=>_.unsubscribe():_}function h_(m){let f;return Vp(m,_=>f=_)(),f}function $r(m,f,_){m.$$.on_destroy.push(Vp(f,_))}function Ys(m,f,_,v){if(m){const E=Up(m,f,_,v);return m[0](E)}}function Up(m,f,_,v){return m[1]&&v?c_(_.ctx.slice(),m[1](v(f))):_.ctx}function Qs(m,f,_,v){if(m[2]&&v){const E=m[2](v(_));if(f.dirty===void 0)return E;if(typeof E=="object"){const k=[],F=Math.max(f.dirty.length,E.length);for(let s=0;s32){const f=[],_=m.ctx.length/32;for(let v=0;v<_;v++)f[v]=-1;return f}return-1}function d_(m){const f={};for(const _ in m)f[_]=!0;return f}function fp(m){return m??""}function ol(m,f,_){return m.set(_),f}function p_(m){return m&&Th(m.destroy)?m.destroy:Nr}function pi(m,f){m.appendChild(f)}function ci(m,f,_){m.insertBefore(f,_||null)}function si(m){m.parentNode&&m.parentNode.removeChild(m)}function f_(m,f){for(let _=0;_m.removeEventListener(f,_,v)}function xs(m,f,_){_==null?m.removeAttribute(f):m.getAttribute(f)!==_&&m.setAttribute(f,_)}function m_(m){return Array.from(m.childNodes)}function yh(m,f){f=""+f,m.data!==f&&(m.data=f)}function Uo(m,f){m.value=f??""}function Cc(m,f,_,v){_==null?m.style.removeProperty(f):m.style.setProperty(f,_,v?"important":"")}function mp(m,f,_){for(let v=0;v{const E=m.$$.callbacks[f];if(E){const k=g_(f,_,{cancelable:v});return E.slice().forEach(F=>{F.call(m,k)}),!k.defaultPrevented}return!0}}function qp(m,f){return Dc().$$.context.set(m,f),f}function y_(m){return Dc().$$.context.get(m)}function pn(m,f){const _=m.$$.callbacks[f.type];_&&_.slice().forEach(v=>v.call(this,f))}const Al=[],bs=[];let Pl=[];const vh=[],Zp=Promise.resolve();let xh=!1;function Gp(){xh||(xh=!0,Zp.then(Wp))}function v_(){return Gp(),Zp}function gu(m){Pl.push(m)}function Ll(m){vh.push(m)}const dh=new Set;let Cl=0;function Wp(){if(Cl!==0)return;const m=Lc;do{try{for(;Clm.indexOf(v)===-1?f.push(v):_.push(v)),_.forEach(v=>v()),Pl=f}const pu=new Set;let rl;function rs(){rl={r:0,c:[],p:rl}}function ns(){rl.r||Oa(rl.c),rl=rl.p}function ft(m,f){m&&m.i&&(pu.delete(m),m.i(f))}function St(m,f,_,v){if(m&&m.o){if(pu.has(m))return;pu.add(m),rl.c.push(()=>{pu.delete(m),v&&(_&&m.d(1),v())}),m.o(f)}else v&&v()}function gp(m){return(m==null?void 0:m.length)!==void 0?m:Array.from(m)}function Dl(m,f,_){const v=m.$$.props[f];v!==void 0&&(m.$$.bound[v]=_,_(m.$$.ctx[v]))}function Ri(m){m&&m.c()}function Ai(m,f,_){const{fragment:v,after_update:E}=m.$$;v&&v.m(f,_),gu(()=>{const k=m.$$.on_mount.map(Np).filter(Th);m.$$.on_destroy?m.$$.on_destroy.push(...k):Oa(k),m.$$.on_mount=[]}),E.forEach(gu)}function ki(m,f){const _=m.$$;_.fragment!==null&&(b_(_.after_update),Oa(_.on_destroy),_.fragment&&_.fragment.d(f),_.on_destroy=_.fragment=null,_.ctx=[])}function w_(m,f){m.$$.dirty[0]===-1&&(Al.push(m),Gp(),m.$$.dirty.fill(0)),m.$$.dirty[f/31|0]|=1<{const ke=Oe.length?Oe[0]:ge;return V.ctx&&E(V.ctx[be],V.ctx[be]=ke)&&(!V.skip_bound&&V.bound[be]&&V.bound[be](ke),me&&w_(m,be)),ge}):[],V.update(),me=!0,Oa(V.before_update),V.fragment=v?v(V.ctx):!1,f.target){if(f.hydrate){const be=m_(f.target);V.fragment&&V.fragment.l(be),be.forEach(si)}else V.fragment&&V.fragment.c();f.intro&&ft(m.$$.fragment),Ai(m,f.target,f.anchor),Wp()}Mc(Z)}class Wr{constructor(){Nn(this,"$$");Nn(this,"$$set")}$destroy(){ki(this,1),this.$destroy=Nr}$on(f,_){if(!Th(_))return Nr;const v=this.$$.callbacks[f]||(this.$$.callbacks[f]=[]);return v.push(_),()=>{const E=v.indexOf(_);E!==-1&&v.splice(E,1)}}$set(f){this.$$set&&!u_(f)&&(this.$$.skip_bound=!0,this.$$set(f),this.$$.skip_bound=!1)}}const S_="4";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(S_);function Hp(m,f,_){if(m!==null)for(var v,E,k,F,s,Z,V,me=0,be=0,ge,Oe=m.type,ke=Oe==="FeatureCollection",Pe=Oe==="Feature",De=ke?m.features.length:1,Ve=0;Ve_[0]&&(f[0]=_[0]),f[1]>_[1]&&(f[1]=_[1]),f[2]<_[0]&&(f[2]=_[0]),f[3]<_[1]&&(f[3]=_[1])}),f}bh.default=bh;let ui;const Xp=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&Xp.decode();let vc=null;function zl(){return(vc===null||vc.byteLength===0)&&(vc=new Uint8Array(ui.memory.buffer)),vc}function nl(m,f){return m=m>>>0,Xp.decode(zl().subarray(m,m+f))}const Xs=new Array(128).fill(void 0);Xs.push(void 0,null,!0,!1);let Ac=Xs.length;function Br(m){Ac===Xs.length&&Xs.push(Xs.length+1);const f=Ac;return Ac=Xs[f],Xs[f]=m,f}function Wt(m){return Xs[m]}let sl=0;const fu=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},T_=typeof fu.encodeInto=="function"?function(m,f){return fu.encodeInto(m,f)}:function(m,f){const _=fu.encode(m);return f.set(_),{read:m.length,written:_.length}};function ph(m,f,_){if(_===void 0){const s=fu.encode(m),Z=f(s.length,1)>>>0;return zl().subarray(Z,Z+s.length).set(s),sl=s.length,Z}let v=m.length,E=f(v,1)>>>0;const k=zl();let F=0;for(;F127)break;k[E+F]=s}if(F!==v){F!==0&&(m=m.slice(F)),E=_(E,v,v=F+m.length*3,1)>>>0;const s=zl().subarray(E+F,E+v),Z=T_(m,s);F+=Z.written}return sl=F,E}function gc(m){return m==null}let xc=null;function ur(){return(xc===null||xc.byteLength===0)&&(xc=new Int32Array(ui.memory.buffer)),xc}function I_(m){m<132||(Xs[m]=Ac,Ac=m)}function bc(m){const f=Wt(m);return I_(m),f}let wc=null;function E_(){return(wc===null||wc.byteLength===0)&&(wc=new Float64Array(ui.memory.buffer)),wc}let Sc=null;function C_(){return(Sc===null||Sc.byteLength===0)&&(Sc=new BigInt64Array(ui.memory.buffer)),Sc}function wh(m){const f=typeof m;if(f=="number"||f=="boolean"||m==null)return`${m}`;if(f=="string")return`"${m}"`;if(f=="symbol"){const E=m.description;return E==null?"Symbol":`Symbol(${E})`}if(f=="function"){const E=m.name;return typeof E=="string"&&E.length>0?`Function(${E})`:"Function"}if(Array.isArray(m)){const E=m.length;let k="[";E>0&&(k+=wh(m[0]));for(let F=1;F1)v=_[1];else return toString.call(m);if(v=="Object")try{return"Object("+JSON.stringify(m)+")"}catch{return"Object"}return m instanceof Error?`${m.name}: ${m.message} +${m.stack}`:v}function M_(m,f){const _=f(m.length*1,1)>>>0;return zl().set(m,_/1),sl=m.length,_}function A_(m,f){return m=m>>>0,zl().subarray(m/1,m/1+f)}function fh(m,f){try{return m.apply(this,f)}catch(_){ui.__wbindgen_exn_store(Br(_))}}class k_{__destroy_into_raw(){const f=this.__wbg_ptr;return this.__wbg_ptr=0,f}free(){const f=this.__destroy_into_raw();ui.__wbg_ltn_free(f)}constructor(f){try{const k=ui.__wbindgen_add_to_stack_pointer(-16),F=M_(f,ui.__wbindgen_malloc),s=sl;ui.ltn_new(k,F,s);var _=ur()[k/4+0],v=ur()[k/4+1],E=ur()[k/4+2];if(E)throw bc(v);return this.__wbg_ptr=_>>>0,this}finally{ui.__wbindgen_add_to_stack_pointer(16)}}render(){let f,_;try{const V=ui.__wbindgen_add_to_stack_pointer(-16);ui.ltn_render(V,this.__wbg_ptr);var v=ur()[V/4+0],E=ur()[V/4+1],k=ur()[V/4+2],F=ur()[V/4+3],s=v,Z=E;if(F)throw s=0,Z=0,bc(k);return f=s,_=Z,nl(s,Z)}finally{ui.__wbindgen_add_to_stack_pointer(16),ui.__wbindgen_free(f,_,1)}}toRouteSnapper(){try{const E=ui.__wbindgen_add_to_stack_pointer(-16);ui.ltn_toRouteSnapper(E,this.__wbg_ptr);var f=ur()[E/4+0],_=ur()[E/4+1],v=A_(f,_).slice();return ui.__wbindgen_free(f,_*1,1),v}finally{ui.__wbindgen_add_to_stack_pointer(16)}}analyzeNeighbourhood(f){let _,v;try{const me=ui.__wbindgen_add_to_stack_pointer(-16);ui.ltn_analyzeNeighbourhood(me,this.__wbg_ptr,Br(f));var E=ur()[me/4+0],k=ur()[me/4+1],F=ur()[me/4+2],s=ur()[me/4+3],Z=E,V=k;if(s)throw Z=0,V=0,bc(F);return _=Z,v=V,nl(Z,V)}finally{ui.__wbindgen_add_to_stack_pointer(16),ui.__wbindgen_free(_,v,1)}}unsetNeighbourhood(){ui.ltn_unsetNeighbourhood(this.__wbg_ptr)}addModalFilter(f){let _,v;try{const me=ui.__wbindgen_add_to_stack_pointer(-16);ui.ltn_addModalFilter(me,this.__wbg_ptr,Br(f));var E=ur()[me/4+0],k=ur()[me/4+1],F=ur()[me/4+2],s=ur()[me/4+3],Z=E,V=k;if(s)throw Z=0,V=0,bc(F);return _=Z,v=V,nl(Z,V)}finally{ui.__wbindgen_add_to_stack_pointer(16),ui.__wbindgen_free(_,v,1)}}}async function P_(m,f){if(typeof Response=="function"&&m instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(m,f)}catch(v){if(m.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",v);else throw v}const _=await m.arrayBuffer();return await WebAssembly.instantiate(_,f)}else{const _=await WebAssembly.instantiate(m,f);return _ instanceof WebAssembly.Instance?{instance:_,module:m}:_}}function z_(){const m={};return m.wbg={},m.wbg.__wbindgen_error_new=function(f,_){const v=new Error(nl(f,_));return Br(v)},m.wbg.__wbindgen_string_new=function(f,_){const v=nl(f,_);return Br(v)},m.wbg.__wbindgen_string_get=function(f,_){const v=Wt(_),E=typeof v=="string"?v:void 0;var k=gc(E)?0:ph(E,ui.__wbindgen_malloc,ui.__wbindgen_realloc),F=sl;ur()[f/4+1]=F,ur()[f/4+0]=k},m.wbg.__wbindgen_object_drop_ref=function(f){bc(f)},m.wbg.__wbindgen_boolean_get=function(f){const _=Wt(f);return typeof _=="boolean"?_?1:0:2},m.wbg.__wbindgen_is_bigint=function(f){return typeof Wt(f)=="bigint"},m.wbg.__wbindgen_bigint_from_i64=function(f){return Br(f)},m.wbg.__wbindgen_jsval_eq=function(f,_){return Wt(f)===Wt(_)},m.wbg.__wbindgen_bigint_from_u64=function(f){const _=BigInt.asUintN(64,f);return Br(_)},m.wbg.__wbindgen_number_get=function(f,_){const v=Wt(_),E=typeof v=="number"?v:void 0;E_()[f/8+1]=gc(E)?0:E,ur()[f/4+0]=!gc(E)},m.wbg.__wbindgen_is_object=function(f){const _=Wt(f);return typeof _=="object"&&_!==null},m.wbg.__wbindgen_in=function(f,_){return Wt(f)in Wt(_)},m.wbg.__wbindgen_is_undefined=function(f){return Wt(f)===void 0},m.wbg.__wbindgen_object_clone_ref=function(f){const _=Wt(f);return Br(_)},m.wbg.__wbindgen_jsval_loose_eq=function(f,_){return Wt(f)==Wt(_)},m.wbg.__wbg_getwithrefkey_3b3c46ba20582127=function(f,_){const v=Wt(f)[Wt(_)];return Br(v)},m.wbg.__wbg_debug_34c9290896ec9856=function(f){console.debug(Wt(f))},m.wbg.__wbg_error_e60eff06f24ab7a4=function(f){console.error(Wt(f))},m.wbg.__wbg_info_d7d58472d0bab115=function(f){console.info(Wt(f))},m.wbg.__wbg_log_a4530b4fe289336f=function(f){console.log(Wt(f))},m.wbg.__wbg_warn_f260f49434e45e62=function(f){console.warn(Wt(f))},m.wbg.__wbg_get_f01601b5a68d10e3=function(f,_){const v=Wt(f)[_>>>0];return Br(v)},m.wbg.__wbg_length_1009b1af0c481d7b=function(f){return Wt(f).length},m.wbg.__wbindgen_is_function=function(f){return typeof Wt(f)=="function"},m.wbg.__wbg_next_9b877f231f476d01=function(f){const _=Wt(f).next;return Br(_)},m.wbg.__wbg_next_6529ee0cca8d57ed=function(){return fh(function(f){const _=Wt(f).next();return Br(_)},arguments)},m.wbg.__wbg_done_5fe336b092d60cf2=function(f){return Wt(f).done},m.wbg.__wbg_value_0c248a78fdc8e19f=function(f){const _=Wt(f).value;return Br(_)},m.wbg.__wbg_iterator_db7ca081358d4fb2=function(){return Br(Symbol.iterator)},m.wbg.__wbg_get_7b48513de5dc5ea4=function(){return fh(function(f,_){const v=Reflect.get(Wt(f),Wt(_));return Br(v)},arguments)},m.wbg.__wbg_call_90c26b09837aba1c=function(){return fh(function(f,_){const v=Wt(f).call(Wt(_));return Br(v)},arguments)},m.wbg.__wbg_isArray_74fb723e24f76012=function(f){return Array.isArray(Wt(f))},m.wbg.__wbg_instanceof_ArrayBuffer_e7d53d51371448e2=function(f){let _;try{_=Wt(f)instanceof ArrayBuffer}catch{_=!1}return _},m.wbg.__wbg_isSafeInteger_f93fde0dca9820f8=function(f){return Number.isSafeInteger(Wt(f))},m.wbg.__wbg_entries_9e2e2aa45aa5094a=function(f){const _=Object.entries(Wt(f));return Br(_)},m.wbg.__wbg_buffer_a448f833075b71ba=function(f){const _=Wt(f).buffer;return Br(_)},m.wbg.__wbg_new_8f67e318f15d7254=function(f){const _=new Uint8Array(Wt(f));return Br(_)},m.wbg.__wbg_set_2357bf09366ee480=function(f,_,v){Wt(f).set(Wt(_),v>>>0)},m.wbg.__wbg_length_1d25fa9e4ac21ce7=function(f){return Wt(f).length},m.wbg.__wbg_instanceof_Uint8Array_bced6f43aed8c1aa=function(f){let _;try{_=Wt(f)instanceof Uint8Array}catch{_=!1}return _},m.wbg.__wbg_new_abda76e883ba8a5f=function(){const f=new Error;return Br(f)},m.wbg.__wbg_stack_658279fe44541cf6=function(f,_){const v=Wt(_).stack,E=ph(v,ui.__wbindgen_malloc,ui.__wbindgen_realloc),k=sl;ur()[f/4+1]=k,ur()[f/4+0]=E},m.wbg.__wbg_error_f851667af71bcfc6=function(f,_){let v,E;try{v=f,E=_,console.error(nl(f,_))}finally{ui.__wbindgen_free(v,E,1)}},m.wbg.__wbindgen_bigint_get_as_i64=function(f,_){const v=Wt(_),E=typeof v=="bigint"?v:void 0;C_()[f/8+1]=gc(E)?BigInt(0):E,ur()[f/4+0]=!gc(E)},m.wbg.__wbindgen_debug_string=function(f,_){const v=wh(Wt(_)),E=ph(v,ui.__wbindgen_malloc,ui.__wbindgen_realloc),k=sl;ur()[f/4+1]=k,ur()[f/4+0]=E},m.wbg.__wbindgen_throw=function(f,_){throw new Error(nl(f,_))},m.wbg.__wbindgen_memory=function(){const f=ui.memory;return Br(f)},m}function L_(m,f){return ui=m.exports,Kp.__wbindgen_wasm_module=f,Sc=null,wc=null,xc=null,vc=null,ui}async function Kp(m){if(ui!==void 0)return ui;typeof m>"u"&&(m="/ltn/assets/backend_bg.wasm");const f=z_();(typeof m=="string"||typeof Request=="function"&&m instanceof Request||typeof URL=="function"&&m instanceof URL)&&(m=fetch(m));const{instance:_,module:v}=await P_(await m,f);return L_(_,v)}const Ml=[];function mh(m,f){return{subscribe:bo(m,f).subscribe}}function bo(m,f=Nr){let _;const v=new Set;function E(s){if(Tr(m,s)&&(m=s,_)){const Z=!Ml.length;for(const V of v)V[1](),Ml.push(V,m);if(Z){for(let V=0;V{v.delete(V),v.size===0&&_&&(_(),_=null)}}return{set:E,update:k,subscribe:F}}let D_=Date.now();function Fc(m){return`${m}-${D_++}`}const Eh=Symbol.for("svelte-maplibre");function Fl(){return y_(Eh)}function F_(m){let f=new WeakMap;return _=>{var F;let v=f.get(_.originalEvent);if(v!==void 0)return v;let k=(F=_.target.queryRenderedFeatures(_.point).find(s=>{var Z;return(Z=m.get(s.layer.id))==null?void 0:Z.interactive}))==null?void 0:F.layer.id;return f.set(_.originalEvent,k),k}}function R_(){let m=new Map;return qp(Eh,{map:bo(null),source:mh(null),layer:mh(null),popupTarget:mh(null),cluster:bo(),loadedImages:bo(new Set),minzoom:bo(0),maxzoom:bo(24),layerEvent:bo(null),layerInfo:m,eventTopMost:F_(m)})}function yp(m){return{subscribe:m.subscribe}}function Jp({key:m,setPopupTarget:f=!1,setCluster:_=!1,setMouseEvent:v=!1}){let E=Fl(),k=bo(null),F=yp(k),s={...E,[m]:yp(k)};if(f&&(s.popupTarget=F),v){let Z=bo(null);s.layerEvent=Z,E.layerEvent=Z}return _&&(s.cluster=bo()),qp(Eh,s),{...E,self:k}}function O_(){return Jp({key:"source",setCluster:!0})}function B_(m=!0){return Jp({key:"layer",setPopupTarget:m,setMouseEvent:m})}function N_(m){return"layerType"in m&&m.layerType==="deckgl"}var kl=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yp(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var Qp={exports:{}};(function(m,f){(function(_,v){m.exports=v()})(kl,function(){var _,v,E;function k(s,Z){if(!_)_=Z;else if(!v)v=Z;else{var V="var sharedChunk = {}; ("+_+")(sharedChunk); ("+v+")(sharedChunk);",me={};_(me),E=Z(me),typeof window<"u"&&(E.workerUrl=window.URL.createObjectURL(new Blob([V],{type:"text/javascript"})))}}k(["exports"],function(s){function Z(i,e,r,o){return new(r||(r=Promise))(function(l,h){function p(T){try{w(o.next(T))}catch(M){h(M)}}function y(T){try{w(o.throw(T))}catch(M){h(M)}}function w(T){var M;T.done?l(T.value):(M=T.value,M instanceof r?M:new r(function(z){z(M)})).then(p,y)}w((o=o.apply(i,e||[])).next())})}function V(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var me=be;function be(i,e){this.x=i,this.y=e}be.prototype={clone:function(){return new be(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,e){return this.clone()._rotateAround(i,e)},matMult:function(i){return this.clone()._matMult(i)},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(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var e=i.x-this.x,r=i.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult:function(i){var e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var e=Math.cos(i),r=Math.sin(i),o=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=o,this},_rotateAround:function(i,e){var r=Math.cos(i),o=Math.sin(i),l=e.y+o*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-o*(this.y-e.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},be.convert=function(i){return i instanceof be?i:Array.isArray(i)?new be(i[0],i[1]):i};var ge=V(me),Oe=ke;function ke(i,e,r,o){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(o-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=o}ke.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,o=0;o<8;o++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?p=r:y=r,r=.5*(y-p)+p;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var Pe=V(Oe);let De,Ve;function at(){return De==null&&(De=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),De}function nt(){if(Ve==null&&(Ve=!1,at())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let o=0;o<5*5;o++){const l=4*o;e.fillStyle=`rgb(${l},${l+1},${l+2})`,e.fillRect(o%5,Math.floor(o/5),1,1)}const r=e.getImageData(0,0,5,5).data;for(let o=0;o<5*5*4;o++)if(o%4!=3&&r[o]!==o){Ve=!0;break}}}return Ve||!1}function it(i,e,r,o){const l=new Pe(i,e,r,o);return function(h){return l.solve(h)}}const Vt=it(.25,.1,.25,1);function ti(i,e,r){return Math.min(r,Math.max(e,i))}function Xt(i,e,r){const o=r-e,l=((i-e)%o+o)%o+e;return l===e?r:l}function Nt(i,...e){for(const r of e)for(const o in r)i[o]=r[o];return i}let Yt=1;function At(i,e,r){const o={};for(const l in i)o[l]=e.call(r||this,i[l],l,i);return o}function Ae(i,e,r){const o={};for(const l in i)e.call(r||this,i[l],l,i)&&(o[l]=i[l]);return o}function We(i){return Array.isArray(i)?i.map(We):typeof i=="object"&&i?At(i,We):i}const Ui={};function Dt(i){Ui[i]||(typeof console<"u"&&console.warn(i),Ui[i]=!0)}function qt(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function Lt(i){let e=0;for(let r,o,l=0,h=i.length,p=h-1;l"u")throw new Error("VideoFrame not supported");const h=new VideoFrame(i,{timestamp:0});try{const p=h==null?void 0:h.format;if(!p||!p.startsWith("BGR")&&!p.startsWith("RGB"))throw new Error(`Unrecognized format ${p}`);const y=p.startsWith("BGR"),w=new Uint8ClampedArray(o*l*4);if(yield h.copyTo(w,function(T,M,z,D,N){const U=4*Math.max(-M,0),G=(Math.max(0,z)-z)*D*4+U,$=4*D,ie=Math.max(0,M),ue=Math.max(0,z);return{rect:{x:ie,y:ue,width:Math.min(T.width,M+D)-ie,height:Math.min(T.height,z+N)-ue},layout:[{offset:G,stride:$}]}}(i,e,r,o,l)),y)for(let T=0;TcancelAnimationFrame(e)}},getImageData(i,e=0){return this.getImageCanvasContext(i).getImageData(-e,-e,i.width+2*e,i.height+2*e)},getImageCanvasContext(i){const e=window.document.createElement("canvas"),r=e.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return e.width=i.width,e.height=i.height,r.drawImage(i,0,0,i.width,i.height),r},resolveURL:i=>(mi||(mi=document.createElement("a")),mi.href=i,mi.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(Oi==null&&(Oi=matchMedia("(prefers-reduced-motion: reduce)")),Oi.matches)}},Pt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};class Xe extends Error{constructor(e,r,o,l){super(`AJAXError: ${r} (${e}): ${o}`),this.status=e,this.statusText=r,this.url=o,this.body=l}}const Gt=fi()?()=>self.worker&&self.worker.referrer:()=>(window.location.protocol==="blob:"?window.parent:window).location.href,ct=i=>Pt.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))];function Zi(i,e){const r=new AbortController,o=new Request(i.url,{method:i.method||"GET",body:i.body,credentials:i.credentials,headers:i.headers,cache:i.cache,referrer:Gt(),signal:r.signal});let l=!1,h=!1;return i.type==="json"&&o.headers.set("Accept","application/json"),h||fetch(o).then(p=>p.ok?(y=>{(i.type==="arrayBuffer"||i.type==="image"?y.arrayBuffer():i.type==="json"?y.json():y.text()).then(w=>{h||(l=!0,e(null,w,y.headers.get("Cache-Control"),y.headers.get("Expires")))}).catch(w=>{h||e(new Error(w.message))})})(p):p.blob().then(y=>e(new Xe(p.status,p.statusText,i.url,y)))).catch(p=>{p.code!==20&&e(new Error(p.message))}),{cancel:()=>{h=!0,l||r.abort()}}}const gr=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){if(fi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e);if(!fi())return(ct(i.url)||Zi)(i,e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(Gt())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return Zi(i,e);if(fi()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",i,e,void 0,!0)}var r;return function(o,l){const h=new XMLHttpRequest;h.open(o.method||"GET",o.url,!0),o.type!=="arrayBuffer"&&o.type!=="image"||(h.responseType="arraybuffer");for(const p in o.headers)h.setRequestHeader(p,o.headers[p]);return o.type==="json"&&(h.responseType="text",h.setRequestHeader("Accept","application/json")),h.withCredentials=o.credentials==="include",h.onerror=()=>{l(new Error(h.statusText))},h.onload=()=>{if((h.status>=200&&h.status<300||h.status===0)&&h.response!==null){let p=h.response;if(o.type==="json")try{p=JSON.parse(h.response)}catch(y){return l(y)}l(null,p,h.getResponseHeader("Cache-Control"),h.getResponseHeader("Expires"))}else{const p=new Blob([h.response],{type:h.getResponseHeader("Content-Type")});l(new Xe(h.status,h.statusText,o.url,p))}},h.send(o.body),{cancel:()=>h.abort()}}(i,e)},je=function(i,e){return gr(Nt(i,{type:"arrayBuffer"}),e)};function Bi(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;const e=new URL(i),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function yr(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function hi(i,e,r){if(r&&r[i]){const o=r[i].indexOf(e);o!==-1&&r[i].splice(o,1)}}class co{constructor(e,r={}){Nt(this,r),this.type=e}}class wo extends co{constructor(e,r={}){super("error",Nt({error:e},r))}}class jo{on(e,r){return this._listeners=this._listeners||{},yr(e,r,this._listeners),this}off(e,r){return hi(e,r,this._listeners),hi(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},yr(e,r,this._oneTimeListeners),this):new Promise(o=>this.once(e,o))}fire(e,r){typeof e=="string"&&(e=new co(e,r||{}));const o=e.type;if(this.listens(o)){e.target=this;const l=this._listeners&&this._listeners[o]?this._listeners[o].slice():[];for(const y of l)y.call(this,e);const h=this._oneTimeListeners&&this._oneTimeListeners[o]?this._oneTimeListeners[o].slice():[];for(const y of h)hi(o,y,this._oneTimeListeners),y.call(this,e);const p=this._eventedParent;p&&(Nt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),p.fire(e))}else e instanceof wo&&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,r){return this._eventedParent=e,this._eventedParentData=r,this}}var Se={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const tn=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function In(i,e){const r={};for(const o in i)o!=="ref"&&(r[o]=i[o]);return tn.forEach(o=>{o in e&&(r[o]=e[o])}),r}function Ii(i,e){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let r=0;r`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const he=[rn,He,Bt,Mt,Ur,X,_n,J(It),L,R,j];function oe(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!oe(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(const r of he)if(!oe(r,e))return null}}return`Expected ${Q(i)} but found ${Q(e)} instead.`}function te(i,e){return e.some(r=>r.kind===i.kind)}function ae(i,e){return e.some(r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i)}function Te(i,e){return i.kind==="array"&&e.kind==="array"?i.itemType.kind===e.itemType.kind&&typeof i.N=="number":i.kind===e.kind}const Ie=.96422,Ee=.82521,mt=4/29,kt=6/29,ut=3*kt*kt,vt=kt*kt*kt,Ft=Math.PI/180,gi=180/Math.PI;function Ut(i){return(i%=360)<0&&(i+=360),i}function ai([i,e,r,o]){let l,h;const p=jr((.2225045*(i=ri(i))+.7168786*(e=ri(e))+.0606169*(r=ri(r)))/1);i===e&&e===r?l=h=p:(l=jr((.4360747*i+.3850649*e+.1430804*r)/Ie),h=jr((.0139322*i+.0971045*e+.7141733*r)/Ee));const y=116*p-16;return[y<0?0:y,500*(l-p),200*(p-h),o]}function ri(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function jr(i){return i>vt?Math.pow(i,1/3):i/ut+mt}function Ei([i,e,r,o]){let l=(i+16)/116,h=isNaN(e)?l:l+e/500,p=isNaN(r)?l:l-r/200;return l=1*vr(l),h=Ie*vr(h),p=Ee*vr(p),[hr(3.1338561*h-1.6168667*l-.4906146*p),hr(-.9787684*h+1.9161415*l+.033454*p),hr(.0719453*h-.2289914*l+1.4052427*p),o]}function hr(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function vr(i){return i>kt?i*i*i:ut*(i-mt)}function An(i){return parseInt(i.padEnd(2,i),16)/255}function ws(i,e){return To(e?i/100:i,0,1)}function To(i,e,r){return Math.min(Math.max(e,i),r)}function Io(i){return!i.some(Number.isNaN)}const xr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class yi{constructor(e,r,o,l=1,h=!0){this.r=e,this.g=r,this.b=o,this.a=l,h||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,r,o,l]))}static parse(e){if(e instanceof yi)return e;if(typeof e!="string")return;const r=function(o){if((o=o.toLowerCase().trim())==="transparent")return[0,0,0,0];const l=xr[o];if(l){const[p,y,w]=l;return[p/255,y/255,w/255,1]}if(o.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(o)){const p=o.length<6?1:2;let y=1;return[An(o.slice(y,y+=p)),An(o.slice(y,y+=p)),An(o.slice(y,y+=p)),An(o.slice(y,y+p)||"ff")]}if(o.startsWith("rgb")){const p=o.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(p){const[y,w,T,M,z,D,N,U,G,$,ie,ue]=p,re=[M||" ",N||" ",$].join("");if(re===" "||re===" /"||re===",,"||re===",,,"){const pe=[T,D,G].join(""),ye=pe==="%%%"?100:pe===""?255:0;if(ye){const Me=[To(+w/ye,0,1),To(+z/ye,0,1),To(+U/ye,0,1),ie?ws(+ie,ue):1];if(Io(Me))return Me}}return}}const h=o.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(h){const[p,y,w,T,M,z,D,N,U]=h,G=[w||" ",M||" ",D].join("");if(G===" "||G===" /"||G===",,"||G===",,,"){const $=[+y,To(+T,0,100),To(+z,0,100),N?ws(+N,U):1];if(Io($))return function([ie,ue,re,pe]){function ye(Me){const lt=(Me+ie/30)%12,pt=ue*Math.min(re,1-re);return re-pt*Math.max(-1,Math.min(lt-3,9-lt,1))}return ie=Ut(ie),ue/=100,re/=100,[ye(0),ye(8),ye(4),pe]}($)}}}(e);return r?new yi(...r,!1):void 0}get rgb(){const{r:e,g:r,b:o,a:l}=this,h=l||1/0;return this.overwriteGetter("rgb",[e/h,r/h,o/h,l])}get hcl(){return this.overwriteGetter("hcl",function(e){const[r,o,l,h]=ai(e),p=Math.sqrt(o*o+l*l);return[Math.round(1e4*p)?Ut(Math.atan2(l,o)*gi):NaN,p,r,h]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ai(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,o,l]=this.rgb;return`rgba(${[e,r,o].map(h=>Math.round(255*h)).join(",")},${l})`}}yi.black=new yi(0,0,0,1),yi.white=new yi(1,1,1,1),yi.transparent=new yi(0,0,0,0),yi.red=new yi(1,0,0,1);class ta{constructor(e,r,o){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=o,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class jn{constructor(e,r,o,l,h){this.text=e,this.image=r,this.scale=o,this.fontStack=l,this.textColor=h}}class ji{constructor(e){this.sections=e}static fromString(e){return new ji([new jn(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof ji?e:ji.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}}class qr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof qr)return e;if(typeof e=="number")return new qr([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const r of e)if(typeof r!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new qr(e)}}toString(){return JSON.stringify(this.values)}}const Go=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Ir{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Ir)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let r=0;r=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?o===void 0||typeof o=="number"&&o>=0&&o<=1?null:`Invalid rgba value [${[i,e,r,o].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof o=="number"?[i,e,r,o]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function os(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof yi||i instanceof ta||i instanceof ji||i instanceof qr||i instanceof Ir||i instanceof Er)return!0;if(Array.isArray(i)){for(const e of i)if(!os(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!os(i[e]))return!1;return!0}return!1}function Gi(i){if(i===null)return rn;if(typeof i=="string")return Bt;if(typeof i=="boolean")return Mt;if(typeof i=="number")return He;if(i instanceof yi)return Ur;if(i instanceof ta)return Mn;if(i instanceof ji)return X;if(i instanceof qr)return L;if(i instanceof Ir)return j;if(i instanceof Er)return R;if(Array.isArray(i)){const e=i.length;let r;for(const o of i){const l=Gi(o);if(r){if(r===l)continue;r=It;break}r=l}return J(r||It,e)}return _n}function di(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof yi||i instanceof ji||i instanceof qr||i instanceof Ir||i instanceof Er?i.toString():JSON.stringify(i)}class uo{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!os(e[1]))return r.error("invalid value");const o=e[1];let l=Gi(o);const h=r.expectedType;return l.kind!=="array"||l.N!==0||!h||h.kind!=="array"||typeof h.N=="number"&&h.N!==0||(l=h),new uo(l,o)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Wi{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const Ss={string:Bt,number:He,boolean:Mt,object:_n};class kn{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let o,l=1;const h=e[0];if(h==="array"){let y,w;if(e.length>2){const T=e[1];if(typeof T!="string"||!(T in Ss)||T==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);y=Ss[T],l++}else y=It;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);w=e[2],l++}o=J(y,w)}else{if(!Ss[h])throw new Error(`Types doesn't contain name = ${h}`);o=Ss[h]}const p=[];for(;le.outputDefined())}}const Va={"to-boolean":Mt,"to-color":Ur,"to-number":He,"to-string":Bt};class Eo{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const o=e[0];if(!Va[o])throw new Error(`Can't parse ${o} as it is not part of the known types`);if((o==="to-boolean"||o==="to-string")&&e.length!==2)return r.error("Expected one argument.");const l=Va[o],h=[];for(let p=1;p4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:ia(r[0],r[1],r[2],r[3]),!o))return new yi(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new Wi(o||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const o of this.args){r=o.evaluate(e);const l=qr.parse(r);if(l)return l}throw new Wi(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const o of this.args){r=o.evaluate(e);const l=Ir.parse(r);if(l)return l}throw new Wi(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const o of this.args){if(r=o.evaluate(e),r===null)return 0;const l=Number(r);if(!isNaN(l))return l}throw new Wi(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return ji.fromString(di(this.args[0].evaluate(e)));case"resolvedImage":return Er.fromString(di(this.args[0].evaluate(e)));default:return di(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Ts=["Unknown","Point","LineString","Polygon"];class g{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Ts[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let r=this._parseColorCache[e];return r||(r=this._parseColorCache[e]=yi.parse(e)),r}}class I{constructor(e,r,o=[],l,h=new Zo,p=[]){this.registry=e,this.path=o,this.key=o.map(y=>`[${y}]`).join(""),this.scope=h,this.errors=p,this.expectedType=l,this._isConstant=r}parse(e,r,o,l,h={}){return r?this.concat(r,o,l)._parse(e,h):this._parse(e,h)}_parse(e,r){function o(l,h,p){return p==="assert"?new kn(h,[l]):p==="coerce"?new Eo(h,[l]):l}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=e[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[l];if(h){let p=h.parse(e,this);if(!p)return null;if(this.expectedType){const y=this.expectedType,w=p.type;if(y.kind!=="string"&&y.kind!=="number"&&y.kind!=="boolean"&&y.kind!=="object"&&y.kind!=="array"||w.kind!=="value")if(y.kind!=="color"&&y.kind!=="formatted"&&y.kind!=="resolvedImage"||w.kind!=="value"&&w.kind!=="string")if(y.kind!=="padding"||w.kind!=="value"&&w.kind!=="number"&&w.kind!=="array")if(y.kind!=="variableAnchorOffsetCollection"||w.kind!=="value"&&w.kind!=="array"){if(this.checkSubtype(y,w))return null}else p=o(p,y,r.typeAnnotation||"coerce");else p=o(p,y,r.typeAnnotation||"coerce");else p=o(p,y,r.typeAnnotation||"coerce");else p=o(p,y,r.typeAnnotation||"assert")}if(!(p instanceof uo)&&p.type.kind!=="resolvedImage"&&this._isConstant(p)){const y=new g;try{p=new uo(p.type,p.evaluate(y))}catch(w){return this.error(w.message),null}}return p}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,o){const l=typeof e=="number"?this.path.concat(e):this.path,h=o?this.scope.concat(o):this.scope;return new I(this.registry,this._isConstant,l,r||null,h,this.errors)}error(e,...r){const o=`${this.key}${r.map(l=>`[${l}]`).join("")}`;this.errors.push(new er(o,e))}checkSubtype(e,r){const o=oe(e,r);return o&&this.error(o),o}}class B{constructor(e,r,o){this.type=Mn,this.locale=o,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const o=e[1];if(typeof o!="object"||Array.isArray(o))return r.error("Collator options argument must be an object.");const l=r.parse(o["case-sensitive"]!==void 0&&o["case-sensitive"],1,Mt);if(!l)return null;const h=r.parse(o["diacritic-sensitive"]!==void 0&&o["diacritic-sensitive"],1,Mt);if(!h)return null;let p=null;return o.locale&&(p=r.parse(o.locale,1,Bt),!p)?null:new B(l,h,p)}evaluate(e){return new ta(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}const Y=8192;function ne(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function se(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function fe(i,e){const r=(180+i[0])/360,o=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,e.z);return[Math.round(r*l*Y),Math.round(o*l*Y)]}function Re(i,e,r){const o=i[0]-e[0],l=i[1]-e[1],h=i[0]-r[0],p=i[1]-r[1];return o*p-h*l==0&&o*h<=0&&l*p<=0}function Ue(i,e){let r=!1;for(let p=0,y=e.length;p(o=i)[1]!=(h=w[T+1])[1]>o[1]&&o[0]<(h[0]-l[0])*(o[1]-l[1])/(h[1]-l[1])+l[0]&&(r=!r)}}var o,l,h;return r}function rt(i,e){for(let r=0;r0&&y<0||p<0&&y>0}function Ye(i,e,r){for(const T of r)for(let M=0;Mr[2]){const l=.5*o;let h=i[0]-r[0]>l?-o:r[0]-i[0]>l?o:0;h===0&&(h=i[0]-r[2]>l?-o:r[2]-i[0]>l?o:0),i[0]+=h}ne(e,i)}function _t(i,e,r,o){const l=Math.pow(2,o.z)*Y,h=[o.x*Y,o.y*Y],p=[];for(const y of i)for(const w of y){const T=[w.x+h[0],w.y+h[1]];ze(T,e,r,l),p.push(T)}return p}function vi(i,e,r,o){const l=Math.pow(2,o.z)*Y,h=[o.x*Y,o.y*Y],p=[];for(const w of i){const T=[];for(const M of w){const z=[M.x+h[0],M.y+h[1]];ne(e,z),T.push(z)}p.push(T)}if(e[2]-e[0]<=l/2){(y=e)[0]=y[1]=1/0,y[2]=y[3]=-1/0;for(const w of p)for(const T of w)ze(T,e,r,l)}var y;return p}class Xi{constructor(e,r){this.type=Mt,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(os(e[1])){const o=e[1];if(o.type==="FeatureCollection")for(let l=0;l!Array.isArray(T)||T.length===e.length-1);let w=null;for(const[T,M]of y){w=new I(r.registry,ra,r.path,null,r.scope);const z=[];let D=!1;for(let N=1;N{return D=z,Array.isArray(D)?`(${D.map(Q).join(", ")})`:`(${Q(D.type)}...)`;var D}).join(" | "),M=[];for(let z=1;z{r=e?r&&ra(o):r&&o instanceof uo}),!!r&&Ci(i)&&na(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Ci(i){if(i instanceof nn&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof Xi)return!1;let e=!0;return i.eachChild(r=>{e&&!Ci(r)&&(e=!1)}),e}function ss(i){if(i instanceof nn&&i.name==="feature-state")return!1;let e=!0;return i.eachChild(r=>{e&&!ss(r)&&(e=!1)}),e}function na(i,e){if(i instanceof nn&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(o=>{r&&!na(o,e)&&(r=!1)}),r}function on(i,e){const r=i.length-1;let o,l,h=0,p=r,y=0;for(;h<=p;)if(y=Math.floor((h+p)/2),o=i[y],l=i[y+1],o<=e){if(y===r||ee))throw new Wi("Input is not a number.");p=y-1}return 0}class ho{constructor(e,r,o){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[l,h]of o)this.labels.push(l),this.outputs.push(h)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const o=r.parse(e[1],1,He);if(!o)return null;const l=[];let h=null;r.expectedType&&r.expectedType.kind!=="value"&&(h=r.expectedType);for(let p=1;p=y)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',T);const z=r.parse(w,M,h);if(!z)return null;h=h||z.type,l.push([y,z])}return new ho(h,o,l)}evaluate(e){const r=this.labels,o=this.outputs;if(r.length===1)return o[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return o[0].evaluate(e);const h=r.length;return l>=r[h-1]?o[h-1].evaluate(e):o[on(r,l)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function Kt(i,e,r){return i+r*(e-i)}function Is(i,e,r){return i.map((o,l)=>Kt(o,e[l],r))}const Hr={number:Kt,color:function(i,e,r,o="rgb"){switch(o){case"rgb":{const[l,h,p,y]=Is(i.rgb,e.rgb,r);return new yi(l,h,p,y,!1)}case"hcl":{const[l,h,p,y]=i.hcl,[w,T,M,z]=e.hcl;let D,N;if(isNaN(l)||isNaN(w))isNaN(l)?isNaN(w)?D=NaN:(D=w,p!==1&&p!==0||(N=T)):(D=l,M!==1&&M!==0||(N=h));else{let ue=w-l;w>l&&ue>180?ue-=360:w180&&(ue+=360),D=l+r*ue}const[U,G,$,ie]=function([ue,re,pe,ye]){return ue=isNaN(ue)?0:ue*Ft,Ei([pe,Math.cos(ue)*re,Math.sin(ue)*re,ye])}([D,N??Kt(h,T,r),Kt(p,M,r),Kt(y,z,r)]);return new yi(U,G,$,ie,!1)}case"lab":{const[l,h,p,y]=Ei(Is(i.lab,e.lab,r));return new yi(l,h,p,y,!1)}}},array:Is,padding:function(i,e,r){return new qr(Is(i.values,e.values,r))},variableAnchorOffsetCollection:function(i,e,r){const o=i.values,l=e.values;if(o.length!==l.length)throw new Wi(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${e.toString()}`);const h=[];for(let p=0;ptypeof M!="number"||M<0||M>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:T}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(h=r.parse(h,2,He),!h)return null;const y=[];let w=null;o==="interpolate-hcl"||o==="interpolate-lab"?w=Ur:r.expectedType&&r.expectedType.kind!=="value"&&(w=r.expectedType);for(let T=0;T=M)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',D);const U=r.parse(z,N,w);if(!U)return null;w=w||U.type,y.push([M,U])}return Te(w,He)||Te(w,Ur)||Te(w,L)||Te(w,j)||Te(w,J(He))?new sn(w,o,l,h,y):r.error(`Type ${Q(w)} is not interpolatable.`)}evaluate(e){const r=this.labels,o=this.outputs;if(r.length===1)return o[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return o[0].evaluate(e);const h=r.length;if(l>=r[h-1])return o[h-1].evaluate(e);const p=on(r,l),y=sn.interpolationFactor(this.interpolation,l,r[p],r[p+1]),w=o[p].evaluate(e),T=o[p+1].evaluate(e);switch(this.operator){case"interpolate":return Hr[this.type.kind](w,T,y);case"interpolate-hcl":return Hr.color(w,T,y,"hcl");case"interpolate-lab":return Hr.color(w,T,y,"lab")}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function oa(i,e,r,o){const l=o-r,h=i-r;return l===0?0:e===1?h/l:(Math.pow(e,h)-1)/(Math.pow(e,l)-1)}class sa{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let o=null;const l=r.expectedType;l&&l.kind!=="value"&&(o=l);const h=[];for(const y of e.slice(1)){const w=r.parse(y,1+h.length,o,void 0,{typeAnnotation:"omit"});if(!w)return null;o=o||w.type,h.push(w)}if(!o)throw new Error("No output type");const p=l&&h.some(y=>oe(l,y.type));return new sa(p?It:o,h)}evaluate(e){let r,o=null,l=0;for(const h of this.args)if(l++,o=h.evaluate(e),o&&o instanceof Er&&!o.available&&(r||(r=o.name),o=null,l===this.args.length&&(o=r)),o!==null)break;return o}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}class aa{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const o=[];for(let h=1;h=o.length)throw new Wi(`Array index out of bounds: ${r} > ${o.length-1}.`);if(r!==Math.floor(r))throw new Wi(`Array index must be an integer, but found ${r} instead.`);return o[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class la{constructor(e,r){this.type=Mt,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const o=r.parse(e[1],1,It),l=r.parse(e[2],2,It);return o&&l?te(o.type,[Mt,Bt,He,rn,It])?new la(o,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Q(o.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(!o)return!1;if(!ae(r,["boolean","string","number","null"]))throw new Wi(`Expected first argument to be of type boolean, string, number or null, but found ${Q(Gi(r))} instead.`);if(!ae(o,["string","array"]))throw new Wi(`Expected second argument to be of type array or string, but found ${Q(Gi(o))} instead.`);return o.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Es{constructor(e,r,o){this.type=He,this.needle=e,this.haystack=r,this.fromIndex=o}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const o=r.parse(e[1],1,It),l=r.parse(e[2],2,It);if(!o||!l)return null;if(!te(o.type,[Mt,Bt,He,rn,It]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${Q(o.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,He);return h?new Es(o,l,h):null}return new Es(o,l)}evaluate(e){const r=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(!ae(r,["boolean","string","number","null"]))throw new Wi(`Expected first argument to be of type boolean, string, number or null, but found ${Q(Gi(r))} instead.`);if(!ae(o,["string","array"]))throw new Wi(`Expected second argument to be of type array or string, but found ${Q(Gi(o))} instead.`);if(this.fromIndex){const l=this.fromIndex.evaluate(e);return o.indexOf(r,l)}return o.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ca{constructor(e,r,o,l,h,p){this.inputType=e,this.type=r,this.input=o,this.cases=l,this.outputs=h,this.otherwise=p}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let o,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);const h={},p=[];for(let T=2;TNumber.MAX_SAFE_INTEGER)return D.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof U=="number"&&Math.floor(U)!==U)return D.error("Numeric branch labels must be integer values.");if(o){if(D.checkSubtype(o,Gi(U)))return null}else o=Gi(U);if(h[String(U)]!==void 0)return D.error("Branch labels must be unique.");h[String(U)]=p.length}const N=r.parse(z,T,l);if(!N)return null;l=l||N.type,p.push(N)}const y=r.parse(e[1],1,It);if(!y)return null;const w=r.parse(e[e.length-1],e.length-1,l);return w?y.type.kind!=="value"&&r.concat(1).checkSubtype(o,y.type)?null:new ca(o,l,y,h,p,w):null}evaluate(e){const r=this.input.evaluate(e);return(Gi(r)===this.inputType&&this.outputs[this.cases[r]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class ja{constructor(e,r,o){this.type=e,this.branches=r,this.otherwise=o}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let o;r.expectedType&&r.expectedType.kind!=="value"&&(o=r.expectedType);const l=[];for(let p=1;pr.outputDefined())&&this.otherwise.outputDefined()}}class ua{constructor(e,r,o,l){this.type=e,this.input=r,this.beginIndex=o,this.endIndex=l}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const o=r.parse(e[1],1,It),l=r.parse(e[2],2,He);if(!o||!l)return null;if(!te(o.type,[J(It),Bt,It]))return r.error(`Expected first argument to be of type array or string, but found ${Q(o.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,He);return h?new ua(o.type,o,l,h):null}return new ua(o.type,o,l)}evaluate(e){const r=this.input.evaluate(e),o=this.beginIndex.evaluate(e);if(!ae(r,["string","array"]))throw new Wi(`Expected first argument to be of type array or string, but found ${Q(Gi(r))} instead.`);if(this.endIndex){const l=this.endIndex.evaluate(e);return r.slice(o,l)}return r.slice(o)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function Cs(i,e){return i==="=="||i==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function ha(i,e,r,o){return o.compare(e,r)===0}function Wo(i,e,r){const o=i!=="=="&&i!=="!=";return class $p{constructor(h,p,y){this.type=Mt,this.lhs=h,this.rhs=p,this.collator=y,this.hasUntypedArgument=h.type.kind==="value"||p.type.kind==="value"}static parse(h,p){if(h.length!==3&&h.length!==4)return p.error("Expected two or three arguments.");const y=h[0];let w=p.parse(h[1],1,It);if(!w)return null;if(!Cs(y,w.type))return p.concat(1).error(`"${y}" comparisons are not supported for type '${Q(w.type)}'.`);let T=p.parse(h[2],2,It);if(!T)return null;if(!Cs(y,T.type))return p.concat(2).error(`"${y}" comparisons are not supported for type '${Q(T.type)}'.`);if(w.type.kind!==T.type.kind&&w.type.kind!=="value"&&T.type.kind!=="value")return p.error(`Cannot compare types '${Q(w.type)}' and '${Q(T.type)}'.`);o&&(w.type.kind==="value"&&T.type.kind!=="value"?w=new kn(T.type,[w]):w.type.kind!=="value"&&T.type.kind==="value"&&(T=new kn(w.type,[T])));let M=null;if(h.length===4){if(w.type.kind!=="string"&&T.type.kind!=="string"&&w.type.kind!=="value"&&T.type.kind!=="value")return p.error("Cannot use collator to compare non-string types.");if(M=p.parse(h[3],3,Mn),!M)return null}return new $p(w,T,M)}evaluate(h){const p=this.lhs.evaluate(h),y=this.rhs.evaluate(h);if(o&&this.hasUntypedArgument){const w=Gi(p),T=Gi(y);if(w.kind!==T.kind||w.kind!=="string"&&w.kind!=="number")throw new Wi(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${w.kind}, ${T.kind}) instead.`)}if(this.collator&&!o&&this.hasUntypedArgument){const w=Gi(p),T=Gi(y);if(w.kind!=="string"||T.kind!=="string")return e(h,p,y)}return this.collator?r(h,p,y,this.collator.evaluate(h)):e(h,p,y)}eachChild(h){h(this.lhs),h(this.rhs),this.collator&&h(this.collator)}outputDefined(){return!0}}}const eo=Wo("==",function(i,e,r){return e===r},ha),al=Wo("!=",function(i,e,r){return e!==r},function(i,e,r,o){return!ha(0,e,r,o)}),ll=Wo("<",function(i,e,r){return e",function(i,e,r){return e>r},function(i,e,r,o){return o.compare(e,r)>0}),cl=Wo("<=",function(i,e,r){return e<=r},function(i,e,r,o){return o.compare(e,r)<=0}),da=Wo(">=",function(i,e,r){return e>=r},function(i,e,r,o){return o.compare(e,r)>=0});class pa{constructor(e,r,o,l,h){this.type=Bt,this.number=e,this.locale=r,this.currency=o,this.minFractionDigits=l,this.maxFractionDigits=h}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const o=r.parse(e[1],1,He);if(!o)return null;const l=e[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let h=null;if(l.locale&&(h=r.parse(l.locale,1,Bt),!h))return null;let p=null;if(l.currency&&(p=r.parse(l.currency,1,Bt),!p))return null;let y=null;if(l["min-fraction-digits"]&&(y=r.parse(l["min-fraction-digits"],1,He),!y))return null;let w=null;return l["max-fraction-digits"]&&(w=r.parse(l["max-fraction-digits"],1,He),!w)?null:new pa(o,h,p,y,w)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Ms{constructor(e){this.type=X,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const o=e[1];if(!Array.isArray(o)&&typeof o=="object")return r.error("First argument must be an image or text section.");const l=[];let h=!1;for(let p=1;p<=e.length-1;++p){const y=e[p];if(h&&typeof y=="object"&&!Array.isArray(y)){h=!1;let w=null;if(y["font-scale"]&&(w=r.parse(y["font-scale"],1,He),!w))return null;let T=null;if(y["text-font"]&&(T=r.parse(y["text-font"],1,J(Bt)),!T))return null;let M=null;if(y["text-color"]&&(M=r.parse(y["text-color"],1,Ur),!M))return null;const z=l[l.length-1];z.scale=w,z.font=T,z.textColor=M}else{const w=r.parse(e[p],1,It);if(!w)return null;const T=w.type.kind;if(T!=="string"&&T!=="value"&&T!=="null"&&T!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,l.push({content:w,scale:null,font:null,textColor:null})}}return new Ms(l)}evaluate(e){return new ji(this.sections.map(r=>{const o=r.content.evaluate(e);return Gi(o)===R?new jn("",o,null,null,null):new jn(di(o),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}}class qa{constructor(e){this.type=R,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const o=r.parse(e[1],1,Bt);return o?new qa(o):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),o=Er.fromString(r);return o&&e.availableImages&&(o.available=e.availableImages.indexOf(r)>-1),o}eachChild(e){e(this.input)}outputDefined(){return!1}}class po{constructor(e){this.type=He,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const o=r.parse(e[1],1);return o?o.type.kind!=="array"&&o.type.kind!=="string"&&o.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${Q(o.type)} instead.`):new po(o):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new Wi(`Expected value to be of type string or array, but found ${Q(Gi(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Ho={"==":eo,"!=":al,">":Rl,"<":ll,">=":da,"<=":cl,array:kn,at:Ua,boolean:kn,case:ja,coalesce:sa,collator:B,format:Ms,image:qa,in:la,"index-of":Es,interpolate:sn,"interpolate-hcl":sn,"interpolate-lab":sn,length:po,let:aa,literal:uo,match:ca,number:kn,"number-format":pa,object:kn,slice:ua,step:ho,string:kn,"to-boolean":Eo,"to-color":Eo,"to-number":Eo,"to-string":Eo,var:tr,within:Xi};function ul(i,[e,r,o,l]){e=e.evaluate(i),r=r.evaluate(i),o=o.evaluate(i);const h=l?l.evaluate(i):1,p=ia(e,r,o,h);if(p)throw new Wi(p);return new yi(e/255,r/255,o/255,h,!1)}function hl(i,e){return i in e}function As(i,e){const r=e[i];return r===void 0?null:r}function qn(i){return{type:i}}function fa(i){return{result:"success",value:i}}function to(i){return{result:"error",value:i}}function Co(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function as(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function Za(i){return!!i.expression&&i.expression.interpolated}function _i(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function Ki(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function Ol(i){return i}function Qt(i,e){const r=e.type==="color",o=i.stops&&typeof i.stops[0][0]=="object",l=o||!(o||i.property!==void 0),h=i.type||(Za(e)?"exponential":"interval");if(r||e.type==="padding"){const M=r?yi.parse:qr.parse;(i=mn({},i)).stops&&(i.stops=i.stops.map(z=>[z[0],M(z[1])])),i.default=M(i.default?i.default:e.default)}if(i.colorSpace&&(p=i.colorSpace)!=="rgb"&&p!=="hcl"&&p!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var p;let y,w,T;if(h==="exponential")y=gn;else if(h==="interval")y=xi;else if(h==="categorical"){y=Ni,w=Object.create(null);for(const M of i.stops)w[M[0]]=M[1];T=typeof i.stops[0][0]}else{if(h!=="identity")throw new Error(`Unknown function type "${h}"`);y=Ao}if(o){const M={},z=[];for(let U=0;UU[0]),evaluate:({zoom:U},G)=>gn({stops:D,base:i.base},e,U).evaluate(U,G)}}if(l){const M=h==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:M,interpolationFactor:sn.interpolationFactor.bind(void 0,M),zoomStops:i.stops.map(z=>z[0]),evaluate:({zoom:z})=>y(i,e,z,w,T)}}return{kind:"source",evaluate(M,z){const D=z&&z.properties?z.properties[i.property]:void 0;return D===void 0?Mo(i.default,e.default):y(i,e,D,w,T)}}}function Mo(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function Ni(i,e,r,o,l){return Mo(typeof r===l?o[r]:void 0,i.default,e.default)}function xi(i,e,r){if(_i(r)!=="number")return Mo(i.default,e.default);const o=i.stops.length;if(o===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[o-1][0])return i.stops[o-1][1];const l=on(i.stops.map(h=>h[0]),r);return i.stops[l][1]}function gn(i,e,r){const o=i.base!==void 0?i.base:1;if(_i(r)!=="number")return Mo(i.default,e.default);const l=i.stops.length;if(l===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[l-1][0])return i.stops[l-1][1];const h=on(i.stops.map(M=>M[0]),r),p=function(M,z,D,N){const U=N-D,G=M-D;return U===0?0:z===1?G/U:(Math.pow(z,G)-1)/(Math.pow(z,U)-1)}(r,o,i.stops[h][0],i.stops[h+1][0]),y=i.stops[h][1],w=i.stops[h+1][1],T=Hr[e.type]||Ol;return typeof y.evaluate=="function"?{evaluate(...M){const z=y.evaluate.apply(void 0,M),D=w.evaluate.apply(void 0,M);if(z!==void 0&&D!==void 0)return T(z,D,p,i.colorSpace)}}:T(y,w,p,i.colorSpace)}function Ao(i,e,r){switch(e.type){case"color":r=yi.parse(r);break;case"formatted":r=ji.fromString(r.toString());break;case"resolvedImage":r=Er.fromString(r.toString());break;case"padding":r=qr.parse(r);break;default:_i(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return Mo(r,i.default,e.default)}nn.register(Ho,{error:[{kind:"error"},[Bt],(i,[e])=>{throw new Wi(e.evaluate(i))}],typeof:[Bt,[It],(i,[e])=>Q(Gi(e.evaluate(i)))],"to-rgba":[J(He,4),[Ur],(i,[e])=>{const[r,o,l,h]=e.evaluate(i).rgb;return[255*r,255*o,255*l,h]}],rgb:[Ur,[He,He,He],ul],rgba:[Ur,[He,He,He,He],ul],has:{type:Mt,overloads:[[[Bt],(i,[e])=>hl(e.evaluate(i),i.properties())],[[Bt,_n],(i,[e,r])=>hl(e.evaluate(i),r.evaluate(i))]]},get:{type:It,overloads:[[[Bt],(i,[e])=>As(e.evaluate(i),i.properties())],[[Bt,_n],(i,[e,r])=>As(e.evaluate(i),r.evaluate(i))]]},"feature-state":[It,[Bt],(i,[e])=>As(e.evaluate(i),i.featureState||{})],properties:[_n,[],i=>i.properties()],"geometry-type":[Bt,[],i=>i.geometryType()],id:[It,[],i=>i.id()],zoom:[He,[],i=>i.globals.zoom],"heatmap-density":[He,[],i=>i.globals.heatmapDensity||0],"line-progress":[He,[],i=>i.globals.lineProgress||0],accumulated:[It,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[He,qn(He),(i,e)=>{let r=0;for(const o of e)r+=o.evaluate(i);return r}],"*":[He,qn(He),(i,e)=>{let r=1;for(const o of e)r*=o.evaluate(i);return r}],"-":{type:He,overloads:[[[He,He],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[He],(i,[e])=>-e.evaluate(i)]]},"/":[He,[He,He],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[He,[He,He],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[He,[],()=>Math.LN2],pi:[He,[],()=>Math.PI],e:[He,[],()=>Math.E],"^":[He,[He,He],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[He,[He],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[He,[He],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[He,[He],(i,[e])=>Math.log(e.evaluate(i))],log2:[He,[He],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[He,[He],(i,[e])=>Math.sin(e.evaluate(i))],cos:[He,[He],(i,[e])=>Math.cos(e.evaluate(i))],tan:[He,[He],(i,[e])=>Math.tan(e.evaluate(i))],asin:[He,[He],(i,[e])=>Math.asin(e.evaluate(i))],acos:[He,[He],(i,[e])=>Math.acos(e.evaluate(i))],atan:[He,[He],(i,[e])=>Math.atan(e.evaluate(i))],min:[He,qn(He),(i,e)=>Math.min(...e.map(r=>r.evaluate(i)))],max:[He,qn(He),(i,e)=>Math.max(...e.map(r=>r.evaluate(i)))],abs:[He,[He],(i,[e])=>Math.abs(e.evaluate(i))],round:[He,[He],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[He,[He],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[He,[He],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[Mt,[Bt,It],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[Mt,[It],(i,[e])=>i.id()===e.value],"filter-type-==":[Mt,[Bt],(i,[e])=>i.geometryType()===e.value],"filter-<":[Mt,[Bt,It],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o{const r=i.id(),o=e.value;return typeof r==typeof o&&r":[Mt,[Bt,It],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o>l}],"filter-id->":[Mt,[It],(i,[e])=>{const r=i.id(),o=e.value;return typeof r==typeof o&&r>o}],"filter-<=":[Mt,[Bt,It],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o<=l}],"filter-id-<=":[Mt,[It],(i,[e])=>{const r=i.id(),o=e.value;return typeof r==typeof o&&r<=o}],"filter->=":[Mt,[Bt,It],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o>=l}],"filter-id->=":[Mt,[It],(i,[e])=>{const r=i.id(),o=e.value;return typeof r==typeof o&&r>=o}],"filter-has":[Mt,[It],(i,[e])=>e.value in i.properties()],"filter-has-id":[Mt,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[Mt,[J(Bt)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[Mt,[J(It)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[Mt,[Bt,J(It)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[Mt,[Bt,J(It)],(i,[e,r])=>function(o,l,h,p){for(;h<=p;){const y=h+p>>1;if(l[y]===o)return!0;l[y]>o?p=y-1:h=y+1}return!1}(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:Mt,overloads:[[[Mt,Mt],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[qn(Mt),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:Mt,overloads:[[[Mt,Mt],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[qn(Mt),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[Mt,[Mt],(i,[e])=>!e.evaluate(i)],"is-supported-script":[Mt,[Bt],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[Bt,[Bt],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[Bt,[Bt],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[Bt,qn(It),(i,e)=>e.map(r=>di(r.evaluate(i))).join("")],"resolved-locale":[Bt,[Mn],(i,[e])=>e.evaluate(i).resolvedLocale()]});class ls{constructor(e,r){var o;this.expression=e,this._warningHistory={},this._evaluator=new g,this._defaultValue=r?(o=r).type==="color"&&Ki(o.default)?new yi(0,0,0,0):o.type==="color"?yi.parse(o.default)||null:o.type==="padding"?qr.parse(o.default)||null:o.type==="variableAnchorOffsetCollection"?Ir.parse(o.default)||null:o.default===void 0?null:o.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,o,l,h,p){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=o,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(e,r,o,l,h,p){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=o||null,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=p||null;try{const y=this.expression.evaluate(this._evaluator);if(y==null||typeof y=="number"&&y!=y)return this._defaultValue;if(this._enumValues&&!(y in this._enumValues))throw new Wi(`Expected value to be one of ${Object.keys(this._enumValues).map(w=>JSON.stringify(w)).join(", ")}, but found ${JSON.stringify(y)} instead.`);return y}catch(y){return this._warningHistory[y.message]||(this._warningHistory[y.message]=!0,typeof console<"u"&&console.warn(y.message)),this._defaultValue}}}function Zn(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in Ho}function ma(i,e){const r=new I(Ho,ra,[],e?function(l){const h={color:Ur,string:Bt,number:He,enum:Bt,boolean:Mt,formatted:X,padding:L,resolvedImage:R,variableAnchorOffsetCollection:j};return l.type==="array"?J(h[l.value]||It,l.length):h[l.type]}(e):void 0),o=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return o?fa(new ls(o,e)):to(r.errors)}class cs{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!ss(r.expression)}evaluateWithoutErrorHandling(e,r,o,l,h,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,o,l,h,p)}evaluate(e,r,o,l,h,p){return this._styleExpression.evaluate(e,r,o,l,h,p)}}class ko{constructor(e,r,o,l){this.kind=e,this.zoomStops=o,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!ss(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(e,r,o,l,h,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,o,l,h,p)}evaluate(e,r,o,l,h,p){return this._styleExpression.evaluate(e,r,o,l,h,p)}interpolationFactor(e,r,o){return this.interpolationType?sn.interpolationFactor(this.interpolationType,e,r,o):0}}function _a(i,e){const r=ma(i,e);if(r.result==="error")return r;const o=r.value.expression,l=Ci(o);if(!l&&!Co(e))return to([new er("","data expressions not supported")]);const h=na(o,["zoom"]);if(!h&&!as(e))return to([new er("","zoom expressions not supported")]);const p=ks(o);return p||h?p instanceof er?to([p]):p instanceof sn&&!Za(e)?to([new er("",'"interpolate" expressions cannot be used with this property')]):fa(p?new ko(l?"camera":"composite",r.value,p.labels,p instanceof sn?p.interpolation:void 0):new cs(l?"constant":"source",r.value)):to([new er("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class us{constructor(e,r){this._parameters=e,this._specification=r,mn(this,Qt(this._parameters,this._specification))}static deserialize(e){return new us(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ks(i){let e=null;if(i instanceof aa)e=ks(i.result);else if(i instanceof sa){for(const r of i.args)if(e=ks(r),e)break}else(i instanceof ho||i instanceof sn)&&i.input instanceof nn&&i.input.name==="zoom"&&(e=i);return e instanceof er||i.eachChild(r=>{const o=ks(r);o instanceof er?e=o:!e&&o?e=new er("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&o&&e!==o&&(e=new er("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function Ps(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const e of i.slice(1))if(!Ps(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const dl={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ga(i){if(i==null)return{filter:()=>!0,needGeometry:!1};Ps(i)||(i=va(i));const e=ma(i,dl);if(e.result==="error")throw new Error(e.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,o,l)=>e.value.evaluate(r,o,{},l),needGeometry:Xo(i)}}function ya(i,e){return ie?1:0}function Xo(i){if(!Array.isArray(i))return!1;if(i[0]==="within")return!0;for(let e=1;e"||e==="<="||e===">="?io(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(va))):e==="all"?["all"].concat(i.slice(1).map(va)):e==="none"?["all"].concat(i.slice(1).map(va).map(hs)):e==="in"?pl(i[1],i.slice(2)):e==="!in"?hs(pl(i[1],i.slice(2))):e==="has"?Po(i[1]):e==="!has"?hs(Po(i[1])):e!=="within"||i;var r}function io(i,e,r){switch(i){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,i,e]}}function pl(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",i,["literal",e.sort(ya)]]:["filter-in-small",i,["literal",e]]}}function Po(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function hs(i){return["!",i]}function xa(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(const h of i)l+=`${xa(h)},`;return`${l}]`}const r=Object.keys(i).sort();let o="{";for(let l=0;lo.maximum?[new Ze(e,r,`${r} is greater than the maximum value ${o.maximum}`)]:[]}function wa(i){const e=i.valueSpec,r=Ji(i.value.type);let o,l,h,p={};const y=r!=="categorical"&&i.value.property===void 0,w=!y,T=_i(i.value.stops)==="array"&&_i(i.value.stops[0])==="array"&&_i(i.value.stops[0][0])==="object",M=Xr({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(N){if(r==="identity")return[new Ze(N.key,N.value,'identity function may not have a "stops" property')];let U=[];const G=N.value;return U=U.concat(ro({key:N.key,value:G,valueSpec:N.valueSpec,validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec,arrayElementValidator:z})),_i(G)==="array"&&G.length===0&&U.push(new Ze(N.key,G,"array must have at least one stop")),U},default:function(N){return N.validateSpec({key:N.key,value:N.value,valueSpec:e,validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec})}}});return r==="identity"&&y&&M.push(new Ze(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||M.push(new Ze(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!Za(i.valueSpec)&&M.push(new Ze(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(w&&!Co(i.valueSpec)?M.push(new Ze(i.key,i.value,"property functions not supported")):y&&!as(i.valueSpec)&&M.push(new Ze(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!T||i.value.property!==void 0||M.push(new Ze(i.key,i.value,'"property" property is required')),M;function z(N){let U=[];const G=N.value,$=N.key;if(_i(G)!=="array")return[new Ze($,G,`array expected, ${_i(G)} found`)];if(G.length!==2)return[new Ze($,G,`array length 2 expected, length ${G.length} found`)];if(T){if(_i(G[0])!=="object")return[new Ze($,G,`object expected, ${_i(G[0])} found`)];if(G[0].zoom===void 0)return[new Ze($,G,"object stop key must have zoom")];if(G[0].value===void 0)return[new Ze($,G,"object stop key must have value")];if(h&&h>Ji(G[0].zoom))return[new Ze($,G[0].zoom,"stop zoom values must appear in ascending order")];Ji(G[0].zoom)!==h&&(h=Ji(G[0].zoom),l=void 0,p={}),U=U.concat(Xr({key:`${$}[0]`,value:G[0],valueSpec:{zoom:{}},validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec,objectElementValidators:{zoom:ds,value:D}}))}else U=U.concat(D({key:`${$}[0]`,value:G[0],valueSpec:{},validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec},G));return Zn(zo(G[1]))?U.concat([new Ze(`${$}[1]`,G[1],"expressions are not allowed in function stops.")]):U.concat(N.validateSpec({key:`${$}[1]`,value:G[1],valueSpec:e,validateSpec:N.validateSpec,style:N.style,styleSpec:N.styleSpec}))}function D(N,U){const G=_i(N.value),$=Ji(N.value),ie=N.value!==null?N.value:U;if(o){if(G!==o)return[new Ze(N.key,ie,`${G} stop domain type must match previous stop domain type ${o}`)]}else o=G;if(G!=="number"&&G!=="string"&&G!=="boolean")return[new Ze(N.key,ie,"stop domain value must be a number, string, or boolean")];if(G!=="number"&&r!=="categorical"){let ue=`number expected, ${G} found`;return Co(e)&&r===void 0&&(ue+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Ze(N.key,ie,ue)]}return r!=="categorical"||G!=="number"||isFinite($)&&Math.floor($)===$?r!=="categorical"&&G==="number"&&l!==void 0&&$new Ze(`${i.key}${o.key}`,i.value,o.message));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new Ze(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!ss(r))return[new Ze(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!ss(r))return[new Ze(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!na(r,["zoom","feature-state"]))return[new Ze(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!Ci(r))return[new Ze(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function we(i){const e=i.key,r=i.value,o=i.valueSpec,l=[];return Array.isArray(o.values)?o.values.indexOf(Ji(r))===-1&&l.push(new Ze(e,r,`expected one of [${o.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(o.values).indexOf(Ji(r))===-1&&l.push(new Ze(e,r,`expected one of [${Object.keys(o.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function Qe(i){return Ps(zo(i.value))?de(mn({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):wt(i)}function wt(i){const e=i.value,r=i.key;if(_i(e)!=="array")return[new Ze(r,e,`array expected, ${_i(e)} found`)];const o=i.styleSpec;let l,h=[];if(e.length<1)return[new Ze(r,e,"filter array must have at least 1 element")];switch(h=h.concat(we({key:`${r}[0]`,value:e[0],valueSpec:o.filter_operator,style:i.style,styleSpec:i.styleSpec})),Ji(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&Ji(e[1])==="$type"&&h.push(new Ze(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&h.push(new Ze(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(l=_i(e[1]),l!=="string"&&h.push(new Ze(`${r}[1]`,e[1],`string expected, ${l} found`)));for(let p=2;p{T in r&&e.push(new Ze(o,r[T],`"${T}" is prohibited for ref layers`))}),l.layers.forEach(T=>{Ji(T.id)===y&&(w=T)}),w?w.ref?e.push(new Ze(o,r.ref,"ref cannot reference another ref layer")):p=Ji(w.type):e.push(new Ze(o,r.ref,`ref layer "${y}" not found`))}else if(p!=="background")if(r.source){const w=l.sources&&l.sources[r.source],T=w&&Ji(w.type);w?T==="vector"&&p==="raster"?e.push(new Ze(o,r.source,`layer "${r.id}" requires a raster source`)):T!=="raster-dem"&&p==="hillshade"?e.push(new Ze(o,r.source,`layer "${r.id}" requires a raster-dem source`)):T==="raster"&&p!=="raster"?e.push(new Ze(o,r.source,`layer "${r.id}" requires a vector source`)):T!=="vector"||r["source-layer"]?T==="raster-dem"&&p!=="hillshade"?e.push(new Ze(o,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):p!=="line"||!r.paint||!r.paint["line-gradient"]||T==="geojson"&&w.lineMetrics||e.push(new Ze(o,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Ze(o,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new Ze(o,r.source,`source "${r.source}" not found`))}else e.push(new Ze(o,r,'missing required property "source"'));return e=e.concat(Xr({key:o,value:r,valueSpec:h.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${o}.type`,value:r.type,valueSpec:h.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:Qe,layout:w=>Xr({layer:r,key:w.key,value:w.value,style:w.style,styleSpec:w.styleSpec,validateSpec:w.validateSpec,objectElementValidators:{"*":T=>ir(mn({layerType:p},T))}}),paint:w=>Xr({layer:r,key:w.key,value:w.value,style:w.style,styleSpec:w.styleSpec,validateSpec:w.validateSpec,objectElementValidators:{"*":T=>ni(mn({layerType:p},T))}})}})),e}function dr(i){const e=i.value,r=i.key,o=_i(e);return o!=="string"?[new Ze(r,e,`string expected, ${o} found`)]:[]}const rr={promoteId:function({key:i,value:e}){if(_i(e)==="string")return dr({key:i,value:e});{const r=[];for(const o in e)r.push(...dr({key:`${i}.${o}`,value:e[o]}));return r}}};function bi(i){const e=i.value,r=i.key,o=i.styleSpec,l=i.style,h=i.validateSpec;if(!e.type)return[new Ze(r,e,'"type" is required')];const p=Ji(e.type);let y;switch(p){case"vector":case"raster":return y=Xr({key:r,value:e,valueSpec:o[`source_${p.replace("-","_")}`],style:i.style,styleSpec:o,objectElementValidators:rr,validateSpec:h}),y;case"raster-dem":return y=function(w){var T;const M=(T=w.sourceName)!==null&&T!==void 0?T:"",z=w.value,D=w.styleSpec,N=D.source_raster_dem,U=w.style;let G=[];const $=_i(z);if(z===void 0)return G;if($!=="object")return G.push(new Ze("source_raster_dem",z,`object expected, ${$} found`)),G;const ie=Ji(z.encoding)==="custom",ue=["redFactor","greenFactor","blueFactor","baseShift"],re=w.value.encoding?`"${w.value.encoding}"`:"Default";for(const pe in z)!ie&&ue.includes(pe)?G.push(new Ze(pe,z[pe],`In "${M}": "${pe}" is only valid when "encoding" is set to "custom". ${re} encoding found`)):N[pe]?G=G.concat(w.validateSpec({key:pe,value:z[pe],valueSpec:N[pe],validateSpec:w.validateSpec,style:U,styleSpec:D})):G.push(new Ze(pe,z[pe],`unknown property "${pe}"`));return G}({sourceName:r,value:e,style:i.style,styleSpec:o,validateSpec:h}),y;case"geojson":if(y=Xr({key:r,value:e,valueSpec:o.source_geojson,style:l,styleSpec:o,validateSpec:h,objectElementValidators:rr}),e.cluster)for(const w in e.clusterProperties){const[T,M]=e.clusterProperties[w],z=typeof T=="string"?[T,["accumulated"],["get",w]]:T;y.push(...de({key:`${r}.${w}.map`,value:M,validateSpec:h,expressionContext:"cluster-map"})),y.push(...de({key:`${r}.${w}.reduce`,value:z,validateSpec:h,expressionContext:"cluster-reduce"}))}return y;case"video":return Xr({key:r,value:e,valueSpec:o.source_video,style:l,validateSpec:h,styleSpec:o});case"image":return Xr({key:r,value:e,valueSpec:o.source_image,style:l,validateSpec:h,styleSpec:o});case"canvas":return[new Ze(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return we({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:l,validateSpec:h,styleSpec:o})}}function an(i){const e=i.value,r=i.styleSpec,o=r.light,l=i.style;let h=[];const p=_i(e);if(e===void 0)return h;if(p!=="object")return h=h.concat([new Ze("light",e,`object expected, ${p} found`)]),h;for(const y in e){const w=y.match(/^(.*)-transition$/);h=h.concat(w&&o[w[1]]&&o[w[1]].transition?i.validateSpec({key:y,value:e[y],valueSpec:r.transition,validateSpec:i.validateSpec,style:l,styleSpec:r}):o[y]?i.validateSpec({key:y,value:e[y],valueSpec:o[y],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new Ze(y,e[y],`unknown property "${y}"`)])}return h}function no(i){const e=i.value,r=i.styleSpec,o=r.terrain,l=i.style;let h=[];const p=_i(e);if(e===void 0)return h;if(p!=="object")return h=h.concat([new Ze("terrain",e,`object expected, ${p} found`)]),h;for(const y in e)h=h.concat(o[y]?i.validateSpec({key:y,value:e[y],valueSpec:o[y],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new Ze(y,e[y],`unknown property "${y}"`)]);return h}function Zr(i){let e=[];const r=i.value,o=i.key;if(Array.isArray(r)){const l=[],h=[];for(const p in r)r[p].id&&l.includes(r[p].id)&&e.push(new Ze(o,r,`all the sprites' ids must be unique, but ${r[p].id} is duplicated`)),l.push(r[p].id),r[p].url&&h.includes(r[p].url)&&e.push(new Ze(o,r,`all the sprites' URLs must be unique, but ${r[p].url} is duplicated`)),h.push(r[p].url),e=e.concat(Xr({key:`${o}[${p}]`,value:r[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return dr({key:o,value:r})}const oo={"*":()=>[],array:ro,boolean:function(i){const e=i.value,r=i.key,o=_i(e);return o!=="boolean"?[new Ze(r,e,`boolean expected, ${o} found`)]:[]},number:ds,color:function(i){const e=i.key,r=i.value,o=_i(r);return o!=="string"?[new Ze(e,r,`color expected, ${o} found`)]:yi.parse(String(r))?[]:[new Ze(e,r,`color expected, "${r}" found`)]},constants:ba,enum:we,filter:Qe,function:wa,layer:lr,object:Xr,source:bi,light:an,terrain:no,string:dr,formatted:function(i){return dr(i).length===0?[]:de(i)},resolvedImage:function(i){return dr(i).length===0?[]:de(i)},padding:function(i){const e=i.key,r=i.value;if(_i(r)==="array"){if(r.length<1||r.length>4)return[new Ze(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const o={type:"number"};let l=[];for(let h=0;h[]}})),i.constants&&(r=r.concat(ba({key:"constants",value:i.constants,style:i,styleSpec:e,validateSpec:ln}))),Ls(r)}function yn(i){return function(e){return i({...e,validateSpec:ln})}}function Ls(i){return[].concat(i).sort((e,r)=>e.line-r.line)}function fo(i){return function(...e){return Ls(i.apply(this,e))}}Ar.source=fo(yn(bi)),Ar.sprite=fo(yn(Zr)),Ar.glyphs=fo(yn(zs)),Ar.light=fo(yn(an)),Ar.terrain=fo(yn(no)),Ar.layer=fo(yn(lr)),Ar.filter=fo(yn(Qe)),Ar.paintProperty=fo(yn(ni)),Ar.layoutProperty=fo(yn(ir));const mo=Ar,Li=mo.light,wi=mo.paintProperty,Ds=mo.layoutProperty;function Gn(i,e){let r=!1;if(e&&e.length)for(const o of e)i.fire(new wo(new Error(o.message))),r=!0;return r}class Lo{constructor(e,r,o){const l=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const p=new Int32Array(this.arrayBuffer);e=p[0],this.d=(r=p[1])+2*(o=p[2]);for(let w=0;w=z[U+0]&&l>=z[U+1])?(y[N]=!0,p.push(M[N])):y[N]=!1}}}}_forEachCell(e,r,o,l,h,p,y,w){const T=this._convertToCellCoord(e),M=this._convertToCellCoord(r),z=this._convertToCellCoord(o),D=this._convertToCellCoord(l);for(let N=T;N<=z;N++)for(let U=M;U<=D;U++){const G=this.d*U+N;if((!w||w(this._convertFromCellCoord(N),this._convertFromCellCoord(U),this._convertFromCellCoord(N+1),this._convertFromCellCoord(U+1)))&&h.call(this,e,r,o,l,G,p,y,w))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,r=3+this.cells.length+1+1;let o=0;for(let p=0;p=0)continue;const p=i[h];l[h]=pr[o].shallow.indexOf(h)>=0?p:Pn(p,e)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return o!=="Object"&&(l.$name=o),l}throw new Error("can't serialize object of type "+typeof i)}function _o(i){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob||Wn(i)||en(i)||ArrayBuffer.isView(i)||i instanceof ImageData)return i;if(Array.isArray(i))return i.map(_o);if(typeof i=="object"){const e=i.$name||"Object";if(!pr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=pr[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const o=Object.create(r.prototype);for(const l of Object.keys(i)){if(l==="$name")continue;const h=i[l];o[l]=pr[e].shallow.indexOf(l)>=0?h:_o(h)}return o}throw new Error("can't deserialize object of type "+typeof i)}class Jo{constructor(){this.first=!0}update(e,r){const o=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=o,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=o,!0):(this.lastFloorZoom>o?(this.lastIntegerZoom=o+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=128&&i<=255,Arabic:i=>i>=1536&&i<=1791,"Arabic Supplement":i=>i>=1872&&i<=1919,"Arabic Extended-A":i=>i>=2208&&i<=2303,"Hangul Jamo":i=>i>=4352&&i<=4607,"Unified Canadian Aboriginal Syllabics":i=>i>=5120&&i<=5759,Khmer:i=>i>=6016&&i<=6143,"Unified Canadian Aboriginal Syllabics Extended":i=>i>=6320&&i<=6399,"General Punctuation":i=>i>=8192&&i<=8303,"Letterlike Symbols":i=>i>=8448&&i<=8527,"Number Forms":i=>i>=8528&&i<=8591,"Miscellaneous Technical":i=>i>=8960&&i<=9215,"Control Pictures":i=>i>=9216&&i<=9279,"Optical Character Recognition":i=>i>=9280&&i<=9311,"Enclosed Alphanumerics":i=>i>=9312&&i<=9471,"Geometric Shapes":i=>i>=9632&&i<=9727,"Miscellaneous Symbols":i=>i>=9728&&i<=9983,"Miscellaneous Symbols and Arrows":i=>i>=11008&&i<=11263,"CJK Radicals Supplement":i=>i>=11904&&i<=12031,"Kangxi Radicals":i=>i>=12032&&i<=12255,"Ideographic Description Characters":i=>i>=12272&&i<=12287,"CJK Symbols and Punctuation":i=>i>=12288&&i<=12351,Hiragana:i=>i>=12352&&i<=12447,Katakana:i=>i>=12448&&i<=12543,Bopomofo:i=>i>=12544&&i<=12591,"Hangul Compatibility Jamo":i=>i>=12592&&i<=12687,Kanbun:i=>i>=12688&&i<=12703,"Bopomofo Extended":i=>i>=12704&&i<=12735,"CJK Strokes":i=>i>=12736&&i<=12783,"Katakana Phonetic Extensions":i=>i>=12784&&i<=12799,"Enclosed CJK Letters and Months":i=>i>=12800&&i<=13055,"CJK Compatibility":i=>i>=13056&&i<=13311,"CJK Unified Ideographs Extension A":i=>i>=13312&&i<=19903,"Yijing Hexagram Symbols":i=>i>=19904&&i<=19967,"CJK Unified Ideographs":i=>i>=19968&&i<=40959,"Yi Syllables":i=>i>=40960&&i<=42127,"Yi Radicals":i=>i>=42128&&i<=42191,"Hangul Jamo Extended-A":i=>i>=43360&&i<=43391,"Hangul Syllables":i=>i>=44032&&i<=55215,"Hangul Jamo Extended-B":i=>i>=55216&&i<=55295,"Private Use Area":i=>i>=57344&&i<=63743,"CJK Compatibility Ideographs":i=>i>=63744&&i<=64255,"Arabic Presentation Forms-A":i=>i>=64336&&i<=65023,"Vertical Forms":i=>i>=65040&&i<=65055,"CJK Compatibility Forms":i=>i>=65072&&i<=65103,"Small Form Variants":i=>i>=65104&&i<=65135,"Arabic Presentation Forms-B":i=>i>=65136&&i<=65279,"Halfwidth and Fullwidth Forms":i=>i>=65280&&i<=65519};function Sa(i){for(const e of i)if(fs(e.charCodeAt(0)))return!0;return!1}function ps(i){for(const e of i)if(!Ga(e.charCodeAt(0)))return!1;return!0}function Ga(i){return!(Ke.Arabic(i)||Ke["Arabic Supplement"](i)||Ke["Arabic Extended-A"](i)||Ke["Arabic Presentation Forms-A"](i)||Ke["Arabic Presentation Forms-B"](i))}function fs(i){return!(i!==746&&i!==747&&(i<4352||!(Ke["Bopomofo Extended"](i)||Ke.Bopomofo(i)||Ke["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||Ke["CJK Compatibility Ideographs"](i)||Ke["CJK Compatibility"](i)||Ke["CJK Radicals Supplement"](i)||Ke["CJK Strokes"](i)||!(!Ke["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||Ke["CJK Unified Ideographs Extension A"](i)||Ke["CJK Unified Ideographs"](i)||Ke["Enclosed CJK Letters and Months"](i)||Ke["Hangul Compatibility Jamo"](i)||Ke["Hangul Jamo Extended-A"](i)||Ke["Hangul Jamo Extended-B"](i)||Ke["Hangul Jamo"](i)||Ke["Hangul Syllables"](i)||Ke.Hiragana(i)||Ke["Ideographic Description Characters"](i)||Ke.Kanbun(i)||Ke["Kangxi Radicals"](i)||Ke["Katakana Phonetic Extensions"](i)||Ke.Katakana(i)&&i!==12540||!(!Ke["Halfwidth and Fullwidth Forms"](i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!Ke["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||Ke["Unified Canadian Aboriginal Syllabics"](i)||Ke["Unified Canadian Aboriginal Syllabics Extended"](i)||Ke["Vertical Forms"](i)||Ke["Yijing Hexagram Symbols"](i)||Ke["Yi Syllables"](i)||Ke["Yi Radicals"](i))))}function Fs(i){return!(fs(i)||function(e){return!!(Ke["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Ke["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Ke["Letterlike Symbols"](e)||Ke["Number Forms"](e)||Ke["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Ke["Control Pictures"](e)&&e!==9251||Ke["Optical Character Recognition"](e)||Ke["Enclosed Alphanumerics"](e)||Ke["Geometric Shapes"](e)||Ke["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Ke["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Ke["CJK Symbols and Punctuation"](e)||Ke.Katakana(e)||Ke["Private Use Area"](e)||Ke["CJK Compatibility Forms"](e)||Ke["Small Form Variants"](e)||Ke["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(i))}function Wa(i){return i>=1424&&i<=2303||Ke["Arabic Presentation Forms-A"](i)||Ke["Arabic Presentation Forms-B"](i)}function Rs(i,e){return!(!e&&Wa(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||Ke.Khmer(i))}function Ta(i){for(const e of i)if(Wa(e.charCodeAt(0)))return!0;return!1}const Bl="deferred",Nl="loading",Vl="loaded";let Ul=null,zn="unavailable",ms=null;const Ha=function(i){i&&typeof i=="string"&&i.indexOf("NetworkError")>-1&&(zn="error"),Ul&&Ul(i)};function jl(){Xa.fire(new co("pluginStateChange",{pluginStatus:zn,pluginURL:ms}))}const Xa=new jo,ql=function(){return zn},Oc=function(){if(zn!==Bl||!ms)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");zn=Nl,jl(),ms&&je({url:ms},i=>{i?Ha(i):(zn=Vl,jl())})},Hn={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>zn===Vl||Hn.applyArabicShaping!=null,isLoading:()=>zn===Nl,setState(i){if(!fi())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");zn=i.pluginStatus,ms=i.pluginURL},isParsed(){if(!fi())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return Hn.applyArabicShaping!=null&&Hn.processBidirectionalText!=null&&Hn.processStyledBidirectionalText!=null},getPluginURL(){if(!fi())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return ms}};class Yi{constructor(e,r){this.zoom=e,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Jo,this.transition={})}isSupportedScript(e){return function(r,o){for(const l of r)if(!Rs(l.charCodeAt(0),o))return!1;return!0}(e,Hn.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),o=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*o}:{fromScale:.5,toScale:1,t:1-(1-o)*r}}}class fl{constructor(e,r){this.property=e,this.value=r,this.expression=function(o,l){if(Ki(o))return new us(o,l);if(Zn(o)){const h=_a(o,l);if(h.result==="error")throw new Error(h.value.map(p=>`${p.key}: ${p.message}`).join(", "));return h.value}{let h=o;return l.type==="color"&&typeof o=="string"?h=yi.parse(o):l.type!=="padding"||typeof o!="number"&&!Array.isArray(o)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(o)&&(h=Ir.parse(o)):h=qr.parse(o),{kind:"constant",evaluate:()=>h}}}(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,o){return this.property.possiblyEvaluate(this,e,r,o)}}class Zl{constructor(e){this.property=e,this.value=new fl(e,void 0)}transitioned(e,r){return new Nc(this.property,this.value,r,Nt({},e.transition,this.transition),e.now)}untransitioned(){return new Nc(this.property,this.value,null,{},0)}}class Bc{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return We(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Zl(this._values[e].property)),this._values[e].value=new fl(this._values[e].property,r===null?void 0:We(r))}getTransition(e){return We(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Zl(this._values[e].property)),this._values[e].transition=We(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const o=this.getValue(r);o!==void 0&&(e[r]=o);const l=this.getTransition(r);l!==void 0&&(e[`${r}-transition`]=l)}return e}transitioned(e,r){const o=new Vc(this._properties);for(const l of Object.keys(this._values))o._values[l]=this._values[l].transitioned(e,r._values[l]);return o}untransitioned(){const e=new Vc(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Nc{constructor(e,r,o,l,h){this.property=e,this.value=r,this.begin=h+l.delay||0,this.end=this.begin+l.duration||0,e.specification.transition&&(l.delay||l.duration)&&(this.prior=o)}possiblyEvaluate(e,r,o){const l=e.now||0,h=this.value.possiblyEvaluate(e,r,o),p=this.prior;if(p){if(l>this.end)return this.prior=null,h;if(this.value.isDataDriven())return this.prior=null,h;if(l=1)return 1;const T=w*w,M=T*w;return 4*(w<.5?M:3*(w-T)+M-.75)}(y))}}return h}}class Vc{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,o){const l=new ml(this._properties);for(const h of Object.keys(this._values))l._values[h]=this._values[h].possiblyEvaluate(e,r,o);return l}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class bu{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return We(this._values[e].value)}setValue(e,r){this._values[e]=new fl(this._values[e].property,r===null?void 0:We(r))}serialize(){const e={};for(const r of Object.keys(this._values)){const o=this.getValue(r);o!==void 0&&(e[r]=o)}return e}possiblyEvaluate(e,r,o){const l=new ml(this._properties);for(const h of Object.keys(this._values))l._values[h]=this._values[h].possiblyEvaluate(e,r,o);return l}}class vn{constructor(e,r,o){this.property=e,this.value=r,this.parameters=o}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,o,l){return this.property.evaluate(this.value,this.parameters,e,r,o,l)}}class ml{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class xt{constructor(e){this.specification=e}possiblyEvaluate(e,r){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(r)}interpolate(e,r,o){const l=Hr[this.specification.type];return l?l(e,r,o):e}}class Et{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,o,l){return new vn(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},o,l)}:e.expression,r)}interpolate(e,r,o){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new vn(this,{kind:"constant",value:void 0},e.parameters);const l=Hr[this.specification.type];if(l){const h=l(e.value.value,r.value.value,o);return new vn(this,{kind:"constant",value:h},e.parameters)}return e}evaluate(e,r,o,l,h,p){return e.kind==="constant"?e.value:e.evaluate(r,o,l,h,p)}}class Ka extends Et{possiblyEvaluate(e,r,o,l){if(e.value===void 0)return new vn(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const h=e.expression.evaluate(r,null,{},o,l),p=e.property.specification.type==="resolvedImage"&&typeof h!="string"?h.name:h,y=this._calculate(p,p,p,r);return new vn(this,{kind:"constant",value:y},r)}if(e.expression.kind==="camera"){const h=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new vn(this,{kind:"constant",value:h},r)}return new vn(this,e.expression,r)}evaluate(e,r,o,l,h,p){if(e.kind==="source"){const y=e.evaluate(r,o,l,h,p);return this._calculate(y,y,y,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},o,l),e.evaluate({zoom:Math.floor(r.zoom)},o,l),e.evaluate({zoom:Math.floor(r.zoom)+1},o,l),r):e.value}_calculate(e,r,o,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:o,to:r}}interpolate(e){return e}}class Gl{constructor(e){this.specification=e}possiblyEvaluate(e,r,o,l){if(e.value!==void 0){if(e.expression.kind==="constant"){const h=e.expression.evaluate(r,null,{},o,l);return this._calculate(h,h,h,r)}return this._calculate(e.expression.evaluate(new Yi(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Yi(Math.floor(r.zoom),r)),e.expression.evaluate(new Yi(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,o,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:o,to:r}}interpolate(e){return e}}class Wl{constructor(e){this.specification=e}possiblyEvaluate(e,r,o,l){return!!e.expression.evaluate(r,null,{},o,l)}interpolate(){return!1}}class br{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const o=e[r];o.specification.overridable&&this.overridableProperties.push(r);const l=this.defaultPropertyValues[r]=new fl(o,void 0),h=this.defaultTransitionablePropertyValues[r]=new Zl(o);this.defaultTransitioningPropertyValues[r]=h.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}tt("DataDrivenProperty",Et),tt("DataConstantProperty",xt),tt("CrossFadedDataDrivenProperty",Ka),tt("CrossFadedProperty",Gl),tt("ColorRampProperty",Wl);const Hl="-transition";class so extends jo{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new bu(r.layout)),r.paint)){this._transitionablePaint=new Bc(r.paint);for(const o in e.paint)this.setPaintProperty(o,e.paint[o],{validate:!1});for(const o in e.layout)this.setLayoutProperty(o,e.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ml(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,o={}){r!=null&&this._validate(Ds,`layers.${this.id}.layout.${e}`,e,r,o)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(Hl)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,o={}){if(r!=null&&this._validate(wi,`layers.${this.id}.paint.${e}`,e,r,o))return!1;if(e.endsWith(Hl))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const l=this._transitionablePaint._values[e],h=l.property.specification["property-type"]==="cross-faded-data-driven",p=l.value.isDataDriven(),y=l.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const w=this._transitionablePaint._values[e].value;return w.isDataDriven()||p||h||this._handleOverridablePaintPropertyUpdate(e,y,w)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,o){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),Ae(e,(r,o)=>!(r===void 0||o==="layout"&&!Object.keys(r).length||o==="paint"&&!Object.keys(r).length))}_validate(e,r,o,l,h={}){return(!h||h.validate!==!1)&&Gn(this,e.call(mo,{key:r,layerType:this.type,objectKey:o,value:l,styleSpec:Se,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof vn&&Co(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const Uc={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Os{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class cr{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_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 r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function or(i,e=1){let r=0,o=0;return{members:i.map(l=>{const h=Uc[l.type].BYTES_PER_ELEMENT,p=r=Ia(r,Math.max(e,h)),y=l.components||1;return o=Math.max(o,h),r+=h*y,{name:l.name,type:l.type,components:y,offset:p}}),size:Ia(r,Math.max(o,e)),alignment:e}}function Ia(i,e){return Math.ceil(i/e)*e}class Ja extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,r)}emplace(e,r,o){const l=2*e;return this.int16[l+0]=r,this.int16[l+1]=o,e}}Ja.prototype.bytesPerElement=4,tt("StructArrayLayout2i4",Ja);class Ya extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.int16[h+0]=r,this.int16[h+1]=o,this.int16[h+2]=l,e}}Ya.prototype.bytesPerElement=6,tt("StructArrayLayout3i6",Ya);class Bs extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,o,l)}emplace(e,r,o,l,h){const p=4*e;return this.int16[p+0]=r,this.int16[p+1]=o,this.int16[p+2]=l,this.int16[p+3]=h,e}}Bs.prototype.bytesPerElement=8,tt("StructArrayLayout4i8",Bs);class Xl extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,o,l,h,p)}emplace(e,r,o,l,h,p,y){const w=6*e;return this.int16[w+0]=r,this.int16[w+1]=o,this.int16[w+2]=l,this.int16[w+3]=h,this.int16[w+4]=p,this.int16[w+5]=y,e}}Xl.prototype.bytesPerElement=12,tt("StructArrayLayout2i4i12",Xl);class Kl extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,o,l,h,p)}emplace(e,r,o,l,h,p,y){const w=4*e,T=8*e;return this.int16[w+0]=r,this.int16[w+1]=o,this.uint8[T+4]=l,this.uint8[T+5]=h,this.uint8[T+6]=p,this.uint8[T+7]=y,e}}Kl.prototype.bytesPerElement=8,tt("StructArrayLayout2i4ub8",Kl);class Ea extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,r)}emplace(e,r,o){const l=2*e;return this.float32[l+0]=r,this.float32[l+1]=o,e}}Ea.prototype.bytesPerElement=8,tt("StructArrayLayout2f8",Ea);class Jl extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T,M){const z=this.length;return this.resize(z+1),this.emplace(z,e,r,o,l,h,p,y,w,T,M)}emplace(e,r,o,l,h,p,y,w,T,M,z){const D=10*e;return this.uint16[D+0]=r,this.uint16[D+1]=o,this.uint16[D+2]=l,this.uint16[D+3]=h,this.uint16[D+4]=p,this.uint16[D+5]=y,this.uint16[D+6]=w,this.uint16[D+7]=T,this.uint16[D+8]=M,this.uint16[D+9]=z,e}}Jl.prototype.bytesPerElement=20,tt("StructArrayLayout10ui20",Jl);class Yl extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T,M,z,D){const N=this.length;return this.resize(N+1),this.emplace(N,e,r,o,l,h,p,y,w,T,M,z,D)}emplace(e,r,o,l,h,p,y,w,T,M,z,D,N){const U=12*e;return this.int16[U+0]=r,this.int16[U+1]=o,this.int16[U+2]=l,this.int16[U+3]=h,this.uint16[U+4]=p,this.uint16[U+5]=y,this.uint16[U+6]=w,this.uint16[U+7]=T,this.int16[U+8]=M,this.int16[U+9]=z,this.int16[U+10]=D,this.int16[U+11]=N,e}}Yl.prototype.bytesPerElement=24,tt("StructArrayLayout4i4ui4i24",Yl);class Si extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.float32[h+0]=r,this.float32[h+1]=o,this.float32[h+2]=l,e}}Si.prototype.bytesPerElement=12,tt("StructArrayLayout3f12",Si);class u extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}u.prototype.bytesPerElement=4,tt("StructArrayLayout1ul4",u);class t extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T){const M=this.length;return this.resize(M+1),this.emplace(M,e,r,o,l,h,p,y,w,T)}emplace(e,r,o,l,h,p,y,w,T,M){const z=10*e,D=5*e;return this.int16[z+0]=r,this.int16[z+1]=o,this.int16[z+2]=l,this.int16[z+3]=h,this.int16[z+4]=p,this.int16[z+5]=y,this.uint32[D+3]=w,this.uint16[z+8]=T,this.uint16[z+9]=M,e}}t.prototype.bytesPerElement=20,tt("StructArrayLayout6i1ul2ui20",t);class n extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p){const y=this.length;return this.resize(y+1),this.emplace(y,e,r,o,l,h,p)}emplace(e,r,o,l,h,p,y){const w=6*e;return this.int16[w+0]=r,this.int16[w+1]=o,this.int16[w+2]=l,this.int16[w+3]=h,this.int16[w+4]=p,this.int16[w+5]=y,e}}n.prototype.bytesPerElement=12,tt("StructArrayLayout2i2i2i12",n);class a extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,r,o,l,h)}emplace(e,r,o,l,h,p){const y=4*e,w=8*e;return this.float32[y+0]=r,this.float32[y+1]=o,this.float32[y+2]=l,this.int16[w+6]=h,this.int16[w+7]=p,e}}a.prototype.bytesPerElement=16,tt("StructArrayLayout2f1f2i16",a);class c extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,o,l)}emplace(e,r,o,l,h){const p=12*e,y=3*e;return this.uint8[p+0]=r,this.uint8[p+1]=o,this.float32[y+1]=l,this.float32[y+2]=h,e}}c.prototype.bytesPerElement=12,tt("StructArrayLayout2ub2f12",c);class d extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.uint16[h+0]=r,this.uint16[h+1]=o,this.uint16[h+2]=l,e}}d.prototype.bytesPerElement=6,tt("StructArrayLayout3ui6",d);class x extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T,M,z,D,N,U,G,$,ie){const ue=this.length;return this.resize(ue+1),this.emplace(ue,e,r,o,l,h,p,y,w,T,M,z,D,N,U,G,$,ie)}emplace(e,r,o,l,h,p,y,w,T,M,z,D,N,U,G,$,ie,ue){const re=24*e,pe=12*e,ye=48*e;return this.int16[re+0]=r,this.int16[re+1]=o,this.uint16[re+2]=l,this.uint16[re+3]=h,this.uint32[pe+2]=p,this.uint32[pe+3]=y,this.uint32[pe+4]=w,this.uint16[re+10]=T,this.uint16[re+11]=M,this.uint16[re+12]=z,this.float32[pe+7]=D,this.float32[pe+8]=N,this.uint8[ye+36]=U,this.uint8[ye+37]=G,this.uint8[ye+38]=$,this.uint32[pe+10]=ie,this.int16[re+22]=ue,e}}x.prototype.bytesPerElement=48,tt("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",x);class b extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,y,w,T,M,z,D,N,U,G,$,ie,ue,re,pe,ye,Me,lt,pt,st,et,Ge,ht){const Je=this.length;return this.resize(Je+1),this.emplace(Je,e,r,o,l,h,p,y,w,T,M,z,D,N,U,G,$,ie,ue,re,pe,ye,Me,lt,pt,st,et,Ge,ht)}emplace(e,r,o,l,h,p,y,w,T,M,z,D,N,U,G,$,ie,ue,re,pe,ye,Me,lt,pt,st,et,Ge,ht,Je){const Ne=32*e,bt=16*e;return this.int16[Ne+0]=r,this.int16[Ne+1]=o,this.int16[Ne+2]=l,this.int16[Ne+3]=h,this.int16[Ne+4]=p,this.int16[Ne+5]=y,this.int16[Ne+6]=w,this.int16[Ne+7]=T,this.uint16[Ne+8]=M,this.uint16[Ne+9]=z,this.uint16[Ne+10]=D,this.uint16[Ne+11]=N,this.uint16[Ne+12]=U,this.uint16[Ne+13]=G,this.uint16[Ne+14]=$,this.uint16[Ne+15]=ie,this.uint16[Ne+16]=ue,this.uint16[Ne+17]=re,this.uint16[Ne+18]=pe,this.uint16[Ne+19]=ye,this.uint16[Ne+20]=Me,this.uint16[Ne+21]=lt,this.uint16[Ne+22]=pt,this.uint32[bt+12]=st,this.float32[bt+13]=et,this.float32[bt+14]=Ge,this.uint16[Ne+30]=ht,this.uint16[Ne+31]=Je,e}}b.prototype.bytesPerElement=64,tt("StructArrayLayout8i15ui1ul2f2ui64",b);class S extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}S.prototype.bytesPerElement=4,tt("StructArrayLayout1f4",S);class C extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.uint16[6*e+0]=r,this.float32[h+1]=o,this.float32[h+2]=l,e}}C.prototype.bytesPerElement=12,tt("StructArrayLayout1ui2f12",C);class A extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=4*e;return this.uint32[2*e+0]=r,this.uint16[h+2]=o,this.uint16[h+3]=l,e}}A.prototype.bytesPerElement=8,tt("StructArrayLayout1ul2ui8",A);class P extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,r)}emplace(e,r,o){const l=2*e;return this.uint16[l+0]=r,this.uint16[l+1]=o,e}}P.prototype.bytesPerElement=4,tt("StructArrayLayout2ui4",P);class O extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}O.prototype.bytesPerElement=2,tt("StructArrayLayout1ui2",O);class H extends cr{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,o,l)}emplace(e,r,o,l,h){const p=4*e;return this.float32[p+0]=r,this.float32[p+1]=o,this.float32[p+2]=l,this.float32[p+3]=h,e}}H.prototype.bytesPerElement=16,tt("StructArrayLayout4f16",H);class W extends Os{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new ge(this.anchorPointX,this.anchorPointY)}}W.prototype.size=20;class K extends t{get(e){return new W(this,e)}}tt("CollisionBoxArray",K);class q extends Os{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}q.prototype.size=48;class le extends x{get(e){return new q(this,e)}}tt("PlacedSymbolArray",le);class _e extends Os{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}_e.prototype.size=64;class ee extends b{get(e){return new _e(this,e)}}tt("SymbolInstanceArray",ee);class ce extends S{getoffsetX(e){return this.float32[1*e+0]}}tt("GlyphOffsetArray",ce);class ve extends Ya{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}tt("SymbolLineVertexArray",ve);class xe extends Os{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}xe.prototype.size=12;class Ce extends C{get(e){return new xe(this,e)}}tt("TextAnchorOffsetArray",Ce);class Be extends Os{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]}}Be.prototype.size=8;class Le extends A{get(e){return new Be(this,e)}}tt("FeatureIndexArray",Le);class qe extends Ja{}class dt extends Ja{}class $t extends Ja{}class $e extends Xl{}class Ct extends Kl{}class gt extends Ea{}class Mi extends Jl{}class Jt extends Yl{}class jt extends Si{}class ei extends u{}class fr extends n{}class qi extends c{}class Kr extends d{}class kr extends P{}const wr=or([{name:"a_pos",components:2,type:"Int16"}],4),{members:Xn}=wr;class Qi{constructor(e=[]){this.segments=e}prepareSegment(e,r,o,l){let h=this.segments[this.segments.length-1];return e>Qi.MAX_VERTEX_ARRAY_LENGTH&&Dt(`Max vertices per segment is ${Qi.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!h||h.vertexLength+e>Qi.MAX_VERTEX_ARRAY_LENGTH||h.sortKey!==l)&&(h={vertexOffset:r.length,primitiveOffset:o.length,vertexLength:0,primitiveLength:0},l!==void 0&&(h.sortKey=l),this.segments.push(h)),h}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,o,l){return new Qi([{vertexOffset:e,primitiveOffset:r,vertexLength:o,primitiveLength:l,vaos:{},sortKey:0}])}}function Do(i,e){return 256*(i=ti(Math.floor(i),0,255))+ti(Math.floor(e),0,255)}Qi.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,tt("SegmentVector",Qi);const Fo=or([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var _s={exports:{}},Ns={exports:{}};Ns.exports=function(i,e){var r,o,l,h,p,y,w,T;for(o=i.length-(r=3&i.length),l=e,p=3432918353,y=461845907,T=0;T>>16)*p&65535)<<16)&4294967295)<<15|w>>>17))*y+(((w>>>16)*y&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(h>>>16)&65535)<<16);switch(w=0,r){case 3:w^=(255&i.charCodeAt(T+2))<<16;case 2:w^=(255&i.charCodeAt(T+1))<<8;case 1:l^=w=(65535&(w=(w=(65535&(w^=255&i.charCodeAt(T)))*p+(((w>>>16)*p&65535)<<16)&4294967295)<<15|w>>>17))*y+(((w>>>16)*y&65535)<<16)&4294967295}return l^=i.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0};var Ca=Ns.exports,cn={exports:{}};cn.exports=function(i,e){for(var r,o=i.length,l=e^o,h=0;o>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(h)|(255&i.charCodeAt(++h))<<8|(255&i.charCodeAt(++h))<<16|(255&i.charCodeAt(++h))<<24))+((1540483477*(r>>>16)&65535)<<16),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),o-=4,++h;switch(o){case 3:l^=(255&i.charCodeAt(h+2))<<16;case 2:l^=(255&i.charCodeAt(h+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(h)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var Jr=Ca,xn=cn.exports;_s.exports=Jr,_s.exports.murmur3=Jr,_s.exports.murmur2=xn;var Vs=V(_s.exports);class mr{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,o,l){this.ids.push(Pr(e)),this.positions.push(r,o,l)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=Pr(e);let o=0,l=this.ids.length-1;for(;o>1;this.ids[p]>=r?l=p:o=p+1}const h=[];for(;this.ids[o]===r;)h.push({index:this.positions[3*o],start:this.positions[3*o+1],end:this.positions[3*o+2]}),o++;return h}static serialize(e,r){const o=new Float64Array(e.ids),l=new Uint32Array(e.positions);return Ln(o,l,0,o.length-1),r&&r.push(o.buffer,l.buffer),{ids:o,positions:l}}static deserialize(e){const r=new mr;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function Pr(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:Vs(String(i))}function Ln(i,e,r,o){for(;r>1];let h=r-1,p=o+1;for(;;){do h++;while(i[h]l);if(h>=p)break;_r(i,h,p),_r(e,3*h,3*p),_r(e,3*h+1,3*p+1),_r(e,3*h+2,3*p+2)}p-r`u_${l}`),this.type=o}setUniform(e,r,o){e.set(o.constantOr(this.value))}getBinding(e,r,o){return this.type==="color"?new qc(e,r):new _l(e,r)}}class js{constructor(e,r){this.uniformNames=r.map(o=>`u_${o}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setUniform(e,r,o,l){const h=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;h&&e.set(h)}getBinding(e,r,o){return o.substr(0,9)==="u_pattern"?new jc(e,r):new _l(e,r)}}class Oo{constructor(e,r,o,l){this.expression=e,this.type=o,this.maxValue=0,this.paintVertexAttributes=r.map(h=>({name:`a_${h}`,type:"Float32",components:o==="color"?2:1,offset:0})),this.paintVertexArray=new l}populatePaintArray(e,r,o,l,h){const p=this.paintVertexArray.length,y=this.expression.evaluate(new Yi(0),r,{},l,[],h);this.paintVertexArray.resize(e),this._setPaintValue(p,e,y)}updatePaintArray(e,r,o,l){const h=this.expression.evaluate({zoom:0},o,l);this._setPaintValue(e,r,h)}_setPaintValue(e,r,o){if(this.type==="color"){const l=Ql(o);for(let h=e;h`u_${y}_t`),this.type=o,this.useIntegerZoom=l,this.zoom=h,this.maxValue=0,this.paintVertexAttributes=r.map(y=>({name:`a_${y}`,type:"Float32",components:o==="color"?4:2,offset:0})),this.paintVertexArray=new p}populatePaintArray(e,r,o,l,h){const p=this.expression.evaluate(new Yi(this.zoom),r,{},l,[],h),y=this.expression.evaluate(new Yi(this.zoom+1),r,{},l,[],h),w=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(w,e,p,y)}updatePaintArray(e,r,o,l){const h=this.expression.evaluate({zoom:this.zoom},o,l),p=this.expression.evaluate({zoom:this.zoom+1},o,l);this._setPaintValue(e,r,h,p)}_setPaintValue(e,r,o,l){if(this.type==="color"){const h=Ql(o),p=Ql(l);for(let y=e;y`#define HAS_UNIFORM_${l}`))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const o=this.binders[r];if(o instanceof Oo||o instanceof ao)for(let l=0;l!0){this.programConfigurations={};for(const l of e)this.programConfigurations[l.id]=new $l(l,r,o);this.needsUpload=!1,this._featureMap=new mr,this._bufferOffset=0}populatePaintArrays(e,r,o,l,h,p){for(const y in this.programConfigurations)this.programConfigurations[y].populatePaintArrays(e,r,l,h,p);r.id!==void 0&&this._featureMap.add(r.id,o,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,o,l){for(const h of o)this.needsUpload=this.programConfigurations[h.id].updatePaintArrays(e,this._featureMap,r,h,l)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function pf(i,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}function Lh(i,e,r){const o={color:{source:Ea,composite:H},number:{source:S,composite:Ea}},l=function(h){return{"line-pattern":{source:Mi,composite:Mi},"fill-pattern":{source:Mi,composite:Mi},"fill-extrusion-pattern":{source:Mi,composite:Mi}}[h]}(i);return l&&l[r]||o[e][r]}tt("ConstantBinder",Ro),tt("CrossFadedConstantBinder",js),tt("SourceExpressionBinder",Oo),tt("CrossFadedCompositeBinder",Bo),tt("CompositeExpressionBinder",ao),tt("ProgramConfiguration",$l,{omit:["_buffers"]}),tt("ProgramConfigurationSet",Yo);const Cr=8192,Su=Math.pow(2,14)-1,Dh=-Su-1;function Qa(i){const e=Cr/i.extent,r=i.loadGeometry();for(let o=0;op.x+1||wp.y+1)&&Dt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function $a(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?Qa(i):[]}}function Zc(i,e,r,o,l){i.emplaceBack(2*e+(o+1)/2,2*r+(l+1)/2)}class Tu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new dt,this.indexArray=new Kr,this.segments=new Qi,this.programConfigurations=new Yo(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){const l=this.layers[0],h=[];let p=null,y=!1;l.type==="circle"&&(p=l.layout.get("circle-sort-key"),y=!p.isConstant());for(const{feature:w,id:T,index:M,sourceLayerIndex:z}of e){const D=this.layers[0]._featureFilter.needGeometry,N=$a(w,D);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom),N,o))continue;const U=y?p.evaluate(N,{},o):void 0,G={id:T,properties:w.properties,type:w.type,sourceLayerIndex:z,index:M,geometry:D?N.geometry:Qa(w),patterns:{},sortKey:U};h.push(G)}y&&h.sort((w,T)=>w.sortKey-T.sortKey);for(const w of h){const{geometry:T,index:M,sourceLayerIndex:z}=w,D=e[M].feature;this.addFeature(w,T,M,o),r.featureIndex.insert(D,T,M,z,this.index)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Xn),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,r,o,l){for(const h of r)for(const p of h){const y=p.x,w=p.y;if(y<0||y>=Cr||w<0||w>=Cr)continue;const T=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),M=T.vertexLength;Zc(this.layoutVertexArray,y,w,-1,-1),Zc(this.layoutVertexArray,y,w,1,-1),Zc(this.layoutVertexArray,y,w,1,1),Zc(this.layoutVertexArray,y,w,-1,1),this.indexArray.emplaceBack(M,M+1,M+2),this.indexArray.emplaceBack(M,M+3,M+2),T.vertexLength+=4,T.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,{},l)}}function Fh(i,e){for(let r=0;r1){if(Iu(i,e))return!0;for(let o=0;o1?r:r.sub(e)._mult(l)._add(e))}function Bh(i,e){let r,o,l,h=!1;for(let p=0;pe.y!=l.y>e.y&&e.x<(l.x-o.x)*(e.y-o.y)/(l.y-o.y)+o.x&&(h=!h)}return h}function gl(i,e){let r=!1;for(let o=0,l=i.length-1;oe.y!=p.y>e.y&&e.x<(p.x-h.x)*(e.y-h.y)/(p.y-h.y)+h.x&&(r=!r)}return r}function gf(i,e,r){const o=r[0],l=r[2];if(i.xl.x&&e.x>l.x||i.yl.y&&e.y>l.y)return!1;const h=qt(i,e,r[0]);return h!==qt(i,e,r[1])||h!==qt(i,e,r[2])||h!==qt(i,e,r[3])}function ec(i,e,r){const o=e.paint.get(i).value;return o.kind==="constant"?o.value:r.programConfigurations.get(e.id).getMaxValue(i)}function Gc(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Wc(i,e,r,o,l){if(!e[0]&&!e[1])return i;const h=ge.convert(e)._mult(l);r==="viewport"&&h._rotate(-o);const p=[];for(let y=0;yjh($,G))}(T,w),N=z?M*y:M;for(const U of l)for(const G of U){const $=z?G:jh(G,w);let ie=N;const ue=Hc([],[G.x,G.y,0,1],w);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?ie*=ue[3]/p.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(ie*=p.cameraToCenterDistance/ue[3]),ff(D,$,ie))return!0}return!1}}function jh(i,e){const r=Hc([],[i.x,i.y,0,1],e);return new ge(r[0]/r[3],r[1]/r[3])}class qh extends Tu{}let Zh;tt("HeatmapBucket",qh,{omit:["layers"]});var bf={get paint(){return Zh=Zh||new br({"heatmap-radius":new Et(Se.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Et(Se.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new xt(Se.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Wl(Se.paint_heatmap["heatmap-color"]),"heatmap-opacity":new xt(Se.paint_heatmap["heatmap-opacity"])})}};function Mu(i,{width:e,height:r},o,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==e*r*o)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${e*r*o}`)}else l=new Uint8Array(e*r*o);return i.width=e,i.height=r,i.data=l,i}function Gh(i,{width:e,height:r},o){if(e===i.width&&r===i.height)return;const l=Mu({},{width:e,height:r},o);Au(i,l,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},o),i.width=e,i.height=r,i.data=l.data}function Au(i,e,r,o,l,h){if(l.width===0||l.height===0)return e;if(l.width>i.width||l.height>i.height||r.x>i.width-l.width||r.y>i.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>e.width||l.height>e.height||o.x>e.width-l.width||o.y>e.height-l.height)throw new RangeError("out of range destination coordinates for image copy");const p=i.data,y=e.data;if(p===y)throw new Error("srcData equals dstData, so image is already copied");for(let w=0;w{e[i.evaluationKey]=w;const T=i.expression.evaluate(e);l.data[p+y+0]=Math.floor(255*T.r/T.a),l.data[p+y+1]=Math.floor(255*T.g/T.a),l.data[p+y+2]=Math.floor(255*T.b/T.a),l.data[p+y+3]=Math.floor(255*T.a)};if(i.clips)for(let p=0,y=0;p80*r){o=h=i[0],l=p=i[1];for(var U=r;Uh&&(h=y),w>p&&(p=w);T=(T=Math.max(h-o,p-l))!==0?32767/T:0}return rc(D,N,r,o,l,T,0),N}function Xh(i,e,r,o,l){var h,p;if(l===Lu(i,e,r,o)>0)for(h=e;h=e;h-=o)p=Yh(h,i[h],i[h+1],p);return p&&Kc(p,p.next)&&(oc(p),p=p.next),p}function el(i,e){if(!i)return i;e||(e=i);var r,o=i;do if(r=!1,o.steiner||!Kc(o,o.next)&&Sr(o.prev,o,o.next)!==0)o=o.next;else{if(oc(o),(o=e=o.prev)===o.next)break;r=!0}while(r||o!==e);return e}function rc(i,e,r,o,l,h,p){if(i){!p&&h&&function(M,z,D,N){var U=M;do U.z===0&&(U.z=Pu(U.x,U.y,z,D,N)),U.prevZ=U.prev,U.nextZ=U.next,U=U.next;while(U!==M);U.prevZ.nextZ=null,U.prevZ=null,function(G){var $,ie,ue,re,pe,ye,Me,lt,pt=1;do{for(ie=G,G=null,pe=null,ye=0;ie;){for(ye++,ue=ie,Me=0,$=0;$0||lt>0&&ue;)Me!==0&&(lt===0||!ue||ie.z<=ue.z)?(re=ie,ie=ie.nextZ,Me--):(re=ue,ue=ue.nextZ,lt--),pe?pe.nextZ=re:G=re,re.prevZ=pe,pe=re;ie=ue}pe.nextZ=null,pt*=2}while(ye>1)}(U)}(i,o,l,h);for(var y,w,T=i;i.prev!==i.next;)if(y=i.prev,w=i.next,h?Mf(i,o,l,h):Cf(i))e.push(y.i/r|0),e.push(i.i/r|0),e.push(w.i/r|0),oc(i),i=w.next,T=w.next;else if((i=w)===T){p?p===1?rc(i=Af(el(i),e,r),e,r,o,l,h,2):p===2&&kf(i,e,r,o,l,h):rc(el(i),e,r,o,l,h,1);break}}}function Cf(i){var e=i.prev,r=i,o=i.next;if(Sr(e,r,o)>=0)return!1;for(var l=e.x,h=r.x,p=o.x,y=e.y,w=r.y,T=o.y,M=lh?l>p?l:p:h>p?h:p,N=y>w?y>T?y:T:w>T?w:T,U=o.next;U!==e;){if(U.x>=M&&U.x<=D&&U.y>=z&&U.y<=N&&vl(l,y,h,w,p,T,U.x,U.y)&&Sr(U.prev,U,U.next)>=0)return!1;U=U.next}return!0}function Mf(i,e,r,o){var l=i.prev,h=i,p=i.next;if(Sr(l,h,p)>=0)return!1;for(var y=l.x,w=h.x,T=p.x,M=l.y,z=h.y,D=p.y,N=yw?y>T?y:T:w>T?w:T,$=M>z?M>D?M:D:z>D?z:D,ie=Pu(N,U,e,r,o),ue=Pu(G,$,e,r,o),re=i.prevZ,pe=i.nextZ;re&&re.z>=ie&&pe&&pe.z<=ue;){if(re.x>=N&&re.x<=G&&re.y>=U&&re.y<=$&&re!==l&&re!==p&&vl(y,M,w,z,T,D,re.x,re.y)&&Sr(re.prev,re,re.next)>=0||(re=re.prevZ,pe.x>=N&&pe.x<=G&&pe.y>=U&&pe.y<=$&&pe!==l&&pe!==p&&vl(y,M,w,z,T,D,pe.x,pe.y)&&Sr(pe.prev,pe,pe.next)>=0))return!1;pe=pe.nextZ}for(;re&&re.z>=ie;){if(re.x>=N&&re.x<=G&&re.y>=U&&re.y<=$&&re!==l&&re!==p&&vl(y,M,w,z,T,D,re.x,re.y)&&Sr(re.prev,re,re.next)>=0)return!1;re=re.prevZ}for(;pe&&pe.z<=ue;){if(pe.x>=N&&pe.x<=G&&pe.y>=U&&pe.y<=$&&pe!==l&&pe!==p&&vl(y,M,w,z,T,D,pe.x,pe.y)&&Sr(pe.prev,pe,pe.next)>=0)return!1;pe=pe.nextZ}return!0}function Af(i,e,r){var o=i;do{var l=o.prev,h=o.next.next;!Kc(l,h)&&Kh(l,o,o.next,h)&&nc(l,h)&&nc(h,l)&&(e.push(l.i/r|0),e.push(o.i/r|0),e.push(h.i/r|0),oc(o),oc(o.next),o=i=h),o=o.next}while(o!==i);return el(o)}function kf(i,e,r,o,l,h){var p=i;do{for(var y=p.next.next;y!==p.prev;){if(p.i!==y.i&&Ff(p,y)){var w=Jh(p,y);return p=el(p,p.next),w=el(w,w.next),rc(p,e,r,o,l,h,0),void rc(w,e,r,o,l,h,0)}y=y.next}p=p.next}while(p!==i)}function Pf(i,e){return i.x-e.x}function zf(i,e){var r=function(l,h){var p,y=h,w=l.x,T=l.y,M=-1/0;do{if(T<=y.y&&T>=y.next.y&&y.next.y!==y.y){var z=y.x+(T-y.y)*(y.next.x-y.x)/(y.next.y-y.y);if(z<=w&&z>M&&(M=z,p=y.x=y.x&&y.x>=U&&w!==y.x&&vl(Tp.x||y.x===p.x&&Lf(p,y)))&&(p=y,$=D)),y=y.next;while(y!==N);return p}(i,e);if(!r)return e;var o=Jh(r,i);return el(o,o.next),el(r,r.next)}function Lf(i,e){return Sr(i.prev,i,e.prev)<0&&Sr(e.next,i,i.next)<0}function Pu(i,e,r,o,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-o)*l|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Df(i){var e=i,r=i;do(e.x=(i-p)*(h-y)&&(i-p)*(o-y)>=(r-p)*(e-y)&&(r-p)*(h-y)>=(l-p)*(o-y)}function Ff(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!function(r,o){var l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==o.i&&l.next.i!==o.i&&Kh(l,l.next,r,o))return!0;l=l.next}while(l!==r);return!1}(i,e)&&(nc(i,e)&&nc(e,i)&&function(r,o){var l=r,h=!1,p=(r.x+o.x)/2,y=(r.y+o.y)/2;do l.y>y!=l.next.y>y&&l.next.y!==l.y&&p<(l.next.x-l.x)*(y-l.y)/(l.next.y-l.y)+l.x&&(h=!h),l=l.next;while(l!==r);return h}(i,e)&&(Sr(i.prev,i,e.prev)||Sr(i,e.prev,e))||Kc(i,e)&&Sr(i.prev,i,i.next)>0&&Sr(e.prev,e,e.next)>0)}function Sr(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function Kc(i,e){return i.x===e.x&&i.y===e.y}function Kh(i,e,r,o){var l=Yc(Sr(i,e,r)),h=Yc(Sr(i,e,o)),p=Yc(Sr(r,o,i)),y=Yc(Sr(r,o,e));return l!==h&&p!==y||!(l!==0||!Jc(i,r,e))||!(h!==0||!Jc(i,o,e))||!(p!==0||!Jc(r,i,o))||!(y!==0||!Jc(r,e,o))}function Jc(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function Yc(i){return i>0?1:i<0?-1:0}function nc(i,e){return Sr(i.prev,i,i.next)<0?Sr(i,e,i.next)>=0&&Sr(i,i.prev,e)>=0:Sr(i,e,i.prev)<0||Sr(i,i.next,e)<0}function Jh(i,e){var r=new zu(i.i,i.x,i.y),o=new zu(e.i,e.x,e.y),l=i.next,h=e.prev;return i.next=e,e.prev=i,r.next=l,l.prev=r,o.next=r,r.prev=o,h.next=o,o.prev=h,o}function Yh(i,e,r,o){var l=new zu(i,e,r);return o?(l.next=o.next,l.prev=o,o.next.prev=l,o.next=l):(l.prev=l,l.next=l),l}function oc(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function zu(i,e,r){this.i=i,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Lu(i,e,r,o){for(var l=0,h=e,p=r-o;h0&&r.holes.push(o+=i[l-1].length)}return r};var Qh=V(ku.exports);function Rf(i,e,r,o,l){$h(i,e,r||0,o||i.length-1,l||Of)}function $h(i,e,r,o,l){for(;o>r;){if(o-r>600){var h=o-r+1,p=e-r+1,y=Math.log(h),w=.5*Math.exp(2*y/3),T=.5*Math.sqrt(y*w*(h-w)/h)*(p-h/2<0?-1:1);$h(i,e,Math.max(r,Math.floor(e-p*w/h+T)),Math.min(o,Math.floor(e+(h-p)*w/h+T)),l)}var M=i[e],z=r,D=o;for(sc(i,r,e),l(i[o],M)>0&&sc(i,r,o);z0;)D--}l(i[r],M)===0?sc(i,r,D):sc(i,++D,o),D<=e&&(r=D+1),e<=D&&(o=D-1)}}function sc(i,e,r){var o=i[e];i[e]=i[r],i[r]=o}function Of(i,e){return ie?1:0}function Du(i,e){const r=i.length;if(r<=1)return[i];const o=[];let l,h;for(let p=0;p1)for(let p=0;pr.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new $t,this.indexArray=new Kr,this.indexArray2=new kr,this.programConfigurations=new Yo(e.layers,e.zoom),this.segments=new Qi,this.segments2=new Qi,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){this.hasPattern=Fu("fill",this.layers,r);const l=this.layers[0].layout.get("fill-sort-key"),h=!l.isConstant(),p=[];for(const{feature:y,id:w,index:T,sourceLayerIndex:M}of e){const z=this.layers[0]._featureFilter.needGeometry,D=$a(y,z);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom),D,o))continue;const N=h?l.evaluate(D,{},o,r.availableImages):void 0,U={id:w,properties:y.properties,type:y.type,sourceLayerIndex:M,index:T,geometry:z?D.geometry:Qa(y),patterns:{},sortKey:N};p.push(U)}h&&p.sort((y,w)=>y.sortKey-w.sortKey);for(const y of p){const{geometry:w,index:T,sourceLayerIndex:M}=y;if(this.hasPattern){const z=Ru("fill",this.layers,y,this.zoom,r);this.patternFeatures.push(z)}else this.addFeature(y,w,T,o,{});r.featureIndex.insert(e[T].feature,w,T,M,this.index)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}addFeatures(e,r,o){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,o)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ef),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,r,o,l,h){for(const p of Du(r,500)){let y=0;for(const N of p)y+=N.length;const w=this.segments.prepareSegment(y,this.layoutVertexArray,this.indexArray),T=w.vertexLength,M=[],z=[];for(const N of p){if(N.length===0)continue;N!==p[0]&&z.push(M.length/2);const U=this.segments2.prepareSegment(N.length,this.layoutVertexArray,this.indexArray2),G=U.vertexLength;this.layoutVertexArray.emplaceBack(N[0].x,N[0].y),this.indexArray2.emplaceBack(G+N.length-1,G),M.push(N[0].x),M.push(N[0].y);for(let $=1;$>3}if(l--,o===1||o===2)h+=i.readSVarint(),p+=i.readSVarint(),o===1&&(e&&y.push(e),e=[]),e.push(new Zf(h,p));else{if(o!==7)throw new Error("unknown command "+o);e&&e.push(e[0].clone())}}return e&&y.push(e),y},xl.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,o=0,l=0,h=0,p=1/0,y=-1/0,w=1/0,T=-1/0;i.pos>3}if(o--,r===1||r===2)(l+=i.readSVarint())y&&(y=l),(h+=i.readSVarint())T&&(T=h);else if(r!==7)throw new Error("unknown command "+r)}return[p,w,y,T]},xl.prototype.toGeoJSON=function(i,e,r){var o,l,h=this.extent*Math.pow(2,r),p=this.extent*i,y=this.extent*e,w=this.loadGeometry(),T=xl.types[this.type];function M(N){for(var U=0;U>3;l=p===1?o.readString():p===2?o.readFloat():p===3?o.readDouble():p===4?o.readVarint64():p===5?o.readVarint():p===6?o.readSVarint():p===7?o.readBoolean():null}return l}(r))}nd.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var e=this._pbf.readVarint()+this._pbf.pos;return new Hf(this._pbf,e,this.extent,this._keys,this._values)};var Kf=rd;function Jf(i,e,r){if(i===3){var o=new Kf(r,r.readVarint()+r.pos);o.length&&(e[o.name]=o)}}Ma.VectorTile=function(i,e){this.layers=i.readFields(Jf,{},e)},Ma.VectorTileFeature=id,Ma.VectorTileLayer=rd;const Yf=Ma.VectorTileFeature.types,Bu=Math.pow(2,13);function ac(i,e,r,o,l,h,p,y){i.emplaceBack(e,r,2*Math.floor(o*Bu)+p,l*Bu*2,h*Bu*2,Math.round(y))}class Nu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new $e,this.centroidVertexArray=new qe,this.indexArray=new Kr,this.programConfigurations=new Yo(e.layers,e.zoom),this.segments=new Qi,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){this.features=[],this.hasPattern=Fu("fill-extrusion",this.layers,r);for(const{feature:l,id:h,index:p,sourceLayerIndex:y}of e){const w=this.layers[0]._featureFilter.needGeometry,T=$a(l,w);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom),T,o))continue;const M={id:h,sourceLayerIndex:y,index:p,geometry:w?T.geometry:Qa(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(Ru("fill-extrusion",this.layers,M,this.zoom,r)):this.addFeature(M,M.geometry,p,o,{}),r.featureIndex.insert(l,M.geometry,p,y,this.index,!0)}}addFeatures(e,r,o){for(const l of this.features){const{geometry:h}=l;this.addFeature(l,h,l.index,r,o)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,qf),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,jf.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,r,o,l,h){const p={x:0,y:0,vertexCount:0};for(const y of Du(r,500)){let w=0;for(const U of y)w+=U.length;let T=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const U of y){if(U.length===0||$f(U))continue;let G=0;for(let $=0;$=1){const ue=U[$-1];if(!Qf(ie,ue)){T.vertexLength+4>Qi.MAX_VERTEX_ARRAY_LENGTH&&(T=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const re=ie.sub(ue)._perp()._unit(),pe=ue.dist(ie);G+pe>32768&&(G=0),ac(this.layoutVertexArray,ie.x,ie.y,re.x,re.y,0,0,G),ac(this.layoutVertexArray,ie.x,ie.y,re.x,re.y,0,1,G),p.x+=2*ie.x,p.y+=2*ie.y,p.vertexCount+=2,G+=pe,ac(this.layoutVertexArray,ue.x,ue.y,re.x,re.y,0,0,G),ac(this.layoutVertexArray,ue.x,ue.y,re.x,re.y,0,1,G),p.x+=2*ue.x,p.y+=2*ue.y,p.vertexCount+=2;const ye=T.vertexLength;this.indexArray.emplaceBack(ye,ye+2,ye+1),this.indexArray.emplaceBack(ye+1,ye+2,ye+3),T.vertexLength+=4,T.primitiveLength+=2}}}}if(T.vertexLength+w>Qi.MAX_VERTEX_ARRAY_LENGTH&&(T=this.segments.prepareSegment(w,this.layoutVertexArray,this.indexArray)),Yf[e.type]!=="Polygon")continue;const M=[],z=[],D=T.vertexLength;for(const U of y)if(U.length!==0){U!==y[0]&&z.push(M.length/2);for(let G=0;GCr)||i.y===e.y&&(i.y<0||i.y>Cr)}function $f(i){return i.every(e=>e.x<0)||i.every(e=>e.x>Cr)||i.every(e=>e.y<0)||i.every(e=>e.y>Cr)}let od;tt("FillExtrusionBucket",Nu,{omit:["layers","features"]});var em={get paint(){return od=od||new br({"fill-extrusion-opacity":new xt(Se["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Et(Se["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new xt(Se["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new xt(Se["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Ka(Se["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Et(Se["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Et(Se["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new xt(Se["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class tm extends so{constructor(e){super(e,em)}createBucket(e){return new Nu(e)}queryRadius(){return Gc(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(e,r,o,l,h,p,y,w){const T=Wc(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),p.angle,y),M=this.paint.get("fill-extrusion-height").evaluate(r,o),z=this.paint.get("fill-extrusion-base").evaluate(r,o),D=function(U,G,$,ie){const ue=[];for(const re of U){const pe=[re.x,re.y,0,1];Hc(pe,pe,G),ue.push(new ge(pe[0]/pe[3],pe[1]/pe[3]))}return ue}(T,w),N=function(U,G,$,ie){const ue=[],re=[],pe=ie[8]*G,ye=ie[9]*G,Me=ie[10]*G,lt=ie[11]*G,pt=ie[8]*$,st=ie[9]*$,et=ie[10]*$,Ge=ie[11]*$;for(const ht of U){const Je=[],Ne=[];for(const bt of ht){const yt=bt.x,Ht=bt.y,$i=ie[0]*yt+ie[4]*Ht+ie[12],nr=ie[1]*yt+ie[5]*Ht+ie[13],Lr=ie[2]*yt+ie[6]*Ht+ie[14],lo=ie[3]*yt+ie[7]*Ht+ie[15],Fn=Lr+Me,Mr=lo+lt,Yr=$i+pt,hn=nr+st,Rn=Lr+et,On=lo+Ge,Dr=new ge(($i+pe)/Mr,(nr+ye)/Mr);Dr.z=Fn/Mr,Je.push(Dr);const Fr=new ge(Yr/On,hn/On);Fr.z=Rn/On,Ne.push(Fr)}ue.push(Je),re.push(Ne)}return[ue,re]}(l,z,M,w);return function(U,G,$){let ie=1/0;Rh($,G)&&(ie=sd($,G[0]));for(let ue=0;uer.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new Ct,this.layoutVertexArray2=new gt,this.indexArray=new Kr,this.programConfigurations=new Yo(e.layers,e.zoom),this.segments=new Qi,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){this.hasPattern=Fu("line",this.layers,r);const l=this.layers[0].layout.get("line-sort-key"),h=!l.isConstant(),p=[];for(const{feature:y,id:w,index:T,sourceLayerIndex:M}of e){const z=this.layers[0]._featureFilter.needGeometry,D=$a(y,z);if(!this.layers[0]._featureFilter.filter(new Yi(this.zoom),D,o))continue;const N=h?l.evaluate(D,{},o):void 0,U={id:w,properties:y.properties,type:y.type,sourceLayerIndex:M,index:T,geometry:z?D.geometry:Qa(y),patterns:{},sortKey:N};p.push(U)}h&&p.sort((y,w)=>y.sortKey-w.sortKey);for(const y of p){const{geometry:w,index:T,sourceLayerIndex:M}=y;if(this.hasPattern){const z=Ru("line",this.layers,y,this.zoom,r);this.patternFeatures.push(z)}else this.addFeature(y,w,T,o,{});r.featureIndex.insert(e[T].feature,w,T,M,this.index)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}addFeatures(e,r,o){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,o)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,om)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,rm),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,o,l,h){const p=this.layers[0].layout,y=p.get("line-join").evaluate(e,{}),w=p.get("line-cap"),T=p.get("line-miter-limit"),M=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const z of r)this.addLine(z,e,y,w,T,M);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,h,l)}addLine(e,r,o,l,h,p){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let ie=0;ie=2&&e[w-1].equals(e[w-2]);)w--;let T=0;for(;T0;if(lt&&ie>T){const Ge=D.dist(N);if(Ge>2*M){const ht=D.sub(D.sub(N)._mult(M/Ge)._round());this.updateDistance(N,ht),this.addCurrentVertex(ht,G,0,0,z),N=ht}}const st=N&&U;let et=st?o:y?"butt":l;if(st&&et==="round"&&(yeh&&(et="bevel"),et==="bevel"&&(ye>2&&(et="flipbevel"),ye100)ue=$.mult(-1);else{const Ge=ye*G.add($).mag()/G.sub($).mag();ue._perp()._mult(Ge*(pt?-1:1))}this.addCurrentVertex(D,ue,0,0,z),this.addCurrentVertex(D,ue.mult(-1),0,0,z)}else if(et==="bevel"||et==="fakeround"){const Ge=-Math.sqrt(ye*ye-1),ht=pt?Ge:0,Je=pt?0:Ge;if(N&&this.addCurrentVertex(D,G,ht,Je,z),et==="fakeround"){const Ne=Math.round(180*Me/Math.PI/20);for(let bt=1;bt2*M){const ht=D.add(U.sub(D)._mult(M/Ge)._round());this.updateDistance(D,ht),this.addCurrentVertex(ht,$,0,0,z),D=ht}}}}addCurrentVertex(e,r,o,l,h,p=!1){const y=r.y*l-r.x,w=-r.y-r.x*l;this.addHalfVertex(e,r.x+r.y*o,r.y-r.x*o,p,!1,o,h),this.addHalfVertex(e,y,w,p,!0,-l,h),this.distance>ad/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,o,l,h,p))}addHalfVertex({x:e,y:r},o,l,h,p,y,w){const T=.5*(this.lineClips?this.scaledDistance*(ad-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(h?1:0),(r<<1)+(p?1:0),Math.round(63*o)+128,Math.round(63*l)+128,1+(y===0?0:y<0?-1:1)|(63&T)<<2,T>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const M=w.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,M),w.primitiveLength++),p?this.e2=M:this.e1=M}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}let ld,cd;tt("LineBucket",Vu,{omit:["layers","patternFeatures"]});var ud={get paint(){return cd=cd||new br({"line-opacity":new Et(Se.paint_line["line-opacity"]),"line-color":new Et(Se.paint_line["line-color"]),"line-translate":new xt(Se.paint_line["line-translate"]),"line-translate-anchor":new xt(Se.paint_line["line-translate-anchor"]),"line-width":new Et(Se.paint_line["line-width"]),"line-gap-width":new Et(Se.paint_line["line-gap-width"]),"line-offset":new Et(Se.paint_line["line-offset"]),"line-blur":new Et(Se.paint_line["line-blur"]),"line-dasharray":new Gl(Se.paint_line["line-dasharray"]),"line-pattern":new Ka(Se.paint_line["line-pattern"]),"line-gradient":new Wl(Se.paint_line["line-gradient"])})},get layout(){return ld=ld||new br({"line-cap":new xt(Se.layout_line["line-cap"]),"line-join":new Et(Se.layout_line["line-join"]),"line-miter-limit":new xt(Se.layout_line["line-miter-limit"]),"line-round-limit":new xt(Se.layout_line["line-round-limit"]),"line-sort-key":new Et(Se.layout_line["line-sort-key"])})}};class lm extends Et{possiblyEvaluate(e,r){return r=new Yi(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,o,l){return r=Nt({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,o,l)}}let Qc;class cm extends so{constructor(e){super(e,ud),this.gradientVersion=0,Qc||(Qc=new lm(ud.paint.properties["line-width"].specification),Qc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!function(o){return o._styleExpression!==void 0}(r)&&r._styleExpression.expression instanceof ho,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values["line-floorwidth"]=Qc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Vu(e)}queryRadius(e){const r=e,o=hd(ec("line-width",this,r),ec("line-gap-width",this,r)),l=ec("line-offset",this,r);return o/2+Math.abs(l)+Gc(this.paint.get("line-translate"))}queryIntersectsFeature(e,r,o,l,h,p,y){const w=Wc(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),p.angle,y),T=y/2*hd(this.paint.get("line-width").evaluate(r,o),this.paint.get("line-gap-width").evaluate(r,o)),M=this.paint.get("line-offset").evaluate(r,o);return M&&(l=function(z,D){const N=[];for(let U=0;U=3){for(let $=0;$0?e+2*i:i}const um=or([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),hm=or([{name:"a_projected_pos",components:3,type:"Float32"}],4);or([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const dm=or([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);or([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const dd=or([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),pm=or([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function fm(i,e,r){return i.sections.forEach(o=>{o.text=function(l,h,p){const y=h.layout.get("text-transform").evaluate(p,{});return y==="uppercase"?l=l.toLocaleUpperCase():y==="lowercase"&&(l=l.toLocaleLowerCase()),Hn.applyArabicShaping&&(l=Hn.applyArabicShaping(l)),l}(o.text,e,r)}),i}or([{name:"triangle",components:3,type:"Uint16"}]),or([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),or([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),or([{type:"Float32",name:"offsetX"}]),or([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),or([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const cc={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var zr=24,pd=Di,fd=function(i,e,r,o,l){var h,p,y=8*l-o-1,w=(1<>1,M=-7,z=r?l-1:0,D=r?-1:1,N=i[e+z];for(z+=D,h=N&(1<<-M)-1,N>>=-M,M+=y;M>0;h=256*h+i[e+z],z+=D,M-=8);for(p=h&(1<<-M)-1,h>>=-M,M+=o;M>0;p=256*p+i[e+z],z+=D,M-=8);if(h===0)h=1-T;else{if(h===w)return p?NaN:1/0*(N?-1:1);p+=Math.pow(2,o),h-=T}return(N?-1:1)*p*Math.pow(2,h-o)},md=function(i,e,r,o,l,h){var p,y,w,T=8*h-l-1,M=(1<>1,D=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=o?0:h-1,U=o?1:-1,G=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(y=isNaN(e)?1:0,p=M):(p=Math.floor(Math.log(e)/Math.LN2),e*(w=Math.pow(2,-p))<1&&(p--,w*=2),(e+=p+z>=1?D/w:D*Math.pow(2,1-z))*w>=2&&(p++,w/=2),p+z>=M?(y=0,p=M):p+z>=1?(y=(e*w-1)*Math.pow(2,l),p+=z):(y=e*Math.pow(2,z-1)*Math.pow(2,l),p=0));l>=8;i[r+N]=255&y,N+=U,y/=256,l-=8);for(p=p<0;i[r+N]=255&p,N+=U,p/=256,T-=8);i[r+N-U]|=128*G};function Di(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}Di.Varint=0,Di.Fixed64=1,Di.Bytes=2,Di.Fixed32=5;var Uu=4294967296,_d=1/Uu,gd=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function qs(i){return i.type===Di.Bytes?i.readVarint()+i.pos:i.pos+1}function bl(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function yd(i,e,r){var o=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(o);for(var l=r.pos-1;l>=i;l--)r.buf[l+o]=r.buf[l]}function mm(i,e){for(var r=0;r>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function vd(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+(i[e+3]<<24)}Di.prototype={destroy:function(){this.buf=null},readFields:function(i,e,r){for(r=r||this.length;this.pos>3,h=this.pos;this.type=7&o,i(l,e,this),this.pos===h&&this.skip(o)}return e},readMessage:function(i,e){return this.readFields(i,e,this.readVarint()+this.pos)},readFixed32:function(){var i=$c(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=vd(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=$c(this.buf,this.pos)+$c(this.buf,this.pos+4)*Uu;return this.pos+=8,i},readSFixed64:function(){var i=$c(this.buf,this.pos)+vd(this.buf,this.pos+4)*Uu;return this.pos+=8,i},readFloat:function(){var i=fd(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=fd(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var e,r,o=this.buf;return e=127&(r=o[this.pos++]),r<128?e:(e|=(127&(r=o[this.pos++]))<<7,r<128?e:(e|=(127&(r=o[this.pos++]))<<14,r<128?e:(e|=(127&(r=o[this.pos++]))<<21,r<128?e:function(l,h,p){var y,w,T=p.buf;if(y=(112&(w=T[p.pos++]))>>4,w<128||(y|=(127&(w=T[p.pos++]))<<3,w<128)||(y|=(127&(w=T[p.pos++]))<<10,w<128)||(y|=(127&(w=T[p.pos++]))<<17,w<128)||(y|=(127&(w=T[p.pos++]))<<24,w<128)||(y|=(1&(w=T[p.pos++]))<<31,w<128))return bl(l,y,h);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,e=this.pos;return this.pos=i,i-e>=12&&gd?function(r,o,l){return gd.decode(r.subarray(o,l))}(this.buf,e,i):function(r,o,l){for(var h="",p=o;p239?4:M>223?3:M>191?2:1;if(p+D>l)break;D===1?M<128&&(z=M):D===2?(192&(y=r[p+1]))==128&&(z=(31&M)<<6|63&y)<=127&&(z=null):D===3?(w=r[p+2],(192&(y=r[p+1]))==128&&(192&w)==128&&((z=(15&M)<<12|(63&y)<<6|63&w)<=2047||z>=55296&&z<=57343)&&(z=null)):D===4&&(w=r[p+2],T=r[p+3],(192&(y=r[p+1]))==128&&(192&w)==128&&(192&T)==128&&((z=(15&M)<<18|(63&y)<<12|(63&w)<<6|63&T)<=65535||z>=1114112)&&(z=null)),z===null?(z=65533,D=1):z>65535&&(z-=65536,h+=String.fromCharCode(z>>>10&1023|55296),z=56320|1023&z),h+=String.fromCharCode(z),p+=D}return h}(this.buf,e,i)},readBytes:function(){var i=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,i);return this.pos=i,e},readPackedVarint:function(i,e){if(this.type!==Di.Bytes)return i.push(this.readVarint(e));var r=qs(this);for(i=i||[];this.pos127;);else if(e===Di.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Di.Fixed32)this.pos+=4;else{if(e!==Di.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(i,e){this.writeVarint(i<<3|e)},realloc:function(i){for(var e=this.length||16;e268435455||i<0?function(e,r){var o,l;if(e>=0?(o=e%4294967296|0,l=e/4294967296|0):(l=~(-e/4294967296),4294967295^(o=~(-e%4294967296))?o=o+1|0:(o=0,l=l+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(h,p,y){y.buf[y.pos++]=127&h|128,h>>>=7,y.buf[y.pos++]=127&h|128,h>>>=7,y.buf[y.pos++]=127&h|128,h>>>=7,y.buf[y.pos++]=127&h|128,y.buf[y.pos]=127&(h>>>=7)}(o,0,r),function(h,p){var y=(7&h)<<4;p.buf[p.pos++]|=y|((h>>>=3)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h)))))}(l,r)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var e=this.pos;this.pos=function(o,l,h){for(var p,y,w=0;w55295&&p<57344){if(!y){p>56319||w+1===l.length?(o[h++]=239,o[h++]=191,o[h++]=189):y=p;continue}if(p<56320){o[h++]=239,o[h++]=191,o[h++]=189,y=p;continue}p=y-55296<<10|p-56320|65536,y=null}else y&&(o[h++]=239,o[h++]=191,o[h++]=189,y=null);p<128?o[h++]=p:(p<2048?o[h++]=p>>6|192:(p<65536?o[h++]=p>>12|224:(o[h++]=p>>18|240,o[h++]=p>>12&63|128),o[h++]=p>>6&63|128),o[h++]=63&p|128)}return h}(this.buf,i,this.pos);var r=this.pos-e;r>=128&&yd(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),md(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),md(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var e=i.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&yd(r,o,this),this.pos=r-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,e,r){this.writeTag(i,Di.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(i,e){e.length&&this.writeMessage(i,mm,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,_m,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,vm,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,gm,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,ym,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,xm,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,bm,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,wm,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,Sm,e)},writeBytesField:function(i,e){this.writeTag(i,Di.Bytes),this.writeBytes(e)},writeFixed32Field:function(i,e){this.writeTag(i,Di.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(i,e){this.writeTag(i,Di.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(i,e){this.writeTag(i,Di.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(i,e){this.writeTag(i,Di.Fixed64),this.writeSFixed64(e)},writeVarintField:function(i,e){this.writeTag(i,Di.Varint),this.writeVarint(e)},writeSVarintField:function(i,e){this.writeTag(i,Di.Varint),this.writeSVarint(e)},writeStringField:function(i,e){this.writeTag(i,Di.Bytes),this.writeString(e)},writeFloatField:function(i,e){this.writeTag(i,Di.Fixed32),this.writeFloat(e)},writeDoubleField:function(i,e){this.writeTag(i,Di.Fixed64),this.writeDouble(e)},writeBooleanField:function(i,e){this.writeVarintField(i,!!e)}};var ju=V(pd);const qu=3;function Tm(i,e,r){i===1&&r.readMessage(Im,e)}function Im(i,e,r){if(i===3){const{id:o,bitmap:l,width:h,height:p,left:y,top:w,advance:T}=r.readMessage(Em,{});e.push({id:o,bitmap:new ic({width:h+2*qu,height:p+2*qu},l),metrics:{width:h,height:p,left:y,top:w,advance:T}})}}function Em(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}const xd=qu;function bd(i){let e=0,r=0;for(const p of i)e+=p.w*p.h,r=Math.max(r,p.w);i.sort((p,y)=>y.h-p.h);const o=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let l=0,h=0;for(const p of i)for(let y=o.length-1;y>=0;y--){const w=o[y];if(!(p.w>w.w||p.h>w.h)){if(p.x=w.x,p.y=w.y,h=Math.max(h,p.y+p.h),l=Math.max(l,p.x+p.w),p.w===w.w&&p.h===w.h){const T=o.pop();y=0&&o>=e&&tu[this.text.charCodeAt(o)];o--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const o=new Sl;return o.text=this.text.substring(e,r),o.sectionIndex=this.sectionIndex.slice(e,r),o.sections=this.sections,o}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(hc.forText(e.scale,e.fontStack||r));const o=this.sections.length-1;for(let l=0;l=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function eu(i,e,r,o,l,h,p,y,w,T,M,z,D,N,U,G){const $=Sl.fromFeature(i,l);let ie;z===s.ai.vertical&&$.verticalizePunctuation();const{processBidirectionalText:ue,processStyledBidirectionalText:re}=Hn;if(ue&&$.sections.length===1){ie=[];const Me=ue($.toString(),Gu($,T,h,e,o,N,U));for(const lt of Me){const pt=new Sl;pt.text=lt,pt.sections=$.sections;for(let st=0;st0&&Gs>Jn&&(Jn=Gs)}else{const vo=pt[oi.fontStack],Qn=vo&&vo[dn];if(Qn&&Qn.rect)Qo=Qn.rect,No=Qn.metrics;else{const Gs=lt[oi.fontStack],_c=Gs&&Gs[dn];if(!_c)continue;No=_c.metrics}Or=(Fr-oi.scale)*zr}Vo?(Me.verticalizable=!0,wn.push({glyph:dn,imageName:$o,x:$i,y:nr+Or,vertical:Vo,scale:oi.scale,fontStack:oi.fontStack,sectionIndex:Sn,metrics:No,rect:Qo}),$i+=Zs*oi.scale+bt):(wn.push({glyph:dn,imageName:$o,x:$i,y:nr+Or,vertical:Vo,scale:oi.scale,fontStack:oi.fontStack,sectionIndex:Sn,metrics:No,rect:Qo}),$i+=No.advance*oi.scale+bt)}wn.length!==0&&(Lr=Math.max($i-bt,Lr),Am(wn,0,wn.length-1,Fn,Jn)),$i=0;const Yn=Ge*Fr+Jn;Bn.lineOffset=Math.max(Jn,bn),nr+=Yn,lo=Math.max(Yn,lo),++Mr}var Yr;const hn=nr-uc,{horizontalAlign:Rn,verticalAlign:On}=Wu(ht);(function(Dr,Fr,bn,Bn,wn,Jn,Yn,Rr,oi){const Sn=(Fr-bn)*wn;let dn=0;dn=Jn!==Yn?-Rr*Bn-uc:(-Bn*oi+.5)*Yn;for(const Or of Dr)for(const No of Or.positionedGlyphs)No.x+=Sn,No.y+=dn})(Me.positionedLines,Fn,Rn,On,Lr,lo,Ge,hn,et.length),Me.top+=-On*hn,Me.bottom=Me.top+hn,Me.left+=-Rn*Lr,Me.right=Me.left+Lr}(ye,e,r,o,ie,p,y,w,z,T,D,G),!function(Me){for(const lt of Me)if(lt.positionedGlyphs.length!==0)return!1;return!0}(pe)&&ye}const tu={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Cm={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Sd(i,e,r,o,l,h){if(e.imageName){const p=o[e.imageName];return p?p.displaySize[0]*e.scale*zr/h+l:0}{const p=r[e.fontStack],y=p&&p[i];return y?y.metrics.advance*e.scale+l:0}}function Td(i,e,r,o){const l=Math.pow(i-e,2);return o?i=0;let M=0;for(let D=0;Dp.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Cu([]),this.placementViewportMatrix=Cu([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Md(this.zoom,r["text-size"]),this.iconSizeData=Md(this.zoom,r["icon-size"]);const o=this.layers[0].layout,l=o.get("symbol-sort-key"),h=o.get("symbol-z-order");this.canOverlap=Hu(o,"text-overlap","text-allow-overlap")!=="never"||Hu(o,"icon-overlap","icon-allow-overlap")!=="never"||o.get("text-ignore-placement")||o.get("icon-ignore-placement"),this.sortFeaturesByKey=h!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(h==="viewport-y"||h==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,o.get("symbol-placement")==="point"&&(this.writingModes=o.get("text-writing-mode").map(p=>s.ai[p])),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.sourceID=e.sourceID}createArrays(){this.text=new Ku(new Yo(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Ku(new Yo(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new ce,this.lineVertexArray=new ve,this.symbolInstances=new ee,this.textAnchorOffsets=new Ce}calculateGlyphDependencies(e,r,o,l,h){for(let p=0;p0)&&(p.value.kind!=="constant"||p.value.value.length>0),M=w.value.kind!=="constant"||!!w.value.value||Object.keys(w.parameters).length>0,z=h.get("symbol-sort-key");if(this.features=[],!T&&!M)return;const D=r.iconDependencies,N=r.glyphDependencies,U=r.availableImages,G=new Yi(this.zoom);for(const{feature:$,id:ie,index:ue,sourceLayerIndex:re}of e){const pe=l._featureFilter.needGeometry,ye=$a($,pe);if(!l._featureFilter.filter(G,ye,o))continue;let Me,lt;if(pe||(ye.geometry=Qa($)),T){const st=l.getValueAndResolveTokens("text-field",ye,o,U),et=ji.factory(st);Lm(et)&&(this.hasRTLText=!0),(!this.hasRTLText||ql()==="unavailable"||this.hasRTLText&&Hn.isParsed())&&(Me=fm(et,l,ye))}if(M){const st=l.getValueAndResolveTokens("icon-image",ye,o,U);lt=st instanceof Er?st:Er.fromString(st)}if(!Me&&!lt)continue;const pt=this.sortFeaturesByKey?z.evaluate(ye,{},o):void 0;if(this.features.push({id:ie,text:Me,icon:lt,index:ue,sourceLayerIndex:re,geometry:ye.geometry,properties:$.properties,type:Pm[$.type],sortKey:pt}),lt&&(D[lt.name]=!0),Me){const st=p.evaluate(ye,{},o).join(","),et=h.get("text-rotation-alignment")!=="viewport"&&h.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(s.ai.vertical)>=0;for(const Ge of Me.sections)if(Ge.image)D[Ge.image.name]=!0;else{const ht=Sa(Me.toString()),Je=Ge.fontStack||st,Ne=N[Je]=N[Je]||{};this.calculateGlyphDependencies(Ge.text,Ne,et,this.allowVerticalPlacement,ht)}}}h.get("symbol-placement")==="line"&&(this.features=function($){const ie={},ue={},re=[];let pe=0;function ye(st){re.push($[st]),pe++}function Me(st,et,Ge){const ht=ue[st];return delete ue[st],ue[et]=ht,re[ht].geometry[0].pop(),re[ht].geometry[0]=re[ht].geometry[0].concat(Ge[0]),ht}function lt(st,et,Ge){const ht=ie[et];return delete ie[et],ie[st]=ht,re[ht].geometry[0].shift(),re[ht].geometry[0]=Ge[0].concat(re[ht].geometry[0]),ht}function pt(st,et,Ge){const ht=Ge?et[0][et[0].length-1]:et[0][0];return`${st}:${ht.x}:${ht.y}`}for(let st=0;st<$.length;st++){const et=$[st],Ge=et.geometry,ht=et.text?et.text.toString():null;if(!ht){ye(st);continue}const Je=pt(ht,Ge),Ne=pt(ht,Ge,!0);if(Je in ue&&Ne in ie&&ue[Je]!==ie[Ne]){const bt=lt(Je,Ne,Ge),yt=Me(Je,Ne,re[bt].geometry);delete ie[Je],delete ue[Ne],ue[pt(ht,re[yt].geometry,!0)]=yt,re[bt].geometry=null}else Je in ue?Me(Je,Ne,Ge):Ne in ie?lt(Je,Ne,Ge):(ye(st),ie[Je]=pe-1,ue[Ne]=pe-1)}return re.filter(st=>st.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort(($,ie)=>$.sortKey-ie.sortKey)}update(e,r,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,o),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,o))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const o=this.lineVertexArray.length;if(e.segment!==void 0){let l=e.dist(r[e.segment+1]),h=e.dist(r[e.segment]);const p={};for(let y=e.segment+1;y=0;y--)p[y]={x:r[y].x,y:r[y].y,tileUnitDistanceFromAnchor:h},y>0&&(h+=r[y-1].dist(r[y]));for(let y=0;y0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,r){const o=e.placedSymbolArray.get(r),l=o.vertexStartIndex+4*o.numGlyphs;for(let h=o.vertexStartIndex;hl[y]-l[w]||h[w]-h[y]),p}addToSortKeyRanges(e,r){const o=this.sortKeyRanges[this.sortKeyRanges.length-1];o&&o.sortKey===r?o.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,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 r of this.symbolInstanceIndexes){const o=this.symbolInstances.get(r);this.featureSortOrder.push(o.featureIndex),[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((l,h,p)=>{l>=0&&p.indexOf(l)===h&&this.addIndicesForPlacedSymbol(this.text,l)}),o.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,o.verticalPlacedTextSymbolIndex),o.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,o.placedIconSymbolIndex),o.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,o.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Ad,kd;tt("SymbolBucket",Tl,{omit:["layers","collisionBoxArray","features","compareText"]}),Tl.MAX_GLYPHS=65535,Tl.addDynamicAttributes=Xu;var Yu={get paint(){return kd=kd||new br({"icon-opacity":new Et(Se.paint_symbol["icon-opacity"]),"icon-color":new Et(Se.paint_symbol["icon-color"]),"icon-halo-color":new Et(Se.paint_symbol["icon-halo-color"]),"icon-halo-width":new Et(Se.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Et(Se.paint_symbol["icon-halo-blur"]),"icon-translate":new xt(Se.paint_symbol["icon-translate"]),"icon-translate-anchor":new xt(Se.paint_symbol["icon-translate-anchor"]),"text-opacity":new Et(Se.paint_symbol["text-opacity"]),"text-color":new Et(Se.paint_symbol["text-color"],{runtimeType:Ur,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new Et(Se.paint_symbol["text-halo-color"]),"text-halo-width":new Et(Se.paint_symbol["text-halo-width"]),"text-halo-blur":new Et(Se.paint_symbol["text-halo-blur"]),"text-translate":new xt(Se.paint_symbol["text-translate"]),"text-translate-anchor":new xt(Se.paint_symbol["text-translate-anchor"])})},get layout(){return Ad=Ad||new br({"symbol-placement":new xt(Se.layout_symbol["symbol-placement"]),"symbol-spacing":new xt(Se.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new xt(Se.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Et(Se.layout_symbol["symbol-sort-key"]),"symbol-z-order":new xt(Se.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new xt(Se.layout_symbol["icon-allow-overlap"]),"icon-overlap":new xt(Se.layout_symbol["icon-overlap"]),"icon-ignore-placement":new xt(Se.layout_symbol["icon-ignore-placement"]),"icon-optional":new xt(Se.layout_symbol["icon-optional"]),"icon-rotation-alignment":new xt(Se.layout_symbol["icon-rotation-alignment"]),"icon-size":new Et(Se.layout_symbol["icon-size"]),"icon-text-fit":new xt(Se.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new xt(Se.layout_symbol["icon-text-fit-padding"]),"icon-image":new Et(Se.layout_symbol["icon-image"]),"icon-rotate":new Et(Se.layout_symbol["icon-rotate"]),"icon-padding":new Et(Se.layout_symbol["icon-padding"]),"icon-keep-upright":new xt(Se.layout_symbol["icon-keep-upright"]),"icon-offset":new Et(Se.layout_symbol["icon-offset"]),"icon-anchor":new Et(Se.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new xt(Se.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new xt(Se.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new xt(Se.layout_symbol["text-rotation-alignment"]),"text-field":new Et(Se.layout_symbol["text-field"]),"text-font":new Et(Se.layout_symbol["text-font"]),"text-size":new Et(Se.layout_symbol["text-size"]),"text-max-width":new Et(Se.layout_symbol["text-max-width"]),"text-line-height":new xt(Se.layout_symbol["text-line-height"]),"text-letter-spacing":new Et(Se.layout_symbol["text-letter-spacing"]),"text-justify":new Et(Se.layout_symbol["text-justify"]),"text-radial-offset":new Et(Se.layout_symbol["text-radial-offset"]),"text-variable-anchor":new xt(Se.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Et(Se.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Et(Se.layout_symbol["text-anchor"]),"text-max-angle":new xt(Se.layout_symbol["text-max-angle"]),"text-writing-mode":new xt(Se.layout_symbol["text-writing-mode"]),"text-rotate":new Et(Se.layout_symbol["text-rotate"]),"text-padding":new xt(Se.layout_symbol["text-padding"]),"text-keep-upright":new xt(Se.layout_symbol["text-keep-upright"]),"text-transform":new Et(Se.layout_symbol["text-transform"]),"text-offset":new Et(Se.layout_symbol["text-offset"]),"text-allow-overlap":new xt(Se.layout_symbol["text-allow-overlap"]),"text-overlap":new xt(Se.layout_symbol["text-overlap"]),"text-ignore-placement":new xt(Se.layout_symbol["text-ignore-placement"]),"text-optional":new xt(Se.layout_symbol["text-optional"])})}};class Pd{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:rn,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.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}}tt("FormatSectionOverride",Pd,{omit:["defaultValue"]});class ru extends so{constructor(e){super(e,Yu)}recalculate(e,r){if(super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const o=this.layout.get("text-writing-mode");if(o){const l=[];for(const h of o)l.indexOf(h)<0&&l.push(h);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,o,l){const h=this.layout.get(e).evaluate(r,{},o,l),p=this._unevaluatedLayout._values[e];return p.isDataDriven()||Zn(p.value)||!h?h:function(y,w){return w.replace(/{([^{}]+)}/g,(T,M)=>y&&M in y?String(y[M]):"")}(r.properties,h)}createBucket(e){return new Tl(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Yu.paint.overridableProperties){if(!ru.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),o=new Pd(r),l=new ls(o,r.property.specification);let h=null;h=r.value.kind==="constant"||r.value.kind==="source"?new cs("source",l):new ko("composite",l,r.value.zoomStops),this.paint._values[e]=new vn(r.property,h,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,o){return!(!this.layout||r.isDataDriven()||o.isDataDriven())&&ru.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const o=e.get("text-field"),l=Yu.paint.properties[r];let h=!1;const p=y=>{for(const w of y)if(l.overrides&&l.overrides.hasOverride(w))return void(h=!0)};if(o.value.kind==="constant"&&o.value.value instanceof ji)p(o.value.value.sections);else if(o.value.kind==="source"){const y=T=>{h||(T instanceof uo&&Gi(T.value)===X?p(T.value.sections):T instanceof Ms?p(T.sections):T.eachChild(y))},w=o.value;w._styleExpression&&y(w._styleExpression.expression)}return h}}let zd;var Dm={get paint(){return zd=zd||new br({"background-color":new xt(Se.paint_background["background-color"]),"background-pattern":new Gl(Se.paint_background["background-pattern"]),"background-opacity":new xt(Se.paint_background["background-opacity"])})}};class Fm extends so{constructor(e){super(e,Dm)}}let Ld;var Rm={get paint(){return Ld=Ld||new br({"raster-opacity":new xt(Se.paint_raster["raster-opacity"]),"raster-hue-rotate":new xt(Se.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new xt(Se.paint_raster["raster-brightness-min"]),"raster-brightness-max":new xt(Se.paint_raster["raster-brightness-max"]),"raster-saturation":new xt(Se.paint_raster["raster-saturation"]),"raster-contrast":new xt(Se.paint_raster["raster-contrast"]),"raster-resampling":new xt(Se.paint_raster["raster-resampling"]),"raster-fade-duration":new xt(Se.paint_raster["raster-fade-duration"])})}};class Om extends so{constructor(e){super(e,Rm)}}class Bm extends so{constructor(e){super(e,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Nm{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=()=>{}}}const Qu=63710088e-1;class Pa{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Pa(Xt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,o=this.lat*r,l=e.lat*r,h=Math.sin(o)*Math.sin(l)+Math.cos(o)*Math.cos(l)*Math.cos((e.lng-this.lng)*r);return Qu*Math.acos(Math.min(h,1))}static convert(e){if(e instanceof Pa)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Pa(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Pa(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 [, ]")}}const Dd=2*Math.PI*Qu;function Fd(i){return Dd*Math.cos(i*Math.PI/180)}function Rd(i){return(180+i)/360}function Od(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function Bd(i,e){return i/Fd(e)}function Nd(i){return 360*i-180}function $u(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class nu{constructor(e,r,o=0){this.x=+e,this.y=+r,this.z=+o}static fromLngLat(e,r=0){const o=Pa.convert(e);return new nu(Rd(o.lng),Od(o.lat),Bd(r,o.lat))}toLngLat(){return new Pa(Nd(this.x),$u(this.y))}toAltitude(){return this.z*Fd($u(this.y))}meterInMercatorCoordinateUnits(){return 1/Dd*(e=$u(this.y),1/Math.cos(e*Math.PI/180));var e}}function Vd(i,e,r){var o=2*Math.PI*6378137/256/Math.pow(2,r);return[i*o-2*Math.PI*6378137/2,e*o-2*Math.PI*6378137/2]}class eh{constructor(e,r,o){if(e<0||e>25||o<0||o>=Math.pow(2,e)||r<0||r>=Math.pow(2,e))throw new Error(`x=${r}, y=${o}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=o,this.key=pc(0,e,e,r,o)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,o){const l=(p=this.y,y=this.z,w=Vd(256*(h=this.x),256*(p=Math.pow(2,y)-p-1),y),T=Vd(256*(h+1),256*(p+1),y),w[0]+","+w[1]+","+T[0]+","+T[1]);var h,p,y,w,T;const M=function(z,D,N){let U,G="";for(let $=z;$>0;$--)U=1<<$-1,G+=(D&U?1:0)+(N&U?2:0);return G}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(o==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,r>1?"@2x":"").replace(/{quadkey}/g,M).replace(/{bbox-epsg-3857}/g,l)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new ge((e.x*r-this.x)*Cr,(e.y*r-this.y)*Cr)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Ud{constructor(e,r){this.wrap=e,this.canonical=r,this.key=pc(e,r.z,r.z,r.x,r.y)}}class yo{constructor(e,r,o,l,h){if(e= z; overscaledZ = ${e}; z = ${o}`);this.overscaledZ=e,this.wrap=r,this.canonical=new eh(o,+l,+h),this.key=pc(r,e,o,l,h)}clone(){return new yo(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?new yo(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new yo(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const o=this.canonical.z-e;return e>this.canonical.z?pc(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):pc(this.wrap*+r,e,e,this.canonical.x>>o,this.canonical.y>>o)}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new yo(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,o=2*this.canonical.x,l=2*this.canonical.y;return[new yo(r,this.wrap,r,o,l),new yo(r,this.wrap,r,o+1,l),new yo(r,this.wrap,r,o,l+1),new yo(r,this.wrap,r,o+1,l+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ythis.max&&(this.max=z),z=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}unpack(e,r,o){return e*this.redFactor+r*this.greenFactor+o*this.blueFactor-this.baseShift}getPixels(){return new go({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,o){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,h=r*this.dim+this.dim,p=o*this.dim,y=o*this.dim+this.dim;switch(r){case-1:l=h-1;break;case 1:h=l+1}switch(o){case-1:p=y-1;break;case 1:y=p+1}const w=-r*this.dim,T=-o*this.dim;for(let M=p;M=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Zd{constructor(e,r,o,l,h){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=o,e._y=l,this.properties=e.properties,this.id=h}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(e[r]=this[r]);return e}}class Gd{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Lo(Cr,16,0),this.grid3D=new Lo(Cr,16,0),this.featureIndexArray=new Le,this.promoteId=r}insert(e,r,o,l,h,p){const y=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(o,l,h);const w=p?this.grid3D:this.grid;for(let T=0;T=0&&z[3]>=0&&w.insert(y,z[0],z[1],z[2],z[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ma.VectorTile(new ju(this.rawTileData)).layers,this.sourceLayerCoder=new qd(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,o,l){this.loadVTLayers();const h=e.params||{},p=Cr/e.tileSize/e.scale,y=ga(h.filter),w=e.queryGeometry,T=e.queryPadding*p,M=Hd(w),z=this.grid.query(M.minX-T,M.minY-T,M.maxX+T,M.maxY+T),D=Hd(e.cameraQueryGeometry),N=this.grid3D.query(D.minX-T,D.minY-T,D.maxX+T,D.maxY+T,($,ie,ue,re)=>function(pe,ye,Me,lt,pt){for(const et of pe)if(ye<=et.x&&Me<=et.y&<>=et.x&&pt>=et.y)return!0;const st=[new ge(ye,Me),new ge(ye,pt),new ge(lt,pt),new ge(lt,Me)];if(pe.length>2){for(const et of st)if(gl(pe,et))return!0}for(let et=0;et(re||(re=Qa(pe)),ye.queryIntersectsFeature(w,pe,Me,re,this.z,e.transform,p,e.pixelPosMatrix)))}return U}loadMatchingFeature(e,r,o,l,h,p,y,w,T,M,z){const D=this.bucketLayerIDs[r];if(p&&!function($,ie){for(let ue=0;ue<$.length;ue++)if(ie.indexOf($[ue])>=0)return!0;return!1}(p,D))return;const N=this.sourceLayerCoder.decode(o),U=this.vtLayers[N].feature(l);if(h.needGeometry){const $=$a(U,!0);if(!h.filter(new Yi(this.tileID.overscaledZ),$,this.tileID.canonical))return}else if(!h.filter(new Yi(this.tileID.overscaledZ),U))return;const G=this.getId(U,N);for(let $=0;${const y=e instanceof ml?e.get(p):null;return y&&y.evaluate?y.evaluate(r,o,l):y})}function Hd(i){let e=1/0,r=1/0,o=-1/0,l=-1/0;for(const h of i)e=Math.min(e,h.x),r=Math.min(r,h.y),o=Math.max(o,h.x),l=Math.max(l,h.y);return{minX:e,minY:r,maxX:o,maxY:l}}function Vm(i,e){return e-i}function Xd(i,e,r,o,l){const h=[];for(let p=0;p=o&&z.x>=o||(M.x>=o?M=new ge(o,M.y+(o-M.x)/(z.x-M.x)*(z.y-M.y))._round():z.x>=o&&(z=new ge(o,M.y+(o-M.x)/(z.x-M.x)*(z.y-M.y))._round()),M.y>=l&&z.y>=l||(M.y>=l?M=new ge(M.x+(l-M.y)/(z.y-M.y)*(z.x-M.x),l)._round():z.y>=l&&(z=new ge(M.x+(l-M.y)/(z.y-M.y)*(z.x-M.x),l)._round()),w&&M.equals(w[w.length-1])||(w=[M],h.push(w)),w.push(z)))))}}return h}tt("FeatureIndex",Gd,{omit:["rawTileData","sourceLayerCoder"]});class za extends ge{constructor(e,r,o,l){super(e,r),this.angle=o,l!==void 0&&(this.segment=l)}clone(){return new za(this.x,this.y,this.angle,this.segment)}}function Kd(i,e,r,o,l){if(e.segment===void 0||r===0)return!0;let h=e,p=e.segment+1,y=0;for(;y>-r/2;){if(p--,p<0)return!1;y-=i[p].dist(h),h=i[p]}y+=i[p].dist(i[p+1]),p++;const w=[];let T=0;for(;yo;)T-=w.shift().angleDelta;if(T>l)return!1;p++,y+=M.dist(z)}return!0}function Jd(i){let e=0;for(let r=0;rT){const U=(T-w)/N,G=Hr.number(z.x,D.x,U),$=Hr.number(z.y,D.y,U),ie=new za(G,$,D.angleTo(z),M);return ie._round(),!p||Kd(i,ie,y,p,e)?ie:void 0}w+=N}}function jm(i,e,r,o,l,h,p,y,w){const T=Yd(o,h,p),M=Qd(o,l),z=M*p,D=i[0].x===0||i[0].x===w||i[0].y===0||i[0].y===w;return e-z=0&&pe=0&&ye=0&&D+T<=M){const Me=new za(pe,ye,ue,U);Me._round(),o&&!Kd(i,Me,h,o,l)||N.push(Me)}}z+=ie}return y||N.length||p||(N=$d(i,z/2,r,o,l,h,p,!0,w)),N}tt("Anchor",za);const Il=Kn;function ep(i,e,r,o){const l=[],h=i.image,p=h.pixelRatio,y=h.paddedRect.w-2*Il,w=h.paddedRect.h-2*Il,T=i.right-i.left,M=i.bottom-i.top,z=h.stretchX||[[0,y]],D=h.stretchY||[[0,w]],N=(Ge,ht)=>Ge+ht[1]-ht[0],U=z.reduce(N,0),G=D.reduce(N,0),$=y-U,ie=w-G;let ue=0,re=U,pe=0,ye=G,Me=0,lt=$,pt=0,st=ie;if(h.content&&o){const Ge=h.content;ue=ou(z,0,Ge[0]),pe=ou(D,0,Ge[1]),re=ou(z,Ge[0],Ge[2]),ye=ou(D,Ge[1],Ge[3]),Me=Ge[0]-ue,pt=Ge[1]-pe,lt=Ge[2]-Ge[0]-re,st=Ge[3]-Ge[1]-ye}const et=(Ge,ht,Je,Ne)=>{const bt=su(Ge.stretch-ue,re,T,i.left),yt=au(Ge.fixed-Me,lt,Ge.stretch,U),Ht=su(ht.stretch-pe,ye,M,i.top),$i=au(ht.fixed-pt,st,ht.stretch,G),nr=su(Je.stretch-ue,re,T,i.left),Lr=au(Je.fixed-Me,lt,Je.stretch,U),lo=su(Ne.stretch-pe,ye,M,i.top),Fn=au(Ne.fixed-pt,st,Ne.stretch,G),Mr=new ge(bt,Ht),Yr=new ge(nr,Ht),hn=new ge(nr,lo),Rn=new ge(bt,lo),On=new ge(yt/p,$i/p),Dr=new ge(Lr/p,Fn/p),Fr=e*Math.PI/180;if(Fr){const wn=Math.sin(Fr),Jn=Math.cos(Fr),Yn=[Jn,-wn,wn,Jn];Mr._matMult(Yn),Yr._matMult(Yn),Rn._matMult(Yn),hn._matMult(Yn)}const bn=Ge.stretch+Ge.fixed,Bn=ht.stretch+ht.fixed;return{tl:Mr,tr:Yr,bl:Rn,br:hn,tex:{x:h.paddedRect.x+Il+bn,y:h.paddedRect.y+Il+Bn,w:Je.stretch+Je.fixed-bn,h:Ne.stretch+Ne.fixed-Bn},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:On,pixelOffsetBR:Dr,minFontScaleX:lt/p/T,minFontScaleY:st/p/M,isSDF:r}};if(o&&(h.stretchX||h.stretchY)){const Ge=tp(z,$,U),ht=tp(D,ie,G);for(let Je=0;Je0&&(U=Math.max(10,U),this.circleDiameter=U)}else{let z=p.top*y-w[0],D=p.bottom*y+w[2],N=p.left*y-w[3],U=p.right*y+w[1];const G=p.collisionPadding;if(G&&(N-=G[0]*y,z-=G[1]*y,U+=G[2]*y,D+=G[3]*y),M){const $=new ge(N,z),ie=new ge(U,z),ue=new ge(N,D),re=new ge(U,D),pe=M*Math.PI/180;$._rotate(pe),ie._rotate(pe),ue._rotate(pe),re._rotate(pe),N=Math.min($.x,ie.x,ue.x,re.x),U=Math.max($.x,ie.x,ue.x,re.x),z=Math.min($.y,ie.y,ue.y,re.y),D=Math.max($.y,ie.y,ue.y,re.y)}e.emplaceBack(r.x,r.y,N,z,U,D,o,l,h)}this.boxEndIndex=e.length}}class qm{constructor(e=[],r=Zm){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let o=(this.length>>1)-1;o>=0;o--)this._down(o)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:o}=this,l=r[e];for(;e>0;){const h=e-1>>1,p=r[h];if(o(l,p)>=0)break;r[e]=p,e=h}r[e]=l}_down(e){const{data:r,compare:o}=this,l=this.length>>1,h=r[e];for(;e=0)break;r[e]=y,e=p}r[e]=h}}function Zm(i,e){return ie?1:0}function Gm(i,e=1,r=!1){let o=1/0,l=1/0,h=-1/0,p=-1/0;const y=i[0];for(let N=0;Nh)&&(h=U.x),(!N||U.y>p)&&(p=U.y)}const w=Math.min(h-o,p-l);let T=w/2;const M=new qm([],Wm);if(w===0)return new ge(o,l);for(let N=o;Nz.d||!z.d)&&(z=N,r&&console.log("found best %d after %d probes",Math.round(1e4*N.d)/1e4,D)),N.max-z.d<=e||(T=N.h/2,M.push(new El(N.p.x-T,N.p.y-T,T,i)),M.push(new El(N.p.x+T,N.p.y-T,T,i)),M.push(new El(N.p.x-T,N.p.y+T,T,i)),M.push(new El(N.p.x+T,N.p.y+T,T,i)),D+=4)}return r&&(console.log(`num probes: ${D}`),console.log(`best distance: ${z.d}`)),z.p}function Wm(i,e){return e.max-i.max}function El(i,e,r,o){this.p=new ge(i,e),this.h=r,this.d=function(l,h){let p=!1,y=1/0;for(let w=0;wl.y!=U.y>l.y&&l.x<(U.x-N.x)*(l.y-N.y)/(U.y-N.y)+N.x&&(p=!p),y=Math.min(y,Oh(l,N,U))}}return(p?1:-1)*Math.sqrt(y)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}var un;s.aq=void 0,(un=s.aq||(s.aq={}))[un.center=1]="center",un[un.left=2]="left",un[un.right=3]="right",un[un.top=4]="top",un[un.bottom=5]="bottom",un[un["top-left"]=6]="top-left",un[un["top-right"]=7]="top-right",un[un["bottom-left"]=8]="bottom-left",un[un["bottom-right"]=9]="bottom-right";const La=7,th=Number.POSITIVE_INFINITY;function ip(i,e){return e[1]!==th?function(r,o,l){let h=0,p=0;switch(o=Math.abs(o),l=Math.abs(l),r){case"top-right":case"top-left":case"top":p=l-La;break;case"bottom-right":case"bottom-left":case"bottom":p=-l+La}switch(r){case"top-right":case"bottom-right":case"right":h=-o;break;case"top-left":case"bottom-left":case"left":h=o}return[h,p]}(i,e[0],e[1]):function(r,o){let l=0,h=0;o<0&&(o=0);const p=o/Math.SQRT2;switch(r){case"top-right":case"top-left":h=p-La;break;case"bottom-right":case"bottom-left":h=-p+La;break;case"bottom":h=-o+La;break;case"top":h=o-La}switch(r){case"top-right":case"bottom-right":l=-p;break;case"top-left":case"bottom-left":l=p;break;case"left":l=o;break;case"right":l=-o}return[l,h]}(i,e[0])}function rp(i,e,r){var o;const l=i.layout,h=(o=l.get("text-variable-anchor-offset"))===null||o===void 0?void 0:o.evaluate(e,{},r);if(h){const y=h.values,w=[];for(let T=0;TD*zr);M.startsWith("top")?z[1]-=La:M.startsWith("bottom")&&(z[1]+=La),w[T+1]=z}return new Ir(w)}const p=l.get("text-variable-anchor");if(p){let y;y=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(e,{},r)*zr,th]:l.get("text-offset").evaluate(e,{},r).map(T=>T*zr);const w=[];for(const T of p)w.push(T,ip(T,y));return new Ir(w)}return null}function ih(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Hm(i,e,r,o,l,h,p,y,w,T,M){let z=h.textMaxSize.evaluate(e,{});z===void 0&&(z=p);const D=i.layers[0].layout,N=D.get("icon-offset").evaluate(e,{},M),U=op(r.horizontal),G=p/24,$=i.tilePixelRatio*G,ie=i.tilePixelRatio*z/24,ue=i.tilePixelRatio*y,re=i.tilePixelRatio*D.get("symbol-spacing"),pe=D.get("text-padding")*i.tilePixelRatio,ye=function(Ne,bt,yt,Ht=1){const $i=Ne.get("icon-padding").evaluate(bt,{},yt),nr=$i&&$i.values;return[nr[0]*Ht,nr[1]*Ht,nr[2]*Ht,nr[3]*Ht]}(D,e,M,i.tilePixelRatio),Me=D.get("text-max-angle")/180*Math.PI,lt=D.get("text-rotation-alignment")!=="viewport"&&D.get("symbol-placement")!=="point",pt=D.get("icon-rotation-alignment")==="map"&&D.get("symbol-placement")!=="point",st=D.get("symbol-placement"),et=re/2,Ge=D.get("icon-text-fit");let ht;o&&Ge!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(ht=Cd(o,r.vertical,Ge,D.get("icon-text-fit-padding"),N,G)),U&&(o=Cd(o,U,Ge,D.get("icon-text-fit-padding"),N,G)));const Je=(Ne,bt)=>{bt.x<0||bt.x>=Cr||bt.y<0||bt.y>=Cr||function(yt,Ht,$i,nr,Lr,lo,Fn,Mr,Yr,hn,Rn,On,Dr,Fr,bn,Bn,wn,Jn,Yn,Rr,oi,Sn,dn,Or,No){const Qo=yt.addToLineVertexArray(Ht,$i);let $o,Zs,Vo,vo,Qn=0,Gs=0,_c=0,cp=0,uh=-1,hh=-1;const Ws={};let up=Vs("");if(yt.allowVerticalPlacement&&nr.vertical){const Tn=Mr.layout.get("text-rotate").evaluate(oi,{},Or)+90;Vo=new lu(Yr,Ht,hn,Rn,On,nr.vertical,Dr,Fr,bn,Tn),Fn&&(vo=new lu(Yr,Ht,hn,Rn,On,Fn,wn,Jn,bn,Tn))}if(Lr){const Tn=Mr.layout.get("icon-rotate").evaluate(oi,{}),xo=Mr.layout.get("icon-text-fit")!=="none",tl=ep(Lr,Tn,dn,xo),ts=Fn?ep(Fn,Tn,dn,xo):void 0;Zs=new lu(Yr,Ht,hn,Rn,On,Lr,wn,Jn,!1,Tn),Qn=4*tl.length;const il=yt.iconSizeData;let ys=null;il.kind==="source"?(ys=[gs*Mr.layout.get("icon-size").evaluate(oi,{})],ys[0]>ka&&Dt(`${yt.layerIds[0]}: Value for "icon-size" is >= ${dc}. Reduce your "icon-size".`)):il.kind==="composite"&&(ys=[gs*Sn.compositeIconSizes[0].evaluate(oi,{},Or),gs*Sn.compositeIconSizes[1].evaluate(oi,{},Or)],(ys[0]>ka||ys[1]>ka)&&Dt(`${yt.layerIds[0]}: Value for "icon-size" is >= ${dc}. Reduce your "icon-size".`)),yt.addSymbols(yt.icon,tl,ys,Rr,Yn,oi,s.ai.none,Ht,Qo.lineStartIndex,Qo.lineLength,-1,Or),uh=yt.icon.placedSymbolArray.length-1,ts&&(Gs=4*ts.length,yt.addSymbols(yt.icon,ts,ys,Rr,Yn,oi,s.ai.vertical,Ht,Qo.lineStartIndex,Qo.lineLength,-1,Or),hh=yt.icon.placedSymbolArray.length-1)}const hp=Object.keys(nr.horizontal);for(const Tn of hp){const xo=nr.horizontal[Tn];if(!$o){up=Vs(xo.text);const ts=Mr.layout.get("text-rotate").evaluate(oi,{},Or);$o=new lu(Yr,Ht,hn,Rn,On,xo,Dr,Fr,bn,ts)}const tl=xo.positionedLines.length===1;if(_c+=np(yt,Ht,xo,lo,Mr,bn,oi,Bn,Qo,nr.vertical?s.ai.horizontal:s.ai.horizontalOnly,tl?hp:[Tn],Ws,uh,Sn,Or),tl)break}nr.vertical&&(cp+=np(yt,Ht,nr.vertical,lo,Mr,bn,oi,Bn,Qo,s.ai.vertical,["vertical"],Ws,hh,Sn,Or));const Jm=$o?$o.boxStartIndex:yt.collisionBoxArray.length,Ym=$o?$o.boxEndIndex:yt.collisionBoxArray.length,Qm=Vo?Vo.boxStartIndex:yt.collisionBoxArray.length,$m=Vo?Vo.boxEndIndex:yt.collisionBoxArray.length,e_=Zs?Zs.boxStartIndex:yt.collisionBoxArray.length,t_=Zs?Zs.boxEndIndex:yt.collisionBoxArray.length,i_=vo?vo.boxStartIndex:yt.collisionBoxArray.length,r_=vo?vo.boxEndIndex:yt.collisionBoxArray.length;let es=-1;const uu=(Tn,xo)=>Tn&&Tn.circleDiameter?Math.max(Tn.circleDiameter,xo):xo;es=uu($o,es),es=uu(Vo,es),es=uu(Zs,es),es=uu(vo,es);const dp=es>-1?1:0;dp&&(es*=No/zr),yt.glyphOffsetArray.length>=Tl.MAX_GLYPHS&&Dt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),oi.sortKey!==void 0&&yt.addToSortKeyRanges(yt.symbolInstances.length,oi.sortKey);const n_=rp(Mr,oi,Or),[o_,s_]=function(Tn,xo){const tl=Tn.length,ts=xo==null?void 0:xo.values;if((ts==null?void 0:ts.length)>0)for(let il=0;il=0?Ws.right:-1,Ws.center>=0?Ws.center:-1,Ws.left>=0?Ws.left:-1,Ws.vertical||-1,uh,hh,up,Jm,Ym,Qm,$m,e_,t_,i_,r_,hn,_c,cp,Qn,Gs,dp,0,Dr,es,o_,s_)}(i,bt,Ne,r,o,l,ht,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,$,[pe,pe,pe,pe],lt,w,ue,ye,pt,N,e,h,T,M,p)};if(st==="line")for(const Ne of Xd(e.geometry,0,0,Cr,Cr)){const bt=jm(Ne,re,Me,r.vertical||U,o,24,ie,i.overscaling,Cr);for(const yt of bt)U&&Xm(i,U.text,et,yt)||Je(Ne,yt)}else if(st==="line-center"){for(const Ne of e.geometry)if(Ne.length>1){const bt=Um(Ne,Me,r.vertical||U,o,24,ie);bt&&Je(Ne,bt)}}else if(e.type==="Polygon")for(const Ne of Du(e.geometry,0)){const bt=Gm(Ne,16);Je(Ne[0],new za(bt.x,bt.y,0))}else if(e.type==="LineString")for(const Ne of e.geometry)Je(Ne,new za(Ne[0].x,Ne[0].y,0));else if(e.type==="Point")for(const Ne of e.geometry)for(const bt of Ne)Je([bt],new za(bt.x,bt.y,0))}function np(i,e,r,o,l,h,p,y,w,T,M,z,D,N,U){const G=function(ue,re,pe,ye,Me,lt,pt,st){const et=ye.layout.get("text-rotate").evaluate(lt,{})*Math.PI/180,Ge=[];for(const ht of re.positionedLines)for(const Je of ht.positionedGlyphs){if(!Je.rect)continue;const Ne=Je.rect||{};let bt=xd+1,yt=!0,Ht=1,$i=0;const nr=(Me||st)&&Je.vertical,Lr=Je.metrics.advance*Je.scale/2;if(st&&re.verticalizable&&($i=ht.lineOffset/2-(Je.imageName?-(zr-Je.metrics.width*Je.scale)/2:(Je.scale-1)*zr)),Je.imageName){const Rr=pt[Je.imageName];yt=Rr.sdf,Ht=Rr.pixelRatio,bt=Kn/Ht}const lo=Me?[Je.x+Lr,Je.y]:[0,0];let Fn=Me?[0,0]:[Je.x+Lr+pe[0],Je.y+pe[1]-$i],Mr=[0,0];nr&&(Mr=Fn,Fn=[0,0]);const Yr=Je.metrics.isDoubleResolution?2:1,hn=(Je.metrics.left-bt)*Je.scale-Lr+Fn[0],Rn=(-Je.metrics.top-bt)*Je.scale+Fn[1],On=hn+Ne.w/Yr*Je.scale/Ht,Dr=Rn+Ne.h/Yr*Je.scale/Ht,Fr=new ge(hn,Rn),bn=new ge(On,Rn),Bn=new ge(hn,Dr),wn=new ge(On,Dr);if(nr){const Rr=new ge(-Lr,Lr-uc),oi=-Math.PI/2,Sn=zr/2-Lr,dn=new ge(5-uc-Sn,-(Je.imageName?Sn:0)),Or=new ge(...Mr);Fr._rotateAround(oi,Rr)._add(dn)._add(Or),bn._rotateAround(oi,Rr)._add(dn)._add(Or),Bn._rotateAround(oi,Rr)._add(dn)._add(Or),wn._rotateAround(oi,Rr)._add(dn)._add(Or)}if(et){const Rr=Math.sin(et),oi=Math.cos(et),Sn=[oi,-Rr,Rr,oi];Fr._matMult(Sn),bn._matMult(Sn),Bn._matMult(Sn),wn._matMult(Sn)}const Jn=new ge(0,0),Yn=new ge(0,0);Ge.push({tl:Fr,tr:bn,bl:Bn,br:wn,tex:Ne,writingMode:re.writingMode,glyphOffset:lo,sectionIndex:Je.sectionIndex,isSDF:yt,pixelOffsetTL:Jn,pixelOffsetBR:Yn,minFontScaleX:0,minFontScaleY:0})}return Ge}(0,r,y,l,h,p,o,i.allowVerticalPlacement),$=i.textSizeData;let ie=null;$.kind==="source"?(ie=[gs*l.layout.get("text-size").evaluate(p,{})],ie[0]>ka&&Dt(`${i.layerIds[0]}: Value for "text-size" is >= ${dc}. Reduce your "text-size".`)):$.kind==="composite"&&(ie=[gs*N.compositeTextSizes[0].evaluate(p,{},U),gs*N.compositeTextSizes[1].evaluate(p,{},U)],(ie[0]>ka||ie[1]>ka)&&Dt(`${i.layerIds[0]}: Value for "text-size" is >= ${dc}. Reduce your "text-size".`)),i.addSymbols(i.text,G,ie,y,h,p,T,e,w.lineStartIndex,w.lineLength,D,U);for(const ue of M)z[ue]=i.text.placedSymbolArray.length-1;return 4*G.length}function op(i){for(const e in i)return i[e];return null}function Xm(i,e,r,o){const l=i.compareText;if(e in l){const h=l[e];for(let p=h.length-1;p>=0;p--)if(o.dist(h[p])>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);const h=sp[15&o];if(!h)throw new Error("Unrecognized array type.");const[p]=new Uint16Array(e,2,1),[y]=new Uint32Array(e,4,1);return new rh(y,p,h,e)}constructor(e,r=64,o=Float64Array,l){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=o,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const h=sp.indexOf(this.ArrayType),p=2*e*this.ArrayType.BYTES_PER_ELEMENT,y=e*this.IndexArrayType.BYTES_PER_ELEMENT,w=(8-y%8)%8;if(h<0)throw new Error(`Unexpected typed array class: ${o}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+y+w,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+p+y+w),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+y+w,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+h]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const o=this._pos>>1;return this.ids[o]=o,this.coords[this._pos++]=e,this.coords[this._pos++]=r,o}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return nh(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,o,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:h,coords:p,nodeSize:y}=this,w=[0,h.length-1,0],T=[];for(;w.length;){const M=w.pop()||0,z=w.pop()||0,D=w.pop()||0;if(z-D<=y){for(let $=D;$<=z;$++){const ie=p[2*$],ue=p[2*$+1];ie>=e&&ie<=o&&ue>=r&&ue<=l&&T.push(h[$])}continue}const N=D+z>>1,U=p[2*N],G=p[2*N+1];U>=e&&U<=o&&G>=r&&G<=l&&T.push(h[N]),(M===0?e<=U:r<=G)&&(w.push(D),w.push(N-1),w.push(1-M)),(M===0?o>=U:l>=G)&&(w.push(N+1),w.push(z),w.push(1-M))}return T}within(e,r,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:h,nodeSize:p}=this,y=[0,l.length-1,0],w=[],T=o*o;for(;y.length;){const M=y.pop()||0,z=y.pop()||0,D=y.pop()||0;if(z-D<=p){for(let $=D;$<=z;$++)lp(h[2*$],h[2*$+1],e,r)<=T&&w.push(l[$]);continue}const N=D+z>>1,U=h[2*N],G=h[2*N+1];lp(U,G,e,r)<=T&&w.push(l[N]),(M===0?e-o<=U:r-o<=G)&&(y.push(D),y.push(N-1),y.push(1-M)),(M===0?e+o>=U:r+o>=G)&&(y.push(N+1),y.push(z),y.push(1-M))}return w}}function nh(i,e,r,o,l,h){if(l-o<=r)return;const p=o+l>>1;ap(i,e,p,o,l,h),nh(i,e,r,o,p-1,1-h),nh(i,e,r,p+1,l,1-h)}function ap(i,e,r,o,l,h){for(;l>o;){if(l-o>600){const T=l-o+1,M=r-o+1,z=Math.log(T),D=.5*Math.exp(2*z/3),N=.5*Math.sqrt(z*D*(T-D)/T)*(M-T/2<0?-1:1);ap(i,e,r,Math.max(o,Math.floor(r-M*D/T+N)),Math.min(l,Math.floor(r+(T-M)*D/T+N)),h)}const p=e[2*r+h];let y=o,w=l;for(fc(i,e,o,r),e[2*l+h]>p&&fc(i,e,o,l);yp;)w--}e[2*o+h]===p?fc(i,e,o,w):(w++,fc(i,e,w,l)),w<=r&&(o=w+1),r<=w&&(l=w-1)}}function fc(i,e,r,o){oh(i,r,o),oh(e,2*r,2*o),oh(e,2*r+1,2*o+1)}function oh(i,e,r){const o=i[e];i[e]=i[r],i[r]=o}function lp(i,e,r,o){const l=i-r,h=e-o;return l*l+h*h}var sh;s.bh=void 0,(sh=s.bh||(s.bh={})).create="create",sh.load="load",sh.fullLoad="fullLoad";let cu=null,mc=[];const ah=1e3/60,lh="loadTime",ch="fullLoadTime",Km={mark(i){performance.mark(i)},frame(i){const e=i;cu!=null&&mc.push(e-cu),cu=e},clearMetrics(){cu=null,mc=[],performance.clearMeasures(lh),performance.clearMeasures(ch);for(const i in s.bh)performance.clearMarks(s.bh[i])},getPerformanceMetrics(){performance.measure(lh,s.bh.create,s.bh.load),performance.measure(ch,s.bh.create,s.bh.fullLoad);const i=performance.getEntriesByName(lh)[0].duration,e=performance.getEntriesByName(ch)[0].duration,r=mc.length,o=1/(mc.reduce((h,p)=>h+p,0)/r/1e3),l=mc.filter(h=>h>ah).reduce((h,p)=>h+(p-ah)/ah,0);return{loadTime:i,fullLoadTime:e,fps:o,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};s.$=function(i,e,r){var o,l,h,p,y,w,T,M,z,D,N,U,G=r[0],$=r[1],ie=r[2];return e===i?(i[12]=e[0]*G+e[4]*$+e[8]*ie+e[12],i[13]=e[1]*G+e[5]*$+e[9]*ie+e[13],i[14]=e[2]*G+e[6]*$+e[10]*ie+e[14],i[15]=e[3]*G+e[7]*$+e[11]*ie+e[15]):(l=e[1],h=e[2],p=e[3],y=e[4],w=e[5],T=e[6],M=e[7],z=e[8],D=e[9],N=e[10],U=e[11],i[0]=o=e[0],i[1]=l,i[2]=h,i[3]=p,i[4]=y,i[5]=w,i[6]=T,i[7]=M,i[8]=z,i[9]=D,i[10]=N,i[11]=U,i[12]=o*G+y*$+z*ie+e[12],i[13]=l*G+w*$+D*ie+e[13],i[14]=h*G+T*$+N*ie+e[14],i[15]=p*G+M*$+U*ie+e[15]),i},s.A=yl,s.B=Hr,s.C=class{constructor(i,e,r){this.receive=o=>{const l=o.data,h=l.id;if(h&&(!l.targetMapId||this.mapId===l.targetMapId))if(l.type===""){delete this.tasks[h];const p=this.cancelCallbacks[h];delete this.cancelCallbacks[h],p&&p()}else fi()||l.mustQueue?(this.tasks[h]=l,this.taskQueue.push(h),this.invoker.trigger()):this.processTask(h,l)},this.process=()=>{if(!this.taskQueue.length)return;const o=this.taskQueue.shift(),l=this.tasks[o];delete this.tasks[o],this.taskQueue.length&&this.invoker.trigger(),l&&this.processTask(o,l)},this.target=i,this.parent=e,this.mapId=r,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},this.invoker=new Nm(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=fi()?i:window}send(i,e,r,o,l=!1){const h=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(this.callbacks[h]=r);const p=[],y={id:h,type:i,hasCallback:!!r,targetMapId:o,mustQueue:l,sourceMapId:this.mapId,data:Pn(e,p)};return this.target.postMessage(y,{transfer:p}),{cancel:()=>{r&&delete this.callbacks[h],this.target.postMessage({id:h,type:"",targetMapId:o,sourceMapId:this.mapId})}}}processTask(i,e){if(e.type===""){const r=this.callbacks[i];delete this.callbacks[i],r&&(e.error?r(_o(e.error)):r(null,_o(e.data)))}else{let r=!1;const o=[],l=e.hasCallback?(y,w)=>{r=!0,delete this.cancelCallbacks[i];const T={id:i,type:"",sourceMapId:this.mapId,error:y?Pn(y):null,data:Pn(w,o)};this.target.postMessage(T,{transfer:o})}:y=>{r=!0};let h=null;const p=_o(e.data);if(this.parent[e.type])h=this.parent[e.type](e.sourceMapId,p,l);else if("getWorkerSource"in this.parent){const y=e.type.split(".");h=this.parent.getWorkerSource(e.sourceMapId,y[0],p.source)[y[1]](p,l)}else l(new Error(`Could not find function ${e.type}`));!r&&h&&h.cancel&&(this.cancelCallbacks[i]=h.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},s.D=xt,s.E=jo,s.F=function(i,e){const r={};for(let o=0;o{}}},s.Y=Ze,s.Z=function(){var i=new yl(16);return yl!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},s._=Z,s.a=en,s.a$=class extends O{},s.a0=function(i,e,r){var o=r[0],l=r[1],h=r[2];return i[0]=e[0]*o,i[1]=e[1]*o,i[2]=e[2]*o,i[3]=e[3]*o,i[4]=e[4]*l,i[5]=e[5]*l,i[6]=e[6]*l,i[7]=e[7]*l,i[8]=e[8]*h,i[9]=e[9]*h,i[10]=e[10]*h,i[11]=e[11]*h,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},s.a1=Uh,s.a2=function(){return Yt++},s.a3=K,s.a4=Tl,s.a5=function(){Hn.isLoading()||Hn.isLoaded()||ql()!=="deferred"||Oc()},s.a6=ga,s.a7=$a,s.a8=Yi,s.a9=Zd,s.aA=Ha,s.aB=function(i){i=i.slice();const e=Object.create(null);for(let r=0;r{o[p.source]?r.push({command:ii.removeLayer,args:[p.id]}):h.push(p)}),r=r.concat(l),function(p,y,w){y=y||[];const T=(p=p||[]).map(Cn),M=y.map(Cn),z=p.reduce($n,{}),D=y.reduce($n,{}),N=T.slice(),U=Object.create(null);let G,$,ie,ue,re,pe,ye;for(G=0,$=0;G@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,o,l,h)=>{const p=l||h;return e[o]=!p||p.toLowerCase(),""}),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},s.ab=function(i,e){const r=[];for(const o in i)o in e||r.push(o);return r},s.ac=function(i){if(Pi==null){const e=i.navigator?i.navigator.userAgent:null;Pi=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Pi},s.ad=ti,s.ae=function(i,e,r){var o=Math.sin(r),l=Math.cos(r),h=e[0],p=e[1],y=e[2],w=e[3],T=e[4],M=e[5],z=e[6],D=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=h*l+T*o,i[1]=p*l+M*o,i[2]=y*l+z*o,i[3]=w*l+D*o,i[4]=T*l-h*o,i[5]=M*l-p*o,i[6]=z*l-y*o,i[7]=D*l-w*o,i},s.af=function(i){var e=new yl(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},s.ag=Hc,s.ah=function(i,e){let r=0,o=0;if(i.kind==="constant")o=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:l,minZoom:h,maxZoom:p}=i,y=l?ti(sn.interpolationFactor(l,e,h,p),0,1):0;i.kind==="camera"?o=Hr.number(i.minSize,i.maxSize,y):r=y}return{uSizeT:r,uSize:o}},s.aj=function(i,{uSize:e,uSizeT:r},{lowerSize:o,upperSize:l}){return i.kind==="source"?o/gs:i.kind==="composite"?Hr.number(o/gs,l/gs,r):e},s.ak=Xu,s.al=function(i,e,r,o){const l=e.y-i.y,h=e.x-i.x,p=o.y-r.y,y=o.x-r.x,w=p*h-y*l;if(w===0)return null;const T=(y*(i.y-r.y)-p*(i.x-r.x))/w;return new ge(i.x+T*h,i.y+T*l)},s.am=Xd,s.an=Fh,s.ao=Cu,s.ap=zr,s.ar=Hu,s.as=function(i,e){var r=e[0],o=e[1],l=e[2],h=e[3],p=e[4],y=e[5],w=e[6],T=e[7],M=e[8],z=e[9],D=e[10],N=e[11],U=e[12],G=e[13],$=e[14],ie=e[15],ue=r*y-o*p,re=r*w-l*p,pe=r*T-h*p,ye=o*w-l*y,Me=o*T-h*y,lt=l*T-h*w,pt=M*G-z*U,st=M*$-D*U,et=M*ie-N*U,Ge=z*$-D*G,ht=z*ie-N*G,Je=D*ie-N*$,Ne=ue*Je-re*ht+pe*Ge+ye*et-Me*st+lt*pt;return Ne?(i[0]=(y*Je-w*ht+T*Ge)*(Ne=1/Ne),i[1]=(l*ht-o*Je-h*Ge)*Ne,i[2]=(G*lt-$*Me+ie*ye)*Ne,i[3]=(D*Me-z*lt-N*ye)*Ne,i[4]=(w*et-p*Je-T*st)*Ne,i[5]=(r*Je-l*et+h*st)*Ne,i[6]=($*pe-U*lt-ie*re)*Ne,i[7]=(M*lt-D*pe+N*re)*Ne,i[8]=(p*ht-y*et+T*pt)*Ne,i[9]=(o*et-r*ht-h*pt)*Ne,i[10]=(U*Me-G*pe+ie*ue)*Ne,i[11]=(z*pe-M*Me-N*ue)*Ne,i[12]=(y*st-p*Ge-w*pt)*Ne,i[13]=(r*Ge-o*st+l*pt)*Ne,i[14]=(G*re-U*ye-$*ue)*Ne,i[15]=(M*ye-z*re+D*ue)*Ne,i):null},s.at=ih,s.au=Wu,s.av=rh,s.aw=function(){const i={},e=Se.$version;for(const r in Se.$root){const o=Se.$root[r];if(o.required){let l=null;l=r==="version"?e:o.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},s.ax=ii,s.ay=Jo,s.az=Gt,s.b=function(i,e){const r=new Blob([new Uint8Array(i)],{type:"image/png"});createImageBitmap(r).then(o=>{e(null,o)}).catch(o=>{e(new Error(`Could not load image because of ${o.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})},s.b0=Kr,s.b1=function(i,e){var r=i[0],o=i[1],l=i[2],h=i[3],p=i[4],y=i[5],w=i[6],T=i[7],M=i[8],z=i[9],D=i[10],N=i[11],U=i[12],G=i[13],$=i[14],ie=i[15],ue=e[0],re=e[1],pe=e[2],ye=e[3],Me=e[4],lt=e[5],pt=e[6],st=e[7],et=e[8],Ge=e[9],ht=e[10],Je=e[11],Ne=e[12],bt=e[13],yt=e[14],Ht=e[15];return Math.abs(r-ue)<=Dn*Math.max(1,Math.abs(r),Math.abs(ue))&&Math.abs(o-re)<=Dn*Math.max(1,Math.abs(o),Math.abs(re))&&Math.abs(l-pe)<=Dn*Math.max(1,Math.abs(l),Math.abs(pe))&&Math.abs(h-ye)<=Dn*Math.max(1,Math.abs(h),Math.abs(ye))&&Math.abs(p-Me)<=Dn*Math.max(1,Math.abs(p),Math.abs(Me))&&Math.abs(y-lt)<=Dn*Math.max(1,Math.abs(y),Math.abs(lt))&&Math.abs(w-pt)<=Dn*Math.max(1,Math.abs(w),Math.abs(pt))&&Math.abs(T-st)<=Dn*Math.max(1,Math.abs(T),Math.abs(st))&&Math.abs(M-et)<=Dn*Math.max(1,Math.abs(M),Math.abs(et))&&Math.abs(z-Ge)<=Dn*Math.max(1,Math.abs(z),Math.abs(Ge))&&Math.abs(D-ht)<=Dn*Math.max(1,Math.abs(D),Math.abs(ht))&&Math.abs(N-Je)<=Dn*Math.max(1,Math.abs(N),Math.abs(Je))&&Math.abs(U-Ne)<=Dn*Math.max(1,Math.abs(U),Math.abs(Ne))&&Math.abs(G-bt)<=Dn*Math.max(1,Math.abs(G),Math.abs(bt))&&Math.abs($-yt)<=Dn*Math.max(1,Math.abs($),Math.abs(yt))&&Math.abs(ie-Ht)<=Dn*Math.max(1,Math.abs(ie),Math.abs(Ht))},s.b2=function(i,e){return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},s.b3=function(i,e,r){return i[0]=e[0]*r[0],i[1]=e[1]*r[1],i[2]=e[2]*r[2],i[3]=e[3]*r[3],i},s.b4=function(i,e){return i[0]*e[0]+i[1]*e[1]+i[2]*e[2]+i[3]*e[3]},s.b5=Xt,s.b6=Ud,s.b7=Bd,s.b8=function(i,e,r,o,l){var h,p=1/Math.tan(e/2);return i[0]=p/r,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=p,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=-1,i[12]=0,i[13]=0,i[15]=0,l!=null&&l!==1/0?(i[10]=(l+o)*(h=1/(o-l)),i[14]=2*l*o*h):(i[10]=-1,i[14]=-2*o),i},s.b9=function(i,e,r){var o=Math.sin(r),l=Math.cos(r),h=e[4],p=e[5],y=e[6],w=e[7],T=e[8],M=e[9],z=e[10],D=e[11];return e!==i&&(i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[4]=h*l+T*o,i[5]=p*l+M*o,i[6]=y*l+z*o,i[7]=w*l+D*o,i[8]=T*l-h*o,i[9]=M*l-p*o,i[10]=z*l-y*o,i[11]=D*l-w*o,i},s.bA=me,s.bB=pd,s.bC=ma,s.bD=Hn,s.ba=it,s.bb=Vt,s.bc=function(i,e){return i[0]=e[0],i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=e[1],i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=e[2],i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,i},s.bd=class extends Ya{},s.be=Qu,s.bf=Nd,s.bg=Km,s.bi=Xe,s.bj=function(i,e,r=!1){if(zn===Bl||zn===Nl||zn===Vl)throw new Error("setRTLTextPlugin cannot be called multiple times.");ms=Fe.resolveURL(i),zn=Bl,Ul=e,jl(),r||Oc()},s.bk=ql,s.bl=function(i,e){const r={};for(let l=0;lNe*zr)}let st=p?"center":r.get("text-justify").evaluate(T,{},i.canonical);const et=r.get("symbol-placement"),Ge=et==="point"?r.get("text-max-width").evaluate(T,{},i.canonical)*zr:0,ht=()=>{i.bucket.allowVerticalPlacement&&Sa(pe)&&(U.vertical=eu(G,i.glyphMap,i.glyphPositions,i.imagePositions,M,Ge,h,lt,"left",Me,ie,s.ai.vertical,!0,et,D,z))};if(!p&&pt){const Je=new Set;if(st==="auto")for(let bt=0;bt{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>{r.src=Vr})},r.onerror=()=>e(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new Blob([new Uint8Array(i)],{type:"image/png"});r.src=i.byteLength?URL.createObjectURL(o):Vr},s.e=Nt,s.f=function(i,e){return gr(Nt(i,{type:"json"}),e)},s.g=ct,s.h=Fe,s.i=fi,s.j=wo,s.k=co,s.l=je,s.m=gr,s.n=function(i){return new ju(i).readFields(Tm,[])},s.o=function(i,e,r){if(!i.length)return r(null,[]);let o=i.length;const l=new Array(i.length);let h=null;i.forEach((p,y)=>{e(p,(w,T)=>{w&&(h=w),l[y]=T,--o==0&&r(h,l)})})},s.p=bd,s.q=ic,s.r=br,s.s=Bi,s.t=Li,s.u=Ke,s.v=Se,s.w=Dt,s.x=Gn,s.y=mo,s.z=function([i,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(e)*Math.sin(r),y:i*Math.sin(e)*Math.sin(r),z:i*Math.cos(r)}}}),k(["./shared"],function(s){class Z{constructor(L){this.keyCache={},L&&this.replace(L)}replace(L){this._layerConfigs={},this._layers={},this.update(L,[])}update(L,R){for(const J of L){this._layerConfigs[J.id]=J;const Q=this._layers[J.id]=s.aC(J);Q._featureFilter=s.a6(Q.filter),this.keyCache[J.id]&&delete this.keyCache[J.id]}for(const J of R)delete this.keyCache[J],delete this._layerConfigs[J],delete this._layers[J];this.familiesBySource={};const j=s.bl(Object.values(this._layerConfigs),this.keyCache);for(const J of j){const Q=J.map(Ie=>this._layers[Ie.id]),he=Q[0];if(he.visibility==="none")continue;const oe=he.source||"";let te=this.familiesBySource[oe];te||(te=this.familiesBySource[oe]={});const ae=he.sourceLayer||"_geojsonTileLayer";let Te=te[ae];Te||(Te=te[ae]=[]),Te.push(Q)}}}class V{constructor(L){const R={},j=[];for(const oe in L){const te=L[oe],ae=R[oe]={};for(const Te in te){const Ie=te[+Te];if(!Ie||Ie.bitmap.width===0||Ie.bitmap.height===0)continue;const Ee={x:0,y:0,w:Ie.bitmap.width+2,h:Ie.bitmap.height+2};j.push(Ee),ae[Te]={rect:Ee,metrics:Ie.metrics}}}const{w:J,h:Q}=s.p(j),he=new s.q({width:J||1,height:Q||1});for(const oe in L){const te=L[oe];for(const ae in te){const Te=te[+ae];if(!Te||Te.bitmap.width===0||Te.bitmap.height===0)continue;const Ie=R[oe][ae].rect;s.q.copy(Te.bitmap,he,{x:0,y:0},{x:Ie.x+1,y:Ie.y+1},Te.bitmap)}}this.image=he,this.positions=R}}s.bm("GlyphAtlas",V);class me{constructor(L){this.tileID=new s.O(L.tileID.overscaledZ,L.tileID.wrap,L.tileID.canonical.z,L.tileID.canonical.x,L.tileID.canonical.y),this.uid=L.uid,this.zoom=L.zoom,this.pixelRatio=L.pixelRatio,this.tileSize=L.tileSize,this.source=L.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=L.showCollisionBoxes,this.collectResourceTiming=!!L.collectResourceTiming,this.returnDependencies=!!L.returnDependencies,this.promoteId=L.promoteId,this.inFlightDependencies=[],this.dependencySentinel=-1}parse(L,R,j,J,Q){this.status="parsing",this.data=L,this.collisionBoxArray=new s.a3;const he=new s.bn(Object.keys(L.layers).sort()),oe=new s.bo(this.tileID,this.promoteId);oe.bucketLayerIDs=[];const te={},ae={featureIndex:oe,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:j},Te=R.familiesBySource[this.source];for(const ai in Te){const ri=L.layers[ai];if(!ri)continue;ri.version===1&&s.w(`Vector tile source "${this.source}" layer "${ai}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const jr=he.encode(ai),Ei=[];for(let hr=0;hr=vr.maxzoom||vr.visibility!=="none"&&(be(hr,this.zoom,j),(te[vr.id]=vr.createBucket({index:oe.bucketLayerIDs.length,layers:hr,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:jr,sourceID:this.source})).populate(Ei,ae,this.tileID.canonical),oe.bucketLayerIDs.push(hr.map(An=>An.id)))}}let Ie,Ee,mt,kt;const ut=s.aH(ae.glyphDependencies,ai=>Object.keys(ai).map(Number));this.inFlightDependencies.forEach(ai=>ai==null?void 0:ai.cancel()),this.inFlightDependencies=[];const vt=++this.dependencySentinel;Object.keys(ut).length?this.inFlightDependencies.push(J.send("getGlyphs",{uid:this.uid,stacks:ut,source:this.source,tileID:this.tileID,type:"glyphs"},(ai,ri)=>{vt===this.dependencySentinel&&(Ie||(Ie=ai,Ee=ri,Ut.call(this)))})):Ee={};const Ft=Object.keys(ae.iconDependencies);Ft.length?this.inFlightDependencies.push(J.send("getImages",{icons:Ft,source:this.source,tileID:this.tileID,type:"icons"},(ai,ri)=>{vt===this.dependencySentinel&&(Ie||(Ie=ai,mt=ri,Ut.call(this)))})):mt={};const gi=Object.keys(ae.patternDependencies);function Ut(){if(Ie)return Q(Ie);if(Ee&&mt&&kt){const ai=new V(Ee),ri=new s.bp(mt,kt);for(const jr in te){const Ei=te[jr];Ei instanceof s.a4?(be(Ei.layers,this.zoom,j),s.bq({bucket:Ei,glyphMap:Ee,glyphPositions:ai.positions,imageMap:mt,imagePositions:ri.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):Ei.hasPattern&&(Ei instanceof s.br||Ei instanceof s.bs||Ei instanceof s.bt)&&(be(Ei.layers,this.zoom,j),Ei.addFeatures(ae,this.tileID.canonical,ri.patternPositions))}this.status="done",Q(null,{buckets:Object.values(te).filter(jr=>!jr.isEmpty()),featureIndex:oe,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ai.image,imageAtlas:ri,glyphMap:this.returnDependencies?Ee:null,iconMap:this.returnDependencies?mt:null,glyphPositions:this.returnDependencies?ai.positions:null})}}gi.length?this.inFlightDependencies.push(J.send("getImages",{icons:gi,source:this.source,tileID:this.tileID,type:"patterns"},(ai,ri)=>{vt===this.dependencySentinel&&(Ie||(Ie=ai,kt=ri,Ut.call(this)))})):kt={},Ut.call(this)}}function be(X,L,R){const j=new s.a8(L);for(const J of X)J.recalculate(j,R)}function ge(X,L){const R=s.l(X.request,(j,J,Q,he)=>{if(j)L(j);else if(J)try{const oe=new s.bw.VectorTile(new s.bv(J));L(null,{vectorTile:oe,rawData:J,cacheControl:Q,expires:he})}catch(oe){const te=new Uint8Array(J);let ae=`Unable to parse the tile at ${X.request.url}, `;ae+=te[0]===31&&te[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${oe.messge}`,L(new Error(ae))}});return()=>{R.cancel(),L()}}class Oe{constructor(L,R,j,J){this.actor=L,this.layerIndex=R,this.availableImages=j,this.loadVectorData=J||ge,this.fetching={},this.loading={},this.loaded={}}loadTile(L,R){const j=L.uid;this.loading||(this.loading={});const J=!!(L&&L.request&&L.request.collectResourceTiming)&&new s.bu(L.request),Q=this.loading[j]=new me(L);Q.abort=this.loadVectorData(L,(he,oe)=>{if(delete this.loading[j],he||!oe)return Q.status="done",this.loaded[j]=Q,R(he);const te=oe.rawData,ae={};oe.expires&&(ae.expires=oe.expires),oe.cacheControl&&(ae.cacheControl=oe.cacheControl);const Te={};if(J){const Ie=J.finish();Ie&&(Te.resourceTiming=JSON.parse(JSON.stringify(Ie)))}Q.vectorTile=oe.vectorTile,Q.parse(oe.vectorTile,this.layerIndex,this.availableImages,this.actor,(Ie,Ee)=>{if(delete this.fetching[j],Ie||!Ee)return R(Ie);R(null,s.e({rawTileData:te.slice(0)},Ee,ae,Te))}),this.loaded=this.loaded||{},this.loaded[j]=Q,this.fetching[j]={rawTileData:te,cacheControl:ae,resourceTiming:Te}})}reloadTile(L,R){const j=this.loaded,J=L.uid;if(j&&j[J]){const Q=j[J];Q.showCollisionBoxes=L.showCollisionBoxes,Q.status==="parsing"?Q.parse(Q.vectorTile,this.layerIndex,this.availableImages,this.actor,(he,oe)=>{if(he||!oe)return R(he,oe);let te;if(this.fetching[J]){const{rawTileData:ae,cacheControl:Te,resourceTiming:Ie}=this.fetching[J];delete this.fetching[J],te=s.e({rawTileData:ae.slice(0)},oe,Te,Ie)}else te=oe;R(null,te)}):Q.status==="done"&&(Q.vectorTile?Q.parse(Q.vectorTile,this.layerIndex,this.availableImages,this.actor,R):R())}}abortTile(L,R){const j=this.loading,J=L.uid;j&&j[J]&&j[J].abort&&(j[J].abort(),delete j[J]),R()}removeTile(L,R){const j=this.loaded,J=L.uid;j&&j[J]&&delete j[J],R()}}class ke{constructor(){this.loaded={}}loadTile(L,R){return s._(this,void 0,void 0,function*(){const{uid:j,encoding:J,rawImageData:Q,redFactor:he,greenFactor:oe,blueFactor:te,baseShift:ae}=L,Te=Q.width+2,Ie=Q.height+2,Ee=s.a(Q)?new s.R({width:Te,height:Ie},yield s.bx(Q,-1,-1,Te,Ie)):Q,mt=new s.by(j,Ee,J,he,oe,te,ae);this.loaded=this.loaded||{},this.loaded[j]=mt,R(null,mt)})}removeTile(L){const R=this.loaded,j=L.uid;R&&R[j]&&delete R[j]}}function Pe(X,L){if(X.length!==0){De(X[0],L);for(var R=1;R=Math.abs(oe)?R-te+oe:oe-te+R,R=te}R+j>=0!=!!L&&X.reverse()}var Ve=s.bz(function X(L,R){var j,J=L&&L.type;if(J==="FeatureCollection")for(j=0;j>31}function fi(X,L){for(var R=X.loadGeometry(),j=X.type,J=0,Q=0,he=R.length,oe=0;oeX},zi=Math.fround||(Ti=new Float32Array(1),X=>(Ti[0]=+X,Ti[0]));var Ti;const Tt=3,mi=5,Oi=6;class Fe{constructor(L){this.options=Object.assign(Object.create(Vr),L),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(L){const{log:R,minZoom:j,maxZoom:J}=this.options;R&&console.time("total time");const Q=`prepare ${L.length} points`;R&&console.time(Q),this.points=L;const he=[];for(let te=0;te=j;te--){const ae=+Date.now();oe=this.trees[te]=this._createTree(this._cluster(oe,te)),R&&console.log("z%d: %d clusters in %dms",te,oe.numItems,+Date.now()-ae)}return R&&console.timeEnd("total time"),this}getClusters(L,R){let j=((L[0]+180)%360+360)%360-180;const J=Math.max(-90,Math.min(90,L[1]));let Q=L[2]===180?180:((L[2]+180)%360+360)%360-180;const he=Math.max(-90,Math.min(90,L[3]));if(L[2]-L[0]>=360)j=-180,Q=180;else if(j>Q){const Ie=this.getClusters([j,J,180,he],R),Ee=this.getClusters([-180,J,Q,he],R);return Ie.concat(Ee)}const oe=this.trees[this._limitZoom(R)],te=oe.range(Gt(j),ct(he),Gt(Q),ct(J)),ae=oe.data,Te=[];for(const Ie of te){const Ee=this.stride*Ie;Te.push(ae[Ee+mi]>1?Pt(ae,Ee,this.clusterProps):this.points[ae[Ee+Tt]])}return Te}getChildren(L){const R=this._getOriginId(L),j=this._getOriginZoom(L),J="No cluster with the specified id.",Q=this.trees[j];if(!Q)throw new Error(J);const he=Q.data;if(R*this.stride>=he.length)throw new Error(J);const oe=this.options.radius/(this.options.extent*Math.pow(2,j-1)),te=Q.within(he[R*this.stride],he[R*this.stride+1],oe),ae=[];for(const Te of te){const Ie=Te*this.stride;he[Ie+4]===L&&ae.push(he[Ie+mi]>1?Pt(he,Ie,this.clusterProps):this.points[he[Ie+Tt]])}if(ae.length===0)throw new Error(J);return ae}getLeaves(L,R,j){const J=[];return this._appendLeaves(J,L,R=R||10,j=j||0,0),J}getTile(L,R,j){const J=this.trees[this._limitZoom(L)],Q=Math.pow(2,L),{extent:he,radius:oe}=this.options,te=oe/he,ae=(j-te)/Q,Te=(j+1+te)/Q,Ie={features:[]};return this._addTileFeatures(J.range((R-te)/Q,ae,(R+1+te)/Q,Te),J.data,R,j,Q,Ie),R===0&&this._addTileFeatures(J.range(1-te/Q,ae,1,Te),J.data,Q,j,Q,Ie),R===Q-1&&this._addTileFeatures(J.range(0,ae,te/Q,Te),J.data,-1,j,Q,Ie),Ie.features.length?Ie:null}getClusterExpansionZoom(L){let R=this._getOriginZoom(L)-1;for(;R<=this.options.maxZoom;){const j=this.getChildren(L);if(R++,j.length!==1)break;L=j[0].properties.cluster_id}return R}_appendLeaves(L,R,j,J,Q){const he=this.getChildren(R);for(const oe of he){const te=oe.properties;if(te&&te.cluster?Q+te.point_count<=J?Q+=te.point_count:Q=this._appendLeaves(L,te.cluster_id,j,J,Q):Q1;let Te,Ie,Ee;if(ae)Te=Xe(R,te,this.clusterProps),Ie=R[te],Ee=R[te+1];else{const ut=this.points[R[te+Tt]];Te=ut.properties;const[vt,Ft]=ut.geometry.coordinates;Ie=Gt(vt),Ee=ct(Ft)}const mt={type:1,geometry:[[Math.round(this.options.extent*(Ie*Q-j)),Math.round(this.options.extent*(Ee*Q-J))]],tags:Te};let kt;kt=ae||this.options.generateId?R[te+Tt]:this.points[R[te+Tt]].id,kt!==void 0&&(mt.id=kt),he.features.push(mt)}}_limitZoom(L){return Math.max(this.options.minZoom,Math.min(Math.floor(+L),this.options.maxZoom+1))}_cluster(L,R){const{radius:j,extent:J,reduce:Q,minPoints:he}=this.options,oe=j/(J*Math.pow(2,R)),te=L.data,ae=[],Te=this.stride;for(let Ie=0;IeR&&(vt+=te[gi+mi])}if(vt>ut&&vt>=he){let Ft,gi=Ee*ut,Ut=mt*ut,ai=-1;const ri=((Ie/Te|0)<<5)+(R+1)+this.points.length;for(const jr of kt){const Ei=jr*Te;if(te[Ei+2]<=R)continue;te[Ei+2]=R;const hr=te[Ei+mi];gi+=te[Ei]*hr,Ut+=te[Ei+1]*hr,te[Ei+4]=ri,Q&&(Ft||(Ft=this._map(te,Ie,!0),ai=this.clusterProps.length,this.clusterProps.push(Ft)),Q(Ft,this._map(te,Ei)))}te[Ie+4]=ri,ae.push(gi/vt,Ut/vt,1/0,ri,-1,vt),Q&&ae.push(ai)}else{for(let Ft=0;Ft1)for(const Ft of kt){const gi=Ft*Te;if(!(te[gi+2]<=R)){te[gi+2]=R;for(let Ut=0;Ut>5}_getOriginZoom(L){return(L-this.points.length)%32}_map(L,R,j){if(L[R+mi]>1){const he=this.clusterProps[L[R+Oi]];return j?Object.assign({},he):he}const J=this.points[L[R+Tt]].properties,Q=this.options.map(J);return j&&Q===J?Object.assign({},Q):Q}}function Pt(X,L,R){return{type:"Feature",id:X[L+Tt],properties:Xe(X,L,R),geometry:{type:"Point",coordinates:[(j=X[L],360*(j-.5)),Zi(X[L+1])]}};var j}function Xe(X,L,R){const j=X[L+mi],J=j>=1e4?`${Math.round(j/1e3)}k`:j>=1e3?Math.round(j/100)/10+"k":j,Q=X[L+Oi],he=Q===-1?{}:Object.assign({},R[Q]);return Object.assign(he,{cluster:!0,cluster_id:X[L+Tt],point_count:j,point_count_abbreviated:J})}function Gt(X){return X/360+.5}function ct(X){const L=Math.sin(X*Math.PI/180),R=.5-.25*Math.log((1+L)/(1-L))/Math.PI;return R<0?0:R>1?1:R}function Zi(X){const L=(180-360*X)*Math.PI/180;return 360*Math.atan(Math.exp(L))/Math.PI-90}function gr(X,L,R,j){for(var J,Q=j,he=R-L>>1,oe=R-L,te=X[L],ae=X[L+1],Te=X[R],Ie=X[R+1],Ee=L+3;EeQ)J=Ee,Q=mt;else if(mt===Q){var kt=Math.abs(Ee-he);ktj&&(J-L>3&&gr(X,L,J,j),X[J+2]=Q,R-J>3&&gr(X,J,R,j))}function je(X,L,R,j,J,Q){var he=J-R,oe=Q-j;if(he!==0||oe!==0){var te=((X-R)*he+(L-j)*oe)/(he*he+oe*oe);te>1?(R=J,j=Q):te>0&&(R+=he*te,j+=oe*te)}return(he=X-R)*he+(oe=L-j)*oe}function Bi(X,L,R,j){var J={id:X===void 0?null:X,type:L,geometry:R,tags:j,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Q){var he=Q.geometry,oe=Q.type;if(oe==="Point"||oe==="MultiPoint"||oe==="LineString")yr(Q,he);else if(oe==="Polygon"||oe==="MultiLineString")for(var te=0;te0&&(he+=j?(J*ae-te*Q)/2:Math.sqrt(Math.pow(te-J,2)+Math.pow(ae-Q,2))),J=te,Q=ae}var Te=L.length-3;L[2]=1,gr(L,0,Te,R),L[Te+2]=1,L.size=Math.abs(he),L.start=0,L.end=L.size}function jo(X,L,R,j){for(var J=0;J1?1:R}function In(X,L,R,j,J,Q,he,oe){if(j/=L,Q>=(R/=L)&&he=j)return null;for(var te=[],ae=0;ae=R&&kt=j)){var ut=[];if(Ee==="Point"||Ee==="MultiPoint")Ii(Ie,ut,R,j,J);else if(Ee==="LineString")ii(Ie,ut,R,j,J,!1,oe.lineMetrics);else if(Ee==="MultiLineString")En(Ie,ut,R,j,J,!1);else if(Ee==="Polygon")En(Ie,ut,R,j,J,!0);else if(Ee==="MultiPolygon")for(var vt=0;vt=R&&he<=j&&(L.push(X[Q]),L.push(X[Q+1]),L.push(X[Q+2]))}}function ii(X,L,R,j,J,Q,he){for(var oe,te,ae=Vn(X),Te=J===0?qo:So,Ie=X.start,Ee=0;EeR&&(te=Te(ae,mt,kt,vt,Ft,R),he&&(ae.start=Ie+oe*te)):gi>j?Ut=R&&(te=Te(ae,mt,kt,vt,Ft,R),ai=!0),Ut>j&&gi<=j&&(te=Te(ae,mt,kt,vt,Ft,j),ai=!0),!Q&&ai&&(he&&(ae.end=Ie+oe*te),L.push(ae),ae=Vn(X)),he&&(Ie+=oe)}var ri=X.length-3;mt=X[ri],kt=X[ri+1],ut=X[ri+2],(gi=J===0?mt:kt)>=R&&gi<=j&&Un(ae,mt,kt,ut),ri=ae.length-3,Q&&ri>=3&&(ae[ri]!==ae[0]||ae[ri+1]!==ae[1])&&Un(ae,ae[0],ae[1],ae[2]),ae.length&&L.push(ae)}function Vn(X){var L=[];return L.size=X.size,L.start=X.start,L.end=X.end,L}function En(X,L,R,j,J,Q){for(var he=0;hehe.maxX&&(he.maxX=Te),Ie>he.maxY&&(he.maxY=Ie)}return he}function Zo(X,L,R,j){var J=L.geometry,Q=L.type,he=[];if(Q==="Point"||Q==="MultiPoint")for(var oe=0;oe0&&L.size<(J?he:j))R.numPoints+=L.length/3;else{for(var oe=[],te=0;tehe)&&(R.numSimplified++,oe.push(L[te]),oe.push(L[te+1])),R.numPoints++;J&&function(ae,Te){for(var Ie=0,Ee=0,mt=ae.length,kt=mt-2;Ee0===Te)for(Ee=0,mt=ae.length;Ee24)throw new Error("maxZoom should be in the 0-24 range");if(L.promoteId&&L.generateId)throw new Error("promoteId and generateId cannot be used together.");var j=function(J,Q){var he=[];if(J.type==="FeatureCollection")for(var oe=0;oe1&&console.time("creation"),Ee=this.tiles[Ie]=er(X,L,R,j,te),this.tileCoords.push({z:L,x:R,y:j}),ae)){ae>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",L,R,j,Ee.numFeatures,Ee.numPoints,Ee.numSimplified),console.timeEnd("creation"));var mt="z"+L;this.stats[mt]=(this.stats[mt]||0)+1,this.total++}if(Ee.source=X,J){if(L===te.maxZoom||L===J)continue;var kt=1<1&&console.time("clipping");var ut,vt,Ft,gi,Ut,ai,ri=.5*te.buffer/te.extent,jr=.5-ri,Ei=.5+ri,hr=1+ri;ut=vt=Ft=gi=null,Ut=In(X,Te,R-ri,R+Ei,0,Ee.minX,Ee.maxX,te),ai=In(X,Te,R+jr,R+hr,0,Ee.minX,Ee.maxX,te),X=null,Ut&&(ut=In(Ut,Te,j-ri,j+Ei,1,Ee.minY,Ee.maxY,te),vt=In(Ut,Te,j+jr,j+hr,1,Ee.minY,Ee.maxY,te),Ut=null),ai&&(Ft=In(ai,Te,j-ri,j+Ei,1,Ee.minY,Ee.maxY,te),gi=In(ai,Te,j+jr,j+hr,1,Ee.minY,Ee.maxY,te),ai=null),ae>1&&console.timeEnd("clipping"),oe.push(ut||[],L+1,2*R,2*j),oe.push(vt||[],L+1,2*R,2*j+1),oe.push(Ft||[],L+1,2*R+1,2*j),oe.push(gi||[],L+1,2*R+1,2*j+1)}}},He.prototype.getTile=function(X,L,R){var j=this.options,J=j.extent,Q=j.debug;if(X<0||X>24)return null;var he=1<1&&console.log("drilling down to z%d-%d-%d",X,L,R);for(var te,ae=X,Te=L,Ie=R;!te&&ae>0;)ae--,Te=Math.floor(Te/2),Ie=Math.floor(Ie/2),te=this.tiles[Bt(ae,Te,Ie)];return te&&te.source?(Q>1&&console.log("found parent tile z%d-%d-%d",ae,Te,Ie),Q>1&&console.time("drilling down"),this.splitTile(te.source,ae,Te,Ie,X,L,R),Q>1&&console.timeEnd("drilling down"),this.tiles[oe]?Ze(this.tiles[oe],J):null):null};class It extends Oe{constructor(L,R,j,J){super(L,R,j),this._dataUpdateable=new Map,this.loadGeoJSON=(Q,he)=>{const{promoteId:oe}=Q;if(Q.request)return s.f(Q.request,(te,ae,Te,Ie)=>{this._dataUpdateable=Ur(ae,oe)?_n(ae,oe):void 0,he(te,ae,Te,Ie)});if(typeof Q.data=="string")try{const te=JSON.parse(Q.data);this._dataUpdateable=Ur(te,oe)?_n(te,oe):void 0,he(null,te)}catch{he(new Error(`Input data given to '${Q.source}' is not a valid GeoJSON object.`))}else Q.dataDiff?this._dataUpdateable?(function(te,ae,Te){var Ie,Ee,mt,kt;if(ae.removeAll&&te.clear(),ae.remove)for(const ut of ae.remove)te.delete(ut);if(ae.add)for(const ut of ae.add){const vt=Mt(ut,Te);vt!=null&&te.set(vt,ut)}if(ae.update)for(const ut of ae.update){let vt=te.get(ut.id);if(vt==null)continue;const Ft=!ut.removeAllProperties&&(((Ie=ut.removeProperties)===null||Ie===void 0?void 0:Ie.length)>0||((Ee=ut.addOrUpdateProperties)===null||Ee===void 0?void 0:Ee.length)>0);if((ut.newGeometry||ut.removeAllProperties||Ft)&&(vt=Object.assign({},vt),te.set(ut.id,vt),Ft&&(vt.properties=Object.assign({},vt.properties))),ut.newGeometry&&(vt.geometry=ut.newGeometry),ut.removeAllProperties)vt.properties={};else if(((mt=ut.removeProperties)===null||mt===void 0?void 0:mt.length)>0)for(const gi of ut.removeProperties)Object.prototype.hasOwnProperty.call(vt.properties,gi)&&delete vt.properties[gi];if(((kt=ut.addOrUpdateProperties)===null||kt===void 0?void 0:kt.length)>0)for(const{key:gi,value:Ut}of ut.addOrUpdateProperties)vt.properties[gi]=Ut}}(this._dataUpdateable,Q.dataDiff,oe),he(null,{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())})):he(new Error(`Cannot update existing geojson data in ${Q.source}`)):he(new Error(`Input data given to '${Q.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}},this.loadVectorData=this.loadGeoJSONTile,J&&(this.loadGeoJSON=J)}loadGeoJSONTile(L,R){const j=L.tileID.canonical;if(!this._geoJSONIndex)return R(null,null);const J=this._geoJSONIndex.getTile(j.z,j.x,j.y);if(!J)return R(null,null);const Q=new class{constructor(oe){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=s.N,this.length=oe.length,this._features=oe}feature(oe){return new class{constructor(te){this._feature=te,this.extent=s.N,this.type=te.type,this.properties=te.tags,"id"in te&&!isNaN(te.id)&&(this.id=parseInt(te.id,10))}loadGeometry(){if(this._feature.type===1){const te=[];for(const ae of this._feature.geometry)te.push([new s.P(ae[0],ae[1])]);return te}{const te=[];for(const ae of this._feature.geometry){const Te=[];for(const Ie of ae)Te.push(new s.P(Ie[0],Ie[1]));te.push(Te)}return te}}toGeoJSON(te,ae,Te){return at.call(this,te,ae,Te)}}(this._features[oe])}}(J.features);let he=en(Q);he.byteOffset===0&&he.byteLength===he.buffer.byteLength||(he=new Uint8Array(he)),R(null,{vectorTile:Q,rawData:he.buffer})}loadData(L,R){var j;(j=this._pendingRequest)===null||j===void 0||j.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const J=!!(L&&L.request&&L.request.collectResourceTiming)&&new s.bu(L.request);this._pendingCallback=R,this._pendingRequest=this.loadGeoJSON(L,(Q,he)=>{if(delete this._pendingCallback,delete this._pendingRequest,Q||!he)return R(Q);if(typeof he!="object")return R(new Error(`Input data given to '${L.source}' is not a valid GeoJSON object.`));{Ve(he,!0);try{if(L.filter){const te=s.bC(L.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(te.result==="error")throw new Error(te.value.map(Te=>`${Te.key}: ${Te.message}`).join(", "));he={type:"FeatureCollection",features:he.features.filter(Te=>te.value.evaluate({zoom:0},Te))}}this._geoJSONIndex=L.cluster?new Fe(function({superclusterOptions:te,clusterProperties:ae}){if(!ae||!te)return te;const Te={},Ie={},Ee={accumulated:null,zoom:0},mt={properties:null},kt=Object.keys(ae);for(const ut of kt){const[vt,Ft]=ae[ut],gi=s.bC(Ft),Ut=s.bC(typeof vt=="string"?[vt,["accumulated"],["get",ut]]:vt);Te[ut]=gi.value,Ie[ut]=Ut.value}return te.map=ut=>{mt.properties=ut;const vt={};for(const Ft of kt)vt[Ft]=Te[Ft].evaluate(Ee,mt);return vt},te.reduce=(ut,vt)=>{mt.properties=vt;for(const Ft of kt)Ee.accumulated=ut[Ft],ut[Ft]=Ie[Ft].evaluate(Ee,mt)},te}(L)).load(he.features):function(te,ae){return new He(te,ae)}(he,L.geojsonVtOptions)}catch(te){return R(te)}this.loaded={};const oe={};if(J){const te=J.finish();te&&(oe.resourceTiming={},oe.resourceTiming[L.source]=JSON.parse(JSON.stringify(te)))}R(null,oe)}})}reloadTile(L,R){const j=this.loaded;return j&&j[L.uid]?super.reloadTile(L,R):this.loadTile(L,R)}removeSource(L,R){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),R()}getClusterExpansionZoom(L,R){try{R(null,this._geoJSONIndex.getClusterExpansionZoom(L.clusterId))}catch(j){R(j)}}getClusterChildren(L,R){try{R(null,this._geoJSONIndex.getChildren(L.clusterId))}catch(j){R(j)}}getClusterLeaves(L,R){try{R(null,this._geoJSONIndex.getLeaves(L.clusterId,L.limit,L.offset))}catch(j){R(j)}}}class Mn{constructor(L){this.self=L,this.actor=new s.C(L,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:Oe,geojson:It},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(R,j)=>{if(this.workerSourceTypes[R])throw new Error(`Worker source with name "${R}" already registered.`);this.workerSourceTypes[R]=j},this.self.registerRTLTextPlugin=R=>{if(s.bD.isParsed())throw new Error("RTL text plugin already registered.");s.bD.applyArabicShaping=R.applyArabicShaping,s.bD.processBidirectionalText=R.processBidirectionalText,s.bD.processStyledBidirectionalText=R.processStyledBidirectionalText}}setReferrer(L,R){this.referrer=R}setImages(L,R,j){this.availableImages[L]=R;for(const J in this.workerSources[L]){const Q=this.workerSources[L][J];for(const he in Q)Q[he].availableImages=R}j()}setLayers(L,R,j){this.getLayerIndex(L).replace(R),j()}updateLayers(L,R,j){this.getLayerIndex(L).update(R.layers,R.removedIds),j()}loadTile(L,R,j){this.getWorkerSource(L,R.type,R.source).loadTile(R,j)}loadDEMTile(L,R,j){this.getDEMWorkerSource(L,R.source).loadTile(R,j)}reloadTile(L,R,j){this.getWorkerSource(L,R.type,R.source).reloadTile(R,j)}abortTile(L,R,j){this.getWorkerSource(L,R.type,R.source).abortTile(R,j)}removeTile(L,R,j){this.getWorkerSource(L,R.type,R.source).removeTile(R,j)}removeDEMTile(L,R){this.getDEMWorkerSource(L,R.source).removeTile(R)}removeSource(L,R,j){if(!this.workerSources[L]||!this.workerSources[L][R.type]||!this.workerSources[L][R.type][R.source])return;const J=this.workerSources[L][R.type][R.source];delete this.workerSources[L][R.type][R.source],J.removeSource!==void 0?J.removeSource(R,j):j()}loadWorkerSource(L,R,j){try{this.self.importScripts(R.url),j()}catch(J){j(J.toString())}}syncRTLPluginState(L,R,j){try{s.bD.setState(R);const J=s.bD.getPluginURL();if(s.bD.isLoaded()&&!s.bD.isParsed()&&J!=null){this.self.importScripts(J);const Q=s.bD.isParsed();j(Q?void 0:new Error(`RTL Text Plugin failed to import scripts from ${J}`),Q)}}catch(J){j(J.toString())}}getAvailableImages(L){let R=this.availableImages[L];return R||(R=[]),R}getLayerIndex(L){let R=this.layerIndexes[L];return R||(R=this.layerIndexes[L]=new Z),R}getWorkerSource(L,R,j){return this.workerSources[L]||(this.workerSources[L]={}),this.workerSources[L][R]||(this.workerSources[L][R]={}),this.workerSources[L][R][j]||(this.workerSources[L][R][j]=new this.workerSourceTypes[R]({send:(J,Q,he)=>{this.actor.send(J,Q,he,L)}},this.getLayerIndex(L),this.getAvailableImages(L))),this.workerSources[L][R][j]}getDEMWorkerSource(L,R){return this.demWorkerSources[L]||(this.demWorkerSources[L]={}),this.demWorkerSources[L][R]||(this.demWorkerSources[L][R]=new ke),this.demWorkerSources[L][R]}}return s.i()&&(self.worker=new Mn(self)),Mn}),k(["./shared"],function(s){var Z="3.6.2";class V{static testProp(t){if(!V.docStyle)return t[0];for(let n=0;n{window.removeEventListener("click",V.suppressClickInternal,!0)},0)}static mousePos(t,n){const a=t.getBoundingClientRect();return new s.P(n.clientX-a.left-t.clientLeft,n.clientY-a.top-t.clientTop)}static touchPos(t,n){const a=t.getBoundingClientRect(),c=[];for(let d=0;d{t=[],n=0,a=0,c={}},u.addThrottleControl=C=>{const A=a++;return c[A]=C,A},u.removeThrottleControl=C=>{delete c[C],b()},u.getImage=(C,A,P=!0)=>{me.supported&&(C.headers||(C.headers={}),C.headers.accept="image/webp,*/*");const O={requestParameters:C,supportImageRefresh:P,callback:A,cancelled:!1,completed:!1,cancel:()=>{O.completed||O.cancelled||(O.cancelled=!0,O.innerRequest&&(O.innerRequest.cancel(),n--),b())}};return t.push(O),b(),O};const d=C=>{const{requestParameters:A,supportImageRefresh:P,callback:O}=C;return s.e(A,{type:"image"}),(P!==!1||s.i()||s.g(A.url)||A.headers&&!Object.keys(A.headers).reduce((H,W)=>H&&W==="accept",!0)?s.m:S)(A,(H,W,K,q)=>{x(C,O,H,W,K,q)})},x=(C,A,P,O,H,W)=>{P?A(P):O instanceof HTMLImageElement||s.a(O)?A(null,O):O&&((K,q)=>{typeof createImageBitmap=="function"?s.b(K,q):s.d(K,q)})(O,(K,q)=>{K!=null?A(K):q!=null&&A(null,q,{cacheControl:H,expires:W})}),C.cancelled||(C.completed=!0,n--,b())},b=()=>{const C=(()=>{const A=Object.keys(c);let P=!1;if(A.length>0){for(const O of A)if(P=c[O](),P)break}return P})()?s.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:s.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let A=n;A0;A++){const P=t.shift();if(P.cancelled){A--;continue}const O=d(P);n++,P.innerRequest=O}},S=(C,A)=>{const P=new Image,O=C.url;let H=!1;const W=C.credentials;return W&&W==="include"?P.crossOrigin="use-credentials":(W&&W==="same-origin"||!s.s(O))&&(P.crossOrigin="anonymous"),P.fetchPriority="high",P.onload=()=>{A(null,P),P.onerror=P.onload=null},P.onerror=()=>{H||A(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.")),P.onerror=P.onload=null},P.src=O,{cancel:()=>{H=!0,P.src=""}}}}(De||(De={})),De.resetRequestQueue(),function(u){u.Glyphs="Glyphs",u.Image="Image",u.Source="Source",u.SpriteImage="SpriteImage",u.SpriteJSON="SpriteJSON",u.Style="Style",u.Tile="Tile",u.Unknown="Unknown"}(Ve||(Ve={}));class at{constructor(t){this._transformRequestFn=t}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}normalizeSpriteURL(t,n,a){const c=function(d){const x=d.match(nt);if(!x)throw new Error(`Unable to parse URL "${d}"`);return{protocol:x[1],authority:x[2],path:x[3]||"/",params:x[4]?x[4].split("&"):[]}}(t);return c.path+=`${n}${a}`,function(d){const x=d.params.length?`?${d.params.join("&")}`:"";return`${d.protocol}://${d.authority}${d.path}${x}`}(c)}setTransformRequest(t){this._transformRequestFn=t}}const nt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function it(u){var t=new s.A(3);return t[0]=u[0],t[1]=u[1],t[2]=u[2],t}var Vt,ti=function(u,t,n){return u[0]=t[0]-n[0],u[1]=t[1]-n[1],u[2]=t[2]-n[2],u};Vt=new s.A(3),s.A!=Float32Array&&(Vt[0]=0,Vt[1]=0,Vt[2]=0);var Xt=function(u){var t=u[0],n=u[1];return t*t+n*n};function Nt(u){const t=[];if(typeof u=="string")t.push({id:"default",url:u});else if(u&&u.length>0){const n=[];for(const{id:a,url:c}of u){const d=`${a}${c}`;n.indexOf(d)===-1&&(n.push(d),t.push({id:a,url:c}))}}return t}function Yt(u,t,n,a,c){if(a)return void u(a);if(c!==Object.values(t).length||c!==Object.values(n).length)return;const d={};for(const x in t){d[x]={};const b=s.h.getImageCanvasContext(n[x]),S=t[x];for(const C in S){const{width:A,height:P,x:O,y:H,sdf:W,pixelRatio:K,stretchX:q,stretchY:le,content:_e}=S[C];d[x][C]={data:null,pixelRatio:K,sdf:W,stretchX:q,stretchY:le,content:_e,spriteData:{width:A,height:P,x:O,y:H,context:b}}}}u(null,d)}(function(){var u=new s.A(2);s.A!=Float32Array&&(u[0]=0,u[1]=0)})();class At{constructor(t,n,a,c){this.context=t,this.format=a,this.texture=t.gl.createTexture(),this.update(n,c)}update(t,n,a){const{width:c,height:d}=t,x=!(this.size&&this.size[0]===c&&this.size[1]===d||a),{context:b}=this,{gl:S}=b;if(this.useMipmap=!!(n&&n.useMipmap),S.bindTexture(S.TEXTURE_2D,this.texture),b.pixelStoreUnpackFlipY.set(!1),b.pixelStoreUnpack.set(1),b.pixelStoreUnpackPremultiplyAlpha.set(this.format===S.RGBA&&(!n||n.premultiply!==!1)),x)this.size=[c,d],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||s.a(t)?S.texImage2D(S.TEXTURE_2D,0,this.format,this.format,S.UNSIGNED_BYTE,t):S.texImage2D(S.TEXTURE_2D,0,this.format,c,d,0,this.format,S.UNSIGNED_BYTE,t.data);else{const{x:C,y:A}=a||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||s.a(t)?S.texSubImage2D(S.TEXTURE_2D,0,C,A,S.RGBA,S.UNSIGNED_BYTE,t):S.texSubImage2D(S.TEXTURE_2D,0,C,A,c,d,S.RGBA,S.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&S.generateMipmap(S.TEXTURE_2D)}bind(t,n,a){const{context:c}=this,{gl:d}=c;d.bindTexture(d.TEXTURE_2D,this.texture),a!==d.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(a=d.LINEAR),t!==this.filter&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,t),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,a||t),this.filter=t),n!==this.wrap&&(d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,n),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function Ae(u){const{userImage:t}=u;return!!(t&&t.render&&t.render())&&(u.data.replace(new Uint8Array(t.data.buffer)),!0)}class We extends s.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new s.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,callback:a}of this.requestors)this._notify(n,a);this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const a=n.spriteData;n.data=new s.R({width:a.width,height:a.height},a.context.getImageData(a.x,a.y,a.width,a.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let a=!0;const c=n.data||n.spriteData;return this._validateStretch(n.stretchX,c&&c.width)||(this.fire(new s.j(new Error(`Image "${t}" has invalid "stretchX" value`))),a=!1),this._validateStretch(n.stretchY,c&&c.height)||(this.fire(new s.j(new Error(`Image "${t}" has invalid "stretchY" value`))),a=!1),this._validateContent(n.content,n)||(this.fire(new s.j(new Error(`Image "${t}" has invalid "content" value`))),a=!1),a}_validateStretch(t,n){if(!t)return!0;let a=0;for(const c of t){if(c[0]-1);S++,d[S]=b,x[S]=C,x[S+1]=Ui}for(let b=0,S=0;b{let b=this.entries[c];b||(b=this.entries[c]={glyphs:{},requests:{},ranges:{}});let S=b.glyphs[d];if(S!==void 0)return void x(null,{stack:c,id:d,glyph:S});if(S=this._tinySDF(b,c,d),S)return b.glyphs[d]=S,void x(null,{stack:c,id:d,glyph:S});const C=Math.floor(d/256);if(256*C>65535)return void x(new Error("glyphs > 65535 not supported"));if(b.ranges[C])return void x(null,{stack:c,id:d,glyph:S});if(!this.url)return void x(new Error("glyphsUrl is not set"));let A=b.requests[C];A||(A=b.requests[C]=[],Lt.loadGlyphRange(c,C,this.url,this.requestManager,(P,O)=>{if(O){for(const H in O)this._doesCharSupportLocalGlyph(+H)||(b.glyphs[+H]=O[+H]);b.ranges[C]=!0}for(const H of A)H(P,O);delete b.requests[C]})),A.push((P,O)=>{P?x(P):O&&x(null,{stack:c,id:d,glyph:O[d]||null})})},(c,d)=>{if(c)n(c);else if(d){const x={};for(const{stack:b,id:S,glyph:C}of d)(x[b]||(x[b]={}))[S]=C&&{id:C.id,bitmap:C.bitmap.clone(),metrics:C.metrics};n(null,x)}})}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(s.u["CJK Unified Ideographs"](t)||s.u["Hangul Syllables"](t)||s.u.Hiragana(t)||s.u.Katakana(t))}_tinySDF(t,n,a){const c=this.localIdeographFontFamily;if(!c||!this._doesCharSupportLocalGlyph(a))return;let d=t.tinySDF;if(!d){let b="400";/bold/i.test(n)?b="900":/medium/i.test(n)?b="500":/light/i.test(n)&&(b="200"),d=t.tinySDF=new Lt.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:c,fontWeight:b})}const x=d.draw(String.fromCharCode(a));return{id:a,bitmap:new s.q({width:x.width||60,height:x.height||60},x.data),metrics:{width:x.glyphWidth/2||24,height:x.glyphHeight/2||24,left:x.glyphLeft/2+.5||0,top:x.glyphTop/2-27.5||-8,advance:x.glyphAdvance/2||24,isDoubleResolution:!0}}}}Lt.loadGlyphRange=function(u,t,n,a,c){const d=256*t,x=d+255,b=a.transformRequest(n.replace("{fontstack}",u).replace("{range}",`${d}-${x}`),Ve.Glyphs);s.l(b,(S,C)=>{if(S)c(S);else if(C){const A={};for(const P of s.n(C))A[P.id]=P;c(null,A)}})},Lt.TinySDF=class{constructor({fontSize:u=24,buffer:t=3,radius:n=8,cutoff:a=.25,fontFamily:c="sans-serif",fontWeight:d="normal",fontStyle:x="normal"}={}){this.buffer=t,this.cutoff=a,this.radius=n;const b=this.size=u+4*t,S=this._createCanvas(b),C=this.ctx=S.getContext("2d",{willReadFrequently:!0});C.font=`${x} ${d} ${u}px ${c}`,C.textBaseline="alphabetic",C.textAlign="left",C.fillStyle="black",this.gridOuter=new Float64Array(b*b),this.gridInner=new Float64Array(b*b),this.f=new Float64Array(b),this.z=new Float64Array(b+1),this.v=new Uint16Array(b)}_createCanvas(u){const t=document.createElement("canvas");return t.width=t.height=u,t}draw(u){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:a,actualBoundingBoxLeft:c,actualBoundingBoxRight:d}=this.ctx.measureText(u),x=Math.ceil(n),b=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(d-c))),S=Math.min(this.size-this.buffer,x+Math.ceil(a)),C=b+2*this.buffer,A=S+2*this.buffer,P=Math.max(C*A,0),O=new Uint8ClampedArray(P),H={data:O,width:C,height:A,glyphWidth:b,glyphHeight:S,glyphTop:x,glyphLeft:0,glyphAdvance:t};if(b===0||S===0)return H;const{ctx:W,buffer:K,gridInner:q,gridOuter:le}=this;W.clearRect(K,K,b,S),W.fillText(u,K,K+x);const _e=W.getImageData(K,K,b,S);le.fill(Ui,0,P),q.fill(0,0,P);for(let ee=0;ee0?Ce*Ce:0,q[xe]=Ce<0?Ce*Ce:0}}Dt(le,0,0,C,A,C,this.f,this.v,this.z),Dt(q,K,K,b,S,C,this.f,this.v,this.z);for(let ee=0;ee1&&(S=t[++b]);const A=Math.abs(C-S.left),P=Math.abs(C-S.right),O=Math.min(A,P);let H;const W=d/a*(c+1);if(S.isDash){const K=c-Math.abs(W);H=Math.sqrt(O*O+K*K)}else H=c-Math.sqrt(O*O+W*W);this.data[x+C]=Math.max(0,Math.min(255,H+128))}}}addRegularDash(t){for(let b=t.length-1;b>=0;--b){const S=t[b],C=t[b+1];S.zeroLength?t.splice(b,1):C&&C.isDash===S.isDash&&(C.left=S.left,t.splice(b,1))}const n=t[0],a=t[t.length-1];n.isDash===a.isDash&&(n.left=a.left-this.width,a.right=n.right+this.width);const c=this.width*this.nextRow;let d=0,x=t[d];for(let b=0;b1&&(x=t[++d]);const S=Math.abs(b-x.left),C=Math.abs(b-x.right),A=Math.min(S,C);this.data[c+b]=Math.max(0,Math.min(255,(x.isDash?A:-A)+128))}}addDash(t,n){const a=n?7:0,c=2*a+1;if(this.nextRow+c>this.height)return s.w("LineAtlas out of space"),null;let d=0;for(let b=0;b{c.send(t,n,d)},a=a||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.actors.forEach(n=>{n.remove()}),this.actors=[],t&&this.workerPool.release(this.id)}}function Ti(u,t,n){const a=function(c,d){if(c)return n(c);if(d){const x=s.F(s.e(d,u),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);d.vector_layers&&(x.vectorLayers=d.vector_layers,x.vectorLayerIds=x.vectorLayers.map(b=>b.id)),n(null,x)}};return u.url?s.f(t.transformRequest(u.url,Ve.Source),a):s.h.frame(()=>a(null,u))}class Tt{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof s.L?new s.L(t.lng,t.lat):s.L.convert(t),this}setSouthWest(t){return this._sw=t instanceof s.L?new s.L(t.lng,t.lat):s.L.convert(t),this}extend(t){const n=this._sw,a=this._ne;let c,d;if(t instanceof s.L)c=t,d=t;else{if(!(t instanceof Tt))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Tt.convert(t)):this.extend(s.L.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(s.L.convert(t)):this;if(c=t._sw,d=t._ne,!c||!d)return this}return n||a?(n.lng=Math.min(c.lng,n.lng),n.lat=Math.min(c.lat,n.lat),a.lng=Math.max(d.lng,a.lng),a.lat=Math.max(d.lat,a.lat)):(this._sw=new s.L(c.lng,c.lat),this._ne=new s.L(d.lng,d.lat)),this}getCenter(){return new s.L((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 s.L(this.getWest(),this.getNorth())}getSouthEast(){return new s.L(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:n,lat:a}=s.L.convert(t);let c=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=a&&a<=this._ne.lat&&c}static convert(t){return t instanceof Tt?t:t&&new Tt(t)}static fromLngLat(t,n=0){const a=360*n/40075017,c=a/Math.cos(Math.PI/180*t.lat);return new Tt(new s.L(t.lng-c,t.lat-a),new s.L(t.lng+c,t.lat+a))}}class mi{constructor(t,n,a){this.bounds=Tt.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=a||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),a=Math.floor(s.G(this.bounds.getWest())*n),c=Math.floor(s.H(this.bounds.getNorth())*n),d=Math.ceil(s.G(this.bounds.getEast())*n),x=Math.ceil(s.H(this.bounds.getSouth())*n);return t.x>=a&&t.x=c&&t.y{this._loaded=!1,this.fire(new s.k("dataloading",{dataType:"source"})),this._tileJSONRequest=Ti(this._options,this.map._requestManager,(d,x)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),d?this.fire(new s.j(d)):x&&(s.e(this,x),x.bounds&&(this.tileBounds=new mi(x.bounds,this.minzoom,this.maxzoom)),this.fire(new s.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.k("data",{dataType:"source",sourceDataType:"content"})))})},this.serialize=()=>s.e({},this._options),this.id=t,this.dispatcher=a,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,s.e(this,s.F(n,["url","scheme","tileSize","promoteId"])),this._options=s.e({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(c)}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}loadTile(t,n){const a=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),c={request:this.map._requestManager.transformRequest(a,Ve.Tile),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function d(x,b){return delete t.request,t.aborted?n(null):x&&x.status!==404?n(x):(b&&b.resourceTiming&&(t.resourceTiming=b.resourceTiming),this.map._refreshExpiredTiles&&b&&t.setExpiryData(b),t.loadVectorData(b,this.map.painter),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}c.request.collectResourceTiming=this._collectResourceTiming,t.actor&&t.state!=="expired"?t.state==="loading"?t.reloadCallback=n:t.request=t.actor.send("reloadTile",c,d.bind(this)):(t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",c,d.bind(this)))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class Fe extends s.E{constructor(t,n,a,c){super(),this.id=t,this.dispatcher=a,this.setEventedParent(c),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=s.e({type:"raster"},n),s.e(this,s.F(n,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new s.k("dataloading",{dataType:"source"})),this._tileJSONRequest=Ti(this._options,this.map._requestManager,(t,n)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new s.j(t)):n&&(s.e(this,n),n.bounds&&(this.tileBounds=new mi(n.bounds,this.minzoom,this.maxzoom)),this.fire(new s.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.k("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}serialize(){return s.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t,n){const a=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.request=De.getImage(this.map._requestManager.transformRequest(a,Ve.Tile),(c,d,x)=>{if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(c)t.state="errored",n(c);else if(d){this.map._refreshExpiredTiles&&x&&t.setExpiryData(x);const b=this.map.painter.context,S=b.gl;t.texture=this.map.painter.getTileTexture(d.width),t.texture?t.texture.update(d,{useMipmap:!0}):(t.texture=new At(b,d,S.RGBA,{useMipmap:!0}),t.texture.bind(S.LINEAR,S.CLAMP_TO_EDGE,S.LINEAR_MIPMAP_NEAREST),b.extTextureFilterAnisotropic&&S.texParameterf(S.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax)),t.state="loaded",n(null)}},this.map._refreshExpiredTiles)}abortTile(t,n){t.request&&(t.request.cancel(),delete t.request),n()}unloadTile(t,n){t.texture&&this.map.painter.saveTileTexture(t.texture),n()}hasTransition(){return!1}}class Pt extends Fe{constructor(t,n,a,c){super(t,n,a,c),this.type="raster-dem",this.maxzoom=22,this._options=s.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(t,n){const a=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),c=this.map._requestManager.transformRequest(a,Ve.Tile);function d(x,b){x&&(t.state="errored",n(x)),b&&(t.dem=b,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded",n(null))}t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.request=De.getImage(c,(x,b,S)=>s._(this,void 0,void 0,function*(){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(x)t.state="errored",n(x);else if(b){this.map._refreshExpiredTiles&&t.setExpiryData(S);const C=s.a(b)&&s.J()?b:yield function(P){return s._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&s.K()){const O=P.width+2,H=P.height+2;try{return new s.R({width:O,height:H},yield s.M(P,-1,-1,O,H))}catch{}}return s.h.getImageData(P,1)})}(b),A={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:C,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};t.actor&&t.state!=="expired"||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",A,d))}}),this.map._refreshExpiredTiles)}_getNeighboringTiles(t){const n=t.canonical,a=Math.pow(2,n.z),c=(n.x-1+a)%a,d=n.x===0?t.wrap-1:t.wrap,x=(n.x+1+a)%a,b=n.x+1===a?t.wrap+1:t.wrap,S={};return S[new s.O(t.overscaledZ,d,n.z,c,n.y).key]={backfilled:!1},S[new s.O(t.overscaledZ,b,n.z,x,n.y).key]={backfilled:!1},n.y>0&&(S[new s.O(t.overscaledZ,d,n.z,c,n.y-1).key]={backfilled:!1},S[new s.O(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},S[new s.O(t.overscaledZ,b,n.z,x,n.y-1).key]={backfilled:!1}),n.y+1{this._updateWorkerData()},this.serialize=()=>s.e({},this._options,{type:this.type,data:this._data}),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._pendingLoads=0,this.actor=a.getActor(),this.setEventedParent(c),this._data=n.data,this._options=s.e({},n),this._collectResourceTiming=n.collectResourceTiming,n.maxzoom!==void 0&&(this.maxzoom=n.maxzoom),n.type&&(this.type=n.type),n.attribution&&(this.attribution=n.attribution),this.promoteId=n.promoteId;const d=s.N/this.tileSize;this.workerOptions=s.e({source:this.id,cluster:n.cluster||!1,geojsonVtOptions:{buffer:(n.buffer!==void 0?n.buffer:128)*d,tolerance:(n.tolerance!==void 0?n.tolerance:.375)*d,extent:s.N,maxZoom:this.maxzoom,lineMetrics:n.lineMetrics||!1,generateId:n.generateId||!1},superclusterOptions:{maxZoom:n.clusterMaxZoom!==void 0?n.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,n.clusterMinPoints||2),extent:s.N,radius:(n.clusterRadius||50)*d,log:!1,generateId:n.generateId||!1},clusterProperties:n.clusterProperties,filter:n.filter},n.workerOptions),typeof this.promoteId=="string"&&(this.workerOptions.promoteId=this.promoteId)}onAdd(t){this.map=t,this.load()}setData(t){return this._data=t,this._updateWorkerData(),this}updateData(t){return this._updateWorkerData(t),this}setClusterOptions(t){return this.workerOptions.cluster=t.cluster,t&&(t.clusterRadius!==void 0&&(this.workerOptions.superclusterOptions.radius=t.clusterRadius),t.clusterMaxZoom!==void 0&&(this.workerOptions.superclusterOptions.maxZoom=t.clusterMaxZoom)),this._updateWorkerData(),this}getClusterExpansionZoom(t,n){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:t,source:this.id},n),this}getClusterChildren(t,n){return this.actor.send("geojson.getClusterChildren",{clusterId:t,source:this.id},n),this}getClusterLeaves(t,n,a,c){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:t,limit:n,offset:a},c),this}_updateWorkerData(t){const n=s.e({},this.workerOptions);t?n.dataDiff=t:typeof this._data=="string"?(n.request=this.map._requestManager.transformRequest(s.h.resolveURL(this._data),Ve.Source),n.request.collectResourceTiming=this._collectResourceTiming):n.data=JSON.stringify(this._data),this._pendingLoads++,this.fire(new s.k("dataloading",{dataType:"source"})),this.actor.send(`${this.type}.loadData`,n,(a,c)=>{if(this._pendingLoads--,this._removed||c&&c.abandoned)return void this.fire(new s.k("dataabort",{dataType:"source"}));let d=null;if(c&&c.resourceTiming&&c.resourceTiming[this.id]&&(d=c.resourceTiming[this.id].slice(0)),a)return void this.fire(new s.j(a));const x={dataType:"source"};this._collectResourceTiming&&d&&d.length>0&&s.e(x,{resourceTiming:d}),this.fire(new s.k("data",Object.assign(Object.assign({},x),{sourceDataType:"metadata"}))),this.fire(new s.k("data",Object.assign(Object.assign({},x),{sourceDataType:"content"})))})}loaded(){return this._pendingLoads===0}loadTile(t,n){const a=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const c={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.request=this.actor.send(a,c,(d,x)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):d?n(d):(t.loadVectorData(x,this.map.painter,a==="reloadTile"),n(null))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}hasTransition(){return!1}}var Gt=s.Q([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class ct extends s.E{constructor(t,n,a,c){super(),this.load=(d,x)=>{this._loaded=!1,this.fire(new s.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=De.getImage(this.map._requestManager.transformRequest(this.url,Ve.Image),(b,S)=>{this._request=null,this._loaded=!0,b?this.fire(new s.j(b)):S&&(this.image=S,d&&(this.coordinates=d),x&&x(),this._finishLoading())})},this.prepare=()=>{if(Object.keys(this.tiles).length===0||!this.image)return;const d=this.map.painter.context,x=d.gl;this.boundsBuffer||(this.boundsBuffer=d.createVertexBuffer(this._boundsArray,Gt.members)),this.boundsSegments||(this.boundsSegments=s.S.simpleSegment(0,0,4,2)),this.texture||(this.texture=new At(d,this.image,x.RGBA),this.texture.bind(x.LINEAR,x.CLAMP_TO_EDGE));let b=!1;for(const S in this.tiles){const C=this.tiles[S];C.state!=="loaded"&&(C.state="loaded",C.texture=this.texture,b=!0)}b&&this.fire(new s.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"image",url:this.options.url,coordinates:this.coordinates}),this.id=t,this.dispatcher=a,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(c),this.options=n}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.cancel(),this._request=null),this.options.url=t.url,this.load(t.coordinates,()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new s.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.cancel(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(s.U.fromLngLat);this.tileID=function(c){let d=1/0,x=1/0,b=-1/0,S=-1/0;for(const O of c)d=Math.min(d,O.x),x=Math.min(x,O.y),b=Math.max(b,O.x),S=Math.max(S,O.y);const C=Math.max(b-d,S-x),A=Math.max(0,Math.floor(-Math.log(C)/Math.LN2)),P=Math.pow(2,A);return new s.W(A,Math.floor((d+b)/2*P),Math.floor((x+S)/2*P))}(n),this.minzoom=this.maxzoom=this.tileID.z;const a=n.map(c=>this.tileID.getTilePoint(c)._round());return this._boundsArray=new s.V,this._boundsArray.emplaceBack(a[0].x,a[0].y,0,0),this._boundsArray.emplaceBack(a[1].x,a[1].y,s.N,0),this._boundsArray.emplaceBack(a[3].x,a[3].y,0,s.N),this._boundsArray.emplaceBack(a[2].x,a[2].y,s.N,s.N),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new s.k("data",{dataType:"source",sourceDataType:"content"})),this}loadTile(t,n){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},n(null)):(t.state="errored",n(null))}hasTransition(){return!1}}class Zi extends ct{constructor(t,n,a,c){super(t,n,a,c),this.load=()=>{this._loaded=!1;const d=this.options;this.urls=[];for(const x of d.urls)this.urls.push(this.map._requestManager.transformRequest(x,Ve.Source).url);s.X(this.urls,(x,b)=>{this._loaded=!0,x?this.fire(new s.j(x)):b&&(this.video=b,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})},this.prepare=()=>{if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const d=this.map.painter.context,x=d.gl;this.boundsBuffer||(this.boundsBuffer=d.createVertexBuffer(this._boundsArray,Gt.members)),this.boundsSegments||(this.boundsSegments=s.S.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(x.LINEAR,x.CLAMP_TO_EDGE),x.texSubImage2D(x.TEXTURE_2D,0,0,0,x.RGBA,x.UNSIGNED_BYTE,this.video)):(this.texture=new At(d,this.video,x.RGBA),this.texture.bind(x.LINEAR,x.CLAMP_TO_EDGE));let b=!1;for(const S in this.tiles){const C=this.tiles[S];C.state!=="loaded"&&(C.state="loaded",C.texture=this.texture,b=!0)}b&&this.fire(new s.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"video",urls:this.urls,coordinates:this.coordinates}),this.roundZoom=!0,this.type="video",this.options=n}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;tn.end(0)?this.fire(new s.j(new s.Y(`sources.${this.id}`,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}hasTransition(){return this.video&&!this.video.paused}}class gr extends ct{constructor(t,n,a,c){super(t,n,a,c),this.load=()=>{this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new s.j(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())},this.prepare=()=>{let d=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,d=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,d=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const x=this.map.painter.context,b=x.gl;this.boundsBuffer||(this.boundsBuffer=x.createVertexBuffer(this._boundsArray,Gt.members)),this.boundsSegments||(this.boundsSegments=s.S.simpleSegment(0,0,4,2)),this.texture?(d||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new At(x,this.canvas,b.RGBA,{premultiply:!0});let S=!1;for(const C in this.tiles){const A=this.tiles[C];A.state!=="loaded"&&(A.state="loaded",A.texture=this.texture,S=!0)}S&&this.fire(new s.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))},this.serialize=()=>({type:"canvas",coordinates:this.coordinates}),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(x=>typeof x!="number"))||this.fire(new s.j(new s.Y(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new s.j(new s.Y(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new s.j(new s.Y(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new s.j(new s.Y(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new s.j(new s.Y(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const je={},Bi=u=>{switch(u){case"geojson":return Xe;case"image":return ct;case"raster":return Fe;case"raster-dem":return Pt;case"vector":return Oi;case"video":return Zi;case"canvas":return gr}return je[u]};function yr(u,t){const n=s.Z();return s.$(n,n,[1,1,0]),s.a0(n,n,[.5*u.width,.5*u.height,1]),s.a1(n,n,u.calculatePosMatrix(t.toUnwrapped()))}function hi(u,t,n,a,c,d){const x=function(P,O,H){if(P)for(const W of P){const K=O[W];if(K&&K.source===H&&K.type==="fill-extrusion")return!0}else for(const W in O){const K=O[W];if(K.source===H&&K.type==="fill-extrusion")return!0}return!1}(c&&c.layers,t,u.id),b=d.maxPitchScaleFactor(),S=u.tilesIn(a,b,x);S.sort(co);const C=[];for(const P of S)C.push({wrappedTileID:P.tileID.wrapped().key,queryResults:P.tile.queryRenderedFeatures(t,n,u._state,P.queryGeometry,P.cameraQueryGeometry,P.scale,c,d,b,yr(u.transform,P.tileID))});const A=function(P){const O={},H={};for(const W of P){const K=W.queryResults,q=W.wrappedTileID,le=H[q]=H[q]||{};for(const _e in K){const ee=K[_e],ce=le[_e]=le[_e]||{},ve=O[_e]=O[_e]||[];for(const xe of ee)ce[xe.featureIndex]||(ce[xe.featureIndex]=!0,ve.push(xe))}}return O}(C);for(const P in A)A[P].forEach(O=>{const H=O.feature,W=u.getFeatureState(H.layer["source-layer"],H.id);H.source=H.layer.source,H.layer["source-layer"]&&(H.sourceLayer=H.layer["source-layer"]),H.state=W});return A}function co(u,t){const n=u.tileID,a=t.tileID;return n.overscaledZ-a.overscaledZ||n.canonical.y-a.canonical.y||n.wrap-a.wrap||n.canonical.x-a.canonical.x}class wo{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=s.a2(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const n=t+this.timeAdded;nd.getLayer(C)).filter(Boolean);if(S.length!==0){b.layers=S,b.stateDependentLayerIds&&(b.stateDependentLayers=b.stateDependentLayerIds.map(C=>S.filter(A=>A.id===C)[0]));for(const C of S)x[C.id]=b}}return x}(t.buckets,n.style),this.hasSymbolBuckets=!1;for(const c in this.buckets){const d=this.buckets[c];if(d instanceof s.a4){if(this.hasSymbolBuckets=!0,!a)break;d.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const c in this.buckets){const d=this.buckets[c];if(d instanceof s.a4&&d.hasRTLText){this.hasRTLText=!0,s.a5();break}}this.queryPadding=0;for(const c in this.buckets){const d=this.buckets[c];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(c).queryRadius(d))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new s.a3}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const a in this.buckets){const c=this.buckets[a];c.uploadPending()&&c.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new At(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new At(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,a,c,d,x,b,S,C,A){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:c,cameraQueryGeometry:d,scale:x,tileSize:this.tileSize,pixelPosMatrix:A,transform:S,params:b,queryPadding:this.queryPadding*C},t,n,a):{}}querySourceFeatures(t,n){const a=this.latestFeatureIndex;if(!a||!a.rawTileData)return;const c=a.loadVTLayers(),d=n&&n.sourceLayer?n.sourceLayer:"",x=c._geojsonTileLayer||c[d];if(!x)return;const b=s.a6(n&&n.filter),{z:S,x:C,y:A}=this.tileID.canonical,P={z:S,x:C,y:A};for(let O=0;Oa)c=!1;else if(n)if(this.expirationTime{this.remove(t,d)},a)),this.data[c].push(d),this.order.push(c),this.order.length>this.max){const x=this._getAndRemoveByKey(this.order[0]);x&&this.onRemove(x)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const n=this.data[t].shift();return n.timeout&&clearTimeout(n.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),n.value}getByKey(t){const n=this.data[t];return n?n[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,n){if(!this.has(t))return this;const a=t.wrapped().key,c=n===void 0?0:this.data[a].indexOf(n),d=this.data[a][c];return this.data[a].splice(c,1),d.timeout&&clearTimeout(d.timeout),this.data[a].length===0&&delete this.data[a],this.onRemove(d.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(t){const n=[];for(const a in this.data)for(const c of this.data[a])t(c.value)||n.push(c);for(const a of n)this.remove(a.value.tileID,a)}}class Se{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,a){const c=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][c]=this.stateChanges[t][c]||{},s.e(this.stateChanges[t][c],a),this.deletedStates[t]===null){this.deletedStates[t]={};for(const d in this.state[t])d!==c&&(this.deletedStates[t][d]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][c]===null){this.deletedStates[t][c]={};for(const d in this.state[t][c])a[d]||(this.deletedStates[t][c][d]=null)}else for(const d in a)this.deletedStates[t]&&this.deletedStates[t][c]&&this.deletedStates[t][c][d]===null&&delete this.deletedStates[t][c][d]}removeFeatureState(t,n,a){if(this.deletedStates[t]===null)return;const c=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},a&&n!==void 0)this.deletedStates[t][c]!==null&&(this.deletedStates[t][c]=this.deletedStates[t][c]||{},this.deletedStates[t][c][a]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][c])for(a in this.deletedStates[t][c]={},this.stateChanges[t][c])this.deletedStates[t][c][a]=null;else this.deletedStates[t][c]=null;else this.deletedStates[t]=null}getState(t,n){const a=String(n),c=s.e({},(this.state[t]||{})[a],(this.stateChanges[t]||{})[a]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const d=this.deletedStates[t][n];if(d===null)return{};for(const x in d)delete c[x]}return c}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const a={};for(const c in this.stateChanges){this.state[c]=this.state[c]||{};const d={};for(const x in this.stateChanges[c])this.state[c][x]||(this.state[c][x]={}),s.e(this.state[c][x],this.stateChanges[c][x]),d[x]=this.state[c][x];a[c]=d}for(const c in this.deletedStates){this.state[c]=this.state[c]||{};const d={};if(this.deletedStates[c]===null)for(const x in this.state[c])d[x]={},this.state[c][x]={};else for(const x in this.deletedStates[c]){if(this.deletedStates[c][x]===null)this.state[c][x]={};else for(const b of Object.keys(this.deletedStates[c][x]))delete this.state[c][x][b];d[x]=this.state[c][x]}a[c]=a[c]||{},s.e(a[c],d)}if(this.stateChanges={},this.deletedStates={},Object.keys(a).length!==0)for(const c in t)t[c].setFeatureState(a,n)}}class tn extends s.E{constructor(t,n,a){super(),this.id=t,this.dispatcher=a,this.on("data",c=>{c.dataType==="source"&&c.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&c.dataType==="source"&&c.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((c,d,x,b)=>{const S=new(Bi(d.type))(c,d,x,b);if(S.id!==c)throw new Error(`Expected Source id to be ${c} instead of ${S.id}`);return S})(t,n,a,this),this._tiles={},this._cache=new jo(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Se,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t in this._tiles){const n=this._tiles[t];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n){return this._source.loadTile(t,n)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,()=>{})}_abortTile(t){this._source.abortTile&&this._source.abortTile(t,()=>{}),this._source.fire(new s.k("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const a=this._tiles[n];a.upload(t),a.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(In).map(t=>t.key)}getRenderableIds(t){const n=[];for(const a in this._tiles)this._isIdRenderable(a,t)&&n.push(this._tiles[a]);return t?n.sort((a,c)=>{const d=a.tileID,x=c.tileID,b=new s.P(d.canonical.x,d.canonical.y)._rotate(this.transform.angle),S=new s.P(x.canonical.x,x.canonical.y)._rotate(this.transform.angle);return d.overscaledZ-x.overscaledZ||S.y-b.y||S.x-b.x}).map(a=>a.tileID.key):n.map(a=>a.tileID).sort(In).map(a=>a.key)}hasRenderableParent(t){const n=this.findLoadedParent(t,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(t,n){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(n||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(t,"reloading")}}_reloadTile(t,n){const a=this._tiles[t];a&&(a.state!=="loading"&&(a.state=n),this._loadTile(a,this._tileLoaded.bind(this,a,t,n)))}_tileLoaded(t,n,a,c){if(c)return t.state="errored",void(c.status!==404?this._source.fire(new s.j(c,{tile:t})):this.update(this.transform,this.terrain));t.timeAdded=s.h.now(),a==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new s.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const n=this.getRenderableIds();for(let c=0;c1||(Math.abs(x)>1&&(Math.abs(x+S)===1?x+=S:Math.abs(x-S)===1&&(x-=S)),d.dem&&c.dem&&(c.dem.backfillBorder(d.dem,x,b),c.neighboringTiles&&c.neighboringTiles[C]&&(c.neighboringTiles[C].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,n,a,c){for(const d in this._tiles){let x=this._tiles[d];if(c[d]||!x.hasData()||x.tileID.overscaledZ<=n||x.tileID.overscaledZ>a)continue;let b=x.tileID;for(;x&&x.tileID.overscaledZ>n+1;){const C=x.tileID.scaledTo(x.tileID.overscaledZ-1);x=this._tiles[C.key],x&&x.hasData()&&(b=C)}let S=b;for(;S.overscaledZ>n;)if(S=S.scaledTo(S.overscaledZ-1),t[S.key]){c[b.key]=b;break}}}findLoadedParent(t,n){if(t.key in this._loadedParentTiles){const a=this._loadedParentTiles[t.key];return a&&a.tileID.overscaledZ>=n?a:null}for(let a=t.overscaledZ-1;a>=n;a--){const c=t.scaledTo(a),d=this._getLoadedTile(c);if(d)return d}}_getLoadedTile(t){const n=this._tiles[t.key];return n&&n.hasData()?n:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,a=Math.ceil(t.height/this._source.tileSize)+1,c=Math.floor(n*a*(this._maxTileCacheZoomLevels===null?s.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),d=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,c):c;this._cache.setMaxSize(d)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,n){const a={};for(const c in this._tiles){const d=this._tiles[c];d.tileID=d.tileID.unwrapTo(d.tileID.wrap+n),a[d.tileID.key]=d}this._tiles=a;for(const c in this._timers)clearTimeout(this._timers[c]),delete this._timers[c];for(const c in this._tiles)this._setTileReloadTimer(c,this._tiles[c])}}update(t,n){if(this.transform=t,this.terrain=n,!this._sourceLoaded||this._paused)return;let a;this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(A=>new s.O(A.canonical.z,A.wrap,A.canonical.z,A.canonical.x,A.canonical.y)):(a=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n}),this._source.hasTile&&(a=a.filter(A=>this._source.hasTile(A)))):a=[];const c=t.coveringZoomLevel(this._source),d=Math.max(c-tn.maxOverzooming,this._source.minzoom),x=Math.max(c+tn.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const A={};for(const P of a)if(P.canonical.z>this._source.minzoom){const O=P.scaledTo(P.canonical.z-1);A[O.key]=O;const H=P.scaledTo(Math.max(this._source.minzoom,Math.min(P.canonical.z,5)));A[H.key]=H}a=a.concat(Object.values(A))}const b=a.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,b&&this.fire(new s.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const S=this._updateRetainedTiles(a,c);if(Ii(this._source.type)){const A={},P={},O=Object.keys(S),H=s.h.now();for(const W of O){const K=S[W],q=this._tiles[W];if(!q||q.fadeEndTime!==0&&q.fadeEndTime<=H)continue;const le=this.findLoadedParent(K,d);le&&(this._addTile(le.tileID),A[le.tileID.key]=le.tileID),P[W]=K}this._retainLoadedChildren(P,c,x,S);for(const W in A)S[W]||(this._coveredTiles[W]=!0,S[W]=A[W]);if(n){const W={},K={};for(const q of a)this._tiles[q.key].hasData()?W[q.key]=q:K[q.key]=q;for(const q in K){const le=K[q].children(this._source.maxzoom);this._tiles[le[0].key]&&this._tiles[le[1].key]&&this._tiles[le[2].key]&&this._tiles[le[3].key]&&(W[le[0].key]=S[le[0].key]=le[0],W[le[1].key]=S[le[1].key]=le[1],W[le[2].key]=S[le[2].key]=le[2],W[le[3].key]=S[le[3].key]=le[3],delete K[q])}for(const q in K){const le=this.findLoadedParent(K[q],this._source.minzoom);if(le){W[le.tileID.key]=S[le.tileID.key]=le.tileID;for(const _e in W)W[_e].isChildOf(le.tileID)&&delete W[_e]}}for(const q in this._tiles)W[q]||(this._coveredTiles[q]=!0)}}for(const A in S)this._tiles[A].clearFadeHold();const C=s.ab(this._tiles,S);for(const A of C){const P=this._tiles[A];P.hasSymbolBuckets&&!P.holdingForFade()?P.setHoldDuration(this.map._fadeDuration):P.hasSymbolBuckets&&!P.symbolFadeFinished()||this._removeTile(A)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){const a={},c={},d=Math.max(n-tn.maxOverzooming,this._source.minzoom),x=Math.max(n+tn.maxUnderzooming,this._source.minzoom),b={};for(const S of t){const C=this._addTile(S);a[S.key]=S,C.hasData()||nthis._source.maxzoom){const P=S.children(this._source.maxzoom)[0],O=this.getTile(P);if(O&&O.hasData()){a[P.key]=P;continue}}else{const P=S.children(this._source.maxzoom);if(a[P[0].key]&&a[P[1].key]&&a[P[2].key]&&a[P[3].key])continue}let A=C.wasRequested();for(let P=S.overscaledZ-1;P>=d;--P){const O=S.scaledTo(P);if(c[O.key])break;if(c[O.key]=!0,C=this.getTile(O),!C&&A&&(C=this._addTile(O)),C){const H=C.hasData();if((A||H)&&(a[O.key]=O),A=C.wasRequested(),H)break}}}return a}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const n=[];let a,c=this._tiles[t].tileID;for(;c.overscaledZ>0;){if(c.key in this._loadedParentTiles){a=this._loadedParentTiles[c.key];break}n.push(c.key);const d=c.scaledTo(c.overscaledZ-1);if(a=this._getLoadedTile(d),a)break;c=d}for(const d of n)this._loadedParentTiles[d]=a}}_addTile(t){let n=this._tiles[t.key];if(n)return n;n=this._cache.getAndRemove(t),n&&(this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,n)));const a=n;return n||(n=new wo(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,this._tileLoaded.bind(this,n,t.key,n.state))),n.uses++,this._tiles[t.key]=n,a||this._source.fire(new s.k("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const a=n.getExpiryTimeout();a&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},a))}_removeTile(t){const n=this._tiles[t];n&&(n.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,n,a){const c=[],d=this.transform;if(!d)return c;const x=a?d.getCameraQueryGeometry(t):t,b=t.map(W=>d.pointCoordinate(W,this.terrain)),S=x.map(W=>d.pointCoordinate(W,this.terrain)),C=this.getIds();let A=1/0,P=1/0,O=-1/0,H=-1/0;for(const W of S)A=Math.min(A,W.x),P=Math.min(P,W.y),O=Math.max(O,W.x),H=Math.max(H,W.y);for(let W=0;W=0&&ee[1].y+_e>=0){const ce=b.map(xe=>q.getTilePoint(xe)),ve=S.map(xe=>q.getTilePoint(xe));c.push({tile:K,tileID:q,queryGeometry:ce,cameraQueryGeometry:ve,scale:le})}}return c}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map(a=>this._tiles[a].tileID);for(const a of n)a.posMatrix=this.transform.calculatePosMatrix(a.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(Ii(this._source.type)){const t=s.h.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=t)return!0}return!1}setFeatureState(t,n,a){this._state.updateState(t=t||"_geojsonTileLayer",n,a)}removeFeatureState(t,n,a){this._state.removeFeatureState(t=t||"_geojsonTileLayer",n,a)}getFeatureState(t,n){return this._state.getState(t=t||"_geojsonTileLayer",n)}setDependencies(t,n,a){const c=this._tiles[t];c&&c.setDependencies(n,a)}reloadTilesForDependencies(t,n){for(const a in this._tiles)this._tiles[a].hasDependency(t,n)&&this._reloadTile(a,"reloading");this._cache.filter(a=>!a.hasDependency(t,n))}}function In(u,t){const n=Math.abs(2*u.wrap)-+(u.wrap<0),a=Math.abs(2*t.wrap)-+(t.wrap<0);return u.overscaledZ-t.overscaledZ||a-n||t.canonical.y-u.canonical.y||t.canonical.x-u.canonical.x}function Ii(u){return u==="raster"||u==="image"||u==="video"}tn.maxOverzooming=10,tn.maxUnderzooming=3;const ii="mapboxgl_preloaded_worker_pool";class Vn{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[ii]}numActive(){return Object.keys(this.active).length}}const En=Math.floor(s.h.hardwareConcurrency/2);let Un;function qo(){return Un||(Un=new Vn),Un}Vn.workerCount=s.ac(globalThis)?Math.max(Math.min(En,3),1):1;class So{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let a=1;a0?(c-x)/b:0;return this.points[d].mult(1-S).add(this.points[n].mult(S))}}function Cn(u,t){let n=!0;return u==="always"||u!=="never"&&t!=="never"||(n=!1),n}class $n{constructor(t,n,a){const c=this.boxCells=[],d=this.circleCells=[];this.xCellCount=Math.ceil(t/a),this.yCellCount=Math.ceil(n/a);for(let x=0;xthis.width||c<0||n>this.height)return[];const S=[];if(t<=0&&n<=0&&this.width<=a&&this.height<=c){if(d)return[{key:null,x1:t,y1:n,x2:a,y2:c}];for(let C=0;C0}hitTestCircle(t,n,a,c,d){const x=t-a,b=t+a,S=n-a,C=n+a;if(b<0||x>this.width||C<0||S>this.height)return!1;const A=[];return this._forEachCell(x,S,b,C,this._queryCellCircle,A,{hitTest:!0,overlapMode:c,circle:{x:t,y:n,radius:a},seenUids:{box:{},circle:{}}},d),A.length>0}_queryCell(t,n,a,c,d,x,b,S){const{seenUids:C,hitTest:A,overlapMode:P}=b,O=this.boxCells[d];if(O!==null){const W=this.bboxes;for(const K of O)if(!C.box[K]){C.box[K]=!0;const q=4*K,le=this.boxKeys[K];if(t<=W[q+2]&&n<=W[q+3]&&a>=W[q+0]&&c>=W[q+1]&&(!S||S(le))&&(!A||!Cn(P,le.overlapMode))&&(x.push({key:le,x1:W[q],y1:W[q+1],x2:W[q+2],y2:W[q+3]}),A))return!0}}const H=this.circleCells[d];if(H!==null){const W=this.circles;for(const K of H)if(!C.circle[K]){C.circle[K]=!0;const q=3*K,le=this.circleKeys[K];if(this._circleAndRectCollide(W[q],W[q+1],W[q+2],t,n,a,c)&&(!S||S(le))&&(!A||!Cn(P,le.overlapMode))){const _e=W[q],ee=W[q+1],ce=W[q+2];if(x.push({key:le,x1:_e-ce,y1:ee-ce,x2:_e+ce,y2:ee+ce}),A)return!0}}}return!1}_queryCellCircle(t,n,a,c,d,x,b,S){const{circle:C,seenUids:A,overlapMode:P}=b,O=this.boxCells[d];if(O!==null){const W=this.bboxes;for(const K of O)if(!A.box[K]){A.box[K]=!0;const q=4*K,le=this.boxKeys[K];if(this._circleAndRectCollide(C.x,C.y,C.radius,W[q+0],W[q+1],W[q+2],W[q+3])&&(!S||S(le))&&!Cn(P,le.overlapMode))return x.push(!0),!0}}const H=this.circleCells[d];if(H!==null){const W=this.circles;for(const K of H)if(!A.circle[K]){A.circle[K]=!0;const q=3*K,le=this.circleKeys[K];if(this._circlesCollide(W[q],W[q+1],W[q+2],C.x,C.y,C.radius)&&(!S||S(le))&&!Cn(P,le.overlapMode))return x.push(!0),!0}}}_forEachCell(t,n,a,c,d,x,b,S){const C=this._convertToXCellCoord(t),A=this._convertToYCellCoord(n),P=this._convertToXCellCoord(a),O=this._convertToYCellCoord(c);for(let H=C;H<=P;H++)for(let W=A;W<=O;W++)if(d.call(this,t,n,a,c,this.xCellCount*W+H,x,b,S))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,a,c,d,x){const b=c-t,S=d-n,C=a+x;return C*C>b*b+S*S}_circleAndRectCollide(t,n,a,c,d,x,b){const S=(x-c)/2,C=Math.abs(t-(c+S));if(C>S+a)return!1;const A=(b-d)/2,P=Math.abs(n-(d+A));if(P>A+a)return!1;if(C<=S||P<=A)return!0;const O=C-S,H=P-A;return O*O+H*H<=a*a}}function Ze(u,t,n,a,c){const d=s.Z();return t?(s.a0(d,d,[1/c,1/c,1]),n||s.ae(d,d,a.angle)):s.a1(d,a.labelPlaneMatrix,u),d}function mn(u,t,n,a,c){if(t){const d=s.af(u);return s.a0(d,d,[c,c,1]),n||s.ae(d,d,-a.angle),d}return a.glCoordMatrix}function er(u,t,n){let a;n?(a=[u.x,u.y,n(u.x,u.y),1],s.ag(a,a,t)):(a=[u.x,u.y,0,1],J(a,a,t));const c=a[3];return{point:new s.P(a[0]/c,a[1]/c),signedDistanceFromCamera:c}}function Zo(u,t){return .5+u/t*.5}function rn(u,t){const n=u[0]/u[3],a=u[1]/u[3];return n>=-t[0]&&n<=t[0]&&a>=-t[1]&&a<=t[1]}function He(u,t,n,a,c,d,x,b,S,C){const A=a?u.textSizeData:u.iconSizeData,P=s.ah(A,n.transform.zoom),O=[256/n.width*2+1,256/n.height*2+1],H=a?u.text.dynamicLayoutVertexArray:u.icon.dynamicLayoutVertexArray;H.clear();const W=u.lineVertexArray,K=a?u.text.placedSymbolArray:u.icon.placedSymbolArray,q=n.transform.width/n.transform.height;let le=!1;for(let _e=0;_eMath.abs(n.x-t.x)*a?{useVertical:!0}:(u===s.ai.vertical?t.yn.x)?{needsFlipping:!0}:null}function Ur(u,t,n,a,c,d,x,b,S,C,A,P,O,H,W,K){const q=t/24,le=u.lineOffsetX*q,_e=u.lineOffsetY*q;let ee;if(u.numGlyphs>1){const ce=u.glyphStartIndex+u.numGlyphs,ve=u.lineStartIndex,xe=u.lineStartIndex+u.lineLength,Ce=Bt(q,b,le,_e,n,A,P,u,S,d,O,W,K);if(!Ce)return{notEnoughRoom:!0};const Be=er(Ce.first.point,x,K).point,Le=er(Ce.last.point,x,K).point;if(a&&!n){const qe=Mt(u.writingMode,Be,Le,H);if(qe)return qe}ee=[Ce.first];for(let qe=u.glyphStartIndex+1;qe0?Be.point:_n(P,Ce,ve,1,c,K),qe=Mt(u.writingMode,ve,Le,H);if(qe)return qe}const ce=L(q*b.getoffsetX(u.glyphStartIndex),le,_e,n,A,P,u.segment,u.lineStartIndex,u.lineStartIndex+u.lineLength,S,d,O,W,K);if(!ce)return{notEnoughRoom:!0};ee=[ce]}for(const ce of ee)s.ak(C,ce.point,ce.angle);return{}}function _n(u,t,n,a,c,d){const x=er(u.add(u.sub(t)._unit()),c,d).point,b=n.sub(x);return n.add(b._mult(a/b.mag()))}function It(u,t){const{projectionCache:n,lineVertexArray:a,labelPlaneMatrix:c,tileAnchorPoint:d,distanceFromAnchor:x,getElevation:b,previousVertex:S,direction:C,absOffsetX:A}=t;if(n.projections[u])return n.projections[u];const P=new s.P(a.getx(u),a.gety(u)),O=er(P,c,b);if(O.signedDistanceFromCamera>0)return n.projections[u]=O.point,O.point;const H=u-C;return _n(x===0?d:new s.P(a.getx(H),a.gety(H)),P,S,A-x+1,c,b)}function Mn(u,t,n){return u._unit()._perp()._mult(t*n)}function X(u,t,n,a,c,d,x,b){const{projectionCache:S,direction:C}=b;if(S.offsets[u])return S.offsets[u];const A=n.add(t);if(u+C=c)return S.offsets[u]=A,A;const P=It(u+C,b),O=Mn(P.sub(n),x,C),H=n.add(O),W=P.add(O);return S.offsets[u]=s.al(d,A,H,W)||A,S.offsets[u]}function L(u,t,n,a,c,d,x,b,S,C,A,P,O,H){const W=a?u-t:u+t;let K=W>0?1:-1,q=0;a&&(K*=-1,q=Math.PI),K<0&&(q+=Math.PI);let le,_e,ee=K>0?b+x:b+x+1,ce=c,ve=c,xe=0,Ce=0;const Be=Math.abs(W),Le=[];let qe;for(;xe+Ce<=Be;){if(ee+=K,ee=S)return null;xe+=Ce,ve=ce,_e=le;const $e={projectionCache:P,lineVertexArray:C,labelPlaneMatrix:A,tileAnchorPoint:d,distanceFromAnchor:xe,getElevation:H,previousVertex:ve,direction:K,absOffsetX:Be};if(ce=It(ee,$e),n===0)Le.push(ve),qe=ce.sub(ve);else{let Ct;const gt=ce.sub(ve);Ct=gt.mag()===0?Mn(It(ee+K,$e).sub(ce),n,K):Mn(gt,n,K),_e||(_e=ve.add(Ct)),le=X(ee,Ct,ce,b,S,_e,n,$e),Le.push(_e),qe=le.sub(_e)}Ce=qe.mag()}const dt=qe._mult((Be-xe)/Ce)._add(_e||ve),$t=q+Math.atan2(ce.y-ve.y,ce.x-ve.x);return Le.push(dt),{point:dt,angle:O?$t:0,path:Le}}const R=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function j(u,t){for(let n=0;n=1;jt--)gt.push($e.path[jt]);for(let jt=1;jter(ei,S,W));gt=jt.some(ei=>ei.signedDistanceFromCamera<=0)?[]:jt.map(ei=>ei.point)}let Jt=[];if(gt.length>0){const jt=gt[0].clone(),ei=gt[0].clone();for(let fr=1;fr=qe.x&&ei.x<=dt.x&&jt.y>=qe.y&&ei.y<=dt.y?[gt]:ei.xdt.x||ei.ydt.y?[]:s.am([gt],qe.x,qe.y,dt.x,dt.y)}for(const jt of Jt){$t.reset(jt,.25*Le);let ei=0;ei=$t.length<=.5*Le?1:Math.ceil($t.paddedLength/Mi)+1;for(let fr=0;fr=this.screenRightBoundary||cthis.screenBottomBoundary}isInsideGrid(t,n,a,c){return a>=0&&t=0&&na.collisionGroupID===n}}return this.collisionGroups[t]}}function kt(u,t,n,a,c){const{horizontalAlign:d,verticalAlign:x}=s.au(u);return new s.P(-(d-.5)*t+a[0]*c,-(x-.5)*n+a[1]*c)}function ut(u,t,n,a,c,d){const{x1:x,x2:b,y1:S,y2:C,anchorPointX:A,anchorPointY:P}=u,O=new s.P(t,n);return a&&O._rotate(c?d:-d),{x1:x+O.x,y1:S+O.y,x2:b+O.x,y2:C+O.y,anchorPointX:A,anchorPointY:P}}class vt{constructor(t,n,a,c,d){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new he(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=a,this.retainedQueryData={},this.collisionGroups=new mt(c),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,a,c){const d=a.getBucket(n),x=a.latestFeatureIndex;if(!d||!x||n.id!==d.layerIds[0])return;const b=a.collisionBoxArray,S=d.layers[0].layout,C=Math.pow(2,this.transform.zoom-a.tileID.overscaledZ),A=a.tileSize/s.N,P=this.transform.calculatePosMatrix(a.tileID.toUnwrapped()),O=S.get("text-pitch-alignment")==="map",H=S.get("text-rotation-alignment")==="map",W=oe(a,1,this.transform.zoom),K=Ze(P,O,H,this.transform,W);let q=null;if(O){const _e=mn(P,O,H,this.transform,W);q=s.a1([],this.transform.labelPlaneMatrix,_e)}this.retainedQueryData[d.bucketInstanceId]=new Ee(d.bucketInstanceId,x,d.sourceLayerIndex,d.index,a.tileID);const le={bucket:d,layout:S,posMatrix:P,textLabelPlaneMatrix:K,labelToScreenMatrix:q,scale:C,textPixelRatio:A,holdingForFade:a.holdingForFade(),collisionBoxArray:b,partiallyEvaluatedTextSize:s.ah(d.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(d.sourceID)};if(c)for(const _e of d.sortKeyRanges){const{sortKey:ee,symbolInstanceStart:ce,symbolInstanceEnd:ve}=_e;t.push({sortKey:ee,symbolInstanceStart:ce,symbolInstanceEnd:ve,parameters:le})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:d.symbolInstances.length,parameters:le})}attemptAnchorPlacement(t,n,a,c,d,x,b,S,C,A,P,O,H,W,K,q){const le=s.aq[t.textAnchor],_e=[t.textOffset0,t.textOffset1],ee=kt(le,a,c,_e,d),ce=this.collisionIndex.placeCollisionBox(ut(n,ee.x,ee.y,x,b,this.transform.angle),P,S,C,A.predicate,q);if((!K||this.collisionIndex.placeCollisionBox(ut(K,ee.x,ee.y,x,b,this.transform.angle),P,S,C,A.predicate,q).box.length!==0)&&ce.box.length>0){let ve;if(this.prevPlacement&&this.prevPlacement.variableOffsets[O.crossTileID]&&this.prevPlacement.placements[O.crossTileID]&&this.prevPlacement.placements[O.crossTileID].text&&(ve=this.prevPlacement.variableOffsets[O.crossTileID].anchor),O.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[O.crossTileID]={textOffset:_e,width:a,height:c,anchor:le,textBoxScale:d,prevAnchor:ve},this.markUsedJustification(H,le,O,W),H.allowVerticalPlacement&&(this.markUsedOrientation(H,W,O),this.placedOrientations[O.crossTileID]=W),{shift:ee,placedGlyphBoxes:ce}}}placeLayerBucketPart(t,n,a){const{bucket:c,layout:d,posMatrix:x,textLabelPlaneMatrix:b,labelToScreenMatrix:S,textPixelRatio:C,holdingForFade:A,collisionBoxArray:P,partiallyEvaluatedTextSize:O,collisionGroup:H}=t.parameters,W=d.get("text-optional"),K=d.get("icon-optional"),q=s.ar(d,"text-overlap","text-allow-overlap"),le=q==="always",_e=s.ar(d,"icon-overlap","icon-allow-overlap"),ee=_e==="always",ce=d.get("text-rotation-alignment")==="map",ve=d.get("text-pitch-alignment")==="map",xe=d.get("icon-text-fit")!=="none",Ce=d.get("symbol-z-order")==="viewport-y",Be=le&&(ee||!c.hasIconData()||K),Le=ee&&(le||!c.hasTextData()||W);!c.collisionArrays&&P&&c.deserializeCollisionBoxes(P);const qe=this.retainedQueryData[c.bucketInstanceId].tileID,dt=this.terrain?($e,Ct)=>this.terrain.getElevation(qe,$e,Ct):null,$t=($e,Ct)=>{var gt,Mi;if(n[$e.crossTileID])return;if(A)return void(this.placements[$e.crossTileID]=new Te(!1,!1,!1));let Jt=!1,jt=!1,ei=!0,fr=null,qi={box:null,offscreen:null},Kr={box:null,offscreen:null},kr=null,wr=null,Xn=null,Qi=0,Do=0,Fo=0;Ct.textFeatureIndex?Qi=Ct.textFeatureIndex:$e.useRuntimeCollisionCircles&&(Qi=$e.featureIndex),Ct.verticalTextFeatureIndex&&(Do=Ct.verticalTextFeatureIndex);const _s=Ct.textBox;if(_s){const cn=mr=>{let Pr=s.ai.horizontal;if(c.allowVerticalPlacement&&!mr&&this.prevPlacement){const Ln=this.prevPlacement.placedOrientations[$e.crossTileID];Ln&&(this.placedOrientations[$e.crossTileID]=Ln,Pr=Ln,this.markUsedOrientation(c,Pr,$e))}return Pr},Jr=(mr,Pr)=>{if(c.allowVerticalPlacement&&$e.numVerticalGlyphVertices>0&&Ct.verticalTextBox){for(const Ln of c.writingModes)if(Ln===s.ai.vertical?(qi=Pr(),Kr=qi):qi=mr(),qi&&qi.box&&qi.box.length)break}else qi=mr()},xn=$e.textAnchorOffsetStartIndex,Vs=$e.textAnchorOffsetEndIndex;if(Vs===xn){const mr=(Pr,Ln)=>{const _r=this.collisionIndex.placeCollisionBox(Pr,q,C,x,H.predicate,dt);return _r&&_r.box&&_r.box.length&&(this.markUsedOrientation(c,Ln,$e),this.placedOrientations[$e.crossTileID]=Ln),_r};Jr(()=>mr(_s,s.ai.horizontal),()=>{const Pr=Ct.verticalTextBox;return c.allowVerticalPlacement&&$e.numVerticalGlyphVertices>0&&Pr?mr(Pr,s.ai.vertical):{box:null,offscreen:null}}),cn(qi&&qi.box&&qi.box.length)}else{let mr=s.aq[(Mi=(gt=this.prevPlacement)===null||gt===void 0?void 0:gt.variableOffsets[$e.crossTileID])===null||Mi===void 0?void 0:Mi.anchor];const Pr=(_r,Us,_l)=>{const jc=_r.x2-_r.x1,qc=_r.y2-_r.y1,wu=$e.textBoxScale,Ql=xe&&_e==="never"?Us:null;let Ro={box:[],offscreen:!1},js=q==="never"?1:2,Oo="never";mr&&js++;for(let ao=0;aoPr(_s,Ct.iconBox,s.ai.horizontal),()=>{const _r=Ct.verticalTextBox;return c.allowVerticalPlacement&&!(qi&&qi.box&&qi.box.length)&&$e.numVerticalGlyphVertices>0&&_r?Pr(_r,Ct.verticalIconBox,s.ai.vertical):{box:null,offscreen:null}}),qi&&(Jt=qi.box,ei=qi.offscreen);const Ln=cn(qi&&qi.box);if(!Jt&&this.prevPlacement){const _r=this.prevPlacement.variableOffsets[$e.crossTileID];_r&&(this.variableOffsets[$e.crossTileID]=_r,this.markUsedJustification(c,_r.anchor,$e,Ln))}}}if(kr=qi,Jt=kr&&kr.box&&kr.box.length>0,ei=kr&&kr.offscreen,$e.useRuntimeCollisionCircles){const cn=c.text.placedSymbolArray.get($e.centerJustifiedTextSymbolIndex),Jr=s.aj(c.textSizeData,O,cn),xn=d.get("text-padding");wr=this.collisionIndex.placeCollisionCircles(q,cn,c.lineVertexArray,c.glyphOffsetArray,Jr,x,b,S,a,ve,H.predicate,$e.collisionCircleDiameter,xn,dt),wr.circles.length&&wr.collisionDetected&&!a&&s.w("Collisions detected, but collision boxes are not shown"),Jt=le||wr.circles.length>0&&!wr.collisionDetected,ei=ei&&wr.offscreen}if(Ct.iconFeatureIndex&&(Fo=Ct.iconFeatureIndex),Ct.iconBox){const cn=Jr=>{const xn=xe&&fr?ut(Jr,fr.x,fr.y,ce,ve,this.transform.angle):Jr;return this.collisionIndex.placeCollisionBox(xn,_e,C,x,H.predicate,dt)};Kr&&Kr.box&&Kr.box.length&&Ct.verticalIconBox?(Xn=cn(Ct.verticalIconBox),jt=Xn.box.length>0):(Xn=cn(Ct.iconBox),jt=Xn.box.length>0),ei=ei&&Xn.offscreen}const Ns=W||$e.numHorizontalGlyphVertices===0&&$e.numVerticalGlyphVertices===0,Ca=K||$e.numIconVertices===0;if(Ns||Ca?Ca?Ns||(jt=jt&&Jt):Jt=jt&&Jt:jt=Jt=jt&&Jt,Jt&&kr&&kr.box&&this.collisionIndex.insertCollisionBox(kr.box,q,d.get("text-ignore-placement"),c.bucketInstanceId,Kr&&Kr.box&&Do?Do:Qi,H.ID),jt&&Xn&&this.collisionIndex.insertCollisionBox(Xn.box,_e,d.get("icon-ignore-placement"),c.bucketInstanceId,Fo,H.ID),wr&&(Jt&&this.collisionIndex.insertCollisionCircles(wr.circles,q,d.get("text-ignore-placement"),c.bucketInstanceId,Qi,H.ID),a)){const cn=c.bucketInstanceId;let Jr=this.collisionCircleArrays[cn];Jr===void 0&&(Jr=this.collisionCircleArrays[cn]=new Ie);for(let xn=0;xn=0;--Ct){const gt=$e[Ct];$t(c.symbolInstances.get(gt),c.collisionArrays[gt])}}else for(let $e=t.symbolInstanceStart;$e=0&&(t.text.placedSymbolArray.get(b).crossTileID=d>=0&&b!==d?0:a.crossTileID)}markUsedOrientation(t,n,a){const c=n===s.ai.horizontal||n===s.ai.horizontalOnly?n:0,d=n===s.ai.vertical?n:0,x=[a.leftJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.rightJustifiedTextSymbolIndex];for(const b of x)t.text.placedSymbolArray.get(b).placedOrientation=c;a.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(a.verticalPlacedTextSymbolIndex).placedOrientation=d)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let a=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const c=n?n.symbolFadeChange(t):1,d=n?n.opacities:{},x=n?n.variableOffsets:{},b=n?n.placedOrientations:{};for(const S in this.placements){const C=this.placements[S],A=d[S];A?(this.opacities[S]=new ae(A,c,C.text,C.icon),a=a||C.text!==A.text.placed||C.icon!==A.icon.placed):(this.opacities[S]=new ae(null,c,C.text,C.icon,C.skipFade),a=a||C.text||C.icon)}for(const S in d){const C=d[S];if(!this.opacities[S]){const A=new ae(C,c,!1,!1);A.isHidden()||(this.opacities[S]=A,a=a||C.text.placed||C.icon.placed)}}for(const S in x)this.variableOffsets[S]||!this.opacities[S]||this.opacities[S].isHidden()||(this.variableOffsets[S]=x[S]);for(const S in b)this.placedOrientations[S]||!this.opacities[S]||this.opacities[S].isHidden()||(this.placedOrientations[S]=b[S]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");a?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const a={};for(const c of n){const d=c.getBucket(t);d&&c.latestFeatureIndex&&t.id===d.layerIds[0]&&this.updateBucketOpacities(d,a,c.collisionBoxArray)}}updateBucketOpacities(t,n,a){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0],d=c.layout,x=new ae(null,0,!1,!1,!0),b=d.get("text-allow-overlap"),S=d.get("icon-allow-overlap"),C=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),A=d.get("text-rotation-alignment")==="map",P=d.get("text-pitch-alignment")==="map",O=d.get("icon-text-fit")!=="none",H=new ae(null,0,b&&(S||!t.hasIconData()||d.get("icon-optional")),S&&(b||!t.hasTextData()||d.get("text-optional")),!0);!t.collisionArrays&&a&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(a);const W=(K,q,le)=>{for(let _e=0;_e0,xe=this.placedOrientations[q.crossTileID],Ce=xe===s.ai.vertical,Be=xe===s.ai.horizontal||xe===s.ai.horizontalOnly;if(le>0||_e>0){const Le=vr(ce.text);W(t.text,le,Ce?An:Le),W(t.text,_e,Be?An:Le);const qe=ce.text.isHidden();[q.rightJustifiedTextSymbolIndex,q.centerJustifiedTextSymbolIndex,q.leftJustifiedTextSymbolIndex].forEach($e=>{$e>=0&&(t.text.placedSymbolArray.get($e).hidden=qe||Ce?1:0)}),q.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(q.verticalPlacedTextSymbolIndex).hidden=qe||Be?1:0);const dt=this.variableOffsets[q.crossTileID];dt&&this.markUsedJustification(t,dt.anchor,q,xe);const $t=this.placedOrientations[q.crossTileID];$t&&(this.markUsedJustification(t,"left",q,$t),this.markUsedOrientation(t,$t,q))}if(ve){const Le=vr(ce.icon),qe=!(O&&q.verticalPlacedIconSymbolIndex&&Ce);q.placedIconSymbolIndex>=0&&(W(t.icon,q.numIconVertices,qe?Le:An),t.icon.placedSymbolArray.get(q.placedIconSymbolIndex).hidden=ce.icon.isHidden()),q.verticalPlacedIconSymbolIndex>=0&&(W(t.icon,q.numVerticalIconVertices,qe?An:Le),t.icon.placedSymbolArray.get(q.verticalPlacedIconSymbolIndex).hidden=ce.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const Le=t.collisionArrays[K];if(Le){let qe=new s.P(0,0);if(Le.textBox||Le.verticalTextBox){let $t=!0;if(C){const $e=this.variableOffsets[ee];$e?(qe=kt($e.anchor,$e.width,$e.height,$e.textOffset,$e.textBoxScale),A&&qe._rotate(P?this.transform.angle:-this.transform.angle)):$t=!1}Le.textBox&&Ft(t.textCollisionBox.collisionVertexArray,ce.text.placed,!$t||Ce,qe.x,qe.y),Le.verticalTextBox&&Ft(t.textCollisionBox.collisionVertexArray,ce.text.placed,!$t||Be,qe.x,qe.y)}const dt=!!(!Be&&Le.verticalIconBox);Le.iconBox&&Ft(t.iconCollisionBox.collisionVertexArray,ce.icon.placed,dt,O?qe.x:0,O?qe.y:0),Le.verticalIconBox&&Ft(t.iconCollisionBox.collisionVertexArray,ce.icon.placed,!dt,O?qe.x:0,O?qe.y:0)}}}if(t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const K=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=K.invProjMatrix,t.placementViewportMatrix=K.viewportMatrix,t.collisionCircleArray=K.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function Ft(u,t,n,a,c){u.emplaceBack(t?1:0,n?1:0,a||0,c||0),u.emplaceBack(t?1:0,n?1:0,a||0,c||0),u.emplaceBack(t?1:0,n?1:0,a||0,c||0),u.emplaceBack(t?1:0,n?1:0,a||0,c||0)}const gi=Math.pow(2,25),Ut=Math.pow(2,24),ai=Math.pow(2,17),ri=Math.pow(2,16),jr=Math.pow(2,9),Ei=Math.pow(2,8),hr=Math.pow(2,1);function vr(u){if(u.opacity===0&&!u.placed)return 0;if(u.opacity===1&&u.placed)return 4294967295;const t=u.placed?1:0,n=Math.floor(127*u.opacity);return n*gi+t*Ut+n*ai+t*ri+n*jr+t*Ei+n*hr+t}const An=0;class ws{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,a,c,d){const x=this._bucketParts;for(;this._currentTileIndexb.sortKey-S.sortKey));this._currentPartIndex!this._forceFullPlacement&&s.h.now()-c>2;for(;this._currentPlacementIndex>=0;){const x=n[t[this._currentPlacementIndex]],b=this.placement.collisionIndex.transform.zoom;if(x.type==="symbol"&&(!x.minzoom||x.minzoom<=b)&&(!x.maxzoom||x.maxzoom>b)){if(this._inProgressLayer||(this._inProgressLayer=new ws(x)),this._inProgressLayer.continuePlacement(a[x.source],this.placement,this._showCollisionBoxes,x,d))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Io=512/s.N/2;class xr{constructor(t,n,a){this.tileID=t,this.bucketInstanceId=a,this._symbolsByKey={};const c=new Map;for(let d=0;d({x:Math.floor(S.anchorX*Io),y:Math.floor(S.anchorY*Io)})),crossTileIDs:x.map(S=>S.crossTileID)};if(b.positions.length>128){const S=new s.av(b.positions.length,16,Uint16Array);for(const{x:C,y:A}of b.positions)S.add(C,A);S.finish(),delete b.positions,b.index=S}this._symbolsByKey[d]=b}}getScaledCoordinates(t,n){const{x:a,y:c,z:d}=this.tileID.canonical,{x,y:b,z:S}=n.canonical,C=Io/Math.pow(2,S-d),A=(b*s.N+t.anchorY)*C,P=c*s.N*Io;return{x:Math.floor((x*s.N+t.anchorX)*C-a*s.N*Io),y:Math.floor(A-P)}}findMatches(t,n,a){const c=this.tileID.canonical.zt)}}class yi{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ta{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const a in this.indexes){const c=this.indexes[a],d={};for(const x in c){const b=c[x];b.tileID=b.tileID.unwrapTo(b.tileID.wrap+n),d[b.tileID.key]=b}this.indexes[a]=d}this.lng=t}addBucket(t,n,a){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let d=0;dt.overscaledZ)for(const b in x){const S=x[b];S.tileID.isChildOf(t)&&S.findMatches(n.symbolInstances,t,c)}else{const b=x[t.scaledTo(Number(d)).key];b&&b.findMatches(n.symbolInstances,t,c)}}for(let d=0;d{n[a]=!0});for(const a in this.layerIndexes)n[a]||delete this.layerIndexes[a]}}const ji=(u,t)=>s.x(u,t&&t.filter(n=>n.identifier!=="source.canvas")),qr=s.F(s.ax,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setGlyphs","setSprite"]),Go=s.F(s.ax,["setCenter","setZoom","setBearing","setPitch"]),Ir=s.aw();class Er extends s.E{constructor(t,n={}){super(),this.map=t,this.dispatcher=new zi(qo(),this,t._getMapId()),this.imageManager=new We,this.imageManager.setEventedParent(this),this.glyphManager=new Lt(t._requestManager,n.localIdeographFontFamily),this.lineAtlas=new Vr(256,512),this.crossTileSymbolIndex=new jn,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new s.ay,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",s.az());const a=this;this._rtlTextPluginCallback=Er.registerForPluginStateChange(c=>{a.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:c.pluginStatus,pluginURL:c.pluginURL},(d,x)=>{if(s.aA(d),x&&x.every(b=>b))for(const b in a.sourceCaches){const S=a.sourceCaches[b].getSource().type;S!=="vector"&&S!=="geojson"||a.sourceCaches[b].reload()}})}),this.on("data",c=>{if(c.dataType!=="source"||c.sourceDataType!=="metadata")return;const d=this.sourceCaches[c.sourceId];if(!d)return;const x=d.getSource();if(x&&x.vectorLayerIds)for(const b in this._layers){const S=this._layers[b];S.source===x.id&&this._validateLayer(S)}})}loadURL(t,n={},a){this.fire(new s.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const c=this.map._requestManager.transformRequest(t,Ve.Style);this._request=s.f(c,(d,x)=>{this._request=null,d?this.fire(new s.j(d)):x&&this._load(x,n,a)})}loadJSON(t,n={},a){this.fire(new s.k("dataloading",{dataType:"style"})),this._request=s.h.frame(()=>{this._request=null,n.validate=n.validate!==!1,this._load(t,n,a)})}loadEmpty(){this.fire(new s.k("dataloading",{dataType:"style"})),this._load(Ir,{validate:!1})}_load(t,n,a){var c;const d=n.transformStyle?n.transformStyle(a,t):t;if(!n.validate||!ji(this,s.y(d))){this._loaded=!0,this.stylesheet=d;for(const x in d.sources)this.addSource(x,d.sources[x],{validate:!1});d.sprite?this._loadSprite(d.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(d.glyphs),this._createLayers(),this.light=new en(this.stylesheet.light),this.map.setTerrain((c=this.stylesheet.terrain)!==null&&c!==void 0?c:null),this.fire(new s.k("data",{dataType:"style"})),this.fire(new s.k("style.load"))}}_createLayers(){const t=s.aB(this.stylesheet.layers);this.dispatcher.broadcast("setLayers",t),this._order=t.map(n=>n.id),this._layers={},this._serializedLayers=null;for(const n of t){const a=s.aC(n);a.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=a}}_loadSprite(t,n=!1,a=void 0){this.imageManager.setLoaded(!1),this._spriteRequest=function(c,d,x,b){const S=Nt(c),C=S.length,A=x>1?"@2x":"",P={},O={},H={};for(const{id:W,url:K}of S){const q=d.transformRequest(d.normalizeSpriteURL(K,A,".json"),Ve.SpriteJSON),le=`${W}_${q.url}`;P[le]=s.f(q,(ce,ve)=>{delete P[le],O[W]=ve,Yt(b,O,H,ce,C)});const _e=d.transformRequest(d.normalizeSpriteURL(K,A,".png"),Ve.SpriteImage),ee=`${W}_${_e.url}`;P[ee]=De.getImage(_e,(ce,ve)=>{delete P[ee],H[W]=ve,Yt(b,O,H,ce,C)})}return{cancel(){for(const W of Object.values(P))W.cancel()}}}(t,this.map._requestManager,this.map.getPixelRatio(),(c,d)=>{if(this._spriteRequest=null,c)this.fire(new s.j(c));else if(d)for(const x in d){this._spritesImagesIds[x]=[];const b=this._spritesImagesIds[x]?this._spritesImagesIds[x].filter(S=>!(S in d)):[];for(const S of b)this.imageManager.removeImage(S),this._changedImages[S]=!0;for(const S in d[x]){const C=x==="default"?S:`${x}:${S}`;this._spritesImagesIds[x].push(C),C in this.imageManager.images?this.imageManager.updateImage(C,d[x][S],!1):this.imageManager.addImage(C,d[x][S]),n&&(this._changedImages[C]=!0)}}this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.k("data",{dataType:"style"})),a&&a(c)})}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.k("data",{dataType:"style"}))}_validateLayer(t){const n=this.sourceCaches[t.source];if(!n)return;const a=t.sourceLayer;if(!a)return;const c=n.getSource();(c.type==="geojson"||c.vectorLayerIds&&c.vectorLayerIds.indexOf(a)===-1)&&this.fire(new s.j(new Error(`Source layer "${a}" does not exist on source "${c.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t){const n=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n);const a=[];for(const c of t)n[c]&&a.push(n[c]);return a}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const n=Object.keys(this._layers);for(const a of n){const c=this._layers[a];c.type!=="custom"&&(t[a]=c.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const c=Object.keys(this._updatedLayers),d=Object.keys(this._removedLayers);(c.length||d.length)&&this._updateWorkerLayers(c,d);for(const x in this._updatedSources){const b=this._updatedSources[x];if(b==="reload")this._reloadSource(x);else{if(b!=="clear")throw new Error(`Invalid action ${b}`);this._clearSource(x)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const x in this._updatedPaintProps)this._layers[x].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const a={};for(const c in this.sourceCaches){const d=this.sourceCaches[c];a[c]=d.used,d.used=!1}for(const c of this._order){const d=this._layers[c];d.recalculate(t,this._availableImages),!d.isHidden(t.zoom)&&d.source&&(this.sourceCaches[d.source].used=!0)}for(const c in a){const d=this.sourceCaches[c];a[c]!==d.used&&d.fire(new s.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:c}))}this.light.recalculate(t),this.z=t.zoom,n&&this.fire(new s.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("updateLayers",{layers:this._serializeByIds(t),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){this._checkLoaded();const a=this.serialize();if(t=n.transformStyle?n.transformStyle(a,t):t,ji(this,s.y(t)))return!1;(t=s.aD(t)).layers=s.aB(t.layers);const c=s.aE(a,t).filter(x=>!(x.command in Go));if(c.length===0)return!1;const d=c.filter(x=>!(x.command in qr));if(d.length>0)throw new Error(`Unimplemented: ${d.map(x=>x.command).join(", ")}.`);for(const x of c)x.command!=="setTransition"&&this[x.command].apply(this,x.args);return this.stylesheet=t,this._serializedLayers=null,!0}addImage(t,n){if(this.getImage(t))return this.fire(new s.j(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new s.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,a={}){if(this._checkLoaded(),this.sourceCaches[t]!==void 0)throw new Error(`Source "${t}" already exists.`);if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(s.y.source,`sources.${t}`,n,null,a))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const c=this.sourceCaches[t]=new tn(t,n,this.dispatcher);c.style=this,c.setEventedParent(this,()=>({isSourceLoaded:c.loaded(),source:c.serialize(),sourceId:t})),c.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error("There is no source with this ID");for(const a in this._layers)if(this._layers[a].source===t)return this.fire(new s.j(new Error(`Source "${t}" cannot be removed while layer "${a}" is using it.`)));const n=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],n.fire(new s.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const a=this.sourceCaches[t].getSource();if(a.type!=="geojson")throw new Error(`geojsonSource.type is ${a.type}, which is !== 'geojson`);a.setData(n),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,n,a={}){this._checkLoaded();const c=t.id;if(this.getLayer(c))return void this.fire(new s.j(new Error(`Layer "${c}" already exists on this map.`)));let d;if(t.type==="custom"){if(ji(this,s.aF(t)))return;d=s.aC(t)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(c,t.source),t=s.aD(t),t=s.e(t,{source:c})),this._validate(s.y.layer,`layers.${c}`,t,{arrayIndex:-1},a))return;d=s.aC(t),this._validateLayer(d),d.setEventedParent(this,{layer:{id:c}})}const x=n?this._order.indexOf(n):this._order.length;if(n&&x===-1)this.fire(new s.j(new Error(`Cannot add layer "${c}" before non-existing layer "${n}".`)));else{if(this._order.splice(x,0,c),this._layerOrderChanged=!0,this._layers[c]=d,this._removedLayers[c]&&d.source&&d.type!=="custom"){const b=this._removedLayers[c];delete this._removedLayers[c],b.type!==d.type?this._updatedSources[d.source]="clear":(this._updatedSources[d.source]="reload",this.sourceCaches[d.source].pause())}this._updateLayer(d),d.onAdd&&d.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new s.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const a=this._order.indexOf(t);this._order.splice(a,1);const c=n?this._order.indexOf(n):this._order.length;n&&c===-1?this.fire(new s.j(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(c,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new s.j(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const a=this._order.indexOf(t);this._order.splice(a,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,a){this._checkLoaded();const c=this.getLayer(t);c?c.minzoom===n&&c.maxzoom===a||(n!=null&&(c.minzoom=n),a!=null&&(c.maxzoom=a),this._updateLayer(c)):this.fire(new s.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,a={}){this._checkLoaded();const c=this.getLayer(t);if(c){if(!s.aG(c.filter,n))return n==null?(c.filter=void 0,void this._updateLayer(c)):void(this._validate(s.y.filter,`layers.${c.id}.filter`,n,null,a)||(c.filter=s.aD(n),this._updateLayer(c)))}else this.fire(new s.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return s.aD(this.getLayer(t).filter)}setLayoutProperty(t,n,a,c={}){this._checkLoaded();const d=this.getLayer(t);d?s.aG(d.getLayoutProperty(n),a)||(d.setLayoutProperty(n,a,c),this._updateLayer(d)):this.fire(new s.j(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const a=this.getLayer(t);if(a)return a.getLayoutProperty(n);this.fire(new s.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,a,c={}){this._checkLoaded();const d=this.getLayer(t);d?s.aG(d.getPaintProperty(n),a)||(d.setPaintProperty(n,a,c)&&this._updateLayer(d),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new s.j(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const a=t.source,c=t.sourceLayer,d=this.sourceCaches[a];if(d===void 0)return void this.fire(new s.j(new Error(`The source '${a}' does not exist in the map's style.`)));const x=d.getSource().type;x==="geojson"&&c?this.fire(new s.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):x!=="vector"||c?(t.id===void 0&&this.fire(new s.j(new Error("The feature id parameter must be provided."))),d.setFeatureState(c,t.id,n)):this.fire(new s.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const a=t.source,c=this.sourceCaches[a];if(c===void 0)return void this.fire(new s.j(new Error(`The source '${a}' does not exist in the map's style.`)));const d=c.getSource().type,x=d==="vector"?t.sourceLayer:void 0;d!=="vector"||x?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new s.j(new Error("A feature id is required to remove its specific state property."))):c.removeFeatureState(x,t.id,n):this.fire(new s.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,a=t.sourceLayer,c=this.sourceCaches[n];if(c!==void 0)return c.getSource().type!=="vector"||a?(t.id===void 0&&this.fire(new s.j(new Error("The feature id parameter must be provided."))),c.getFeatureState(a,t.id)):void this.fire(new s.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new s.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return s.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=s.aH(this.sourceCaches,d=>d.serialize()),n=this._serializeByIds(this._order),a=this.map.getTerrain()||void 0,c=this.stylesheet;return s.aI({version:c.version,name:c.name,metadata:c.metadata,light:c.light,center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch,sprite:c.sprite,glyphs:c.glyphs,transition:c.transition,sources:t,layers:n,terrain:a},d=>d!==void 0)}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.sourceCaches[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=x=>this._layers[x].type==="fill-extrusion",a={},c=[];for(let x=this._order.length-1;x>=0;x--){const b=this._order[x];if(n(b)){a[b]=x;for(const S of t){const C=S[b];if(C)for(const A of C)c.push(A)}}}c.sort((x,b)=>b.intersectionZ-x.intersectionZ);const d=[];for(let x=this._order.length-1;x>=0;x--){const b=this._order[x];if(n(b))for(let S=c.length-1;S>=0;S--){const C=c[S].feature;if(a[C.layer.id]{const Be=le.featureSortOrder;if(Be){const Le=Be.indexOf(xe.featureIndex);return Be.indexOf(Ce.featureIndex)-Le}return Ce.featureIndex-xe.featureIndex});for(const xe of ve)ce.push(xe)}}for(const le in W)W[le].forEach(_e=>{const ee=_e.feature,ce=C[b[le].source].getFeatureState(ee.layer["source-layer"],ee.id);ee.source=ee.layer.source,ee.layer["source-layer"]&&(ee.sourceLayer=ee.layer["source-layer"]),ee.state=ce});return W}(this._layers,x,this.sourceCaches,t,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(d)}querySourceFeatures(t,n){n&&n.filter&&this._validate(s.y.filter,"querySourceFeatures.filter",n.filter,null,n);const a=this.sourceCaches[t];return a?function(c,d){const x=c.getRenderableIds().map(C=>c.getTileByID(C)),b=[],S={};for(let C=0;C{je[c]=d})(t,n),n.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:n.workerSourceURL},a):a(null,null))}getLight(){return this.light.getLight()}setLight(t,n={}){this._checkLoaded();const a=this.light.getLight();let c=!1;for(const x in t)if(!s.aG(t[x],a[x])){c=!0;break}if(!c)return;const d={now:s.h.now(),transition:s.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,n),this.light.updateTransitions(d)}_validate(t,n,a,c,d={}){return(!d||d.validate!==!1)&&ji(this,t.call(s.y,s.e({key:n,style:this.serialize(),value:a,styleSpec:s.v},c)))}_remove(t=!0){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),s.aJ.off("pluginStateChange",this._rtlTextPluginCallback);for(const n in this._layers)this._layers[n].setEventedParent(null);for(const n in this.sourceCaches){const a=this.sourceCaches[n];a.setEventedParent(null),a.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove(t)}_clearSource(t){this.sourceCaches[t].clearTiles()}_reloadSource(t){this.sourceCaches[t].resume(),this.sourceCaches[t].reload()}_updateSources(t){for(const n in this.sourceCaches)this.sourceCaches[n].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.sourceCaches)this._reloadSource(t)}_updatePlacement(t,n,a,c,d=!1){let x=!1,b=!1;const S={};for(const C of this._order){const A=this._layers[C];if(A.type!=="symbol")continue;if(!S[A.source]){const O=this.sourceCaches[A.source];S[A.source]=O.getRenderableIds(!0).map(H=>O.getTileByID(H)).sort((H,W)=>W.tileID.overscaledZ-H.tileID.overscaledZ||(H.tileID.isLessThan(W.tileID)?-1:1))}const P=this.crossTileSymbolIndex.addLayer(A,S[A.source],t.center.lng);x=x||P}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((d=d||this._layerOrderChanged||a===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.h.now(),t.zoom))&&(this.pauseablePlacement=new To(t,this.map.terrain,this._order,d,n,a,c,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,S),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.h.now()),b=!0),x&&this.pauseablePlacement.placement.setStale()),b||x)for(const C of this._order){const A=this._layers[C];A.type==="symbol"&&this.placement.updateLayerOpacities(A,S[A.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.h.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,n,a){this.imageManager.getImages(n.icons,a),this._updateTilesForChangedImages();const c=this.sourceCaches[n.source];c&&c.setDependencies(n.tileID.key,n.type,n.icons)}getGlyphs(t,n,a){this.glyphManager.getGlyphs(n.stacks,a);const c=this.sourceCaches[n.source];c&&c.setDependencies(n.tileID.key,n.type,[""])}getResource(t,n,a){return s.m(n,a)}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(s.y.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,n,a={},c){this._checkLoaded();const d=[{id:t,url:n}],x=[...Nt(this.stylesheet.sprite),...d];this._validate(s.y.sprite,"sprite",x,null,a)||(this.stylesheet.sprite=x,this._loadSprite(d,!0,c))}removeSprite(t){this._checkLoaded();const n=Nt(this.stylesheet.sprite);if(n.find(a=>a.id===t)){if(this._spritesImagesIds[t])for(const a of this._spritesImagesIds[t])this.imageManager.removeImage(a),this._changedImages[a]=!0;n.splice(n.findIndex(a=>a.id===t),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new s.k("data",{dataType:"style"}))}else this.fire(new s.j(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return Nt(this.stylesheet.sprite)}setSprite(t,n={},a){this._checkLoaded(),t&&this._validate(s.y.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,a):(this._unloadSprite(),a&&a(null)))}}Er.registerForPluginStateChange=s.aK;var ia=s.Q([{name:"a_pos",type:"Int16",components:2}]),os="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";const Gi={prelude:di(`#ifdef GL_ES precision mediump float; #else #if !defined(lowp) @@ -524,61 +524,61 @@ void main() { #pragma mapbox: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : -u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:di("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",os),terrainDepth:di("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",os),terrainCoords:di("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",os)};function di(u,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,a=t.match(/attribute ([\w]+) ([\w]+)/g),c=u.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),d=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),x=d?d.concat(c):c,b={};return{fragmentSource:u=u.replace(n,(S,C,A,P,R)=>(b[R]=!0,C==="define"?` -#ifndef HAS_UNIFORM_u_${R} -varying ${A} ${P} ${R}; +u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:di("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",os),terrainDepth:di("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",os),terrainCoords:di("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",os)};function di(u,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,a=t.match(/attribute ([\w]+) ([\w]+)/g),c=u.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),d=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),x=d?d.concat(c):c,b={};return{fragmentSource:u=u.replace(n,(S,C,A,P,O)=>(b[O]=!0,C==="define"?` +#ifndef HAS_UNIFORM_u_${O} +varying ${A} ${P} ${O}; #else -uniform ${A} ${P} u_${R}; +uniform ${A} ${P} u_${O}; #endif `:` -#ifdef HAS_UNIFORM_u_${R} - ${A} ${P} ${R} = u_${R}; -#endif -`)),vertexSource:t=t.replace(n,(S,C,A,P,R)=>{const W=P==="float"?"vec2":"vec4",G=R.match(/color/)?"color":W;return b[R]?C==="define"?` -#ifndef HAS_UNIFORM_u_${R} -uniform lowp float u_${R}_t; -attribute ${A} ${W} a_${R}; -varying ${A} ${P} ${R}; +#ifdef HAS_UNIFORM_u_${O} + ${A} ${P} ${O} = u_${O}; +#endif +`)),vertexSource:t=t.replace(n,(S,C,A,P,O)=>{const H=P==="float"?"vec2":"vec4",W=O.match(/color/)?"color":H;return b[O]?C==="define"?` +#ifndef HAS_UNIFORM_u_${O} +uniform lowp float u_${O}_t; +attribute ${A} ${H} a_${O}; +varying ${A} ${P} ${O}; #else -uniform ${A} ${P} u_${R}; +uniform ${A} ${P} u_${O}; #endif -`:G==="vec4"?` -#ifndef HAS_UNIFORM_u_${R} - ${R} = a_${R}; +`:W==="vec4"?` +#ifndef HAS_UNIFORM_u_${O} + ${O} = a_${O}; #else - ${A} ${P} ${R} = u_${R}; + ${A} ${P} ${O} = u_${O}; #endif `:` -#ifndef HAS_UNIFORM_u_${R} - ${R} = unpack_mix_${G}(a_${R}, u_${R}_t); +#ifndef HAS_UNIFORM_u_${O} + ${O} = unpack_mix_${W}(a_${O}, u_${O}_t); #else - ${A} ${P} ${R} = u_${R}; + ${A} ${P} ${O} = u_${O}; #endif `:C==="define"?` -#ifndef HAS_UNIFORM_u_${R} -uniform lowp float u_${R}_t; -attribute ${A} ${W} a_${R}; +#ifndef HAS_UNIFORM_u_${O} +uniform lowp float u_${O}_t; +attribute ${A} ${H} a_${O}; #else -uniform ${A} ${P} u_${R}; +uniform ${A} ${P} u_${O}; #endif -`:G==="vec4"?` -#ifndef HAS_UNIFORM_u_${R} - ${A} ${P} ${R} = a_${R}; +`:W==="vec4"?` +#ifndef HAS_UNIFORM_u_${O} + ${A} ${P} ${O} = a_${O}; #else - ${A} ${P} ${R} = u_${R}; + ${A} ${P} ${O} = u_${O}; #endif `:` -#ifndef HAS_UNIFORM_u_${R} - ${A} ${P} ${R} = unpack_mix_${G}(a_${R}, u_${R}_t); +#ifndef HAS_UNIFORM_u_${O} + ${A} ${P} ${O} = unpack_mix_${W}(a_${O}, u_${O}_t); #else - ${A} ${P} ${R} = u_${R}; + ${A} ${P} ${O} = u_${O}; #endif -`}),staticAttributes:a,staticUniforms:x}}class uo{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,a,c,d,x,b,S,C){this.context=t;let A=this.boundPaintVertexBuffers.length!==c.length;for(let P=0;!A&&P({u_depth:new s.aL(xe,Me.u_depth),u_terrain:new s.aL(xe,Me.u_terrain),u_terrain_dim:new s.aM(xe,Me.u_terrain_dim),u_terrain_matrix:new s.aN(xe,Me.u_terrain_matrix),u_terrain_unpack:new s.aO(xe,Me.u_terrain_unpack),u_terrain_exaggeration:new s.aM(xe,Me.u_terrain_exaggeration)}))(t,ve),this.binderUniforms=a?a.getUniforms(t,ve):[]}draw(t,n,a,c,d,x,b,S,C,A,P,R,W,G,K,q,le,_e){const ee=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(a),t.setStencilMode(c),t.setColorMode(d),t.setCullFace(x),S){t.activeTexture.set(ee.TEXTURE2),ee.bindTexture(ee.TEXTURE_2D,S.depthTexture),t.activeTexture.set(ee.TEXTURE3),ee.bindTexture(ee.TEXTURE_2D,S.texture);for(const ve in this.terrainUniforms)this.terrainUniforms[ve].set(S[ve])}for(const ve in this.fixedUniforms)this.fixedUniforms[ve].set(b[ve]);K&&K.setUniforms(t,this.binderUniforms,W,{zoom:G});let ce=0;switch(n){case ee.LINES:ce=2;break;case ee.TRIANGLES:ce=3;break;case ee.LINE_STRIP:ce=1}for(const ve of R.get()){const xe=ve.vaos||(ve.vaos={});(xe[C]||(xe[C]=new uo)).bind(t,this,A,K?K.getPaintVertexBuffers():[],P,ve.vertexOffset,q,le,_e),ee.drawElements(n,ve.primitiveLength*ce,ee.UNSIGNED_SHORT,ve.primitiveOffset*ce*2)}}}function kn(u,t,n){const a=1/oe(n,1,t.transform.tileZoom),c=Math.pow(2,n.tileID.overscaledZ),d=n.tileSize*Math.pow(2,t.transform.tileZoom)/c,x=d*(n.tileID.canonical.x+n.tileID.wrap*c),b=d*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,u.fromScale,u.toScale],u_fade:u.t,u_pixel_coord_upper:[x>>16,b>>16],u_pixel_coord_lower:[65535&x,65535&b]}}const Na=(u,t,n,a)=>{const c=t.style.light,d=c.properties.get("position"),x=[d.x,d.y,d.z],b=function(){var C=new s.A(9);return s.A!=Float32Array&&(C[1]=0,C[2]=0,C[3]=0,C[5]=0,C[6]=0,C[7]=0),C[0]=1,C[4]=1,C[8]=1,C}();c.properties.get("anchor")==="viewport"&&function(C,A){var P=Math.sin(A),R=Math.cos(A);C[0]=R,C[1]=P,C[2]=0,C[3]=-P,C[4]=R,C[5]=0,C[6]=0,C[7]=0,C[8]=1}(b,-t.transform.angle),function(C,A,P){var R=A[0],W=A[1],G=A[2];C[0]=R*P[0]+W*P[3]+G*P[6],C[1]=R*P[1]+W*P[4]+G*P[7],C[2]=R*P[2]+W*P[5]+G*P[8]}(x,x,b);const S=c.properties.get("color");return{u_matrix:u,u_lightpos:x,u_lightintensity:c.properties.get("intensity"),u_lightcolor:[S.r,S.g,S.b],u_vertical_gradient:+n,u_opacity:a}},Eo=(u,t,n,a,c,d,x)=>s.e(Na(u,t,n,a),kn(d,t,x),{u_height_factor:-Math.pow(2,c.overscaledZ)/x.tileSize/8}),ws=u=>({u_matrix:u}),g=(u,t,n,a)=>s.e(ws(u),kn(n,t,a)),I=(u,t)=>({u_matrix:u,u_world:t}),O=(u,t,n,a,c)=>s.e(g(u,t,n,a),{u_world:c}),Y=(u,t,n,a)=>{const c=u.transform;let d,x;if(a.paint.get("circle-pitch-alignment")==="map"){const b=oe(n,1,c.zoom);d=!0,x=[b,b]}else d=!1,x=c.pixelsToGLUnits;return{u_camera_to_center_distance:c.cameraToCenterDistance,u_scale_with_map:+(a.paint.get("circle-pitch-scale")==="map"),u_matrix:u.translatePosMatrix(t.posMatrix,n,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_pitch_with_map:+d,u_device_pixel_ratio:u.pixelRatio,u_extrude_scale:x}},ne=(u,t,n)=>{const a=oe(n,1,t.zoom),c=Math.pow(2,t.zoom-n.tileID.overscaledZ),d=n.tileID.overscaleFactor();return{u_matrix:u,u_camera_to_center_distance:t.cameraToCenterDistance,u_pixels_to_tile_units:a,u_extrude_scale:[t.pixelsToGLUnits[0]/(a*c),t.pixelsToGLUnits[1]/(a*c)],u_overscale_factor:d}},se=(u,t,n=1)=>({u_matrix:u,u_color:t,u_overlay:0,u_overlay_scale:n}),fe=u=>({u_matrix:u}),Re=(u,t,n,a)=>({u_matrix:u,u_extrude_scale:oe(t,1,n),u_intensity:a});function Ve(u,t){const n=Math.pow(2,t.canonical.z),a=t.canonical.y;return[new s.U(0,a/n).toLngLat().lat,new s.U(0,(a+1)/n).toLngLat().lat]}const rt=(u,t,n,a)=>{const c=u.transform;return{u_matrix:Ot(u,t,n,a),u_ratio:1/oe(t,1,c.zoom),u_device_pixel_ratio:u.pixelRatio,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},ot=(u,t,n,a,c)=>s.e(rt(u,t,n,c),{u_image:0,u_image_height:a}),Je=(u,t,n,a,c)=>{const d=u.transform,x=Hi(t,d);return{u_matrix:Ot(u,t,n,c),u_texsize:t.imageAtlasTexture.size,u_ratio:1/oe(t,1,d.zoom),u_device_pixel_ratio:u.pixelRatio,u_image:0,u_scale:[x,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/d.pixelsToGLUnits[0],1/d.pixelsToGLUnits[1]]}},Rt=(u,t,n,a,c,d)=>{const x=u.lineAtlas,b=Hi(t,u.transform),S=n.layout.get("line-cap")==="round",C=x.getDash(a.from,S),A=x.getDash(a.to,S),P=C.width*c.fromScale,R=A.width*c.toScale;return s.e(rt(u,t,n,d),{u_patternscale_a:[b/P,-C.height/2],u_patternscale_b:[b/R,-A.height/2],u_sdfgamma:x.width/(256*Math.min(P,R)*u.pixelRatio)/2,u_image:0,u_tex_y_a:C.y,u_tex_y_b:A.y,u_mix:c.t})};function Hi(u,t){return 1/oe(u,1,t.tileZoom)}function Ot(u,t,n,a){return u.translatePosMatrix(a?a.posMatrix:t.tileID.posMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const ar=(u,t,n,a,c)=>{return{u_matrix:u,u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*c.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:c.paint.get("raster-brightness-min"),u_brightness_high:c.paint.get("raster-brightness-max"),u_saturation_factor:(x=c.paint.get("raster-saturation"),x>0?1-1/(1.001-x):-x),u_contrast_factor:(d=c.paint.get("raster-contrast"),d>0?1/(1-d):1+d),u_spin_weights:Pe(c.paint.get("raster-hue-rotate"))};var d,x};function Pe(u){u*=Math.PI/180;const t=Math.sin(u),n=Math.cos(u);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const _t=(u,t,n,a,c,d,x,b,S,C)=>{const A=c.transform;return{u_is_size_zoom_constant:+(u==="constant"||u==="source"),u_is_size_feature_constant:+(u==="constant"||u==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:A.cameraToCenterDistance,u_pitch:A.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:A.width/A.height,u_fade_change:c.options.fadeDuration?c.symbolFadeChange:1,u_matrix:d,u_label_plane_matrix:x,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+a,u_texsize:C,u_texture:0}},vi=(u,t,n,a,c,d,x,b,S,C,A)=>{const P=c.transform;return s.e(_t(u,t,n,a,c,d,x,b,S,C),{u_gamma_scale:a?Math.cos(P._pitch)*P.cameraToCenterDistance:1,u_device_pixel_ratio:c.pixelRatio,u_is_halo:+A})},Xi=(u,t,n,a,c,d,x,b,S,C)=>s.e(vi(u,t,n,a,c,d,x,b,!0,S,!0),{u_texsize_icon:C,u_texture_icon:1}),tr=(u,t,n)=>({u_matrix:u,u_opacity:t,u_color:n}),nn=(u,t,n,a,c,d)=>s.e(function(x,b,S,C){const A=S.imageManager.getPattern(x.from.toString()),P=S.imageManager.getPattern(x.to.toString()),{width:R,height:W}=S.imageManager.getPixelSize(),G=Math.pow(2,C.tileID.overscaledZ),K=C.tileSize*Math.pow(2,S.transform.tileZoom)/G,q=K*(C.tileID.canonical.x+C.tileID.wrap*G),le=K*C.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:A.tl,u_pattern_br_a:A.br,u_pattern_tl_b:P.tl,u_pattern_br_b:P.br,u_texsize:[R,W],u_mix:b.t,u_pattern_size_a:A.displaySize,u_pattern_size_b:P.displaySize,u_scale_a:b.fromScale,u_scale_b:b.toScale,u_tile_units_to_pixels:1/oe(C,1,S.transform.tileZoom),u_pixel_coord_upper:[q>>16,le>>16],u_pixel_coord_lower:[65535&q,65535&le]}}(a,d,n,c),{u_matrix:u,u_opacity:t}),ra={fillExtrusion:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_lightpos:new s.aP(u,t.u_lightpos),u_lightintensity:new s.aM(u,t.u_lightintensity),u_lightcolor:new s.aP(u,t.u_lightcolor),u_vertical_gradient:new s.aM(u,t.u_vertical_gradient),u_opacity:new s.aM(u,t.u_opacity)}),fillExtrusionPattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_lightpos:new s.aP(u,t.u_lightpos),u_lightintensity:new s.aM(u,t.u_lightintensity),u_lightcolor:new s.aP(u,t.u_lightcolor),u_vertical_gradient:new s.aM(u,t.u_vertical_gradient),u_height_factor:new s.aM(u,t.u_height_factor),u_image:new s.aL(u,t.u_image),u_texsize:new s.aQ(u,t.u_texsize),u_pixel_coord_upper:new s.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aQ(u,t.u_pixel_coord_lower),u_scale:new s.aP(u,t.u_scale),u_fade:new s.aM(u,t.u_fade),u_opacity:new s.aM(u,t.u_opacity)}),fill:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix)}),fillPattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_image:new s.aL(u,t.u_image),u_texsize:new s.aQ(u,t.u_texsize),u_pixel_coord_upper:new s.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aQ(u,t.u_pixel_coord_lower),u_scale:new s.aP(u,t.u_scale),u_fade:new s.aM(u,t.u_fade)}),fillOutline:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_world:new s.aQ(u,t.u_world)}),fillOutlinePattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_world:new s.aQ(u,t.u_world),u_image:new s.aL(u,t.u_image),u_texsize:new s.aQ(u,t.u_texsize),u_pixel_coord_upper:new s.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aQ(u,t.u_pixel_coord_lower),u_scale:new s.aP(u,t.u_scale),u_fade:new s.aM(u,t.u_fade)}),circle:(u,t)=>({u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_scale_with_map:new s.aL(u,t.u_scale_with_map),u_pitch_with_map:new s.aL(u,t.u_pitch_with_map),u_extrude_scale:new s.aQ(u,t.u_extrude_scale),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_matrix:new s.aN(u,t.u_matrix)}),collisionBox:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_pixels_to_tile_units:new s.aM(u,t.u_pixels_to_tile_units),u_extrude_scale:new s.aQ(u,t.u_extrude_scale),u_overscale_factor:new s.aM(u,t.u_overscale_factor)}),collisionCircle:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_inv_matrix:new s.aN(u,t.u_inv_matrix),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_viewport_size:new s.aQ(u,t.u_viewport_size)}),debug:(u,t)=>({u_color:new s.aR(u,t.u_color),u_matrix:new s.aN(u,t.u_matrix),u_overlay:new s.aL(u,t.u_overlay),u_overlay_scale:new s.aM(u,t.u_overlay_scale)}),clippingMask:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix)}),heatmap:(u,t)=>({u_extrude_scale:new s.aM(u,t.u_extrude_scale),u_intensity:new s.aM(u,t.u_intensity),u_matrix:new s.aN(u,t.u_matrix)}),heatmapTexture:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_world:new s.aQ(u,t.u_world),u_image:new s.aL(u,t.u_image),u_color_ramp:new s.aL(u,t.u_color_ramp),u_opacity:new s.aM(u,t.u_opacity)}),hillshade:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_image:new s.aL(u,t.u_image),u_latrange:new s.aQ(u,t.u_latrange),u_light:new s.aQ(u,t.u_light),u_shadow:new s.aR(u,t.u_shadow),u_highlight:new s.aR(u,t.u_highlight),u_accent:new s.aR(u,t.u_accent)}),hillshadePrepare:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_image:new s.aL(u,t.u_image),u_dimension:new s.aQ(u,t.u_dimension),u_zoom:new s.aM(u,t.u_zoom),u_unpack:new s.aO(u,t.u_unpack)}),line:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_ratio:new s.aM(u,t.u_ratio),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_units_to_pixels:new s.aQ(u,t.u_units_to_pixels)}),lineGradient:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_ratio:new s.aM(u,t.u_ratio),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_units_to_pixels:new s.aQ(u,t.u_units_to_pixels),u_image:new s.aL(u,t.u_image),u_image_height:new s.aM(u,t.u_image_height)}),linePattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_texsize:new s.aQ(u,t.u_texsize),u_ratio:new s.aM(u,t.u_ratio),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_image:new s.aL(u,t.u_image),u_units_to_pixels:new s.aQ(u,t.u_units_to_pixels),u_scale:new s.aP(u,t.u_scale),u_fade:new s.aM(u,t.u_fade)}),lineSDF:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_ratio:new s.aM(u,t.u_ratio),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_units_to_pixels:new s.aQ(u,t.u_units_to_pixels),u_patternscale_a:new s.aQ(u,t.u_patternscale_a),u_patternscale_b:new s.aQ(u,t.u_patternscale_b),u_sdfgamma:new s.aM(u,t.u_sdfgamma),u_image:new s.aL(u,t.u_image),u_tex_y_a:new s.aM(u,t.u_tex_y_a),u_tex_y_b:new s.aM(u,t.u_tex_y_b),u_mix:new s.aM(u,t.u_mix)}),raster:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_tl_parent:new s.aQ(u,t.u_tl_parent),u_scale_parent:new s.aM(u,t.u_scale_parent),u_buffer_scale:new s.aM(u,t.u_buffer_scale),u_fade_t:new s.aM(u,t.u_fade_t),u_opacity:new s.aM(u,t.u_opacity),u_image0:new s.aL(u,t.u_image0),u_image1:new s.aL(u,t.u_image1),u_brightness_low:new s.aM(u,t.u_brightness_low),u_brightness_high:new s.aM(u,t.u_brightness_high),u_saturation_factor:new s.aM(u,t.u_saturation_factor),u_contrast_factor:new s.aM(u,t.u_contrast_factor),u_spin_weights:new s.aP(u,t.u_spin_weights)}),symbolIcon:(u,t)=>({u_is_size_zoom_constant:new s.aL(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aL(u,t.u_is_size_feature_constant),u_size_t:new s.aM(u,t.u_size_t),u_size:new s.aM(u,t.u_size),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_pitch:new s.aM(u,t.u_pitch),u_rotate_symbol:new s.aL(u,t.u_rotate_symbol),u_aspect_ratio:new s.aM(u,t.u_aspect_ratio),u_fade_change:new s.aM(u,t.u_fade_change),u_matrix:new s.aN(u,t.u_matrix),u_label_plane_matrix:new s.aN(u,t.u_label_plane_matrix),u_coord_matrix:new s.aN(u,t.u_coord_matrix),u_is_text:new s.aL(u,t.u_is_text),u_pitch_with_map:new s.aL(u,t.u_pitch_with_map),u_texsize:new s.aQ(u,t.u_texsize),u_texture:new s.aL(u,t.u_texture)}),symbolSDF:(u,t)=>({u_is_size_zoom_constant:new s.aL(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aL(u,t.u_is_size_feature_constant),u_size_t:new s.aM(u,t.u_size_t),u_size:new s.aM(u,t.u_size),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_pitch:new s.aM(u,t.u_pitch),u_rotate_symbol:new s.aL(u,t.u_rotate_symbol),u_aspect_ratio:new s.aM(u,t.u_aspect_ratio),u_fade_change:new s.aM(u,t.u_fade_change),u_matrix:new s.aN(u,t.u_matrix),u_label_plane_matrix:new s.aN(u,t.u_label_plane_matrix),u_coord_matrix:new s.aN(u,t.u_coord_matrix),u_is_text:new s.aL(u,t.u_is_text),u_pitch_with_map:new s.aL(u,t.u_pitch_with_map),u_texsize:new s.aQ(u,t.u_texsize),u_texture:new s.aL(u,t.u_texture),u_gamma_scale:new s.aM(u,t.u_gamma_scale),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_is_halo:new s.aL(u,t.u_is_halo)}),symbolTextAndIcon:(u,t)=>({u_is_size_zoom_constant:new s.aL(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aL(u,t.u_is_size_feature_constant),u_size_t:new s.aM(u,t.u_size_t),u_size:new s.aM(u,t.u_size),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_pitch:new s.aM(u,t.u_pitch),u_rotate_symbol:new s.aL(u,t.u_rotate_symbol),u_aspect_ratio:new s.aM(u,t.u_aspect_ratio),u_fade_change:new s.aM(u,t.u_fade_change),u_matrix:new s.aN(u,t.u_matrix),u_label_plane_matrix:new s.aN(u,t.u_label_plane_matrix),u_coord_matrix:new s.aN(u,t.u_coord_matrix),u_is_text:new s.aL(u,t.u_is_text),u_pitch_with_map:new s.aL(u,t.u_pitch_with_map),u_texsize:new s.aQ(u,t.u_texsize),u_texsize_icon:new s.aQ(u,t.u_texsize_icon),u_texture:new s.aL(u,t.u_texture),u_texture_icon:new s.aL(u,t.u_texture_icon),u_gamma_scale:new s.aM(u,t.u_gamma_scale),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_is_halo:new s.aL(u,t.u_is_halo)}),background:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_opacity:new s.aM(u,t.u_opacity),u_color:new s.aR(u,t.u_color)}),backgroundPattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_opacity:new s.aM(u,t.u_opacity),u_image:new s.aL(u,t.u_image),u_pattern_tl_a:new s.aQ(u,t.u_pattern_tl_a),u_pattern_br_a:new s.aQ(u,t.u_pattern_br_a),u_pattern_tl_b:new s.aQ(u,t.u_pattern_tl_b),u_pattern_br_b:new s.aQ(u,t.u_pattern_br_b),u_texsize:new s.aQ(u,t.u_texsize),u_mix:new s.aM(u,t.u_mix),u_pattern_size_a:new s.aQ(u,t.u_pattern_size_a),u_pattern_size_b:new s.aQ(u,t.u_pattern_size_b),u_scale_a:new s.aM(u,t.u_scale_a),u_scale_b:new s.aM(u,t.u_scale_b),u_pixel_coord_upper:new s.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aQ(u,t.u_pixel_coord_lower),u_tile_units_to_pixels:new s.aM(u,t.u_tile_units_to_pixels)}),terrain:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_texture:new s.aL(u,t.u_texture),u_ele_delta:new s.aM(u,t.u_ele_delta)}),terrainDepth:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_ele_delta:new s.aM(u,t.u_ele_delta)}),terrainCoords:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_texture:new s.aL(u,t.u_texture),u_terrain_coords_id:new s.aM(u,t.u_terrain_coords_id),u_ele_delta:new s.aM(u,t.u_ele_delta)})};class Ci{constructor(t,n,a){this.context=t;const c=t.gl;this.buffer=c.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ss={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class na{constructor(t,n,a,c){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=c,this.context=t;const d=t.gl;this.buffer=d.createBuffer(),t.bindVertexBuffer.set(this.buffer),d.bufferData(d.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let a=0;a0){const je=s.Z(),dt=Me;s.aU(je,xe.placementInvProjMatrix,u.transform.glCoordMatrix),s.aU(je,je,xe.placementViewportMatrix),A.push({circleArray:ze,circleOffset:R,transform:dt,invTransform:je,coord:ce}),P+=ze.length/4,R=P}Oe&&C.draw(b,S.LINES,Qt.disabled,Ni.disabled,u.colorModeForRenderPass(),xi.disabled,ne(Me,u.transform,ve),u.style.map.terrain&&u.style.map.terrain.getTerrainData(ce),n.id,Oe.layoutVertexBuffer,Oe.indexBuffer,Oe.segments,null,u.transform.zoom,null,null,Oe.collisionVertexBuffer)}if(!x||!A.length)return;const W=u.useProgram("collisionCircle"),G=new s.aV;G.resize(4*P),G._trim();let K=0;for(const ee of A)for(let ce=0;ce=0&&(G[q.associatedIconIndex]={shiftedAnchor:$t,angle:Qe})}else j(q.numGlyphs,R)}if(C){W.clear();const K=u.icon.placedSymbolArray;for(let q=0;qu.style.map.terrain.getElevation(Oe,Ln,_r):null,zr=n.layout.get("text-rotation-alignment")==="map";We(je,Oe.posMatrix,u,c,Qi,Do,q,C,zr,mr)}const Os=u.translatePosMatrix(Oe.posMatrix,ze,d,x),Ca=le||c&&xe||_s?ls:Qi,cn=u.translatePosMatrix(Do,ze,d,x,!0),Jr=Qe&&n.paint.get(c?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let xn;xn=Qe?je.iconsInText?Xi(Ct.kind,Jt,_e,q,u,Os,Ca,cn,ei,Pr):vi(Ct.kind,Jt,_e,q,u,Os,Ca,cn,c,ei,!0):_t(Ct.kind,Jt,_e,q,u,Os,Ca,cn,c,ei);const Bs={program:Mi,buffers:dt,uniformValues:xn,atlasTexture:fr,atlasTextureIcon:wr,atlasInterpolation:qi,atlasInterpolationIcon:Kr,isSDF:Qe,hasHalo:Jr};if(ee&&je.canOverlap){ce=!0;const mr=dt.segments.get();for(const zr of mr)Me.push({segments:new s.S([zr]),sortKey:zr.sortKey,state:Bs,terrainData:jt})}else Me.push({segments:dt.segments,sortKey:0,state:Bs,terrainData:jt})}ce&&Me.sort((Oe,ze)=>Oe.sortKey-ze.sortKey);for(const Oe of Me){const ze=Oe.state;if(R.activeTexture.set(W.TEXTURE0),ze.atlasTexture.bind(ze.atlasInterpolation,W.CLAMP_TO_EDGE),ze.atlasTextureIcon&&(R.activeTexture.set(W.TEXTURE1),ze.atlasTextureIcon&&ze.atlasTextureIcon.bind(ze.atlasInterpolationIcon,W.CLAMP_TO_EDGE)),ze.isSDF){const je=ze.uniformValues;ze.hasHalo&&(je.u_is_halo=1,_a(ze.buffers,Oe.segments,n,u,ze.program,ve,A,P,je,Oe.terrainData)),je.u_is_halo=0}_a(ze.buffers,Oe.segments,n,u,ze.program,ve,A,P,ze.uniformValues,Oe.terrainData)}}function _a(u,t,n,a,c,d,x,b,S,C){const A=a.context;c.draw(A,A.gl.TRIANGLES,d,x,b,xi.disabled,S,C,n.id,u.layoutVertexBuffer,u.indexBuffer,t,n.paint,a.transform.zoom,u.programConfigurations.get(n.id),u.dynamicLayoutVertexBuffer,u.opacityVertexBuffer)}function us(u,t,n,a,c){if(!n||!a||!a.imageAtlas)return;const d=a.imageAtlas.patternPositions;let x=d[n.to.toString()],b=d[n.from.toString()];if(!x&&b&&(x=b),!b&&x&&(b=x),!x||!b){const S=c.getPaintProperty(t);x=d[S],b=d[S]}x&&b&&u.setConstantPatternPositions(x,b)}function Ms(u,t,n,a,c,d,x){const b=u.context.gl,S="fill-pattern",C=n.paint.get(S),A=C&&C.constantOr(1),P=n.getCrossfadeParameters();let R,W,G,K,q;x?(W=A&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",R=b.LINES):(W=A?"fillPattern":"fill",R=b.TRIANGLES);const le=C.constantOr(null);for(const _e of a){const ee=t.getTile(_e);if(A&&!ee.patternsLoaded())continue;const ce=ee.getBucket(n);if(!ce)continue;const ve=ce.programConfigurations.get(n.id),xe=u.useProgram(W,ve),Me=u.style.map.terrain&&u.style.map.terrain.getTerrainData(_e);A&&(u.context.activeTexture.set(b.TEXTURE0),ee.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),ve.updatePaintBuffers(P)),us(ve,S,le,ee,n);const Oe=Me?_e:null,ze=u.translatePosMatrix(Oe?Oe.posMatrix:_e.posMatrix,ee,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(x){K=ce.indexBuffer2,q=ce.segments2;const je=[b.drawingBufferWidth,b.drawingBufferHeight];G=W==="fillOutlinePattern"&&A?O(ze,u,P,ee,je):I(ze,je)}else K=ce.indexBuffer,q=ce.segments,G=A?g(ze,u,P,ee):ws(ze);xe.draw(u.context,R,c,u.stencilModeForClipping(_e),d,xi.disabled,G,Me,n.id,ce.layoutVertexBuffer,K,q,n.paint,u.transform.zoom,ve)}}function As(u,t,n,a,c,d,x){const b=u.context,S=b.gl,C="fill-extrusion-pattern",A=n.paint.get(C),P=A.constantOr(1),R=n.getCrossfadeParameters(),W=n.paint.get("fill-extrusion-opacity"),G=A.constantOr(null);for(const K of a){const q=t.getTile(K),le=q.getBucket(n);if(!le)continue;const _e=u.style.map.terrain&&u.style.map.terrain.getTerrainData(K),ee=le.programConfigurations.get(n.id),ce=u.useProgram(P?"fillExtrusionPattern":"fillExtrusion",ee);P&&(u.context.activeTexture.set(S.TEXTURE0),q.imageAtlasTexture.bind(S.LINEAR,S.CLAMP_TO_EDGE),ee.updatePaintBuffers(R)),us(ee,C,G,q,n);const ve=u.translatePosMatrix(K.posMatrix,q,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),xe=n.paint.get("fill-extrusion-vertical-gradient"),Me=P?Eo(ve,u,xe,W,K,R,q):Na(ve,u,xe,W);ce.draw(b,b.gl.TRIANGLES,c,d,x,xi.backCCW,Me,_e,n.id,le.layoutVertexBuffer,le.indexBuffer,le.segments,n.paint,u.transform.zoom,ee,u.style.map.terrain&&le.centroidVertexBuffer)}}function dl(u,t,n,a,c,d,x){const b=u.context,S=b.gl,C=n.fbo;if(!C)return;const A=u.useProgram("hillshade"),P=u.style.map.terrain&&u.style.map.terrain.getTerrainData(t);b.activeTexture.set(S.TEXTURE0),S.bindTexture(S.TEXTURE_2D,C.colorAttachment.get()),A.draw(b,S.TRIANGLES,c,d,x,xi.disabled,((R,W,G,K)=>{const q=G.paint.get("hillshade-shadow-color"),le=G.paint.get("hillshade-highlight-color"),_e=G.paint.get("hillshade-accent-color");let ee=G.paint.get("hillshade-illumination-direction")*(Math.PI/180);G.paint.get("hillshade-illumination-anchor")==="viewport"&&(ee-=R.transform.angle);const ce=!R.options.moving;return{u_matrix:K?K.posMatrix:R.transform.calculatePosMatrix(W.tileID.toUnwrapped(),ce),u_image:0,u_latrange:Ve(0,W.tileID),u_light:[G.paint.get("hillshade-exaggeration"),ee],u_shadow:q,u_highlight:le,u_accent:_e}})(u,n,a,P?t:null),P,a.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments)}function ga(u,t,n,a,c,d){const x=u.context,b=x.gl,S=t.dem;if(S&&S.data){const C=S.dim,A=S.stride,P=S.getPixels();if(x.activeTexture.set(b.TEXTURE1),x.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||u.getTileTexture(A),t.demTexture){const W=t.demTexture;W.update(P,{premultiply:!1}),W.bind(b.NEAREST,b.CLAMP_TO_EDGE)}else t.demTexture=new At(x,P,b.RGBA,{premultiply:!1}),t.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE);x.activeTexture.set(b.TEXTURE0);let R=t.fbo;if(!R){const W=new At(x,{width:C,height:C,data:null},b.RGBA);W.bind(b.LINEAR,b.CLAMP_TO_EDGE),R=t.fbo=x.createFramebuffer(C,C,!0,!1),R.colorAttachment.set(W.texture)}x.bindFramebuffer.set(R.framebuffer),x.viewport.set([0,0,C,C]),u.useProgram("hillshadePrepare").draw(x,b.TRIANGLES,a,c,d,xi.disabled,((W,G)=>{const K=G.stride,q=s.Z();return s.aS(q,0,s.N,-s.N,0,0,1),s.$(q,q,[0,-s.N,0]),{u_matrix:q,u_image:1,u_dimension:[K,K],u_zoom:W.overscaledZ,u_unpack:G.getUnpackVector()}})(t.tileID,S),null,n.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function ya(u,t,n,a,c,d){const x=a.paint.get("raster-fade-duration");if(!d&&x>0){const b=s.h.now(),S=(b-u.timeAdded)/x,C=t?(b-t.timeAdded)/x:-1,A=n.getSource(),P=c.coveringZoomLevel({tileSize:A.tileSize,roundZoom:A.roundZoom}),R=!t||Math.abs(t.tileID.overscaledZ-P)>Math.abs(u.tileID.overscaledZ-P),W=R&&u.refreshedUponExpiration?1:s.ad(R?S:1-C,0,1);return u.refreshedUponExpiration&&S>=1&&(u.refreshedUponExpiration=!1),t?{opacity:1,mix:1-W}:{opacity:W,mix:0}}return{opacity:1,mix:0}}const Xo=new s.aT(1,0,0,1),va=new s.aT(0,1,0,1),io=new s.aT(0,0,1,1),pl=new s.aT(1,0,1,1),Po=new s.aT(0,1,1,1);function hs(u,t,n,a){Ko(u,0,t+n/2,u.transform.width,n,a)}function xa(u,t,n,a){Ko(u,t-n/2,0,n,u.transform.height,a)}function Ko(u,t,n,a,c,d){const x=u.context,b=x.gl;b.enable(b.SCISSOR_TEST),b.scissor(t*u.pixelRatio,n*u.pixelRatio,a*u.pixelRatio,c*u.pixelRatio),x.clear({color:d}),b.disable(b.SCISSOR_TEST)}function ba(u,t,n){const a=u.context,c=a.gl,d=n.posMatrix,x=u.useProgram("debug"),b=Qt.disabled,S=Ni.disabled,C=u.colorModeForRenderPass(),A="$debug",P=u.style.map.terrain&&u.style.map.terrain.getTerrainData(n);a.activeTexture.set(c.TEXTURE0);const R=t.getTileByID(n.key).latestRawTileData,W=Math.floor((R&&R.byteLength||0)/1024),G=t.getTile(n).tileSize,K=512/Math.min(G,512)*(n.overscaledZ/u.transform.zoom)*.5;let q=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(q+=` => ${n.overscaledZ}`),function(le,_e){le.initDebugOverlayCanvas();const ee=le.debugOverlayCanvas,ce=le.context.gl,ve=le.debugOverlayCanvas.getContext("2d");ve.clearRect(0,0,ee.width,ee.height),ve.shadowColor="white",ve.shadowBlur=2,ve.lineWidth=1.5,ve.strokeStyle="white",ve.textBaseline="top",ve.font="bold 36px Open Sans, sans-serif",ve.fillText(_e,5,5),ve.strokeText(_e,5,5),le.debugOverlayTexture.update(ee),le.debugOverlayTexture.bind(ce.LINEAR,ce.CLAMP_TO_EDGE)}(u,`${q} ${W}kB`),x.draw(a,c.TRIANGLES,b,S,Ki.alphaBlended,xi.disabled,se(d,s.aT.transparent,K),null,A,u.debugBuffer,u.quadTriangleIndexBuffer,u.debugSegments),x.draw(a,c.LINE_STRIP,b,S,C,xi.disabled,se(d,s.aT.red),P,A,u.debugBuffer,u.tileBorderIndexBuffer,u.debugSegments)}function Ji(u,t,n){const a=u.context,c=a.gl,d=u.colorModeForRenderPass(),x=new Qt(c.LEQUAL,Qt.ReadWrite,u.depthRangeFor3D),b=u.useProgram("terrain"),S=t.getTerrainMesh();a.bindFramebuffer.set(null),a.viewport.set([0,0,u.width,u.height]);for(const C of n){const A=u.renderToTexture.getTexture(C),P=t.getTerrainData(C.tileID);a.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,A.texture);const R={u_matrix:u.transform.calculatePosMatrix(C.tileID.toUnwrapped()),u_texture:0,u_ele_delta:t.getMeshFrameDelta(u.transform.zoom)};b.draw(a,c.TRIANGLES,x,Ni.disabled,d,xi.backCCW,R,P,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}}class zo{constructor(t,n){this.context=new Fl(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:s.Z(),renderTime:0},this.setup(),this.numSublayers=tn.maxUnderzooming+tn.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new jn}resize(t,n,a){if(this.width=Math.floor(t*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const c of this.style._order)this.style._layers[c].resize()}setup(){const t=this.context,n=new s.a_;n.emplaceBack(0,0),n.emplaceBack(s.N,0),n.emplaceBack(0,s.N),n.emplaceBack(s.N,s.N),this.tileExtentBuffer=t.createVertexBuffer(n,ia.members),this.tileExtentSegments=s.S.simpleSegment(0,0,4,2);const a=new s.a_;a.emplaceBack(0,0),a.emplaceBack(s.N,0),a.emplaceBack(0,s.N),a.emplaceBack(s.N,s.N),this.debugBuffer=t.createVertexBuffer(a,ia.members),this.debugSegments=s.S.simpleSegment(0,0,4,5);const c=new s.V;c.emplaceBack(0,0,0,0),c.emplaceBack(s.N,0,s.N,0),c.emplaceBack(0,s.N,0,s.N),c.emplaceBack(s.N,s.N,s.N,s.N),this.rasterBoundsBuffer=t.createVertexBuffer(c,Gt.members),this.rasterBoundsSegments=s.S.simpleSegment(0,0,4,2);const d=new s.a_;d.emplaceBack(0,0),d.emplaceBack(1,0),d.emplaceBack(0,1),d.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(d,ia.members),this.viewportSegments=s.S.simpleSegment(0,0,4,2);const x=new s.a$;x.emplaceBack(0),x.emplaceBack(1),x.emplaceBack(3),x.emplaceBack(2),x.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(x);const b=new s.b0;b.emplaceBack(0,1,2),b.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(b);const S=this.context.gl;this.stencilClearMode=new Ni({func:S.ALWAYS,mask:0},0,255,S.ZERO,S.ZERO,S.ZERO)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=s.Z();s.aS(a,0,this.width,this.height,0,0,1),s.a0(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,n.TRIANGLES,Qt.disabled,this.stencilClearMode,Ki.disabled,xi.disabled,fe(a),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source;const a=this.context,c=a.gl;this.nextStencilID+n.length>256&&this.clearStencil(),a.setColorMode(Ki.disabled),a.setDepthMode(Qt.disabled);const d=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const x of n){const b=this._tileClippingMaskIDs[x.key]=this.nextStencilID++,S=this.style.map.terrain&&this.style.map.terrain.getTerrainData(x);d.draw(a,c.TRIANGLES,Qt.disabled,new Ni({func:c.ALWAYS,mask:0},b,255,c.KEEP,c.KEEP,c.REPLACE),Ki.disabled,xi.disabled,fe(x.posMatrix),S,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new Ni({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new Ni({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,a=t.sort((x,b)=>b.overscaledZ-x.overscaledZ),c=a[a.length-1].overscaledZ,d=a[0].overscaledZ-c+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const x={};for(let b=0;b=0;this.currentLayer--){const S=this.style._layers[a[this.currentLayer]],C=c[S.source],A=d[S.source];this._renderTileClippingMasks(S,A),this.renderLayer(this,C,S,A)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerq.source&&!q.isHidden(A)?[C.sourceCaches[q.source]]:[]),W=R.filter(q=>q.getSource().type==="vector"),G=R.filter(q=>q.getSource().type!=="vector"),K=q=>{(!P||P.getSource().maxzoomK(q)),P||G.forEach(q=>K(q)),P}(this.style,this.transform.zoom);S&&function(C,A,P){for(let R=0;RW.style.map.terrain.getElevation(xe,Ct,gt):null)}}}(S,d,b,x,b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),C),b.paint.get("icon-opacity").constantOr(1)!==0&&ko(d,x,b,S,!1,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),b.layout.get("icon-rotation-alignment"),b.layout.get("icon-pitch-alignment"),b.layout.get("icon-keep-upright"),A,P),b.paint.get("text-opacity").constantOr(1)!==0&&ko(d,x,b,S,!0,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),b.layout.get("text-keep-upright"),A,P),x.map.showCollisionBoxes&&(Ao(d,x,b,S,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),!0),Ao(d,x,b,S,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),!1))})(t,n,a,c,this.style.placement.variableOffsets);break;case"circle":(function(d,x,b,S){if(d.renderPass!=="translucent")return;const C=b.paint.get("circle-opacity"),A=b.paint.get("circle-stroke-width"),P=b.paint.get("circle-stroke-opacity"),R=!b.layout.get("circle-sort-key").isConstant();if(C.constantOr(1)===0&&(A.constantOr(1)===0||P.constantOr(1)===0))return;const W=d.context,G=W.gl,K=d.depthModeForSublayer(0,Qt.ReadOnly),q=Ni.disabled,le=d.colorModeForRenderPass(),_e=[];for(let ee=0;eeee.sortKey-ce.sortKey);for(const ee of _e){const{programConfiguration:ce,program:ve,layoutVertexBuffer:xe,indexBuffer:Me,uniformValues:Oe,terrainData:ze}=ee.state;ve.draw(W,G.TRIANGLES,K,q,le,xi.disabled,Oe,ze,b.id,xe,Me,ee.segments,b.paint,d.transform.zoom,ce)}})(t,n,a,c);break;case"heatmap":(function(d,x,b,S){if(b.paint.get("heatmap-opacity")!==0)if(d.renderPass==="offscreen"){const C=d.context,A=C.gl,P=Ni.disabled,R=new Ki([A.ONE,A.ONE],s.aT.transparent,[!0,!0,!0,!0]);(function(W,G,K){const q=W.gl;W.activeTexture.set(q.TEXTURE1),W.viewport.set([0,0,G.width/4,G.height/4]);let le=K.heatmapFbo;if(le)q.bindTexture(q.TEXTURE_2D,le.colorAttachment.get()),W.bindFramebuffer.set(le.framebuffer);else{const _e=q.createTexture();q.bindTexture(q.TEXTURE_2D,_e),q.texParameteri(q.TEXTURE_2D,q.TEXTURE_WRAP_S,q.CLAMP_TO_EDGE),q.texParameteri(q.TEXTURE_2D,q.TEXTURE_WRAP_T,q.CLAMP_TO_EDGE),q.texParameteri(q.TEXTURE_2D,q.TEXTURE_MIN_FILTER,q.LINEAR),q.texParameteri(q.TEXTURE_2D,q.TEXTURE_MAG_FILTER,q.LINEAR),le=K.heatmapFbo=W.createFramebuffer(G.width/4,G.height/4,!1,!1),function(ee,ce,ve,xe){var Me,Oe;const ze=ee.gl,je=(Me=ee.HALF_FLOAT)!==null&&Me!==void 0?Me:ze.UNSIGNED_BYTE,dt=(Oe=ee.RGBA16F)!==null&&Oe!==void 0?Oe:ze.RGBA;ze.texImage2D(ze.TEXTURE_2D,0,dt,ce.width/4,ce.height/4,0,ze.RGBA,je,null),xe.colorAttachment.set(ve)}(W,G,_e,le)}})(C,d,b),C.clear({color:s.aT.transparent});for(let W=0;W{const ee=s.Z();s.aS(ee,0,K.width,K.height,0,0,1);const ce=K.context.gl;return{u_matrix:ee,u_world:[ce.drawingBufferWidth,ce.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:q.paint.get("heatmap-opacity")}})(C,A),null,A.id,C.viewportBuffer,C.quadTriangleIndexBuffer,C.viewportSegments,A.paint,C.transform.zoom)}(d,b))})(t,n,a,c);break;case"line":(function(d,x,b,S){if(d.renderPass!=="translucent")return;const C=b.paint.get("line-opacity"),A=b.paint.get("line-width");if(C.constantOr(1)===0||A.constantOr(1)===0)return;const P=d.depthModeForSublayer(0,Qt.ReadOnly),R=d.colorModeForRenderPass(),W=b.paint.get("line-dasharray"),G=b.paint.get("line-pattern"),K=G.constantOr(1),q=b.paint.get("line-gradient"),le=b.getCrossfadeParameters(),_e=K?"linePattern":W?"lineSDF":q?"lineGradient":"line",ee=d.context,ce=ee.gl;let ve=!0;for(const xe of S){const Me=x.getTile(xe);if(K&&!Me.patternsLoaded())continue;const Oe=Me.getBucket(b);if(!Oe)continue;const ze=Oe.programConfigurations.get(b.id),je=d.context.program.get(),dt=d.useProgram(_e,ze),$t=ve||dt.program!==je,Qe=d.style.map.terrain&&d.style.map.terrain.getTerrainData(xe),Ct=G.constantOr(null);if(Ct&&Me.imageAtlas){const Jt=Me.imageAtlas,jt=Jt.patternPositions[Ct.to.toString()],ei=Jt.patternPositions[Ct.from.toString()];jt&&ei&&ze.setConstantPatternPositions(jt,ei)}const gt=Qe?xe:null,Mi=K?Je(d,Me,b,le,gt):W?Rt(d,Me,b,W,le,gt):q?ot(d,Me,b,Oe.lineClipsArray.length,gt):rt(d,Me,b,gt);if(K)ee.activeTexture.set(ce.TEXTURE0),Me.imageAtlasTexture.bind(ce.LINEAR,ce.CLAMP_TO_EDGE),ze.updatePaintBuffers(le);else if(W&&($t||d.lineAtlas.dirty))ee.activeTexture.set(ce.TEXTURE0),d.lineAtlas.bind(ee);else if(q){const Jt=Oe.gradients[b.id];let jt=Jt.texture;if(b.gradientVersion!==Jt.version){let ei=256;if(b.stepInterpolant){const fr=x.getSource().maxzoom,qi=xe.canonical.z===fr?Math.ceil(1<0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),a=this.imageManager.getPattern(t.to.toString());return!n||!a}useProgram(t,n){this.cache=this.cache||{};const a=t+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[a]||(this.cache[a]=new bs(this.context,Gi[t],n,ra[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[a]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new At(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}class Xr{constructor(t,n){this.points=t,this.planes=n}static fromInvProjectionMatrix(t,n,a){const c=Math.pow(2,a),d=[[-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(b=>{const S=1/(b=s.ag([],b,t))[3]/n*c;return s.b3(b,b,[S,S,1/b[3],S])}),x=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(b=>{const S=function(R,W){var G=W[0],K=W[1],q=W[2],le=G*G+K*K+q*q;return le>0&&(le=1/Math.sqrt(le)),R[0]=W[0]*le,R[1]=W[1]*le,R[2]=W[2]*le,R}([],function(R,W,G){var K=W[0],q=W[1],le=W[2],_e=G[0],ee=G[1],ce=G[2];return R[0]=q*ce-le*ee,R[1]=le*_e-K*ce,R[2]=K*ee-q*_e,R}([],ti([],d[b[0]],d[b[1]]),ti([],d[b[2]],d[b[1]]))),C=-((A=S)[0]*(P=d[b[1]])[0]+A[1]*P[1]+A[2]*P[2]);var A,P;return S.concat(C)});return new Xr(d,x)}}class ro{constructor(t,n){this.min=t,this.max=n,this.center=function(a,c,d){return a[0]=.5*c[0],a[1]=.5*c[1],a[2]=.5*c[2],a}([],function(a,c,d){return a[0]=c[0]+d[0],a[1]=c[1]+d[1],a[2]=c[2]+d[2],a}([],this.min,this.max))}quadrant(t){const n=[t%2==0,t<2],a=it(this.min),c=it(this.max);for(let d=0;d=0&&x++;if(x===0)return 0;x!==n.length&&(a=!1)}if(a)return 2;for(let c=0;c<3;c++){let d=Number.MAX_VALUE,x=-Number.MAX_VALUE;for(let b=0;bthis.max[c]-this.min[c])return 0}return 1}}class ds{constructor(t=0,n=0,a=0,c=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(c)||c<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=a,this.right=c}interpolate(t,n,a){return n.top!=null&&t.top!=null&&(this.top=s.B.number(t.top,n.top,a)),n.bottom!=null&&t.bottom!=null&&(this.bottom=s.B.number(t.bottom,n.bottom,a)),n.left!=null&&t.left!=null&&(this.left=s.B.number(t.left,n.left,a)),n.right!=null&&t.right!=null&&(this.right=s.B.number(t.right,n.right,a)),this}getCenter(t,n){const a=s.ad((this.left+t-this.right)/2,0,t),c=s.ad((this.top+n-this.bottom)/2,0,n);return new s.P(a,c)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new ds(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class wa{constructor(t,n,a,c,d){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=d===void 0||!!d,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=a??0,this._maxPitch=c??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new s.L(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new ds,this._posMatrixCache={},this._alignedPosMatrixCache={},this._minEleveationForCurrentTile=0}clone(){const t=new wa(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this._minEleveationForCurrentTile=t._minEleveationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new s.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const n=-s.b5(t,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var a=new s.A(4);return s.A!=Float32Array&&(a[1]=0,a[2]=0),a[0]=1,a[3]=1,a}(),function(a,c,d){var x=c[0],b=c[1],S=c[2],C=c[3],A=Math.sin(d),P=Math.cos(d);a[0]=x*P+S*A,a[1]=b*P+C*A,a[2]=x*-A+S*P,a[3]=b*-A+C*P}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=s.ad(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const n=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,a){this._unmodified=!1,this._edgeInsets.interpolate(t,n,a),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const n=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(t){const n=[new s.b6(0,t)];if(this._renderWorldCopies){const a=this.pointCoordinate(new s.P(0,0)),c=this.pointCoordinate(new s.P(this.width,0)),d=this.pointCoordinate(new s.P(this.width,this.height)),x=this.pointCoordinate(new s.P(0,this.height)),b=Math.floor(Math.min(a.x,c.x,d.x,x.x)),S=Math.floor(Math.max(a.x,c.x,d.x,x.x)),C=1;for(let A=b-C;A<=S+C;A++)A!==0&&n.push(new s.b6(A,t))}return n}coveringTiles(t){var n,a;let c=this.coveringZoomLevel(t);const d=c;if(t.minzoom!==void 0&&ct.maxzoom&&(c=t.maxzoom);const x=this.pointCoordinate(this.getCameraPoint()),b=s.U.fromLngLat(this.center),S=Math.pow(2,c),C=[S*x.x,S*x.y,0],A=[S*b.x,S*b.y,0],P=Xr.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,c);let R=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(R=c);const W=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,G=ee=>({aabb:new ro([ee*S,0,0],[(ee+1)*S,S,0]),zoom:0,x:0,y:0,wrap:ee,fullyVisible:!1}),K=[],q=[],le=c,_e=t.reparseOverscaled?d:c;if(this._renderWorldCopies)for(let ee=1;ee<=3;ee++)K.push(G(-ee)),K.push(G(ee));for(K.push(G(0));K.length>0;){const ee=K.pop(),ce=ee.x,ve=ee.y;let xe=ee.fullyVisible;if(!xe){const dt=ee.aabb.intersects(P);if(dt===0)continue;xe=dt===2}const Me=t.terrain?C:A,Oe=ee.aabb.distanceX(Me),ze=ee.aabb.distanceY(Me),je=Math.max(Math.abs(Oe),Math.abs(ze));if(ee.zoom===le||je>W+(1<=R){const dt=le-ee.zoom,$t=C[0]-.5-(ce<>1),Ct=ee.zoom+1;let gt=ee.aabb.quadrant(dt);if(t.terrain){const Mi=new s.O(Ct,ee.wrap,Ct,$t,Qe),Jt=t.terrain.getMinMaxElevation(Mi),jt=(n=Jt.minElevation)!==null&&n!==void 0?n:this.elevation,ei=(a=Jt.maxElevation)!==null&&a!==void 0?a:this.elevation;gt=new ro([gt.min[0],gt.min[1],jt],[gt.max[0],gt.max[1],ei])}K.push({aabb:gt,zoom:Ct,x:$t,y:Qe,wrap:ee.wrap,fullyVisible:xe})}}return q.sort((ee,ce)=>ee.distanceSq-ce.distanceSq).map(ee=>ee.tileID)}resize(t,n){this.width=t,this.height=n,this.pixelsToGLUnits=[2/t,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const n=s.ad(t.lat,-this.maxValidLatitude,this.maxValidLatitude);return new s.P(s.G(t.lng)*this.worldSize,s.H(n)*this.worldSize)}unproject(t){return new s.U(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const n=this.pointLocation(this.centerPoint,t),a=t.getElevationForLngLatZoom(n,this.tileZoom);if(!(this.elevation-a))return;const c=this.getCameraPosition(),d=s.U.fromLngLat(c.lngLat,c.altitude),x=s.U.fromLngLat(n,a),b=d.x-x.x,S=d.y-x.y,C=d.z-x.z,A=Math.sqrt(b*b+S*S+C*C),P=this.scaleZoom(this.cameraToCenterDistance/A/this.tileSize);this._elevation=a,this._center=n,this.zoom=P}setLocationAtPoint(t,n){const a=this.pointCoordinate(n),c=this.pointCoordinate(this.centerPoint),d=this.locationCoordinate(t),x=new s.U(d.x-(a.x-c.x),d.y-(a.y-c.y));this.center=this.coordinateLocation(x),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,n){return n?this.coordinatePoint(this.locationCoordinate(t),n.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,n){return this.coordinateLocation(this.pointCoordinate(t,n))}locationCoordinate(t){return s.U.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,n){if(n){const R=n.pointCoordinate(t);if(R!=null)return R}const a=[t.x,t.y,0,1],c=[t.x,t.y,1,1];s.ag(a,a,this.pixelMatrixInverse),s.ag(c,c,this.pixelMatrixInverse);const d=a[3],x=c[3],b=a[1]/d,S=c[1]/x,C=a[2]/d,A=c[2]/x,P=C===A?0:(0-C)/(A-C);return new s.U(s.B.number(a[0]/d,c[0]/x,P)/this.worldSize,s.B.number(b,S,P)/this.worldSize)}coordinatePoint(t,n=0,a=this.pixelMatrix){const c=[t.x*this.worldSize,t.y*this.worldSize,n,1];return s.ag(c,c,a),new s.P(c[0]/c[3],c[1]/c[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new Tt().extend(this.pointLocation(new s.P(0,t))).extend(this.pointLocation(new s.P(this.width,t))).extend(this.pointLocation(new s.P(this.width,this.height))).extend(this.pointLocation(new s.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new Tt([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(t,n=!1){const a=t.key,c=n?this._alignedPosMatrixCache:this._posMatrixCache;if(c[a])return c[a];const d=t.canonical,x=this.worldSize/this.zoomScale(d.z),b=d.x+Math.pow(2,d.z)*t.wrap,S=s.ao(new Float64Array(16));return s.$(S,S,[b*x,d.y*x,0]),s.a0(S,S,[x/s.N,x/s.N,1]),s.a1(S,n?this.alignedProjMatrix:this.projMatrix,S),c[a]=new Float32Array(S),c[a]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t,n,a,c,d=-90,x=90,b=-180,S=180;const C=this.size,A=this._unmodified;if(this.latRange){const W=this.latRange;d=s.H(W[1])*this.worldSize,x=s.H(W[0])*this.worldSize,t=x-dx&&(c=x-G)}if(this.lngRange){const W=(b+S)/2,G=s.b5(P.x,W-this.worldSize/2,W+this.worldSize/2),K=C.x/2;G-KS&&(a=S-K)}a===void 0&&c===void 0||(this.center=this.unproject(new s.P(a!==void 0?a:P.x,c!==void 0?c:P.y)).wrap()),this._unmodified=A,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,n=this.point.x,a=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=s.b7(1,this.center.lat)*this.worldSize;let c=s.ao(new Float64Array(16));s.a0(c,c,[this.width/2,-this.height/2,1]),s.$(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=s.ao(new Float64Array(16)),s.a0(c,c,[1,-1,1]),s.$(c,c,[-1,-1,0]),s.a0(c,c,[2/this.width,2/this.height,1]),this.glCoordMatrix=c;const d=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),x=Math.min(this.elevation,this._minEleveationForCurrentTile),b=d-x*this._pixelPerMeter/Math.cos(this._pitch),S=x<0?b:d,C=Math.PI/2+this._pitch,A=this._fov*(.5+t.y/this.height),P=Math.sin(A)*S/Math.sin(s.ad(Math.PI-C-A,.01,Math.PI-.01)),R=this.getHorizon(),W=2*Math.atan(R/this.cameraToCenterDistance)*(.5+t.y/(2*R)),G=Math.sin(W)*S/Math.sin(s.ad(Math.PI-C-W,.01,Math.PI-.01)),K=Math.min(P,G),q=1.01*(Math.cos(Math.PI/2-this._pitch)*K+S),le=this.height/50;c=new Float64Array(16),s.b8(c,this._fov,this.width/this.height,le,q),c[8]=2*-t.x/this.width,c[9]=2*t.y/this.height,s.a0(c,c,[1,-1,1]),s.$(c,c,[0,0,-this.cameraToCenterDistance]),s.b9(c,c,this._pitch),s.ae(c,c,this.angle),s.$(c,c,[-n,-a,0]),this.mercatorMatrix=s.a0([],c,[this.worldSize,this.worldSize,this.worldSize]),s.a0(c,c,[1,1,this._pixelPerMeter]),this.pixelMatrix=s.a1(new Float64Array(16),this.labelPlaneMatrix,c),s.$(c,c,[0,0,-this.elevation]),this.projMatrix=c,this.invProjMatrix=s.as([],c),this.pixelMatrix3D=s.a1(new Float64Array(16),this.labelPlaneMatrix,c);const _e=this.width%2/2,ee=this.height%2/2,ce=Math.cos(this.angle),ve=Math.sin(this.angle),xe=n-Math.round(n)+ce*_e+ve*ee,Me=a-Math.round(a)+ce*ee+ve*_e,Oe=new Float64Array(c);if(s.$(Oe,Oe,[xe>.5?xe-1:xe,Me>.5?Me-1:Me,0]),this.alignedProjMatrix=Oe,c=s.as(new Float64Array(16),this.pixelMatrix),!c)throw new Error("failed to invert matrix");this.pixelMatrixInverse=c,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new s.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return s.ag(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new s.P(0,t))}getCameraQueryGeometry(t){const n=this.getCameraPoint();if(t.length===1)return[t[0],n];{let a=n.x,c=n.y,d=n.x,x=n.y;for(const b of t)a=Math.min(a,b.x),c=Math.min(c,b.y),d=Math.max(d,b.x),x=Math.max(x,b.y);return[new s.P(a,c),new s.P(d,c),new s.P(d,x),new s.P(a,x),new s.P(a,c)]}}}function de(u,t){let n,a=!1,c=null,d=null;const x=()=>{c=null,a&&(u.apply(d,n),c=setTimeout(x,t),a=!1)};return(...b)=>(a=!0,d=this,n=b,c||x(),c)}class we{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(c=>c.split("=")).forEach(c=>{c[0]===this._hashName&&(a=c)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(n.length>=3&&!n.some(a=>isNaN(a))){const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:a,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,n)}catch{}},this._updateHash=de(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,c=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),d=Math.pow(10,c),x=Math.round(n.lng*d)/d,b=Math.round(n.lat*d)/d,S=this._map.getBearing(),C=this._map.getPitch();let A="";if(A+=t?`/${x}/${b}/${a}`:`${a}/${b}/${x}`,(S||C)&&(A+="/"+Math.round(10*S)/10),C&&(A+=`/${Math.round(C)}`),this._hashName){const P=this._hashName;let R=!1;const W=window.location.hash.slice(1).split("&").map(G=>{const K=G.split("=")[0];return K===P?(R=!0,`${K}=${A}`):G}).filter(G=>G);return R||W.push(`${P}=${A}`),`#${W.join("&")}`}return`#${A}`}}const Ye={linearity:.3,easing:s.ba(0,0,.3,1)},wt=s.e({deceleration:2500,maxSpeed:1400},Ye),Vi=s.e({deceleration:20,maxSpeed:1400},Ye),ni=s.e({deceleration:1e3,maxSpeed:360},Ye),ir=s.e({deceleration:1e3,maxSpeed:90},Ye);class lr{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.h.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=s.h.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new s.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)n.zoom+=d.zoomDelta||0,n.bearing+=d.bearingDelta||0,n.pitch+=d.pitchDelta||0,d.panDelta&&n.pan._add(d.panDelta),d.around&&(n.around=d.around),d.pinchAround&&(n.pinchAround=d.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(n.pan.mag()){const d=rr(n.pan.mag(),a,s.e({},wt,t||{}));c.offset=n.pan.mult(d.amount/n.pan.mag()),c.center=this._map.transform.center,dr(c,d)}if(n.zoom){const d=rr(n.zoom,a,Vi);c.zoom=this._map.transform.zoom+d.amount,dr(c,d)}if(n.bearing){const d=rr(n.bearing,a,ni);c.bearing=this._map.transform.bearing+s.ad(d.amount,-179,179),dr(c,d)}if(n.pitch){const d=rr(n.pitch,a,ir);c.pitch=this._map.transform.pitch+d.amount,dr(c,d)}if(c.zoom||c.bearing){const d=n.pinchAround===void 0?n.around:n.pinchAround;c.around=d?this._map.unproject(d):this._map.getCenter()}return this.clear(),s.e(c,{noMoveStart:!0})}}function dr(u,t){(!u.duration||u.durationn.unproject(S)),b=d.reduce((S,C,A,P)=>S.add(C.div(P.length)),new s.P(0,0));super(t,{points:d,point:b,lngLats:x,lngLat:n.unproject(b),originalEvent:a}),this._defaultPrevented=!1}}class no extends s.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,a){super(t,{originalEvent:a}),this._defaultPrevented=!1}}class Zr{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new no(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new bi(t.type,this._map,t))}mouseup(t){this._map.fire(new bi(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new bi(t.type,this._map,t))}dblclick(t){return this._firePreventable(new bi(t.type,this._map,t))}mouseover(t){this._map.fire(new bi(t.type,this._map,t))}mouseout(t){this._map.fire(new bi(t.type,this._map,t))}touchstart(t){return this._firePreventable(new an(t.type,this._map,t))}touchmove(t){this._map.fire(new an(t.type,this._map,t))}touchend(t){this._map.fire(new an(t.type,this._map,t))}touchcancel(t){this._map.fire(new an(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class oo{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new bi(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new bi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new bi(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ln{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.pointLocation(s.P.convert(t),this._map.terrain)}}class ks{constructor(t,n){this._map=t,this._tr=new ln(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(V.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)d.fitScreenCoordinates(a,c,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(V.remove(this._box),this._box=null),V.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new s.k(t,{originalEvent:n}))}}function kr(u,t){if(u.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${u.length}, points ${t.length}`);const n={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),a.length===this.numTouches&&(this.centroid=function(c){const d=new s.P(0,0);for(const x of c)d._add(x);return d.div(c.length)}(n),this.touches=kr(a,n)))}touchmove(t,n,a){if(this.aborted||!this.centroid)return;const c=kr(a,n);for(const d in this.touches){const x=c[d];(!x||x.dist(this.touches[d])>30)&&(this.aborted=!0)}}touchend(t,n,a){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const c=!this.aborted&&this.centroid;if(this.reset(),c)return c}}}class Ps{constructor(t){this.singleTap=new yn(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,a){this.singleTap.touchstart(t,n,a)}touchmove(t,n,a){this.singleTap.touchmove(t,n,a)}touchend(t,n,a){const c=this.singleTap.touchend(t,n,a);if(c){const d=t.timeStamp-this.lastTime<500,x=!this.lastTap||this.lastTap.dist(c)<30;if(d&&x||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=c,this.count===this.numTaps)return this.reset(),c}}}class fo{constructor(t){this._tr=new ln(t),this._zoomIn=new Ps({numTouches:1,numTaps:2}),this._zoomOut=new Ps({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,a){this._zoomIn.touchstart(t,n,a),this._zoomOut.touchstart(t,n,a)}touchmove(t,n,a){this._zoomIn.touchmove(t,n,a),this._zoomOut.touchmove(t,n,a)}touchend(t,n,a){const c=this._zoomIn.touchend(t,n,a),d=this._zoomOut.touchend(t,n,a),x=this._tr;return c?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:x.zoom+1,around:x.unproject(c)},{originalEvent:t})}):d?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:x.zoom-1,around:x.unproject(d)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class mo{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const c=n.length?n[0]:n;return!this._moved&&c.dist(a){u.mousedown=u.dragStart,u.mousemoveWindow=u.dragMove,u.mouseup=u.dragEnd,u.contextmenu=function(t){t.preventDefault()}},Lo=({enable:u,clickTolerance:t,bearingDegreesPerPixelMoved:n=.8})=>{const a=new wi({checkCorrectEvent:c=>V.mouseButton(c)===0&&c.ctrlKey||V.mouseButton(c)===2});return new mo({clickTolerance:t,move:(c,d)=>({bearingDelta:(d.x-c.x)*n}),moveStateManager:a,enable:u,assignEvents:Gn})},pr=({enable:u,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5})=>{const a=new wi({checkCorrectEvent:c=>V.mouseButton(c)===0&&c.ctrlKey||V.mouseButton(c)===2});return new mo({clickTolerance:t,move:(c,d)=>({pitchDelta:(d.y-c.y)*n}),moveStateManager:a,enable:u,assignEvents:Gn})};class tt{constructor(t,n){this._minTouches=t.cooperativeGestures?2:1,this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new s.P(0,0),setTimeout(()=>{this._cancelCooperativeMessage=!1},200)}touchstart(t,n,a){return this._calculateTransform(t,n,a)}touchmove(t,n,a){if(this._map._cooperativeGestures&&(this._minTouches===2&&a.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,a.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(a.length0&&(this._active=!0);const c=kr(a,n),d=new s.P(0,0),x=new s.P(0,0);let b=0;for(const C in c){const A=c[C],P=this._touches[C];P&&(d._add(A),x._add(A.sub(P)),b++,c[C]=A)}if(this._touches=c,bMath.abs(u.x)}class Za extends Wn{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,a){super.touchstart(t,n,a),this._currentTouchCount=a.length}_start(t){this._lastPoints=t,ps(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,a){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const c=t[0].sub(this._lastPoints[0]),d=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(c,d,a.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(c.y+d.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,a){if(this._valid!==void 0)return this._valid;const c=t.mag()>=2,d=n.mag()>=2;if(!c&&!d)return;if(!c||!d)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const x=t.y>0==n.y>0;return ps(t)&&ps(n)&&x}}const fs={panStep:100,bearingStep:15,pitchStep:10};class Ls{constructor(t){this._tr=new ln(t);const n=fs;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,a=0,c=0,d=0,x=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?a=-1:(t.preventDefault(),d=-1);break;case 39:t.shiftKey?a=1:(t.preventDefault(),d=1);break;case 38:t.shiftKey?c=1:(t.preventDefault(),x=-1);break;case 40:t.shiftKey?c=-1:(t.preventDefault(),x=1);break;default:return}return this._rotationDisabled&&(a=0,c=0),{cameraAnimation:b=>{const S=this._tr;b.easeTo({duration:300,easeId:"keyboardHandler",easing:Ga,zoom:n?Math.round(S.zoom)+n*(t.shiftKey?2:1):S.zoom,bearing:S.bearing+a*this._bearingStep,pitch:S.pitch+c*this._pitchStep,offset:[-d*this._panStep,-x*this._panStep],center:S.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Ga(u){return u*(2-u)}const Ds=4.000244140625;class Ta{constructor(t,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=t,this._tr=new ln(t),this._el=t.getCanvasContainer(),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!t[this._map._metaKey])return;t.preventDefault()}let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const a=s.h.now(),c=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%Ds==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":c>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(c*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=V.mousePos(this._el,t),a=this._tr;this._around=s.L.convert(this._aroundCenter?a.center:a.unproject(n)),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._tr.transform;if(this._delta!==0){const b=this._type==="wheel"&&Math.abs(this._delta)>Ds?this._wheelZoomRate:this._defaultZoomRate;let S=2/(1+Math.exp(-Math.abs(this._delta*b)));this._delta<0&&S!==0&&(S=1/S);const C=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(C*S))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,a=this._startZoom,c=this._easing;let d,x=!1;if(this._type==="wheel"&&a&&c){const b=Math.min((s.h.now()-this._lastWheelEventTime)/200,1),S=c(b);d=s.B.number(a,n,S),b<1?this._frameId||(this._frameId=!0):x=!0}else d=n,x=!0;return this._active=!0,x&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!x,zoomDelta:d-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=s.bb;if(this._prevEase){const a=this._prevEase,c=(s.h.now()-a.start)/a.duration,d=a.easing(c+.01)-a.easing(c),x=.27/Math.sqrt(d*d+1e-4)*.01,b=Math.sqrt(.0729-x*x);n=s.ba(x,b,.25,1)}return this._prevEase={start:s.h.now(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Rl{constructor(t,n){this._clickZoom=t,this._tapZoom=n}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 Ol{constructor(t){this._tr=new ln(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Bl{constructor(){this._tap=new Ps({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,a){if(!this._swipePoint)if(this._tapTime){const c=n[0],d=t.timeStamp-this._tapTime<500,x=this._tapPoint.dist(c)<30;d&&x?a.length>0&&(this._swipePoint=c,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(t,n,a)}touchmove(t,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const c=n[0],d=c.y-this._swipePoint.y;return this._swipePoint=c,t.preventDefault(),this._active=!0,{zoomDelta:d/128}}}else this._tap.touchmove(t,n,a)}touchend(t,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const c=this._tap.touchend(t,n,a);c&&(this._tapTime=t.timeStamp,this._tapPoint=c)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Nl{constructor(t,n,a){this._el=t,this._mousePan=n,this._touchPan=a}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class zn{constructor(t,n,a){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=n,this._mousePitch=a}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 ms{constructor(t,n,a,c){this._el=t,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=c,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Wa=u=>u.zoom||u.drag||u.pitch||u.rotate;class Vl extends s.k{}function Ha(u){return u.panDelta&&u.panDelta.mag()||u.zoomDelta||u.bearingDelta||u.pitchDelta}class Ul{constructor(t,n){this.handleWindowEvent=c=>{this.handleEvent(c,`${c.type}Window`)},this.handleEvent=(c,d)=>{if(c.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const x=c.type==="renderFrame"?void 0:c,b={needsRenderFrame:!1},S={},C={},A=c.touches,P=A?this._getMapTouches(A):void 0,R=P?V.touchPos(this._el,P):V.mousePos(this._el,c);for(const{handlerName:K,handler:q,allowed:le}of this._handlers){if(!q.isEnabled())continue;let _e;this._blockedByActive(C,le,K)?q.reset():q[d||c.type]&&(_e=q[d||c.type](c,R,P),this.mergeHandlerResult(b,S,_e,K,x),_e&&_e.needsRenderFrame&&this._triggerRenderFrame()),(_e||q.isActive())&&(C[K]=q)}const W={};for(const K in this._previousActiveHandlers)C[K]||(W[K]=x);this._previousActiveHandlers=C,(Object.keys(W).length||Ha(b))&&(this._changes.push([b,S,W]),this._triggerRenderFrame()),(Object.keys(C).length||Ha(b))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:G}=b;G&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],G(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new lr(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[c,d,x]of this._listeners)V.addEventListener(c,d,c===document?this.handleWindowEvent:this.handleEvent,x)}destroy(){for(const[t,n,a]of this._listeners)V.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(t){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new Zr(n,t));const c=n.boxZoom=new ks(n,t);this._add("boxZoom",c),t.interactive&&t.boxZoom&&c.enable();const d=new fo(n),x=new Ol(n);n.doubleClickZoom=new Rl(x,d),this._add("tapZoom",d),this._add("clickZoom",x),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const b=new Bl;this._add("tapDragZoom",b);const S=n.touchPitch=new Za(n);this._add("touchPitch",S),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const C=Lo(t),A=pr(t);n.dragRotate=new zn(t,C,A),this._add("mouseRotate",C,["mousePitch"]),this._add("mousePitch",A,["mouseRotate"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const P=(({enable:le,clickTolerance:_e})=>{const ee=new wi({checkCorrectEvent:ce=>V.mouseButton(ce)===0&&!ce.ctrlKey});return new mo({clickTolerance:_e,move:(ce,ve)=>({around:ve,panDelta:ve.sub(ce)}),activateOnStart:!0,moveStateManager:ee,enable:le,assignEvents:Gn})})(t),R=new tt(t,n);n.dragPan=new Nl(a,P,R),this._add("mousePan",P),this._add("touchPan",R,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const W=new Sa,G=new Jo;n.touchZoomRotate=new ms(a,G,W,b),this._add("touchRotate",W,["touchPan","touchZoom"]),this._add("touchZoom",G,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate);const K=n.scrollZoom=new Ta(n,()=>this._triggerRenderFrame());this._add("scrollZoom",K,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const q=n.keyboard=new Ls(n);this._add("keyboard",q),t.interactive&&t.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new oo(n))}_add(t,n,a){this._handlers.push({handlerName:t,handler:n,allowed:a}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Wa(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,a){for(const c in t)if(c!==a&&(!n||n.indexOf(c)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const a of t)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(t,n,a,c,d){if(!a)return;s.e(t,a);const x={handlerName:c,originalEvent:a.originalEvent||d};a.zoomDelta!==void 0&&(n.zoom=x),a.panDelta!==void 0&&(n.drag=x),a.pitchDelta!==void 0&&(n.pitch=x),a.bearingDelta!==void 0&&(n.rotate=x)}_applyChanges(){const t={},n={},a={};for(const[c,d,x]of this._changes)c.panDelta&&(t.panDelta=(t.panDelta||new s.P(0,0))._add(c.panDelta)),c.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+c.zoomDelta),c.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+c.bearingDelta),c.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+c.pitchDelta),c.around!==void 0&&(t.around=c.around),c.pinchAround!==void 0&&(t.pinchAround=c.pinchAround),c.noInertia&&(t.noInertia=c.noInertia),s.e(n,d),s.e(a,x);this._updateMapTransform(t,n,a),this._changes=[]}_updateMapTransform(t,n,a){const c=this._map,d=c._getTransformForUpdate(),x=c.terrain;if(!(Ha(t)||x&&this._terrainMovement))return this._fireEvents(n,a,!0);let{panDelta:b,zoomDelta:S,bearingDelta:C,pitchDelta:A,around:P,pinchAround:R}=t;R!==void 0&&(P=R),c._stop(!0),P=P||c.transform.centerPoint;const W=d.pointLocation(b?P.sub(b):P);C&&(d.bearing+=C),A&&(d.pitch+=A),S&&(d.zoom+=S),x?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?d.center=d.pointLocation(d.centerPoint.sub(b)):d.setLocationAtPoint(W,P):(this._terrainMovement=!0,this._map._elevationFreeze=!0,d.setLocationAtPoint(W,P),this._map.once("moveend",()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,d.recalculateZoom(c.terrain)})):d.setLocationAtPoint(W,P),c._applyUpdatedTransform(d),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,a,!0)}_fireEvents(t,n,a){const c=Wa(this._eventsInProgress),d=Wa(t),x={};for(const A in t){const{originalEvent:P}=t[A];this._eventsInProgress[A]||(x[`${A}start`]=P),this._eventsInProgress[A]=t[A]}!c&&d&&this._fireEvent("movestart",d.originalEvent);for(const A in x)this._fireEvent(A,x[A]);d&&this._fireEvent("move",d.originalEvent);for(const A in t){const{originalEvent:P}=t[A];this._fireEvent(A,P)}const b={};let S;for(const A in this._eventsInProgress){const{handlerName:P,originalEvent:R}=this._eventsInProgress[A];this._handlersById[P].isActive()||(delete this._eventsInProgress[A],S=n[P]||R,b[`${A}end`]=S)}for(const A in b)this._fireEvent(A,b[A]);const C=Wa(this._eventsInProgress);if(a&&(c||d)&&!C){this._updatingCamera=!0;const A=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),P=R=>R!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Vl("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Oc extends s.E{constructor(t,n){super(),this._renderFrameCallback=()=>{const a=Math.min((s.h.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(a)),a<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new s.L(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}panBy(t,n,a){return t=s.P.convert(t).mult(-1),this.panTo(this.transform.center,s.e({offset:t},n),a)}panTo(t,n,a){return this.easeTo(s.e({center:t},n),a)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,a){return this.easeTo(s.e({zoom:t},n),a)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,a){return this.easeTo(s.e({bearing:t},n),a)}resetNorth(t,n){return this.rotateTo(0,s.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(s.e({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing()){if(this._zooming&&(a.zoom=s.B.number(c,S,xe)),this._rotating&&(a.bearing=s.B.number(d,C,xe)),this._pitching&&(a.pitch=s.B.number(x,A,xe)),this._padding&&(a.interpolatePadding(b,P,xe),W=a.centerPoint.add(R)),this.terrain&&!t.freezeElevation&&this._updateElevation(xe),ee)a.setLocationAtPoint(ee,ce);else{const Me=a.zoomScale(a.zoom-c),Oe=S>c?Math.min(2,_e):Math.max(.5,_e),ze=Math.pow(Oe,1-xe),je=a.unproject(q.add(le.mult(xe*ze)).mult(Me));a.setLocationAtPoint(a.renderWorldCopies?je.wrap():je,W)}this._applyUpdatedTransform(a),this._fireMoveEvents(n)},xe=>{this.terrain&&this._finalizeElevation(),this._afterEase(n,xe)},t),this}_prepareEase(t,n,a={}){this._moving=!0,n||a.moving||this.fire(new s.k("movestart",t)),this._zooming&&!a.zooming&&this.fire(new s.k("zoomstart",t)),this._rotating&&!a.rotating&&this.fire(new s.k("rotatestart",t)),this._pitching&&!a.pitching&&this.fire(new s.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(a-(n-(a*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.elevation=s.B.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(t){if(!this.transformCameraUpdate)return;const n=t.clone(),{center:a,zoom:c,pitch:d,bearing:x,elevation:b}=this.transformCameraUpdate(n);a&&(n.center=a),c!==void 0&&(n.zoom=c),d!==void 0&&(n.pitch=d),x!==void 0&&(n.bearing=x),b!==void 0&&(n.elevation=b),this.transform.apply(n)}_fireMoveEvents(t){this.fire(new s.k("move",t)),this._zooming&&this.fire(new s.k("zoom",t)),this._rotating&&this.fire(new s.k("rotate",t)),this._pitching&&this.fire(new s.k("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const a=this._zooming,c=this._rotating,d=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new s.k("zoomend",t)),c&&this.fire(new s.k("rotateend",t)),d&&this.fire(new s.k("pitchend",t)),this.fire(new s.k("moveend",t))}flyTo(t,n){if(!t.essential&&s.h.prefersReducedMotion){const gt=s.F(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(gt,n)}this.stop(),t=s.e({offset:[0,0],speed:1.2,curve:1.42,easing:s.bb},t);const a=this._getTransformForUpdate(),c=this.getZoom(),d=this.getBearing(),x=this.getPitch(),b=this.getPadding(),S="zoom"in t?s.ad(+t.zoom,a.minZoom,a.maxZoom):c,C="bearing"in t?this._normalizeBearing(t.bearing,d):d,A="pitch"in t?+t.pitch:x,P="padding"in t?t.padding:a.padding,R=a.zoomScale(S-c),W=s.P.convert(t.offset);let G=a.centerPoint.add(W);const K=a.pointLocation(G),q=s.L.convert(t.center||K);this._normalizeCenter(q);const le=a.project(K),_e=a.project(q).sub(le);let ee=t.curve;const ce=Math.max(a.width,a.height),ve=ce/R,xe=_e.mag();if("minZoom"in t){const gt=s.ad(Math.min(t.minZoom,c,S),a.minZoom,a.maxZoom),Mi=ce/a.zoomScale(gt-c);ee=Math.sqrt(Mi/xe*2)}const Me=ee*ee;function Oe(gt){const Mi=(ve*ve-ce*ce+(gt?-1:1)*Me*Me*xe*xe)/(2*(gt?ve:ce)*Me*xe);return Math.log(Math.sqrt(Mi*Mi+1)-Mi)}function ze(gt){return(Math.exp(gt)-Math.exp(-gt))/2}function je(gt){return(Math.exp(gt)+Math.exp(-gt))/2}const dt=Oe(!1);let $t=function(gt){return je(dt)/je(dt+ee*gt)},Qe=function(gt){return ce*((je(dt)*(ze(Mi=dt+ee*gt)/je(Mi))-ze(dt))/Me)/xe;var Mi},Ct=(Oe(!0)-dt)/ee;if(Math.abs(xe)<1e-6||!isFinite(Ct)){if(Math.abs(ce-ve)<1e-6)return this.easeTo(t,n);const gt=vet.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=d!==C,this._pitching=A!==x,this._padding=!a.isPaddingEqual(P),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(q),this._ease(gt=>{const Mi=gt*Ct,Jt=1/$t(Mi);a.zoom=gt===1?S:c+a.scaleZoom(Jt),this._rotating&&(a.bearing=s.B.number(d,C,gt)),this._pitching&&(a.pitch=s.B.number(x,A,gt)),this._padding&&(a.interpolatePadding(b,P,gt),G=a.centerPoint.add(W)),this.terrain&&!t.freezeElevation&&this._updateElevation(gt);const jt=gt===1?q:a.unproject(le.add(_e.mult(Qe(Mi))).mult(Jt));a.setLocationAtPoint(a.renderWorldCopies?jt.wrap():jt,G),this._applyUpdatedTransform(a),this._fireMoveEvents(n)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(n)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const a=this._onEaseEnd;delete this._onEaseEnd,a.call(this,n)}if(!t){const a=this.handlers;a&&a.stop(!1)}return this}_ease(t,n,a){a.animate===!1||a.duration===0?(t(1),n()):(this._easeStart=s.h.now(),this._easeOptions=a,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=s.b5(t,-180,180);const a=Math.abs(t-n);return Math.abs(t-360-n)180?-360:a<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(s.L.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}class Hn{constructor(t={}){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=V.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=V.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=V.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){V.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,n){const a=this._map._getUIString(`AttributionControl.${n}`);t.title=a,t.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(c=>typeof c!="string"?"":c)):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const c=this._map.style.stylesheet;this.styleOwner=c.owner,this.styleId=c.id}const n=this._map.style.sourceCaches;for(const c in n){const d=n[c];if(d.used||d.usedForTerrain){const x=d.getSource();x.attribution&&t.indexOf(x.attribution)<0&&t.push(x.attribution)}}t=t.filter(c=>String(c).trim()),t.sort((c,d)=>c.length-d.length),t=t.filter((c,d)=>{for(let x=d+1;x=0)return!1;return!0});const a=t.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,t.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Yi{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=V.create("div","maplibregl-ctrl");const n=V.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){V.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class fl{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(const c of a)if(c.id===t)return void(c.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const a of n)if(!a.cancelled&&(a.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}const jl={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"};var Bc=s.Q([{name:"a_pos3d",type:"Int16",components:3}]);class Nc extends s.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,n){this.sourceCache.update(t,n),this._renderableTilesKeys=[];const a={};for(const c of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))a[c.key]=!0,this._renderableTilesKeys.push(c.key),this._tiles[c.key]||(c.posMatrix=new Float64Array(16),s.aS(c.posMatrix,0,s.N,0,s.N,0,1),this._tiles[c.key]=new wo(c,this.tileSize));for(const c in this._tiles)a[c]||delete this._tiles[c]}freeRtt(t){for(const n in this._tiles){const a=this._tiles[n];(!t||a.tileID.equals(t)||a.tileID.isChildOf(t)||t.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const n={};for(const a of this._renderableTilesKeys){const c=this._tiles[a].tileID;if(c.canonical.equals(t.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16),s.aS(d.posMatrix,0,s.N,0,s.N,0,1),n[a]=d}else if(c.canonical.isChildOf(t.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16);const x=c.canonical.z-t.canonical.z,b=c.canonical.x-(c.canonical.x>>x<>x<>x;s.aS(d.posMatrix,0,C,0,C,0,1),s.$(d.posMatrix,d.posMatrix,[-b*C,-S*C,0]),n[a]=d}else if(t.canonical.isChildOf(c.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16);const x=t.canonical.z-c.canonical.z,b=t.canonical.x-(t.canonical.x>>x<>x<>x;s.aS(d.posMatrix,0,s.N,0,s.N,0,1),s.$(d.posMatrix,d.posMatrix,[b*C,S*C,0]),s.a0(d.posMatrix,d.posMatrix,[1/2**x,1/2**x,0]),n[a]=d}}return n}getSourceTile(t,n){const a=this.sourceCache._source;let c=t.overscaledZ-this.deltaZoom;if(c>a.maxzoom&&(c=a.maxzoom),c=a.minzoom&&(!d||!d.dem);)d=this.sourceCache.getTileByID(t.scaledTo(c--).key);return d}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=t)}}class Vc{constructor(t,n,a){this.painter=t,this.sourceCache=new Nc(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,a,c=s.N){var d;if(!(n>=0&&n=0&&at.canonical.z&&(t.canonical.z>=c?d=t.canonical.z-c:s.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const x=t.canonical.x-(t.canonical.x>>d<>d<>8<<4|d>>8,n[x+3]=0;const a=new s.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),c=new At(t,a,t.gl.RGBA,{premultiply:!1});return c.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=c,c}pointCoordinate(t){const n=new Uint8Array(4),a=this.painter.context,c=a.gl;a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),c.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,c.RGBA,c.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const d=n[0]+(n[2]>>4<<8),x=n[1]+((15&n[2])<<8),b=this.coordsIndex[255-n[3]],S=b&&this.sourceCache.getTileByID(b);if(!S)return null;const C=this._coordsTextureSize,A=(1<0&&Math.sign(d)<0||!a&&Math.sign(c)<0&&Math.sign(d)>0?(c=360*Math.sign(d)+c,s.G(c)):n}}class bu{constructor(t,n,a){this._context=t,this._size=n,this._tileSize=a,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),a=new At(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return a.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(a.texture),{id:t,fbo:n,texture:a,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(n=>t.id!==n),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length!t.inUse)===!1}}const vn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class ml{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new bu(t.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter(a=>!t._layers[a].isHidden(n)),this._coordsDescendingInv={};for(const a in t.sourceCaches){this._coordsDescendingInv[a]={};const c=t.sourceCaches[a].getVisibleCoordinates();for(const d of c){const x=this.terrain.sourceCache.getTerrainCoords(d);for(const b in x)this._coordsDescendingInv[a][b]||(this._coordsDescendingInv[a][b]=[]),this._coordsDescendingInv[a][b].push(x[b])}}this._coordsDescendingInvStr={};for(const a of t._order){const c=t._layers[a],d=c.source;if(vn[c.type]&&!this._coordsDescendingInvStr[d]){this._coordsDescendingInvStr[d]={};for(const x in this._coordsDescendingInv[d])this._coordsDescendingInvStr[d][x]=this._coordsDescendingInv[d][x].map(b=>b.key).sort().join()}}for(const a of this._renderableTiles)for(const c in this._coordsDescendingInvStr){const d=this._coordsDescendingInvStr[c][a.tileID.key];d&&d!==a.rttCoords[c]&&(a.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const n=t.type,a=this.painter,c=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(vn[n]&&(this._prevType&&vn[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!c))return!0;if(vn[this._prevType]||vn[n]&&c){this._prevType=n;const d=this._stacks.length-1,x=this._stacks[d]||[];for(const b of this._renderableTiles){if(this.pool.isFull()&&(Ji(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(b),b.rtt[d]){const C=this.pool.getObjectForId(b.rtt[d].id);if(C.stamp===b.rtt[d].stamp){this.pool.useObject(C);continue}}const S=this.pool.getOrCreateFreeObject();this.pool.useObject(S),this.pool.stampObject(S),b.rtt[d]={id:S.id,stamp:S.stamp},a.context.bindFramebuffer.set(S.fbo.framebuffer),a.context.clear({color:s.aT.transparent,stencil:0}),a.currentStencilSource=void 0;for(let C=0;C{u.touchstart=u.dragStart,u.touchmoveWindow=u.dragMove,u.touchend=u.dragEnd},ql={showCompass:!0,showZoom:!0,visualizePitch:!1};class Zl{constructor(t,n,a=!1){this.mousedown=x=>{this.startMouse(s.e({},x,{ctrlKey:!0,preventDefault:()=>x.preventDefault()}),V.mousePos(this.element,x)),V.addEventListener(window,"mousemove",this.mousemove),V.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=x=>{this.moveMouse(x,V.mousePos(this.element,x))},this.mouseup=x=>{this.mouseRotate.dragEnd(x),this.mousePitch&&this.mousePitch.dragEnd(x),this.offTemp()},this.touchstart=x=>{x.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=V.touchPos(this.element,x.targetTouches)[0],this.startTouch(x,this._startPos),V.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),V.addEventListener(window,"touchend",this.touchend))},this.touchmove=x=>{x.targetTouches.length!==1?this.reset():(this._lastPos=V.touchPos(this.element,x.targetTouches)[0],this.moveTouch(x,this._lastPos))},this.touchend=x=>{x.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const c=t.dragRotate._mouseRotate.getClickTolerance(),d=t.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=Lo({clickTolerance:c,enable:!0}),this.touchRotate=(({enable:x,clickTolerance:b,bearingDegreesPerPixelMoved:S=.8})=>{const C=new zs;return new mo({clickTolerance:b,move:(A,P)=>({bearingDelta:(P.x-A.x)*S}),moveStateManager:C,enable:x,assignEvents:Xa})})({clickTolerance:c,enable:!0}),this.map=t,a&&(this.mousePitch=pr({clickTolerance:d,enable:!0}),this.touchPitch=(({enable:x,clickTolerance:b,pitchDegreesPerPixelMoved:S=-.5})=>{const C=new zs;return new mo({clickTolerance:b,move:(A,P)=>({pitchDelta:(P.y-A.y)*S}),moveStateManager:C,enable:x,assignEvents:Xa})})({clickTolerance:d,enable:!0})),V.addEventListener(n,"mousedown",this.mousedown),V.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),V.addEventListener(n,"touchcancel",this.reset)}startMouse(t,n){this.mouseRotate.dragStart(t,n),this.mousePitch&&this.mousePitch.dragStart(t,n),V.disableDrag()}startTouch(t,n){this.touchRotate.dragStart(t,n),this.touchPitch&&this.touchPitch.dragStart(t,n),V.disableDrag()}moveMouse(t,n){const a=this.map,{bearingDelta:c}=this.mouseRotate.dragMove(t,n)||{};if(c&&a.setBearing(a.getBearing()+c),this.mousePitch){const{pitchDelta:d}=this.mousePitch.dragMove(t,n)||{};d&&a.setPitch(a.getPitch()+d)}}moveTouch(t,n){const a=this.map,{bearingDelta:c}=this.touchRotate.dragMove(t,n)||{};if(c&&a.setBearing(a.getBearing()+c),this.touchPitch){const{pitchDelta:d}=this.touchPitch.dragMove(t,n)||{};d&&a.setPitch(a.getPitch()+d)}}off(){const t=this.element;V.removeEventListener(t,"mousedown",this.mousedown),V.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),V.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),V.removeEventListener(window,"touchend",this.touchend),V.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){V.enableDrag(),V.removeEventListener(window,"mousemove",this.mousemove),V.removeEventListener(window,"mouseup",this.mouseup),V.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),V.removeEventListener(window,"touchend",this.touchend)}}let br;function Gl(u,t,n){if(u=new s.L(u.lng,u.lat),t){const a=new s.L(u.lng-360,u.lat),c=new s.L(u.lng+360,u.lat),d=n.locationPoint(u).distSqr(t);n.locationPoint(a).distSqr(t)180;){const a=n.locationPoint(u);if(a.x>=0&&a.y>=0&&a.x<=n.width&&a.y<=n.height)break;u.lng>n.center.lng?u.lng-=360:u.lng+=360}return u}const so={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Uc(u,t,n){const a=u.classList;for(const c in so)a.remove(`maplibregl-${n}-anchor-${c}`);a.add(`maplibregl-${n}-anchor-${t}`)}class Fs extends s.E{constructor(t){if(super(),this._onKeyPress=n=>{const a=n.code,c=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&c!==32&&c!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,c=this._element;this._popup&&(a===c||c.contains(a))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const a=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!a)&&this._map.once("render",this._update),this._map.transform.renderWorldCopies&&(this._lngLat=Gl(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let d="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?d="rotateX(0deg)":this._pitchAlignment==="map"&&(d=`rotateX(${this._map.getPitch()}deg)`),n&&n.type!=="moveend"||(this._pos=this._pos.round()),V.setTransform(this._element,`${so[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${d} ${c}`),this._map.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout(()=>{const x=this._map.unproject(this._pos),b=40075016686e-3*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=x.distanceTo(this._lngLat)>20*b?"0.2":"1.0",this._opacityTimeout=null},100))},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new s.k("dragstart"))),this.fire(new s.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new s.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,t&&t.element)this._element=t.element,this._offset=s.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=V.create("div"),this._element.setAttribute("aria-label","Map marker");const n=V.createNS("http://www.w3.org/2000/svg","svg"),a=41,c=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${c}px`),n.setAttributeNS(null,"viewBox",`0 0 ${c} ${a}`);const d=V.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"stroke","none"),d.setAttributeNS(null,"stroke-width","1"),d.setAttributeNS(null,"fill","none"),d.setAttributeNS(null,"fill-rule","evenodd");const x=V.createNS("http://www.w3.org/2000/svg","g");x.setAttributeNS(null,"fill-rule","nonzero");const b=V.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"transform","translate(3.0, 29.0)"),b.setAttributeNS(null,"fill","#000000");const S=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const le of S){const _e=V.createNS("http://www.w3.org/2000/svg","ellipse");_e.setAttributeNS(null,"opacity","0.04"),_e.setAttributeNS(null,"cx","10.5"),_e.setAttributeNS(null,"cy","5.80029008"),_e.setAttributeNS(null,"rx",le.rx),_e.setAttributeNS(null,"ry",le.ry),b.appendChild(_e)}const C=V.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"fill",this._color);const A=V.createNS("http://www.w3.org/2000/svg","path");A.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),C.appendChild(A);const P=V.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"opacity","0.25"),P.setAttributeNS(null,"fill","#000000");const R=V.createNS("http://www.w3.org/2000/svg","path");R.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),P.appendChild(R);const W=V.createNS("http://www.w3.org/2000/svg","g");W.setAttributeNS(null,"transform","translate(6.0, 7.0)"),W.setAttributeNS(null,"fill","#FFFFFF");const G=V.createNS("http://www.w3.org/2000/svg","g");G.setAttributeNS(null,"transform","translate(8.0, 8.0)");const K=V.createNS("http://www.w3.org/2000/svg","circle");K.setAttributeNS(null,"fill","#000000"),K.setAttributeNS(null,"opacity","0.25"),K.setAttributeNS(null,"cx","5.5"),K.setAttributeNS(null,"cy","5.5"),K.setAttributeNS(null,"r","5.4999962");const q=V.createNS("http://www.w3.org/2000/svg","circle");q.setAttributeNS(null,"fill","#FFFFFF"),q.setAttributeNS(null,"cx","5.5"),q.setAttributeNS(null,"cy","5.5"),q.setAttributeNS(null,"r","5.4999962"),G.appendChild(K),G.appendChild(q),x.appendChild(b),x.appendChild(C),x.appendChild(P),x.appendChild(W),x.appendChild(G),n.appendChild(x),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",c*this._scale+"px"),this._element.appendChild(n),this._offset=s.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),Uc(this._element,this._anchor,"marker"),t&&t.className)for(const n of t.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),V.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=s.L.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const c=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[c,-1*(38.1-13.5+c)],"bottom-right":[-c,-1*(38.1-13.5+c)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}getOffset(){return this._offset}setOffset(t){return this._offset=s.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const cr={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let or=0,Ia=!1;const Ka={maxWidth:100,unit:"metric"};function Ja(u,t,n){const a=n&&n.maxWidth||100,c=u._container.clientHeight/2,d=u.unproject([0,c]),x=u.unproject([a,c]),b=d.distanceTo(x);if(n&&n.unit==="imperial"){const S=3.2808*b;S>5280?Rs(t,a,S/5280,u._getUIString("ScaleControl.Miles")):Rs(t,a,S,u._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Rs(t,a,b/1852,u._getUIString("ScaleControl.NauticalMiles")):b>=1e3?Rs(t,a,b/1e3,u._getUIString("ScaleControl.Kilometers")):Rs(t,a,b,u._getUIString("ScaleControl.Meters"))}function Rs(u,t,n,a){const c=function(d){const x=Math.pow(10,`${Math.floor(d)}`.length-1);let b=d/x;return b=b>=10?10:b>=5?5:b>=3?3:b>=2?2:b>=1?1:function(S){const C=Math.pow(10,Math.ceil(-Math.log(S)/Math.LN10));return Math.round(S*C)/C}(b),x*b}(n);u.style.width=t*(c/n)+"px",u.innerHTML=`${c} ${a}`}const Wl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Hl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ea(u){if(u){if(typeof u=="number"){const t=Math.round(Math.abs(u)/Math.SQRT2);return{center:new s.P(0,0),top:new s.P(0,u),"top-left":new s.P(t,t),"top-right":new s.P(-t,t),bottom:new s.P(0,-u),"bottom-left":new s.P(t,-t),"bottom-right":new s.P(-t,-t),left:new s.P(u,0),right:new s.P(-u,0)}}if(u instanceof s.P||Array.isArray(u)){const t=s.P.convert(u);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:s.P.convert(u.center||[0,0]),top:s.P.convert(u.top||[0,0]),"top-left":s.P.convert(u["top-left"]||[0,0]),"top-right":s.P.convert(u["top-right"]||[0,0]),bottom:s.P.convert(u.bottom||[0,0]),"bottom-left":s.P.convert(u["bottom-left"]||[0,0]),"bottom-right":s.P.convert(u["bottom-right"]||[0,0]),left:s.P.convert(u.left||[0,0]),right:s.P.convert(u.right||[0,0])}}return Ea(new s.P(0,0))}const Xl={extend:(u,...t)=>s.e(u,...t),run(u){u()},logToElement(u,t=!1,n="log"){const a=window.document.getElementById(n);a&&(t&&(a.innerHTML=""),a.innerHTML+=`
${u}`)}},Kl=H;class Si{static get version(){return Kl}static get workerCount(){return Vn.workerCount}static set workerCount(t){Vn.workerCount=t}static get maxParallelImageRequests(){return s.c.MAX_PARALLEL_IMAGE_REQUESTS}static set maxParallelImageRequests(t){s.c.MAX_PARALLEL_IMAGE_REQUESTS=t}static get workerUrl(){return s.c.WORKER_URL}static set workerUrl(t){s.c.WORKER_URL=t}static addProtocol(t,n){s.c.REGISTERED_PROTOCOLS[t]=n}static removeProtocol(t){delete s.c.REGISTERED_PROTOCOLS[t]}}return Si.Map=class extends Oc{constructor(u){if(s.bg.mark(s.bh.create),(u=s.e({},Et,u)).minZoom!=null&&u.maxZoom!=null&&u.minZoom>u.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(u.minPitch!=null&&u.maxPitch!=null&&u.minPitch>u.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(u.minPitch!=null&&u.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(u.maxPitch!=null&&u.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new wa(u.minZoom,u.maxZoom,u.minPitch,u.maxPitch,u.renderWorldCopies),{bearingSnap:u.bearingSnap}),this._cooperativeGesturesOnWheel=t=>{this._onCooperativeGesture(t,t[this._metaKey],1)},this._contextLost=t=>{t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new s.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new s.k("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=u.interactive,this._cooperativeGestures=u.cooperativeGestures,this._metaKey=navigator.platform.indexOf("Mac")===0?"metaKey":"ctrlKey",this._maxTileCacheSize=u.maxTileCacheSize,this._maxTileCacheZoomLevels=u.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=u.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=u.preserveDrawingBuffer,this._antialias=u.antialias,this._trackResize=u.trackResize,this._bearingSnap=u.bearingSnap,this._refreshExpiredTiles=u.refreshExpiredTiles,this._fadeDuration=u.fadeDuration,this._crossSourceCollisions=u.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=u.collectResourceTiming,this._renderTaskQueue=new fl,this._controls=[],this._mapId=s.a2(),this._locale=s.e({},jl,u.locale),this._clickTolerance=u.clickTolerance,this._overridePixelRatio=u.pixelRatio,this._maxCanvasSize=u.maxCanvasSize,this.transformCameraUpdate=u.transformCameraUpdate,this._imageQueueHandle=Ne.addThrottleControl(()=>this.isMoving()),this._requestManager=new at(u.transformRequest),typeof u.container=="string"){if(this._container=document.getElementById(u.container),!this._container)throw new Error(`Container '${u.container}' not found.`)}else{if(!(u.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=u.container}if(u.maxBounds&&this.setMaxBounds(u.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let t=!1;const n=de(a=>{this._trackResize&&!this._removed&&this.resize(a)._update()},50);this._resizeObserver=new ResizeObserver(a=>{t?n(a):t=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Ul(this,u),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=u.hash&&new we(typeof u.hash=="string"&&u.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:u.center,zoom:u.zoom,bearing:u.bearing,pitch:u.pitch}),u.bounds&&(this.resize(),this.fitBounds(u.bounds,s.e({},u.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=u.localIdeographFontFamily,this._validateStyle=u.validateStyle,u.style&&this.setStyle(u.style,{localIdeographFontFamily:u.localIdeographFontFamily}),u.attributionControl&&this.addControl(new Hn({customAttribution:u.customAttribution})),u.maplibreLogo&&this.addControl(new Yi,u.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update(t.dataType==="style"),this.fire(new s.k(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new s.k(`${t.dataType}dataloading`,t))}),this.on("dataabort",t=>{this.fire(new s.k("sourcedataabort",t))})}_getMapId(){return this._mapId}addControl(u,t){if(t===void 0&&(t=u.getDefaultPosition?u.getDefaultPosition():"top-right"),!u||!u.onAdd)return this.fire(new s.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=u.onAdd(this);this._controls.push(u);const a=this._controlPositions[t];return t.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(u){if(!u||!u.onRemove)return this.fire(new s.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(u);return t>-1&&this._controls.splice(t,1),u.onRemove(this),this}hasControl(u){return this._controls.indexOf(u)>-1}calculateCameraOptionsFromTo(u,t,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(u,t,n,a)}resize(u){var t;const n=this._containerDimensions(),a=n[0],c=n[1],d=this._getClampedPixelRatio(a,c);if(this._resizeCanvas(a,c,d),this.painter.resize(a,c,d),this.painter.overLimit()){const b=this.painter.context.gl;this._maxCanvasSize=[b.drawingBufferWidth,b.drawingBufferHeight];const S=this._getClampedPixelRatio(a,c);this._resizeCanvas(a,c,S),this.painter.resize(a,c,S)}this.transform.resize(a,c),(t=this._requestedCameraState)===null||t===void 0||t.resize(a,c);const x=!this._moving;return x&&(this.stop(),this.fire(new s.k("movestart",u)).fire(new s.k("move",u))),this.fire(new s.k("resize",u)),x&&this.fire(new s.k("moveend",u)),this}_getClampedPixelRatio(u,t){const{0:n,1:a}=this._maxCanvasSize,c=this.getPixelRatio(),d=u*c,x=t*c;return Math.min(d>n?n/d:1,x>a?a/x:1)*c}getPixelRatio(){var u;return(u=this._overridePixelRatio)!==null&&u!==void 0?u:devicePixelRatio}setPixelRatio(u){this._overridePixelRatio=u,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(u){return this.transform.setMaxBounds(Tt.convert(u)),this._update()}setMinZoom(u){if((u=u??-2)>=-2&&u<=this.transform.maxZoom)return this.transform.minZoom=u,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=u,this._update(),this.getZoom()>u&&this.setZoom(u),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(u){if((u=u??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(u>=0&&u<=this.transform.maxPitch)return this.transform.minPitch=u,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(u>=this.transform.minPitch)return this.transform.maxPitch=u,this._update(),this.getPitch()>u&&this.setPitch(u),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(u){return this.transform.renderWorldCopies=u,this._update()}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(u){return this._cooperativeGestures=u,this._cooperativeGestures?this._setupCooperativeGestures():this._destroyCooperativeGestures(),this}project(u){return this.transform.locationPoint(s.L.convert(u),this.style&&this.terrain)}unproject(u){return this.transform.pointLocation(s.P.convert(u),this.terrain)}isMoving(){var u;return this._moving||((u=this.handlers)===null||u===void 0?void 0:u.isMoving())}isZooming(){var u;return this._zooming||((u=this.handlers)===null||u===void 0?void 0:u.isZooming())}isRotating(){var u;return this._rotating||((u=this.handlers)===null||u===void 0?void 0:u.isRotating())}_createDelegatedListener(u,t,n){if(u==="mouseenter"||u==="mouseover"){let a=!1;return{layer:t,listener:n,delegates:{mousemove:d=>{const x=this.getLayer(t)?this.queryRenderedFeatures(d.point,{layers:[t]}):[];x.length?a||(a=!0,n.call(this,new bi(u,this,d.originalEvent,{features:x}))):a=!1},mouseout:()=>{a=!1}}}}if(u==="mouseleave"||u==="mouseout"){let a=!1;return{layer:t,listener:n,delegates:{mousemove:x=>{(this.getLayer(t)?this.queryRenderedFeatures(x.point,{layers:[t]}):[]).length?a=!0:a&&(a=!1,n.call(this,new bi(u,this,x.originalEvent)))},mouseout:x=>{a&&(a=!1,n.call(this,new bi(u,this,x.originalEvent)))}}}}{const a=c=>{const d=this.getLayer(t)?this.queryRenderedFeatures(c.point,{layers:[t]}):[];d.length&&(c.features=d,n.call(this,c),delete c.features)};return{layer:t,listener:n,delegates:{[u]:a}}}}on(u,t,n){if(n===void 0)return super.on(u,t);const a=this._createDelegatedListener(u,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[u]=this._delegatedListeners[u]||[],this._delegatedListeners[u].push(a);for(const c in a.delegates)this.on(c,a.delegates[c]);return this}once(u,t,n){if(n===void 0)return super.once(u,t);const a=this._createDelegatedListener(u,t,n);for(const c in a.delegates)this.once(c,a.delegates[c]);return this}off(u,t,n){return n===void 0?super.off(u,t):(this._delegatedListeners&&this._delegatedListeners[u]&&(a=>{const c=this._delegatedListeners[u];for(let d=0;dthis._updateStyle(u,t));const n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!u)),u?(this.style=new Er(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof u=="string"?this.style.loadURL(u,t,n):this.style.loadJSON(u,t,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Er(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(u,t){if(typeof u=="string"){const n=this._requestManager.transformRequest(u,et.Style);s.f(n,(a,c)=>{a?this.fire(new s.j(a)):c&&this._updateDiff(c,t)})}else typeof u=="object"&&this._updateDiff(u,t)}_updateDiff(u,t){try{this.style.setState(u,t)&&this._update(!0)}catch(n){s.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(u,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():s.w("There is no style added to the map.")}addSource(u,t){return this._lazyInitEmptyStyle(),this.style.addSource(u,t),this._update(!0)}isSourceLoaded(u){const t=this.style&&this.style.sourceCaches[u];if(t!==void 0)return t.loaded();this.fire(new s.j(new Error(`There is no source with ID '${u}'`)))}setTerrain(u){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),u){const t=this.style.sourceCaches[u.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${u.source}`);for(const n in this.style._layers){const a=this.style._layers[n];a.type==="hillshade"&&a.source===u.source&&s.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Vc(this.painter,t,u),this.painter.renderToTexture=new ml(this.painter,this.terrain),this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==u.source||this._elevationFreeze||(this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform._minEleveationForCurrentTile=0,this.transform.elevation=0;return this.fire(new s.k("terrain",{terrain:u})),this}getTerrain(){var u,t;return(t=(u=this.terrain)===null||u===void 0?void 0:u.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const u=this.style&&this.style.sourceCaches;for(const t in u){const n=u[t]._tiles;for(const a in n){const c=n[a];if(c.state!=="loaded"&&c.state!=="errored")return!1}}return!0}addSourceType(u,t,n){return this._lazyInitEmptyStyle(),this.style.addSourceType(u,t,n)}removeSource(u){return this.style.removeSource(u),this._update(!0)}getSource(u){return this.style.getSource(u)}addImage(u,t,n={}){const{pixelRatio:a=1,sdf:c=!1,stretchX:d,stretchY:x,content:b}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||s.a(t))){if(t.width===void 0||t.height===void 0)return this.fire(new s.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:S,height:C,data:A}=t,P=t;return this.style.addImage(u,{data:new s.R({width:S,height:C},new Uint8Array(A)),pixelRatio:a,stretchX:d,stretchY:x,content:b,sdf:c,version:0,userImage:P}),P.onAdd&&P.onAdd(this,u),this}}{const{width:S,height:C,data:A}=s.h.getImageData(t);this.style.addImage(u,{data:new s.R({width:S,height:C},A),pixelRatio:a,stretchX:d,stretchY:x,content:b,sdf:c,version:0})}}updateImage(u,t){const n=this.style.getImage(u);if(!n)return this.fire(new s.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=t instanceof HTMLImageElement||s.a(t)?s.h.getImageData(t):t,{width:c,height:d,data:x}=a;if(c===void 0||d===void 0)return this.fire(new s.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(c!==n.data.width||d!==n.data.height)return this.fire(new s.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const b=!(t instanceof HTMLImageElement||s.a(t));return n.data.replace(x,b),this.style.updateImage(u,n),this}getImage(u){return this.style.getImage(u)}hasImage(u){return u?!!this.style.getImage(u):(this.fire(new s.j(new Error("Missing required image id"))),!1)}removeImage(u){this.style.removeImage(u)}loadImage(u,t){Ne.getImage(this._requestManager.transformRequest(u,et.Image),t)}listImages(){return this.style.listImages()}addLayer(u,t){return this._lazyInitEmptyStyle(),this.style.addLayer(u,t),this._update(!0)}moveLayer(u,t){return this.style.moveLayer(u,t),this._update(!0)}removeLayer(u){return this.style.removeLayer(u),this._update(!0)}getLayer(u){return this.style.getLayer(u)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(u,t,n){return this.style.setLayerZoomRange(u,t,n),this._update(!0)}setFilter(u,t,n={}){return this.style.setFilter(u,t,n),this._update(!0)}getFilter(u){return this.style.getFilter(u)}setPaintProperty(u,t,n,a={}){return this.style.setPaintProperty(u,t,n,a),this._update(!0)}getPaintProperty(u,t){return this.style.getPaintProperty(u,t)}setLayoutProperty(u,t,n,a={}){return this.style.setLayoutProperty(u,t,n,a),this._update(!0)}getLayoutProperty(u,t){return this.style.getLayoutProperty(u,t)}setGlyphs(u,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(u,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(u,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(u,t,n,a=>{a||this._update(!0)}),this}removeSprite(u){return this._lazyInitEmptyStyle(),this.style.removeSprite(u),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(u,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(u,t,n=>{n||this._update(!0)}),this}setLight(u,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(u,t),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(u,t){return this.style.setFeatureState(u,t),this._update()}removeFeatureState(u,t){return this.style.removeFeatureState(u,t),this._update()}getFeatureState(u){return this.style.getFeatureState(u)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let u=0,t=0;return this._container&&(u=this._container.clientWidth||400,t=this._container.clientHeight||300),[u,t]}_setupContainer(){const u=this._container;u.classList.add("maplibregl-map");const t=this._canvasContainer=V.create("div","maplibregl-canvas-container",u);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=V.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const c=this._controlContainer=V.create("div","maplibregl-control-container",u),d=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(x=>{d[x]=V.create("div",`maplibregl-ctrl-${x} `,c)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){this._cooperativeGesturesScreen=V.create("div","maplibregl-cooperative-gesture-screen",this._container);let u=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";navigator.platform.indexOf("Mac")===0&&(u=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use ⌘ + scroll to zoom the map"),this._cooperativeGesturesScreen.innerHTML=` +`),ee=b.createShader(b.FRAGMENT_SHADER);if(b.isContextLost())return void(this.failedToCreate=!0);if(b.shaderSource(ee,le),b.compileShader(ee),!b.getShaderParameter(ee,b.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${b.getShaderInfoLog(ee)}`);b.attachShader(this.program,ee);const ce=b.createShader(b.VERTEX_SHADER);if(b.isContextLost())return void(this.failedToCreate=!0);if(b.shaderSource(ce,_e),b.compileShader(ce),!b.getShaderParameter(ce,b.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${b.getShaderInfoLog(ce)}`);b.attachShader(this.program,ce),this.attributes={};const ve={};this.numAttributes=A.length;for(let xe=0;xe({u_depth:new s.aL(xe,Ce.u_depth),u_terrain:new s.aL(xe,Ce.u_terrain),u_terrain_dim:new s.aM(xe,Ce.u_terrain_dim),u_terrain_matrix:new s.aN(xe,Ce.u_terrain_matrix),u_terrain_unpack:new s.aO(xe,Ce.u_terrain_unpack),u_terrain_exaggeration:new s.aM(xe,Ce.u_terrain_exaggeration)}))(t,ve),this.binderUniforms=a?a.getUniforms(t,ve):[]}draw(t,n,a,c,d,x,b,S,C,A,P,O,H,W,K,q,le,_e){const ee=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(a),t.setStencilMode(c),t.setColorMode(d),t.setCullFace(x),S){t.activeTexture.set(ee.TEXTURE2),ee.bindTexture(ee.TEXTURE_2D,S.depthTexture),t.activeTexture.set(ee.TEXTURE3),ee.bindTexture(ee.TEXTURE_2D,S.texture);for(const ve in this.terrainUniforms)this.terrainUniforms[ve].set(S[ve])}for(const ve in this.fixedUniforms)this.fixedUniforms[ve].set(b[ve]);K&&K.setUniforms(t,this.binderUniforms,H,{zoom:W});let ce=0;switch(n){case ee.LINES:ce=2;break;case ee.TRIANGLES:ce=3;break;case ee.LINE_STRIP:ce=1}for(const ve of O.get()){const xe=ve.vaos||(ve.vaos={});(xe[C]||(xe[C]=new uo)).bind(t,this,A,K?K.getPaintVertexBuffers():[],P,ve.vertexOffset,q,le,_e),ee.drawElements(n,ve.primitiveLength*ce,ee.UNSIGNED_SHORT,ve.primitiveOffset*ce*2)}}}function kn(u,t,n){const a=1/oe(n,1,t.transform.tileZoom),c=Math.pow(2,n.tileID.overscaledZ),d=n.tileSize*Math.pow(2,t.transform.tileZoom)/c,x=d*(n.tileID.canonical.x+n.tileID.wrap*c),b=d*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,u.fromScale,u.toScale],u_fade:u.t,u_pixel_coord_upper:[x>>16,b>>16],u_pixel_coord_lower:[65535&x,65535&b]}}const Va=(u,t,n,a)=>{const c=t.style.light,d=c.properties.get("position"),x=[d.x,d.y,d.z],b=function(){var C=new s.A(9);return s.A!=Float32Array&&(C[1]=0,C[2]=0,C[3]=0,C[5]=0,C[6]=0,C[7]=0),C[0]=1,C[4]=1,C[8]=1,C}();c.properties.get("anchor")==="viewport"&&function(C,A){var P=Math.sin(A),O=Math.cos(A);C[0]=O,C[1]=P,C[2]=0,C[3]=-P,C[4]=O,C[5]=0,C[6]=0,C[7]=0,C[8]=1}(b,-t.transform.angle),function(C,A,P){var O=A[0],H=A[1],W=A[2];C[0]=O*P[0]+H*P[3]+W*P[6],C[1]=O*P[1]+H*P[4]+W*P[7],C[2]=O*P[2]+H*P[5]+W*P[8]}(x,x,b);const S=c.properties.get("color");return{u_matrix:u,u_lightpos:x,u_lightintensity:c.properties.get("intensity"),u_lightcolor:[S.r,S.g,S.b],u_vertical_gradient:+n,u_opacity:a}},Eo=(u,t,n,a,c,d,x)=>s.e(Va(u,t,n,a),kn(d,t,x),{u_height_factor:-Math.pow(2,c.overscaledZ)/x.tileSize/8}),Ts=u=>({u_matrix:u}),g=(u,t,n,a)=>s.e(Ts(u),kn(n,t,a)),I=(u,t)=>({u_matrix:u,u_world:t}),B=(u,t,n,a,c)=>s.e(g(u,t,n,a),{u_world:c}),Y=(u,t,n,a)=>{const c=u.transform;let d,x;if(a.paint.get("circle-pitch-alignment")==="map"){const b=oe(n,1,c.zoom);d=!0,x=[b,b]}else d=!1,x=c.pixelsToGLUnits;return{u_camera_to_center_distance:c.cameraToCenterDistance,u_scale_with_map:+(a.paint.get("circle-pitch-scale")==="map"),u_matrix:u.translatePosMatrix(t.posMatrix,n,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_pitch_with_map:+d,u_device_pixel_ratio:u.pixelRatio,u_extrude_scale:x}},ne=(u,t,n)=>{const a=oe(n,1,t.zoom),c=Math.pow(2,t.zoom-n.tileID.overscaledZ),d=n.tileID.overscaleFactor();return{u_matrix:u,u_camera_to_center_distance:t.cameraToCenterDistance,u_pixels_to_tile_units:a,u_extrude_scale:[t.pixelsToGLUnits[0]/(a*c),t.pixelsToGLUnits[1]/(a*c)],u_overscale_factor:d}},se=(u,t,n=1)=>({u_matrix:u,u_color:t,u_overlay:0,u_overlay_scale:n}),fe=u=>({u_matrix:u}),Re=(u,t,n,a)=>({u_matrix:u,u_extrude_scale:oe(t,1,n),u_intensity:a});function Ue(u,t){const n=Math.pow(2,t.canonical.z),a=t.canonical.y;return[new s.U(0,a/n).toLngLat().lat,new s.U(0,(a+1)/n).toLngLat().lat]}const rt=(u,t,n,a)=>{const c=u.transform;return{u_matrix:Ot(u,t,n,a),u_ratio:1/oe(t,1,c.zoom),u_device_pixel_ratio:u.pixelRatio,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},ot=(u,t,n,a,c)=>s.e(rt(u,t,n,c),{u_image:0,u_image_height:a}),Ye=(u,t,n,a,c)=>{const d=u.transform,x=Hi(t,d);return{u_matrix:Ot(u,t,n,c),u_texsize:t.imageAtlasTexture.size,u_ratio:1/oe(t,1,d.zoom),u_device_pixel_ratio:u.pixelRatio,u_image:0,u_scale:[x,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/d.pixelsToGLUnits[0],1/d.pixelsToGLUnits[1]]}},Rt=(u,t,n,a,c,d)=>{const x=u.lineAtlas,b=Hi(t,u.transform),S=n.layout.get("line-cap")==="round",C=x.getDash(a.from,S),A=x.getDash(a.to,S),P=C.width*c.fromScale,O=A.width*c.toScale;return s.e(rt(u,t,n,d),{u_patternscale_a:[b/P,-C.height/2],u_patternscale_b:[b/O,-A.height/2],u_sdfgamma:x.width/(256*Math.min(P,O)*u.pixelRatio)/2,u_image:0,u_tex_y_a:C.y,u_tex_y_b:A.y,u_mix:c.t})};function Hi(u,t){return 1/oe(u,1,t.tileZoom)}function Ot(u,t,n,a){return u.translatePosMatrix(a?a.posMatrix:t.tileID.posMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const ar=(u,t,n,a,c)=>{return{u_matrix:u,u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*c.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:c.paint.get("raster-brightness-min"),u_brightness_high:c.paint.get("raster-brightness-max"),u_saturation_factor:(x=c.paint.get("raster-saturation"),x>0?1-1/(1.001-x):-x),u_contrast_factor:(d=c.paint.get("raster-contrast"),d>0?1/(1-d):1+d),u_spin_weights:ze(c.paint.get("raster-hue-rotate"))};var d,x};function ze(u){u*=Math.PI/180;const t=Math.sin(u),n=Math.cos(u);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const _t=(u,t,n,a,c,d,x,b,S,C)=>{const A=c.transform;return{u_is_size_zoom_constant:+(u==="constant"||u==="source"),u_is_size_feature_constant:+(u==="constant"||u==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:A.cameraToCenterDistance,u_pitch:A.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:A.width/A.height,u_fade_change:c.options.fadeDuration?c.symbolFadeChange:1,u_matrix:d,u_label_plane_matrix:x,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+a,u_texsize:C,u_texture:0}},vi=(u,t,n,a,c,d,x,b,S,C,A)=>{const P=c.transform;return s.e(_t(u,t,n,a,c,d,x,b,S,C),{u_gamma_scale:a?Math.cos(P._pitch)*P.cameraToCenterDistance:1,u_device_pixel_ratio:c.pixelRatio,u_is_halo:+A})},Xi=(u,t,n,a,c,d,x,b,S,C)=>s.e(vi(u,t,n,a,c,d,x,b,!0,S,!0),{u_texsize_icon:C,u_texture_icon:1}),tr=(u,t,n)=>({u_matrix:u,u_opacity:t,u_color:n}),nn=(u,t,n,a,c,d)=>s.e(function(x,b,S,C){const A=S.imageManager.getPattern(x.from.toString()),P=S.imageManager.getPattern(x.to.toString()),{width:O,height:H}=S.imageManager.getPixelSize(),W=Math.pow(2,C.tileID.overscaledZ),K=C.tileSize*Math.pow(2,S.transform.tileZoom)/W,q=K*(C.tileID.canonical.x+C.tileID.wrap*W),le=K*C.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:A.tl,u_pattern_br_a:A.br,u_pattern_tl_b:P.tl,u_pattern_br_b:P.br,u_texsize:[O,H],u_mix:b.t,u_pattern_size_a:A.displaySize,u_pattern_size_b:P.displaySize,u_scale_a:b.fromScale,u_scale_b:b.toScale,u_tile_units_to_pixels:1/oe(C,1,S.transform.tileZoom),u_pixel_coord_upper:[q>>16,le>>16],u_pixel_coord_lower:[65535&q,65535&le]}}(a,d,n,c),{u_matrix:u,u_opacity:t}),ra={fillExtrusion:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_lightpos:new s.aP(u,t.u_lightpos),u_lightintensity:new s.aM(u,t.u_lightintensity),u_lightcolor:new s.aP(u,t.u_lightcolor),u_vertical_gradient:new s.aM(u,t.u_vertical_gradient),u_opacity:new s.aM(u,t.u_opacity)}),fillExtrusionPattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_lightpos:new s.aP(u,t.u_lightpos),u_lightintensity:new s.aM(u,t.u_lightintensity),u_lightcolor:new s.aP(u,t.u_lightcolor),u_vertical_gradient:new s.aM(u,t.u_vertical_gradient),u_height_factor:new s.aM(u,t.u_height_factor),u_image:new s.aL(u,t.u_image),u_texsize:new s.aQ(u,t.u_texsize),u_pixel_coord_upper:new s.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aQ(u,t.u_pixel_coord_lower),u_scale:new s.aP(u,t.u_scale),u_fade:new s.aM(u,t.u_fade),u_opacity:new s.aM(u,t.u_opacity)}),fill:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix)}),fillPattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_image:new s.aL(u,t.u_image),u_texsize:new s.aQ(u,t.u_texsize),u_pixel_coord_upper:new s.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aQ(u,t.u_pixel_coord_lower),u_scale:new s.aP(u,t.u_scale),u_fade:new s.aM(u,t.u_fade)}),fillOutline:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_world:new s.aQ(u,t.u_world)}),fillOutlinePattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_world:new s.aQ(u,t.u_world),u_image:new s.aL(u,t.u_image),u_texsize:new s.aQ(u,t.u_texsize),u_pixel_coord_upper:new s.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aQ(u,t.u_pixel_coord_lower),u_scale:new s.aP(u,t.u_scale),u_fade:new s.aM(u,t.u_fade)}),circle:(u,t)=>({u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_scale_with_map:new s.aL(u,t.u_scale_with_map),u_pitch_with_map:new s.aL(u,t.u_pitch_with_map),u_extrude_scale:new s.aQ(u,t.u_extrude_scale),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_matrix:new s.aN(u,t.u_matrix)}),collisionBox:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_pixels_to_tile_units:new s.aM(u,t.u_pixels_to_tile_units),u_extrude_scale:new s.aQ(u,t.u_extrude_scale),u_overscale_factor:new s.aM(u,t.u_overscale_factor)}),collisionCircle:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_inv_matrix:new s.aN(u,t.u_inv_matrix),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_viewport_size:new s.aQ(u,t.u_viewport_size)}),debug:(u,t)=>({u_color:new s.aR(u,t.u_color),u_matrix:new s.aN(u,t.u_matrix),u_overlay:new s.aL(u,t.u_overlay),u_overlay_scale:new s.aM(u,t.u_overlay_scale)}),clippingMask:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix)}),heatmap:(u,t)=>({u_extrude_scale:new s.aM(u,t.u_extrude_scale),u_intensity:new s.aM(u,t.u_intensity),u_matrix:new s.aN(u,t.u_matrix)}),heatmapTexture:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_world:new s.aQ(u,t.u_world),u_image:new s.aL(u,t.u_image),u_color_ramp:new s.aL(u,t.u_color_ramp),u_opacity:new s.aM(u,t.u_opacity)}),hillshade:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_image:new s.aL(u,t.u_image),u_latrange:new s.aQ(u,t.u_latrange),u_light:new s.aQ(u,t.u_light),u_shadow:new s.aR(u,t.u_shadow),u_highlight:new s.aR(u,t.u_highlight),u_accent:new s.aR(u,t.u_accent)}),hillshadePrepare:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_image:new s.aL(u,t.u_image),u_dimension:new s.aQ(u,t.u_dimension),u_zoom:new s.aM(u,t.u_zoom),u_unpack:new s.aO(u,t.u_unpack)}),line:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_ratio:new s.aM(u,t.u_ratio),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_units_to_pixels:new s.aQ(u,t.u_units_to_pixels)}),lineGradient:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_ratio:new s.aM(u,t.u_ratio),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_units_to_pixels:new s.aQ(u,t.u_units_to_pixels),u_image:new s.aL(u,t.u_image),u_image_height:new s.aM(u,t.u_image_height)}),linePattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_texsize:new s.aQ(u,t.u_texsize),u_ratio:new s.aM(u,t.u_ratio),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_image:new s.aL(u,t.u_image),u_units_to_pixels:new s.aQ(u,t.u_units_to_pixels),u_scale:new s.aP(u,t.u_scale),u_fade:new s.aM(u,t.u_fade)}),lineSDF:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_ratio:new s.aM(u,t.u_ratio),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_units_to_pixels:new s.aQ(u,t.u_units_to_pixels),u_patternscale_a:new s.aQ(u,t.u_patternscale_a),u_patternscale_b:new s.aQ(u,t.u_patternscale_b),u_sdfgamma:new s.aM(u,t.u_sdfgamma),u_image:new s.aL(u,t.u_image),u_tex_y_a:new s.aM(u,t.u_tex_y_a),u_tex_y_b:new s.aM(u,t.u_tex_y_b),u_mix:new s.aM(u,t.u_mix)}),raster:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_tl_parent:new s.aQ(u,t.u_tl_parent),u_scale_parent:new s.aM(u,t.u_scale_parent),u_buffer_scale:new s.aM(u,t.u_buffer_scale),u_fade_t:new s.aM(u,t.u_fade_t),u_opacity:new s.aM(u,t.u_opacity),u_image0:new s.aL(u,t.u_image0),u_image1:new s.aL(u,t.u_image1),u_brightness_low:new s.aM(u,t.u_brightness_low),u_brightness_high:new s.aM(u,t.u_brightness_high),u_saturation_factor:new s.aM(u,t.u_saturation_factor),u_contrast_factor:new s.aM(u,t.u_contrast_factor),u_spin_weights:new s.aP(u,t.u_spin_weights)}),symbolIcon:(u,t)=>({u_is_size_zoom_constant:new s.aL(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aL(u,t.u_is_size_feature_constant),u_size_t:new s.aM(u,t.u_size_t),u_size:new s.aM(u,t.u_size),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_pitch:new s.aM(u,t.u_pitch),u_rotate_symbol:new s.aL(u,t.u_rotate_symbol),u_aspect_ratio:new s.aM(u,t.u_aspect_ratio),u_fade_change:new s.aM(u,t.u_fade_change),u_matrix:new s.aN(u,t.u_matrix),u_label_plane_matrix:new s.aN(u,t.u_label_plane_matrix),u_coord_matrix:new s.aN(u,t.u_coord_matrix),u_is_text:new s.aL(u,t.u_is_text),u_pitch_with_map:new s.aL(u,t.u_pitch_with_map),u_texsize:new s.aQ(u,t.u_texsize),u_texture:new s.aL(u,t.u_texture)}),symbolSDF:(u,t)=>({u_is_size_zoom_constant:new s.aL(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aL(u,t.u_is_size_feature_constant),u_size_t:new s.aM(u,t.u_size_t),u_size:new s.aM(u,t.u_size),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_pitch:new s.aM(u,t.u_pitch),u_rotate_symbol:new s.aL(u,t.u_rotate_symbol),u_aspect_ratio:new s.aM(u,t.u_aspect_ratio),u_fade_change:new s.aM(u,t.u_fade_change),u_matrix:new s.aN(u,t.u_matrix),u_label_plane_matrix:new s.aN(u,t.u_label_plane_matrix),u_coord_matrix:new s.aN(u,t.u_coord_matrix),u_is_text:new s.aL(u,t.u_is_text),u_pitch_with_map:new s.aL(u,t.u_pitch_with_map),u_texsize:new s.aQ(u,t.u_texsize),u_texture:new s.aL(u,t.u_texture),u_gamma_scale:new s.aM(u,t.u_gamma_scale),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_is_halo:new s.aL(u,t.u_is_halo)}),symbolTextAndIcon:(u,t)=>({u_is_size_zoom_constant:new s.aL(u,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aL(u,t.u_is_size_feature_constant),u_size_t:new s.aM(u,t.u_size_t),u_size:new s.aM(u,t.u_size),u_camera_to_center_distance:new s.aM(u,t.u_camera_to_center_distance),u_pitch:new s.aM(u,t.u_pitch),u_rotate_symbol:new s.aL(u,t.u_rotate_symbol),u_aspect_ratio:new s.aM(u,t.u_aspect_ratio),u_fade_change:new s.aM(u,t.u_fade_change),u_matrix:new s.aN(u,t.u_matrix),u_label_plane_matrix:new s.aN(u,t.u_label_plane_matrix),u_coord_matrix:new s.aN(u,t.u_coord_matrix),u_is_text:new s.aL(u,t.u_is_text),u_pitch_with_map:new s.aL(u,t.u_pitch_with_map),u_texsize:new s.aQ(u,t.u_texsize),u_texsize_icon:new s.aQ(u,t.u_texsize_icon),u_texture:new s.aL(u,t.u_texture),u_texture_icon:new s.aL(u,t.u_texture_icon),u_gamma_scale:new s.aM(u,t.u_gamma_scale),u_device_pixel_ratio:new s.aM(u,t.u_device_pixel_ratio),u_is_halo:new s.aL(u,t.u_is_halo)}),background:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_opacity:new s.aM(u,t.u_opacity),u_color:new s.aR(u,t.u_color)}),backgroundPattern:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_opacity:new s.aM(u,t.u_opacity),u_image:new s.aL(u,t.u_image),u_pattern_tl_a:new s.aQ(u,t.u_pattern_tl_a),u_pattern_br_a:new s.aQ(u,t.u_pattern_br_a),u_pattern_tl_b:new s.aQ(u,t.u_pattern_tl_b),u_pattern_br_b:new s.aQ(u,t.u_pattern_br_b),u_texsize:new s.aQ(u,t.u_texsize),u_mix:new s.aM(u,t.u_mix),u_pattern_size_a:new s.aQ(u,t.u_pattern_size_a),u_pattern_size_b:new s.aQ(u,t.u_pattern_size_b),u_scale_a:new s.aM(u,t.u_scale_a),u_scale_b:new s.aM(u,t.u_scale_b),u_pixel_coord_upper:new s.aQ(u,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aQ(u,t.u_pixel_coord_lower),u_tile_units_to_pixels:new s.aM(u,t.u_tile_units_to_pixels)}),terrain:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_texture:new s.aL(u,t.u_texture),u_ele_delta:new s.aM(u,t.u_ele_delta)}),terrainDepth:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_ele_delta:new s.aM(u,t.u_ele_delta)}),terrainCoords:(u,t)=>({u_matrix:new s.aN(u,t.u_matrix),u_texture:new s.aL(u,t.u_texture),u_terrain_coords_id:new s.aM(u,t.u_terrain_coords_id),u_ele_delta:new s.aM(u,t.u_ele_delta)})};class Ci{constructor(t,n,a){this.context=t;const c=t.gl;this.buffer=c.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ss={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class na{constructor(t,n,a,c){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=c,this.context=t;const d=t.gl;this.buffer=d.createBuffer(),t.bindVertexBuffer.set(this.buffer),d.bufferData(d.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let a=0;a0){const qe=s.Z(),dt=Ce;s.aU(qe,xe.placementInvProjMatrix,u.transform.glCoordMatrix),s.aU(qe,qe,xe.placementViewportMatrix),A.push({circleArray:Le,circleOffset:O,transform:dt,invTransform:qe,coord:ce}),P+=Le.length/4,O=P}Be&&C.draw(b,S.LINES,Qt.disabled,Ni.disabled,u.colorModeForRenderPass(),xi.disabled,ne(Ce,u.transform,ve),u.style.map.terrain&&u.style.map.terrain.getTerrainData(ce),n.id,Be.layoutVertexBuffer,Be.indexBuffer,Be.segments,null,u.transform.zoom,null,null,Be.collisionVertexBuffer)}if(!x||!A.length)return;const H=u.useProgram("collisionCircle"),W=new s.aV;W.resize(4*P),W._trim();let K=0;for(const ee of A)for(let ce=0;ce=0&&(W[q.associatedIconIndex]={shiftedAnchor:$t,angle:$e})}else j(q.numGlyphs,O)}if(C){H.clear();const K=u.icon.placedSymbolArray;for(let q=0;qu.style.map.terrain.getElevation(Be,Ln,_r):null,Pr=n.layout.get("text-rotation-alignment")==="map";He(qe,Be.posMatrix,u,c,Qi,Do,q,C,Pr,mr)}const Ns=u.translatePosMatrix(Be.posMatrix,Le,d,x),Ca=le||c&&xe||_s?ls:Qi,cn=u.translatePosMatrix(Do,Le,d,x,!0),Jr=$e&&n.paint.get(c?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let xn;xn=$e?qe.iconsInText?Xi(Ct.kind,Jt,_e,q,u,Ns,Ca,cn,ei,kr):vi(Ct.kind,Jt,_e,q,u,Ns,Ca,cn,c,ei,!0):_t(Ct.kind,Jt,_e,q,u,Ns,Ca,cn,c,ei);const Vs={program:Mi,buffers:dt,uniformValues:xn,atlasTexture:fr,atlasTextureIcon:wr,atlasInterpolation:qi,atlasInterpolationIcon:Kr,isSDF:$e,hasHalo:Jr};if(ee&&qe.canOverlap){ce=!0;const mr=dt.segments.get();for(const Pr of mr)Ce.push({segments:new s.S([Pr]),sortKey:Pr.sortKey,state:Vs,terrainData:jt})}else Ce.push({segments:dt.segments,sortKey:0,state:Vs,terrainData:jt})}ce&&Ce.sort((Be,Le)=>Be.sortKey-Le.sortKey);for(const Be of Ce){const Le=Be.state;if(O.activeTexture.set(H.TEXTURE0),Le.atlasTexture.bind(Le.atlasInterpolation,H.CLAMP_TO_EDGE),Le.atlasTextureIcon&&(O.activeTexture.set(H.TEXTURE1),Le.atlasTextureIcon&&Le.atlasTextureIcon.bind(Le.atlasInterpolationIcon,H.CLAMP_TO_EDGE)),Le.isSDF){const qe=Le.uniformValues;Le.hasHalo&&(qe.u_is_halo=1,_a(Le.buffers,Be.segments,n,u,Le.program,ve,A,P,qe,Be.terrainData)),qe.u_is_halo=0}_a(Le.buffers,Be.segments,n,u,Le.program,ve,A,P,Le.uniformValues,Be.terrainData)}}function _a(u,t,n,a,c,d,x,b,S,C){const A=a.context;c.draw(A,A.gl.TRIANGLES,d,x,b,xi.disabled,S,C,n.id,u.layoutVertexBuffer,u.indexBuffer,t,n.paint,a.transform.zoom,u.programConfigurations.get(n.id),u.dynamicLayoutVertexBuffer,u.opacityVertexBuffer)}function us(u,t,n,a,c){if(!n||!a||!a.imageAtlas)return;const d=a.imageAtlas.patternPositions;let x=d[n.to.toString()],b=d[n.from.toString()];if(!x&&b&&(x=b),!b&&x&&(b=x),!x||!b){const S=c.getPaintProperty(t);x=d[S],b=d[S]}x&&b&&u.setConstantPatternPositions(x,b)}function ks(u,t,n,a,c,d,x){const b=u.context.gl,S="fill-pattern",C=n.paint.get(S),A=C&&C.constantOr(1),P=n.getCrossfadeParameters();let O,H,W,K,q;x?(H=A&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",O=b.LINES):(H=A?"fillPattern":"fill",O=b.TRIANGLES);const le=C.constantOr(null);for(const _e of a){const ee=t.getTile(_e);if(A&&!ee.patternsLoaded())continue;const ce=ee.getBucket(n);if(!ce)continue;const ve=ce.programConfigurations.get(n.id),xe=u.useProgram(H,ve),Ce=u.style.map.terrain&&u.style.map.terrain.getTerrainData(_e);A&&(u.context.activeTexture.set(b.TEXTURE0),ee.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),ve.updatePaintBuffers(P)),us(ve,S,le,ee,n);const Be=Ce?_e:null,Le=u.translatePosMatrix(Be?Be.posMatrix:_e.posMatrix,ee,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(x){K=ce.indexBuffer2,q=ce.segments2;const qe=[b.drawingBufferWidth,b.drawingBufferHeight];W=H==="fillOutlinePattern"&&A?B(Le,u,P,ee,qe):I(Le,qe)}else K=ce.indexBuffer,q=ce.segments,W=A?g(Le,u,P,ee):Ts(Le);xe.draw(u.context,O,c,u.stencilModeForClipping(_e),d,xi.disabled,W,Ce,n.id,ce.layoutVertexBuffer,K,q,n.paint,u.transform.zoom,ve)}}function Ps(u,t,n,a,c,d,x){const b=u.context,S=b.gl,C="fill-extrusion-pattern",A=n.paint.get(C),P=A.constantOr(1),O=n.getCrossfadeParameters(),H=n.paint.get("fill-extrusion-opacity"),W=A.constantOr(null);for(const K of a){const q=t.getTile(K),le=q.getBucket(n);if(!le)continue;const _e=u.style.map.terrain&&u.style.map.terrain.getTerrainData(K),ee=le.programConfigurations.get(n.id),ce=u.useProgram(P?"fillExtrusionPattern":"fillExtrusion",ee);P&&(u.context.activeTexture.set(S.TEXTURE0),q.imageAtlasTexture.bind(S.LINEAR,S.CLAMP_TO_EDGE),ee.updatePaintBuffers(O)),us(ee,C,W,q,n);const ve=u.translatePosMatrix(K.posMatrix,q,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),xe=n.paint.get("fill-extrusion-vertical-gradient"),Ce=P?Eo(ve,u,xe,H,K,O,q):Va(ve,u,xe,H);ce.draw(b,b.gl.TRIANGLES,c,d,x,xi.backCCW,Ce,_e,n.id,le.layoutVertexBuffer,le.indexBuffer,le.segments,n.paint,u.transform.zoom,ee,u.style.map.terrain&&le.centroidVertexBuffer)}}function dl(u,t,n,a,c,d,x){const b=u.context,S=b.gl,C=n.fbo;if(!C)return;const A=u.useProgram("hillshade"),P=u.style.map.terrain&&u.style.map.terrain.getTerrainData(t);b.activeTexture.set(S.TEXTURE0),S.bindTexture(S.TEXTURE_2D,C.colorAttachment.get()),A.draw(b,S.TRIANGLES,c,d,x,xi.disabled,((O,H,W,K)=>{const q=W.paint.get("hillshade-shadow-color"),le=W.paint.get("hillshade-highlight-color"),_e=W.paint.get("hillshade-accent-color");let ee=W.paint.get("hillshade-illumination-direction")*(Math.PI/180);W.paint.get("hillshade-illumination-anchor")==="viewport"&&(ee-=O.transform.angle);const ce=!O.options.moving;return{u_matrix:K?K.posMatrix:O.transform.calculatePosMatrix(H.tileID.toUnwrapped(),ce),u_image:0,u_latrange:Ue(0,H.tileID),u_light:[W.paint.get("hillshade-exaggeration"),ee],u_shadow:q,u_highlight:le,u_accent:_e}})(u,n,a,P?t:null),P,a.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments)}function ga(u,t,n,a,c,d){const x=u.context,b=x.gl,S=t.dem;if(S&&S.data){const C=S.dim,A=S.stride,P=S.getPixels();if(x.activeTexture.set(b.TEXTURE1),x.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||u.getTileTexture(A),t.demTexture){const H=t.demTexture;H.update(P,{premultiply:!1}),H.bind(b.NEAREST,b.CLAMP_TO_EDGE)}else t.demTexture=new At(x,P,b.RGBA,{premultiply:!1}),t.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE);x.activeTexture.set(b.TEXTURE0);let O=t.fbo;if(!O){const H=new At(x,{width:C,height:C,data:null},b.RGBA);H.bind(b.LINEAR,b.CLAMP_TO_EDGE),O=t.fbo=x.createFramebuffer(C,C,!0,!1),O.colorAttachment.set(H.texture)}x.bindFramebuffer.set(O.framebuffer),x.viewport.set([0,0,C,C]),u.useProgram("hillshadePrepare").draw(x,b.TRIANGLES,a,c,d,xi.disabled,((H,W)=>{const K=W.stride,q=s.Z();return s.aS(q,0,s.N,-s.N,0,0,1),s.$(q,q,[0,-s.N,0]),{u_matrix:q,u_image:1,u_dimension:[K,K],u_zoom:H.overscaledZ,u_unpack:W.getUnpackVector()}})(t.tileID,S),null,n.id,u.rasterBoundsBuffer,u.quadTriangleIndexBuffer,u.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function ya(u,t,n,a,c,d){const x=a.paint.get("raster-fade-duration");if(!d&&x>0){const b=s.h.now(),S=(b-u.timeAdded)/x,C=t?(b-t.timeAdded)/x:-1,A=n.getSource(),P=c.coveringZoomLevel({tileSize:A.tileSize,roundZoom:A.roundZoom}),O=!t||Math.abs(t.tileID.overscaledZ-P)>Math.abs(u.tileID.overscaledZ-P),H=O&&u.refreshedUponExpiration?1:s.ad(O?S:1-C,0,1);return u.refreshedUponExpiration&&S>=1&&(u.refreshedUponExpiration=!1),t?{opacity:1,mix:1-H}:{opacity:H,mix:0}}return{opacity:1,mix:0}}const Xo=new s.aT(1,0,0,1),va=new s.aT(0,1,0,1),io=new s.aT(0,0,1,1),pl=new s.aT(1,0,1,1),Po=new s.aT(0,1,1,1);function hs(u,t,n,a){Ko(u,0,t+n/2,u.transform.width,n,a)}function xa(u,t,n,a){Ko(u,t-n/2,0,n,u.transform.height,a)}function Ko(u,t,n,a,c,d){const x=u.context,b=x.gl;b.enable(b.SCISSOR_TEST),b.scissor(t*u.pixelRatio,n*u.pixelRatio,a*u.pixelRatio,c*u.pixelRatio),x.clear({color:d}),b.disable(b.SCISSOR_TEST)}function ba(u,t,n){const a=u.context,c=a.gl,d=n.posMatrix,x=u.useProgram("debug"),b=Qt.disabled,S=Ni.disabled,C=u.colorModeForRenderPass(),A="$debug",P=u.style.map.terrain&&u.style.map.terrain.getTerrainData(n);a.activeTexture.set(c.TEXTURE0);const O=t.getTileByID(n.key).latestRawTileData,H=Math.floor((O&&O.byteLength||0)/1024),W=t.getTile(n).tileSize,K=512/Math.min(W,512)*(n.overscaledZ/u.transform.zoom)*.5;let q=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(q+=` => ${n.overscaledZ}`),function(le,_e){le.initDebugOverlayCanvas();const ee=le.debugOverlayCanvas,ce=le.context.gl,ve=le.debugOverlayCanvas.getContext("2d");ve.clearRect(0,0,ee.width,ee.height),ve.shadowColor="white",ve.shadowBlur=2,ve.lineWidth=1.5,ve.strokeStyle="white",ve.textBaseline="top",ve.font="bold 36px Open Sans, sans-serif",ve.fillText(_e,5,5),ve.strokeText(_e,5,5),le.debugOverlayTexture.update(ee),le.debugOverlayTexture.bind(ce.LINEAR,ce.CLAMP_TO_EDGE)}(u,`${q} ${H}kB`),x.draw(a,c.TRIANGLES,b,S,Ki.alphaBlended,xi.disabled,se(d,s.aT.transparent,K),null,A,u.debugBuffer,u.quadTriangleIndexBuffer,u.debugSegments),x.draw(a,c.LINE_STRIP,b,S,C,xi.disabled,se(d,s.aT.red),P,A,u.debugBuffer,u.tileBorderIndexBuffer,u.debugSegments)}function Ji(u,t,n){const a=u.context,c=a.gl,d=u.colorModeForRenderPass(),x=new Qt(c.LEQUAL,Qt.ReadWrite,u.depthRangeFor3D),b=u.useProgram("terrain"),S=t.getTerrainMesh();a.bindFramebuffer.set(null),a.viewport.set([0,0,u.width,u.height]);for(const C of n){const A=u.renderToTexture.getTexture(C),P=t.getTerrainData(C.tileID);a.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,A.texture);const O={u_matrix:u.transform.calculatePosMatrix(C.tileID.toUnwrapped()),u_texture:0,u_ele_delta:t.getMeshFrameDelta(u.transform.zoom)};b.draw(a,c.TRIANGLES,x,Ni.disabled,d,xi.backCCW,O,P,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}}class zo{constructor(t,n){this.context=new Ol(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:s.Z(),renderTime:0},this.setup(),this.numSublayers=tn.maxUnderzooming+tn.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new jn}resize(t,n,a){if(this.width=Math.floor(t*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const c of this.style._order)this.style._layers[c].resize()}setup(){const t=this.context,n=new s.a_;n.emplaceBack(0,0),n.emplaceBack(s.N,0),n.emplaceBack(0,s.N),n.emplaceBack(s.N,s.N),this.tileExtentBuffer=t.createVertexBuffer(n,ia.members),this.tileExtentSegments=s.S.simpleSegment(0,0,4,2);const a=new s.a_;a.emplaceBack(0,0),a.emplaceBack(s.N,0),a.emplaceBack(0,s.N),a.emplaceBack(s.N,s.N),this.debugBuffer=t.createVertexBuffer(a,ia.members),this.debugSegments=s.S.simpleSegment(0,0,4,5);const c=new s.V;c.emplaceBack(0,0,0,0),c.emplaceBack(s.N,0,s.N,0),c.emplaceBack(0,s.N,0,s.N),c.emplaceBack(s.N,s.N,s.N,s.N),this.rasterBoundsBuffer=t.createVertexBuffer(c,Gt.members),this.rasterBoundsSegments=s.S.simpleSegment(0,0,4,2);const d=new s.a_;d.emplaceBack(0,0),d.emplaceBack(1,0),d.emplaceBack(0,1),d.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(d,ia.members),this.viewportSegments=s.S.simpleSegment(0,0,4,2);const x=new s.a$;x.emplaceBack(0),x.emplaceBack(1),x.emplaceBack(3),x.emplaceBack(2),x.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(x);const b=new s.b0;b.emplaceBack(0,1,2),b.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(b);const S=this.context.gl;this.stencilClearMode=new Ni({func:S.ALWAYS,mask:0},0,255,S.ZERO,S.ZERO,S.ZERO)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=s.Z();s.aS(a,0,this.width,this.height,0,0,1),s.a0(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,n.TRIANGLES,Qt.disabled,this.stencilClearMode,Ki.disabled,xi.disabled,fe(a),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source;const a=this.context,c=a.gl;this.nextStencilID+n.length>256&&this.clearStencil(),a.setColorMode(Ki.disabled),a.setDepthMode(Qt.disabled);const d=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const x of n){const b=this._tileClippingMaskIDs[x.key]=this.nextStencilID++,S=this.style.map.terrain&&this.style.map.terrain.getTerrainData(x);d.draw(a,c.TRIANGLES,Qt.disabled,new Ni({func:c.ALWAYS,mask:0},b,255,c.KEEP,c.KEEP,c.REPLACE),Ki.disabled,xi.disabled,fe(x.posMatrix),S,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new Ni({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new Ni({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,a=t.sort((x,b)=>b.overscaledZ-x.overscaledZ),c=a[a.length-1].overscaledZ,d=a[0].overscaledZ-c+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const x={};for(let b=0;b=0;this.currentLayer--){const S=this.style._layers[a[this.currentLayer]],C=c[S.source],A=d[S.source];this._renderTileClippingMasks(S,A),this.renderLayer(this,C,S,A)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerq.source&&!q.isHidden(A)?[C.sourceCaches[q.source]]:[]),H=O.filter(q=>q.getSource().type==="vector"),W=O.filter(q=>q.getSource().type!=="vector"),K=q=>{(!P||P.getSource().maxzoomK(q)),P||W.forEach(q=>K(q)),P}(this.style,this.transform.zoom);S&&function(C,A,P){for(let O=0;OH.style.map.terrain.getElevation(xe,Ct,gt):null)}}}(S,d,b,x,b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),C),b.paint.get("icon-opacity").constantOr(1)!==0&&ko(d,x,b,S,!1,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),b.layout.get("icon-rotation-alignment"),b.layout.get("icon-pitch-alignment"),b.layout.get("icon-keep-upright"),A,P),b.paint.get("text-opacity").constantOr(1)!==0&&ko(d,x,b,S,!0,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),b.layout.get("text-keep-upright"),A,P),x.map.showCollisionBoxes&&(Ao(d,x,b,S,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),!0),Ao(d,x,b,S,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),!1))})(t,n,a,c,this.style.placement.variableOffsets);break;case"circle":(function(d,x,b,S){if(d.renderPass!=="translucent")return;const C=b.paint.get("circle-opacity"),A=b.paint.get("circle-stroke-width"),P=b.paint.get("circle-stroke-opacity"),O=!b.layout.get("circle-sort-key").isConstant();if(C.constantOr(1)===0&&(A.constantOr(1)===0||P.constantOr(1)===0))return;const H=d.context,W=H.gl,K=d.depthModeForSublayer(0,Qt.ReadOnly),q=Ni.disabled,le=d.colorModeForRenderPass(),_e=[];for(let ee=0;eeee.sortKey-ce.sortKey);for(const ee of _e){const{programConfiguration:ce,program:ve,layoutVertexBuffer:xe,indexBuffer:Ce,uniformValues:Be,terrainData:Le}=ee.state;ve.draw(H,W.TRIANGLES,K,q,le,xi.disabled,Be,Le,b.id,xe,Ce,ee.segments,b.paint,d.transform.zoom,ce)}})(t,n,a,c);break;case"heatmap":(function(d,x,b,S){if(b.paint.get("heatmap-opacity")!==0)if(d.renderPass==="offscreen"){const C=d.context,A=C.gl,P=Ni.disabled,O=new Ki([A.ONE,A.ONE],s.aT.transparent,[!0,!0,!0,!0]);(function(H,W,K){const q=H.gl;H.activeTexture.set(q.TEXTURE1),H.viewport.set([0,0,W.width/4,W.height/4]);let le=K.heatmapFbo;if(le)q.bindTexture(q.TEXTURE_2D,le.colorAttachment.get()),H.bindFramebuffer.set(le.framebuffer);else{const _e=q.createTexture();q.bindTexture(q.TEXTURE_2D,_e),q.texParameteri(q.TEXTURE_2D,q.TEXTURE_WRAP_S,q.CLAMP_TO_EDGE),q.texParameteri(q.TEXTURE_2D,q.TEXTURE_WRAP_T,q.CLAMP_TO_EDGE),q.texParameteri(q.TEXTURE_2D,q.TEXTURE_MIN_FILTER,q.LINEAR),q.texParameteri(q.TEXTURE_2D,q.TEXTURE_MAG_FILTER,q.LINEAR),le=K.heatmapFbo=H.createFramebuffer(W.width/4,W.height/4,!1,!1),function(ee,ce,ve,xe){var Ce,Be;const Le=ee.gl,qe=(Ce=ee.HALF_FLOAT)!==null&&Ce!==void 0?Ce:Le.UNSIGNED_BYTE,dt=(Be=ee.RGBA16F)!==null&&Be!==void 0?Be:Le.RGBA;Le.texImage2D(Le.TEXTURE_2D,0,dt,ce.width/4,ce.height/4,0,Le.RGBA,qe,null),xe.colorAttachment.set(ve)}(H,W,_e,le)}})(C,d,b),C.clear({color:s.aT.transparent});for(let H=0;H{const ee=s.Z();s.aS(ee,0,K.width,K.height,0,0,1);const ce=K.context.gl;return{u_matrix:ee,u_world:[ce.drawingBufferWidth,ce.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:q.paint.get("heatmap-opacity")}})(C,A),null,A.id,C.viewportBuffer,C.quadTriangleIndexBuffer,C.viewportSegments,A.paint,C.transform.zoom)}(d,b))})(t,n,a,c);break;case"line":(function(d,x,b,S){if(d.renderPass!=="translucent")return;const C=b.paint.get("line-opacity"),A=b.paint.get("line-width");if(C.constantOr(1)===0||A.constantOr(1)===0)return;const P=d.depthModeForSublayer(0,Qt.ReadOnly),O=d.colorModeForRenderPass(),H=b.paint.get("line-dasharray"),W=b.paint.get("line-pattern"),K=W.constantOr(1),q=b.paint.get("line-gradient"),le=b.getCrossfadeParameters(),_e=K?"linePattern":H?"lineSDF":q?"lineGradient":"line",ee=d.context,ce=ee.gl;let ve=!0;for(const xe of S){const Ce=x.getTile(xe);if(K&&!Ce.patternsLoaded())continue;const Be=Ce.getBucket(b);if(!Be)continue;const Le=Be.programConfigurations.get(b.id),qe=d.context.program.get(),dt=d.useProgram(_e,Le),$t=ve||dt.program!==qe,$e=d.style.map.terrain&&d.style.map.terrain.getTerrainData(xe),Ct=W.constantOr(null);if(Ct&&Ce.imageAtlas){const Jt=Ce.imageAtlas,jt=Jt.patternPositions[Ct.to.toString()],ei=Jt.patternPositions[Ct.from.toString()];jt&&ei&&Le.setConstantPatternPositions(jt,ei)}const gt=$e?xe:null,Mi=K?Ye(d,Ce,b,le,gt):H?Rt(d,Ce,b,H,le,gt):q?ot(d,Ce,b,Be.lineClipsArray.length,gt):rt(d,Ce,b,gt);if(K)ee.activeTexture.set(ce.TEXTURE0),Ce.imageAtlasTexture.bind(ce.LINEAR,ce.CLAMP_TO_EDGE),Le.updatePaintBuffers(le);else if(H&&($t||d.lineAtlas.dirty))ee.activeTexture.set(ce.TEXTURE0),d.lineAtlas.bind(ee);else if(q){const Jt=Be.gradients[b.id];let jt=Jt.texture;if(b.gradientVersion!==Jt.version){let ei=256;if(b.stepInterpolant){const fr=x.getSource().maxzoom,qi=xe.canonical.z===fr?Math.ceil(1<0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),a=this.imageManager.getPattern(t.to.toString());return!n||!a}useProgram(t,n){this.cache=this.cache||{};const a=t+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[a]||(this.cache[a]=new Ss(this.context,Gi[t],n,ra[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[a]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new At(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}class Xr{constructor(t,n){this.points=t,this.planes=n}static fromInvProjectionMatrix(t,n,a){const c=Math.pow(2,a),d=[[-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(b=>{const S=1/(b=s.ag([],b,t))[3]/n*c;return s.b3(b,b,[S,S,1/b[3],S])}),x=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(b=>{const S=function(O,H){var W=H[0],K=H[1],q=H[2],le=W*W+K*K+q*q;return le>0&&(le=1/Math.sqrt(le)),O[0]=H[0]*le,O[1]=H[1]*le,O[2]=H[2]*le,O}([],function(O,H,W){var K=H[0],q=H[1],le=H[2],_e=W[0],ee=W[1],ce=W[2];return O[0]=q*ce-le*ee,O[1]=le*_e-K*ce,O[2]=K*ee-q*_e,O}([],ti([],d[b[0]],d[b[1]]),ti([],d[b[2]],d[b[1]]))),C=-((A=S)[0]*(P=d[b[1]])[0]+A[1]*P[1]+A[2]*P[2]);var A,P;return S.concat(C)});return new Xr(d,x)}}class ro{constructor(t,n){this.min=t,this.max=n,this.center=function(a,c,d){return a[0]=.5*c[0],a[1]=.5*c[1],a[2]=.5*c[2],a}([],function(a,c,d){return a[0]=c[0]+d[0],a[1]=c[1]+d[1],a[2]=c[2]+d[2],a}([],this.min,this.max))}quadrant(t){const n=[t%2==0,t<2],a=it(this.min),c=it(this.max);for(let d=0;d=0&&x++;if(x===0)return 0;x!==n.length&&(a=!1)}if(a)return 2;for(let c=0;c<3;c++){let d=Number.MAX_VALUE,x=-Number.MAX_VALUE;for(let b=0;bthis.max[c]-this.min[c])return 0}return 1}}class ds{constructor(t=0,n=0,a=0,c=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(c)||c<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=a,this.right=c}interpolate(t,n,a){return n.top!=null&&t.top!=null&&(this.top=s.B.number(t.top,n.top,a)),n.bottom!=null&&t.bottom!=null&&(this.bottom=s.B.number(t.bottom,n.bottom,a)),n.left!=null&&t.left!=null&&(this.left=s.B.number(t.left,n.left,a)),n.right!=null&&t.right!=null&&(this.right=s.B.number(t.right,n.right,a)),this}getCenter(t,n){const a=s.ad((this.left+t-this.right)/2,0,t),c=s.ad((this.top+n-this.bottom)/2,0,n);return new s.P(a,c)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new ds(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class wa{constructor(t,n,a,c,d){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=d===void 0||!!d,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=a??0,this._maxPitch=c??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new s.L(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new ds,this._posMatrixCache={},this._alignedPosMatrixCache={},this._minEleveationForCurrentTile=0}clone(){const t=new wa(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this._minEleveationForCurrentTile=t._minEleveationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new s.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const n=-s.b5(t,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var a=new s.A(4);return s.A!=Float32Array&&(a[1]=0,a[2]=0),a[0]=1,a[3]=1,a}(),function(a,c,d){var x=c[0],b=c[1],S=c[2],C=c[3],A=Math.sin(d),P=Math.cos(d);a[0]=x*P+S*A,a[1]=b*P+C*A,a[2]=x*-A+S*P,a[3]=b*-A+C*P}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=s.ad(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const n=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,a){this._unmodified=!1,this._edgeInsets.interpolate(t,n,a),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const n=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(t){const n=[new s.b6(0,t)];if(this._renderWorldCopies){const a=this.pointCoordinate(new s.P(0,0)),c=this.pointCoordinate(new s.P(this.width,0)),d=this.pointCoordinate(new s.P(this.width,this.height)),x=this.pointCoordinate(new s.P(0,this.height)),b=Math.floor(Math.min(a.x,c.x,d.x,x.x)),S=Math.floor(Math.max(a.x,c.x,d.x,x.x)),C=1;for(let A=b-C;A<=S+C;A++)A!==0&&n.push(new s.b6(A,t))}return n}coveringTiles(t){var n,a;let c=this.coveringZoomLevel(t);const d=c;if(t.minzoom!==void 0&&ct.maxzoom&&(c=t.maxzoom);const x=this.pointCoordinate(this.getCameraPoint()),b=s.U.fromLngLat(this.center),S=Math.pow(2,c),C=[S*x.x,S*x.y,0],A=[S*b.x,S*b.y,0],P=Xr.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,c);let O=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(O=c);const H=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,W=ee=>({aabb:new ro([ee*S,0,0],[(ee+1)*S,S,0]),zoom:0,x:0,y:0,wrap:ee,fullyVisible:!1}),K=[],q=[],le=c,_e=t.reparseOverscaled?d:c;if(this._renderWorldCopies)for(let ee=1;ee<=3;ee++)K.push(W(-ee)),K.push(W(ee));for(K.push(W(0));K.length>0;){const ee=K.pop(),ce=ee.x,ve=ee.y;let xe=ee.fullyVisible;if(!xe){const dt=ee.aabb.intersects(P);if(dt===0)continue;xe=dt===2}const Ce=t.terrain?C:A,Be=ee.aabb.distanceX(Ce),Le=ee.aabb.distanceY(Ce),qe=Math.max(Math.abs(Be),Math.abs(Le));if(ee.zoom===le||qe>H+(1<=O){const dt=le-ee.zoom,$t=C[0]-.5-(ce<>1),Ct=ee.zoom+1;let gt=ee.aabb.quadrant(dt);if(t.terrain){const Mi=new s.O(Ct,ee.wrap,Ct,$t,$e),Jt=t.terrain.getMinMaxElevation(Mi),jt=(n=Jt.minElevation)!==null&&n!==void 0?n:this.elevation,ei=(a=Jt.maxElevation)!==null&&a!==void 0?a:this.elevation;gt=new ro([gt.min[0],gt.min[1],jt],[gt.max[0],gt.max[1],ei])}K.push({aabb:gt,zoom:Ct,x:$t,y:$e,wrap:ee.wrap,fullyVisible:xe})}}return q.sort((ee,ce)=>ee.distanceSq-ce.distanceSq).map(ee=>ee.tileID)}resize(t,n){this.width=t,this.height=n,this.pixelsToGLUnits=[2/t,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const n=s.ad(t.lat,-this.maxValidLatitude,this.maxValidLatitude);return new s.P(s.G(t.lng)*this.worldSize,s.H(n)*this.worldSize)}unproject(t){return new s.U(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const n=this.pointLocation(this.centerPoint,t),a=t.getElevationForLngLatZoom(n,this.tileZoom);if(!(this.elevation-a))return;const c=this.getCameraPosition(),d=s.U.fromLngLat(c.lngLat,c.altitude),x=s.U.fromLngLat(n,a),b=d.x-x.x,S=d.y-x.y,C=d.z-x.z,A=Math.sqrt(b*b+S*S+C*C),P=this.scaleZoom(this.cameraToCenterDistance/A/this.tileSize);this._elevation=a,this._center=n,this.zoom=P}setLocationAtPoint(t,n){const a=this.pointCoordinate(n),c=this.pointCoordinate(this.centerPoint),d=this.locationCoordinate(t),x=new s.U(d.x-(a.x-c.x),d.y-(a.y-c.y));this.center=this.coordinateLocation(x),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,n){return n?this.coordinatePoint(this.locationCoordinate(t),n.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,n){return this.coordinateLocation(this.pointCoordinate(t,n))}locationCoordinate(t){return s.U.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,n){if(n){const O=n.pointCoordinate(t);if(O!=null)return O}const a=[t.x,t.y,0,1],c=[t.x,t.y,1,1];s.ag(a,a,this.pixelMatrixInverse),s.ag(c,c,this.pixelMatrixInverse);const d=a[3],x=c[3],b=a[1]/d,S=c[1]/x,C=a[2]/d,A=c[2]/x,P=C===A?0:(0-C)/(A-C);return new s.U(s.B.number(a[0]/d,c[0]/x,P)/this.worldSize,s.B.number(b,S,P)/this.worldSize)}coordinatePoint(t,n=0,a=this.pixelMatrix){const c=[t.x*this.worldSize,t.y*this.worldSize,n,1];return s.ag(c,c,a),new s.P(c[0]/c[3],c[1]/c[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new Tt().extend(this.pointLocation(new s.P(0,t))).extend(this.pointLocation(new s.P(this.width,t))).extend(this.pointLocation(new s.P(this.width,this.height))).extend(this.pointLocation(new s.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new Tt([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(t,n=!1){const a=t.key,c=n?this._alignedPosMatrixCache:this._posMatrixCache;if(c[a])return c[a];const d=t.canonical,x=this.worldSize/this.zoomScale(d.z),b=d.x+Math.pow(2,d.z)*t.wrap,S=s.ao(new Float64Array(16));return s.$(S,S,[b*x,d.y*x,0]),s.a0(S,S,[x/s.N,x/s.N,1]),s.a1(S,n?this.alignedProjMatrix:this.projMatrix,S),c[a]=new Float32Array(S),c[a]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t,n,a,c,d=-90,x=90,b=-180,S=180;const C=this.size,A=this._unmodified;if(this.latRange){const H=this.latRange;d=s.H(H[1])*this.worldSize,x=s.H(H[0])*this.worldSize,t=x-dx&&(c=x-W)}if(this.lngRange){const H=(b+S)/2,W=s.b5(P.x,H-this.worldSize/2,H+this.worldSize/2),K=C.x/2;W-KS&&(a=S-K)}a===void 0&&c===void 0||(this.center=this.unproject(new s.P(a!==void 0?a:P.x,c!==void 0?c:P.y)).wrap()),this._unmodified=A,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,n=this.point.x,a=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=s.b7(1,this.center.lat)*this.worldSize;let c=s.ao(new Float64Array(16));s.a0(c,c,[this.width/2,-this.height/2,1]),s.$(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=s.ao(new Float64Array(16)),s.a0(c,c,[1,-1,1]),s.$(c,c,[-1,-1,0]),s.a0(c,c,[2/this.width,2/this.height,1]),this.glCoordMatrix=c;const d=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),x=Math.min(this.elevation,this._minEleveationForCurrentTile),b=d-x*this._pixelPerMeter/Math.cos(this._pitch),S=x<0?b:d,C=Math.PI/2+this._pitch,A=this._fov*(.5+t.y/this.height),P=Math.sin(A)*S/Math.sin(s.ad(Math.PI-C-A,.01,Math.PI-.01)),O=this.getHorizon(),H=2*Math.atan(O/this.cameraToCenterDistance)*(.5+t.y/(2*O)),W=Math.sin(H)*S/Math.sin(s.ad(Math.PI-C-H,.01,Math.PI-.01)),K=Math.min(P,W),q=1.01*(Math.cos(Math.PI/2-this._pitch)*K+S),le=this.height/50;c=new Float64Array(16),s.b8(c,this._fov,this.width/this.height,le,q),c[8]=2*-t.x/this.width,c[9]=2*t.y/this.height,s.a0(c,c,[1,-1,1]),s.$(c,c,[0,0,-this.cameraToCenterDistance]),s.b9(c,c,this._pitch),s.ae(c,c,this.angle),s.$(c,c,[-n,-a,0]),this.mercatorMatrix=s.a0([],c,[this.worldSize,this.worldSize,this.worldSize]),s.a0(c,c,[1,1,this._pixelPerMeter]),this.pixelMatrix=s.a1(new Float64Array(16),this.labelPlaneMatrix,c),s.$(c,c,[0,0,-this.elevation]),this.projMatrix=c,this.invProjMatrix=s.as([],c),this.pixelMatrix3D=s.a1(new Float64Array(16),this.labelPlaneMatrix,c);const _e=this.width%2/2,ee=this.height%2/2,ce=Math.cos(this.angle),ve=Math.sin(this.angle),xe=n-Math.round(n)+ce*_e+ve*ee,Ce=a-Math.round(a)+ce*ee+ve*_e,Be=new Float64Array(c);if(s.$(Be,Be,[xe>.5?xe-1:xe,Ce>.5?Ce-1:Ce,0]),this.alignedProjMatrix=Be,c=s.as(new Float64Array(16),this.pixelMatrix),!c)throw new Error("failed to invert matrix");this.pixelMatrixInverse=c,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new s.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return s.ag(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new s.P(0,t))}getCameraQueryGeometry(t){const n=this.getCameraPoint();if(t.length===1)return[t[0],n];{let a=n.x,c=n.y,d=n.x,x=n.y;for(const b of t)a=Math.min(a,b.x),c=Math.min(c,b.y),d=Math.max(d,b.x),x=Math.max(x,b.y);return[new s.P(a,c),new s.P(d,c),new s.P(d,x),new s.P(a,x),new s.P(a,c)]}}}function de(u,t){let n,a=!1,c=null,d=null;const x=()=>{c=null,a&&(u.apply(d,n),c=setTimeout(x,t),a=!1)};return(...b)=>(a=!0,d=this,n=b,c||x(),c)}class we{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(c=>c.split("=")).forEach(c=>{c[0]===this._hashName&&(a=c)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(n.length>=3&&!n.some(a=>isNaN(a))){const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:a,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,n)}catch{}},this._updateHash=de(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,c=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),d=Math.pow(10,c),x=Math.round(n.lng*d)/d,b=Math.round(n.lat*d)/d,S=this._map.getBearing(),C=this._map.getPitch();let A="";if(A+=t?`/${x}/${b}/${a}`:`${a}/${b}/${x}`,(S||C)&&(A+="/"+Math.round(10*S)/10),C&&(A+=`/${Math.round(C)}`),this._hashName){const P=this._hashName;let O=!1;const H=window.location.hash.slice(1).split("&").map(W=>{const K=W.split("=")[0];return K===P?(O=!0,`${K}=${A}`):W}).filter(W=>W);return O||H.push(`${P}=${A}`),`#${H.join("&")}`}return`#${A}`}}const Qe={linearity:.3,easing:s.ba(0,0,.3,1)},wt=s.e({deceleration:2500,maxSpeed:1400},Qe),Vi=s.e({deceleration:20,maxSpeed:1400},Qe),ni=s.e({deceleration:1e3,maxSpeed:360},Qe),ir=s.e({deceleration:1e3,maxSpeed:90},Qe);class lr{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.h.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=s.h.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new s.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)n.zoom+=d.zoomDelta||0,n.bearing+=d.bearingDelta||0,n.pitch+=d.pitchDelta||0,d.panDelta&&n.pan._add(d.panDelta),d.around&&(n.around=d.around),d.pinchAround&&(n.pinchAround=d.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(n.pan.mag()){const d=rr(n.pan.mag(),a,s.e({},wt,t||{}));c.offset=n.pan.mult(d.amount/n.pan.mag()),c.center=this._map.transform.center,dr(c,d)}if(n.zoom){const d=rr(n.zoom,a,Vi);c.zoom=this._map.transform.zoom+d.amount,dr(c,d)}if(n.bearing){const d=rr(n.bearing,a,ni);c.bearing=this._map.transform.bearing+s.ad(d.amount,-179,179),dr(c,d)}if(n.pitch){const d=rr(n.pitch,a,ir);c.pitch=this._map.transform.pitch+d.amount,dr(c,d)}if(c.zoom||c.bearing){const d=n.pinchAround===void 0?n.around:n.pinchAround;c.around=d?this._map.unproject(d):this._map.getCenter()}return this.clear(),s.e(c,{noMoveStart:!0})}}function dr(u,t){(!u.duration||u.durationn.unproject(S)),b=d.reduce((S,C,A,P)=>S.add(C.div(P.length)),new s.P(0,0));super(t,{points:d,point:b,lngLats:x,lngLat:n.unproject(b),originalEvent:a}),this._defaultPrevented=!1}}class no extends s.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,a){super(t,{originalEvent:a}),this._defaultPrevented=!1}}class Zr{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new no(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new bi(t.type,this._map,t))}mouseup(t){this._map.fire(new bi(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new bi(t.type,this._map,t))}dblclick(t){return this._firePreventable(new bi(t.type,this._map,t))}mouseover(t){this._map.fire(new bi(t.type,this._map,t))}mouseout(t){this._map.fire(new bi(t.type,this._map,t))}touchstart(t){return this._firePreventable(new an(t.type,this._map,t))}touchmove(t){this._map.fire(new an(t.type,this._map,t))}touchend(t){this._map.fire(new an(t.type,this._map,t))}touchcancel(t){this._map.fire(new an(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class oo{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new bi(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new bi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new bi(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ln{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.pointLocation(s.P.convert(t),this._map.terrain)}}class zs{constructor(t,n){this._map=t,this._tr=new ln(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(V.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)d.fitScreenCoordinates(a,c,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(V.remove(this._box),this._box=null),V.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new s.k(t,{originalEvent:n}))}}function Ar(u,t){if(u.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${u.length}, points ${t.length}`);const n={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),a.length===this.numTouches&&(this.centroid=function(c){const d=new s.P(0,0);for(const x of c)d._add(x);return d.div(c.length)}(n),this.touches=Ar(a,n)))}touchmove(t,n,a){if(this.aborted||!this.centroid)return;const c=Ar(a,n);for(const d in this.touches){const x=c[d];(!x||x.dist(this.touches[d])>30)&&(this.aborted=!0)}}touchend(t,n,a){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const c=!this.aborted&&this.centroid;if(this.reset(),c)return c}}}class Ls{constructor(t){this.singleTap=new yn(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,a){this.singleTap.touchstart(t,n,a)}touchmove(t,n,a){this.singleTap.touchmove(t,n,a)}touchend(t,n,a){const c=this.singleTap.touchend(t,n,a);if(c){const d=t.timeStamp-this.lastTime<500,x=!this.lastTap||this.lastTap.dist(c)<30;if(d&&x||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=c,this.count===this.numTaps)return this.reset(),c}}}class fo{constructor(t){this._tr=new ln(t),this._zoomIn=new Ls({numTouches:1,numTaps:2}),this._zoomOut=new Ls({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,a){this._zoomIn.touchstart(t,n,a),this._zoomOut.touchstart(t,n,a)}touchmove(t,n,a){this._zoomIn.touchmove(t,n,a),this._zoomOut.touchmove(t,n,a)}touchend(t,n,a){const c=this._zoomIn.touchend(t,n,a),d=this._zoomOut.touchend(t,n,a),x=this._tr;return c?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:x.zoom+1,around:x.unproject(c)},{originalEvent:t})}):d?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:x.zoom-1,around:x.unproject(d)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class mo{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const c=n.length?n[0]:n;return!this._moved&&c.dist(a){u.mousedown=u.dragStart,u.mousemoveWindow=u.dragMove,u.mouseup=u.dragEnd,u.contextmenu=function(t){t.preventDefault()}},Lo=({enable:u,clickTolerance:t,bearingDegreesPerPixelMoved:n=.8})=>{const a=new wi({checkCorrectEvent:c=>V.mouseButton(c)===0&&c.ctrlKey||V.mouseButton(c)===2});return new mo({clickTolerance:t,move:(c,d)=>({bearingDelta:(d.x-c.x)*n}),moveStateManager:a,enable:u,assignEvents:Gn})},pr=({enable:u,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5})=>{const a=new wi({checkCorrectEvent:c=>V.mouseButton(c)===0&&c.ctrlKey||V.mouseButton(c)===2});return new mo({clickTolerance:t,move:(c,d)=>({pitchDelta:(d.y-c.y)*n}),moveStateManager:a,enable:u,assignEvents:Gn})};class tt{constructor(t,n){this._minTouches=t.cooperativeGestures?2:1,this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new s.P(0,0),setTimeout(()=>{this._cancelCooperativeMessage=!1},200)}touchstart(t,n,a){return this._calculateTransform(t,n,a)}touchmove(t,n,a){if(this._map._cooperativeGestures&&(this._minTouches===2&&a.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,a.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(a.length0&&(this._active=!0);const c=Ar(a,n),d=new s.P(0,0),x=new s.P(0,0);let b=0;for(const C in c){const A=c[C],P=this._touches[C];P&&(d._add(A),x._add(A.sub(P)),b++,c[C]=A)}if(this._touches=c,bMath.abs(u.x)}class Ga extends Wn{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,a){super.touchstart(t,n,a),this._currentTouchCount=a.length}_start(t){this._lastPoints=t,ps(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,a){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const c=t[0].sub(this._lastPoints[0]),d=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(c,d,a.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(c.y+d.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,a){if(this._valid!==void 0)return this._valid;const c=t.mag()>=2,d=n.mag()>=2;if(!c&&!d)return;if(!c||!d)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const x=t.y>0==n.y>0;return ps(t)&&ps(n)&&x}}const fs={panStep:100,bearingStep:15,pitchStep:10};class Fs{constructor(t){this._tr=new ln(t);const n=fs;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,a=0,c=0,d=0,x=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?a=-1:(t.preventDefault(),d=-1);break;case 39:t.shiftKey?a=1:(t.preventDefault(),d=1);break;case 38:t.shiftKey?c=1:(t.preventDefault(),x=-1);break;case 40:t.shiftKey?c=-1:(t.preventDefault(),x=1);break;default:return}return this._rotationDisabled&&(a=0,c=0),{cameraAnimation:b=>{const S=this._tr;b.easeTo({duration:300,easeId:"keyboardHandler",easing:Wa,zoom:n?Math.round(S.zoom)+n*(t.shiftKey?2:1):S.zoom,bearing:S.bearing+a*this._bearingStep,pitch:S.pitch+c*this._pitchStep,offset:[-d*this._panStep,-x*this._panStep],center:S.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Wa(u){return u*(2-u)}const Rs=4.000244140625;class Ta{constructor(t,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=t,this._tr=new ln(t),this._el=t.getCanvasContainer(),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!t[this._map._metaKey])return;t.preventDefault()}let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const a=s.h.now(),c=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%Rs==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":c>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(c*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const n=V.mousePos(this._el,t),a=this._tr;this._around=s.L.convert(this._aroundCenter?a.center:a.unproject(n)),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._tr.transform;if(this._delta!==0){const b=this._type==="wheel"&&Math.abs(this._delta)>Rs?this._wheelZoomRate:this._defaultZoomRate;let S=2/(1+Math.exp(-Math.abs(this._delta*b)));this._delta<0&&S!==0&&(S=1/S);const C=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(C*S))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,a=this._startZoom,c=this._easing;let d,x=!1;if(this._type==="wheel"&&a&&c){const b=Math.min((s.h.now()-this._lastWheelEventTime)/200,1),S=c(b);d=s.B.number(a,n,S),b<1?this._frameId||(this._frameId=!0):x=!0}else d=n,x=!0;return this._active=!0,x&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!x,zoomDelta:d-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=s.bb;if(this._prevEase){const a=this._prevEase,c=(s.h.now()-a.start)/a.duration,d=a.easing(c+.01)-a.easing(c),x=.27/Math.sqrt(d*d+1e-4)*.01,b=Math.sqrt(.0729-x*x);n=s.ba(x,b,.25,1)}return this._prevEase={start:s.h.now(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Bl{constructor(t,n){this._clickZoom=t,this._tapZoom=n}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 Nl{constructor(t){this._tr=new ln(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Vl{constructor(){this._tap=new Ls({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,a){if(!this._swipePoint)if(this._tapTime){const c=n[0],d=t.timeStamp-this._tapTime<500,x=this._tapPoint.dist(c)<30;d&&x?a.length>0&&(this._swipePoint=c,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(t,n,a)}touchmove(t,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const c=n[0],d=c.y-this._swipePoint.y;return this._swipePoint=c,t.preventDefault(),this._active=!0,{zoomDelta:d/128}}}else this._tap.touchmove(t,n,a)}touchend(t,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const c=this._tap.touchend(t,n,a);c&&(this._tapTime=t.timeStamp,this._tapPoint=c)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ul{constructor(t,n,a){this._el=t,this._mousePan=n,this._touchPan=a}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class zn{constructor(t,n,a){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=n,this._mousePitch=a}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 ms{constructor(t,n,a,c){this._el=t,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=c,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Ha=u=>u.zoom||u.drag||u.pitch||u.rotate;class jl extends s.k{}function Xa(u){return u.panDelta&&u.panDelta.mag()||u.zoomDelta||u.bearingDelta||u.pitchDelta}class ql{constructor(t,n){this.handleWindowEvent=c=>{this.handleEvent(c,`${c.type}Window`)},this.handleEvent=(c,d)=>{if(c.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const x=c.type==="renderFrame"?void 0:c,b={needsRenderFrame:!1},S={},C={},A=c.touches,P=A?this._getMapTouches(A):void 0,O=P?V.touchPos(this._el,P):V.mousePos(this._el,c);for(const{handlerName:K,handler:q,allowed:le}of this._handlers){if(!q.isEnabled())continue;let _e;this._blockedByActive(C,le,K)?q.reset():q[d||c.type]&&(_e=q[d||c.type](c,O,P),this.mergeHandlerResult(b,S,_e,K,x),_e&&_e.needsRenderFrame&&this._triggerRenderFrame()),(_e||q.isActive())&&(C[K]=q)}const H={};for(const K in this._previousActiveHandlers)C[K]||(H[K]=x);this._previousActiveHandlers=C,(Object.keys(H).length||Xa(b))&&(this._changes.push([b,S,H]),this._triggerRenderFrame()),(Object.keys(C).length||Xa(b))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:W}=b;W&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],W(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new lr(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[c,d,x]of this._listeners)V.addEventListener(c,d,c===document?this.handleWindowEvent:this.handleEvent,x)}destroy(){for(const[t,n,a]of this._listeners)V.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(t){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new Zr(n,t));const c=n.boxZoom=new zs(n,t);this._add("boxZoom",c),t.interactive&&t.boxZoom&&c.enable();const d=new fo(n),x=new Nl(n);n.doubleClickZoom=new Bl(x,d),this._add("tapZoom",d),this._add("clickZoom",x),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const b=new Vl;this._add("tapDragZoom",b);const S=n.touchPitch=new Ga(n);this._add("touchPitch",S),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const C=Lo(t),A=pr(t);n.dragRotate=new zn(t,C,A),this._add("mouseRotate",C,["mousePitch"]),this._add("mousePitch",A,["mouseRotate"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const P=(({enable:le,clickTolerance:_e})=>{const ee=new wi({checkCorrectEvent:ce=>V.mouseButton(ce)===0&&!ce.ctrlKey});return new mo({clickTolerance:_e,move:(ce,ve)=>({around:ve,panDelta:ve.sub(ce)}),activateOnStart:!0,moveStateManager:ee,enable:le,assignEvents:Gn})})(t),O=new tt(t,n);n.dragPan=new Ul(a,P,O),this._add("mousePan",P),this._add("touchPan",O,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const H=new Sa,W=new Jo;n.touchZoomRotate=new ms(a,W,H,b),this._add("touchRotate",H,["touchPan","touchZoom"]),this._add("touchZoom",W,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate);const K=n.scrollZoom=new Ta(n,()=>this._triggerRenderFrame());this._add("scrollZoom",K,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const q=n.keyboard=new Fs(n);this._add("keyboard",q),t.interactive&&t.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new oo(n))}_add(t,n,a){this._handlers.push({handlerName:t,handler:n,allowed:a}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ha(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,a){for(const c in t)if(c!==a&&(!n||n.indexOf(c)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const a of t)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(t,n,a,c,d){if(!a)return;s.e(t,a);const x={handlerName:c,originalEvent:a.originalEvent||d};a.zoomDelta!==void 0&&(n.zoom=x),a.panDelta!==void 0&&(n.drag=x),a.pitchDelta!==void 0&&(n.pitch=x),a.bearingDelta!==void 0&&(n.rotate=x)}_applyChanges(){const t={},n={},a={};for(const[c,d,x]of this._changes)c.panDelta&&(t.panDelta=(t.panDelta||new s.P(0,0))._add(c.panDelta)),c.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+c.zoomDelta),c.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+c.bearingDelta),c.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+c.pitchDelta),c.around!==void 0&&(t.around=c.around),c.pinchAround!==void 0&&(t.pinchAround=c.pinchAround),c.noInertia&&(t.noInertia=c.noInertia),s.e(n,d),s.e(a,x);this._updateMapTransform(t,n,a),this._changes=[]}_updateMapTransform(t,n,a){const c=this._map,d=c._getTransformForUpdate(),x=c.terrain;if(!(Xa(t)||x&&this._terrainMovement))return this._fireEvents(n,a,!0);let{panDelta:b,zoomDelta:S,bearingDelta:C,pitchDelta:A,around:P,pinchAround:O}=t;O!==void 0&&(P=O),c._stop(!0),P=P||c.transform.centerPoint;const H=d.pointLocation(b?P.sub(b):P);C&&(d.bearing+=C),A&&(d.pitch+=A),S&&(d.zoom+=S),x?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?d.center=d.pointLocation(d.centerPoint.sub(b)):d.setLocationAtPoint(H,P):(this._terrainMovement=!0,this._map._elevationFreeze=!0,d.setLocationAtPoint(H,P),this._map.once("moveend",()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,d.recalculateZoom(c.terrain)})):d.setLocationAtPoint(H,P),c._applyUpdatedTransform(d),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,a,!0)}_fireEvents(t,n,a){const c=Ha(this._eventsInProgress),d=Ha(t),x={};for(const A in t){const{originalEvent:P}=t[A];this._eventsInProgress[A]||(x[`${A}start`]=P),this._eventsInProgress[A]=t[A]}!c&&d&&this._fireEvent("movestart",d.originalEvent);for(const A in x)this._fireEvent(A,x[A]);d&&this._fireEvent("move",d.originalEvent);for(const A in t){const{originalEvent:P}=t[A];this._fireEvent(A,P)}const b={};let S;for(const A in this._eventsInProgress){const{handlerName:P,originalEvent:O}=this._eventsInProgress[A];this._handlersById[P].isActive()||(delete this._eventsInProgress[A],S=n[P]||O,b[`${A}end`]=S)}for(const A in b)this._fireEvent(A,b[A]);const C=Ha(this._eventsInProgress);if(a&&(c||d)&&!C){this._updatingCamera=!0;const A=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),P=O=>O!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new jl("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Oc extends s.E{constructor(t,n){super(),this._renderFrameCallback=()=>{const a=Math.min((s.h.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(a)),a<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new s.L(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}panBy(t,n,a){return t=s.P.convert(t).mult(-1),this.panTo(this.transform.center,s.e({offset:t},n),a)}panTo(t,n,a){return this.easeTo(s.e({center:t},n),a)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,a){return this.easeTo(s.e({zoom:t},n),a)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,a){return this.easeTo(s.e({bearing:t},n),a)}resetNorth(t,n){return this.rotateTo(0,s.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(s.e({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing()){if(this._zooming&&(a.zoom=s.B.number(c,S,xe)),this._rotating&&(a.bearing=s.B.number(d,C,xe)),this._pitching&&(a.pitch=s.B.number(x,A,xe)),this._padding&&(a.interpolatePadding(b,P,xe),H=a.centerPoint.add(O)),this.terrain&&!t.freezeElevation&&this._updateElevation(xe),ee)a.setLocationAtPoint(ee,ce);else{const Ce=a.zoomScale(a.zoom-c),Be=S>c?Math.min(2,_e):Math.max(.5,_e),Le=Math.pow(Be,1-xe),qe=a.unproject(q.add(le.mult(xe*Le)).mult(Ce));a.setLocationAtPoint(a.renderWorldCopies?qe.wrap():qe,H)}this._applyUpdatedTransform(a),this._fireMoveEvents(n)},xe=>{this.terrain&&this._finalizeElevation(),this._afterEase(n,xe)},t),this}_prepareEase(t,n,a={}){this._moving=!0,n||a.moving||this.fire(new s.k("movestart",t)),this._zooming&&!a.zooming&&this.fire(new s.k("zoomstart",t)),this._rotating&&!a.rotating&&this.fire(new s.k("rotatestart",t)),this._pitching&&!a.pitching&&this.fire(new s.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(a-(n-(a*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.elevation=s.B.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(t){if(!this.transformCameraUpdate)return;const n=t.clone(),{center:a,zoom:c,pitch:d,bearing:x,elevation:b}=this.transformCameraUpdate(n);a&&(n.center=a),c!==void 0&&(n.zoom=c),d!==void 0&&(n.pitch=d),x!==void 0&&(n.bearing=x),b!==void 0&&(n.elevation=b),this.transform.apply(n)}_fireMoveEvents(t){this.fire(new s.k("move",t)),this._zooming&&this.fire(new s.k("zoom",t)),this._rotating&&this.fire(new s.k("rotate",t)),this._pitching&&this.fire(new s.k("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const a=this._zooming,c=this._rotating,d=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new s.k("zoomend",t)),c&&this.fire(new s.k("rotateend",t)),d&&this.fire(new s.k("pitchend",t)),this.fire(new s.k("moveend",t))}flyTo(t,n){if(!t.essential&&s.h.prefersReducedMotion){const gt=s.F(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(gt,n)}this.stop(),t=s.e({offset:[0,0],speed:1.2,curve:1.42,easing:s.bb},t);const a=this._getTransformForUpdate(),c=this.getZoom(),d=this.getBearing(),x=this.getPitch(),b=this.getPadding(),S="zoom"in t?s.ad(+t.zoom,a.minZoom,a.maxZoom):c,C="bearing"in t?this._normalizeBearing(t.bearing,d):d,A="pitch"in t?+t.pitch:x,P="padding"in t?t.padding:a.padding,O=a.zoomScale(S-c),H=s.P.convert(t.offset);let W=a.centerPoint.add(H);const K=a.pointLocation(W),q=s.L.convert(t.center||K);this._normalizeCenter(q);const le=a.project(K),_e=a.project(q).sub(le);let ee=t.curve;const ce=Math.max(a.width,a.height),ve=ce/O,xe=_e.mag();if("minZoom"in t){const gt=s.ad(Math.min(t.minZoom,c,S),a.minZoom,a.maxZoom),Mi=ce/a.zoomScale(gt-c);ee=Math.sqrt(Mi/xe*2)}const Ce=ee*ee;function Be(gt){const Mi=(ve*ve-ce*ce+(gt?-1:1)*Ce*Ce*xe*xe)/(2*(gt?ve:ce)*Ce*xe);return Math.log(Math.sqrt(Mi*Mi+1)-Mi)}function Le(gt){return(Math.exp(gt)-Math.exp(-gt))/2}function qe(gt){return(Math.exp(gt)+Math.exp(-gt))/2}const dt=Be(!1);let $t=function(gt){return qe(dt)/qe(dt+ee*gt)},$e=function(gt){return ce*((qe(dt)*(Le(Mi=dt+ee*gt)/qe(Mi))-Le(dt))/Ce)/xe;var Mi},Ct=(Be(!0)-dt)/ee;if(Math.abs(xe)<1e-6||!isFinite(Ct)){if(Math.abs(ce-ve)<1e-6)return this.easeTo(t,n);const gt=vet.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=d!==C,this._pitching=A!==x,this._padding=!a.isPaddingEqual(P),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(q),this._ease(gt=>{const Mi=gt*Ct,Jt=1/$t(Mi);a.zoom=gt===1?S:c+a.scaleZoom(Jt),this._rotating&&(a.bearing=s.B.number(d,C,gt)),this._pitching&&(a.pitch=s.B.number(x,A,gt)),this._padding&&(a.interpolatePadding(b,P,gt),W=a.centerPoint.add(H)),this.terrain&&!t.freezeElevation&&this._updateElevation(gt);const jt=gt===1?q:a.unproject(le.add(_e.mult($e(Mi))).mult(Jt));a.setLocationAtPoint(a.renderWorldCopies?jt.wrap():jt,W),this._applyUpdatedTransform(a),this._fireMoveEvents(n)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(n)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const a=this._onEaseEnd;delete this._onEaseEnd,a.call(this,n)}if(!t){const a=this.handlers;a&&a.stop(!1)}return this}_ease(t,n,a){a.animate===!1||a.duration===0?(t(1),n()):(this._easeStart=s.h.now(),this._easeOptions=a,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=s.b5(t,-180,180);const a=Math.abs(t-n);return Math.abs(t-360-n)180?-360:a<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(s.L.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}class Hn{constructor(t={}){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=V.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=V.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=V.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){V.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,n){const a=this._map._getUIString(`AttributionControl.${n}`);t.title=a,t.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(c=>typeof c!="string"?"":c)):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const c=this._map.style.stylesheet;this.styleOwner=c.owner,this.styleId=c.id}const n=this._map.style.sourceCaches;for(const c in n){const d=n[c];if(d.used||d.usedForTerrain){const x=d.getSource();x.attribution&&t.indexOf(x.attribution)<0&&t.push(x.attribution)}}t=t.filter(c=>String(c).trim()),t.sort((c,d)=>c.length-d.length),t=t.filter((c,d)=>{for(let x=d+1;x=0)return!1;return!0});const a=t.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,t.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Yi{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=V.create("div","maplibregl-ctrl");const n=V.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){V.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class fl{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(const c of a)if(c.id===t)return void(c.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const a of n)if(!a.cancelled&&(a.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}const Zl={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"};var Bc=s.Q([{name:"a_pos3d",type:"Int16",components:3}]);class Nc extends s.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,n){this.sourceCache.update(t,n),this._renderableTilesKeys=[];const a={};for(const c of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))a[c.key]=!0,this._renderableTilesKeys.push(c.key),this._tiles[c.key]||(c.posMatrix=new Float64Array(16),s.aS(c.posMatrix,0,s.N,0,s.N,0,1),this._tiles[c.key]=new wo(c,this.tileSize));for(const c in this._tiles)a[c]||delete this._tiles[c]}freeRtt(t){for(const n in this._tiles){const a=this._tiles[n];(!t||a.tileID.equals(t)||a.tileID.isChildOf(t)||t.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const n={};for(const a of this._renderableTilesKeys){const c=this._tiles[a].tileID;if(c.canonical.equals(t.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16),s.aS(d.posMatrix,0,s.N,0,s.N,0,1),n[a]=d}else if(c.canonical.isChildOf(t.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16);const x=c.canonical.z-t.canonical.z,b=c.canonical.x-(c.canonical.x>>x<>x<>x;s.aS(d.posMatrix,0,C,0,C,0,1),s.$(d.posMatrix,d.posMatrix,[-b*C,-S*C,0]),n[a]=d}else if(t.canonical.isChildOf(c.canonical)){const d=t.clone();d.posMatrix=new Float64Array(16);const x=t.canonical.z-c.canonical.z,b=t.canonical.x-(t.canonical.x>>x<>x<>x;s.aS(d.posMatrix,0,s.N,0,s.N,0,1),s.$(d.posMatrix,d.posMatrix,[b*C,S*C,0]),s.a0(d.posMatrix,d.posMatrix,[1/2**x,1/2**x,0]),n[a]=d}}return n}getSourceTile(t,n){const a=this.sourceCache._source;let c=t.overscaledZ-this.deltaZoom;if(c>a.maxzoom&&(c=a.maxzoom),c=a.minzoom&&(!d||!d.dem);)d=this.sourceCache.getTileByID(t.scaledTo(c--).key);return d}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=t)}}class Vc{constructor(t,n,a){this.painter=t,this.sourceCache=new Nc(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,a,c=s.N){var d;if(!(n>=0&&n=0&&at.canonical.z&&(t.canonical.z>=c?d=t.canonical.z-c:s.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const x=t.canonical.x-(t.canonical.x>>d<>d<>8<<4|d>>8,n[x+3]=0;const a=new s.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),c=new At(t,a,t.gl.RGBA,{premultiply:!1});return c.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=c,c}pointCoordinate(t){const n=new Uint8Array(4),a=this.painter.context,c=a.gl;a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),c.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,c.RGBA,c.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const d=n[0]+(n[2]>>4<<8),x=n[1]+((15&n[2])<<8),b=this.coordsIndex[255-n[3]],S=b&&this.sourceCache.getTileByID(b);if(!S)return null;const C=this._coordsTextureSize,A=(1<0&&Math.sign(d)<0||!a&&Math.sign(c)<0&&Math.sign(d)>0?(c=360*Math.sign(d)+c,s.G(c)):n}}class bu{constructor(t,n,a){this._context=t,this._size=n,this._tileSize=a,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),a=new At(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return a.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(a.texture),{id:t,fbo:n,texture:a,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(n=>t.id!==n),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length!t.inUse)===!1}}const vn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class ml{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new bu(t.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter(a=>!t._layers[a].isHidden(n)),this._coordsDescendingInv={};for(const a in t.sourceCaches){this._coordsDescendingInv[a]={};const c=t.sourceCaches[a].getVisibleCoordinates();for(const d of c){const x=this.terrain.sourceCache.getTerrainCoords(d);for(const b in x)this._coordsDescendingInv[a][b]||(this._coordsDescendingInv[a][b]=[]),this._coordsDescendingInv[a][b].push(x[b])}}this._coordsDescendingInvStr={};for(const a of t._order){const c=t._layers[a],d=c.source;if(vn[c.type]&&!this._coordsDescendingInvStr[d]){this._coordsDescendingInvStr[d]={};for(const x in this._coordsDescendingInv[d])this._coordsDescendingInvStr[d][x]=this._coordsDescendingInv[d][x].map(b=>b.key).sort().join()}}for(const a of this._renderableTiles)for(const c in this._coordsDescendingInvStr){const d=this._coordsDescendingInvStr[c][a.tileID.key];d&&d!==a.rttCoords[c]&&(a.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const n=t.type,a=this.painter,c=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(vn[n]&&(this._prevType&&vn[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!c))return!0;if(vn[this._prevType]||vn[n]&&c){this._prevType=n;const d=this._stacks.length-1,x=this._stacks[d]||[];for(const b of this._renderableTiles){if(this.pool.isFull()&&(Ji(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(b),b.rtt[d]){const C=this.pool.getObjectForId(b.rtt[d].id);if(C.stamp===b.rtt[d].stamp){this.pool.useObject(C);continue}}const S=this.pool.getOrCreateFreeObject();this.pool.useObject(S),this.pool.stampObject(S),b.rtt[d]={id:S.id,stamp:S.stamp},a.context.bindFramebuffer.set(S.fbo.framebuffer),a.context.clear({color:s.aT.transparent,stencil:0}),a.currentStencilSource=void 0;for(let C=0;C{u.touchstart=u.dragStart,u.touchmoveWindow=u.dragMove,u.touchend=u.dragEnd},Gl={showCompass:!0,showZoom:!0,visualizePitch:!1};class Wl{constructor(t,n,a=!1){this.mousedown=x=>{this.startMouse(s.e({},x,{ctrlKey:!0,preventDefault:()=>x.preventDefault()}),V.mousePos(this.element,x)),V.addEventListener(window,"mousemove",this.mousemove),V.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=x=>{this.moveMouse(x,V.mousePos(this.element,x))},this.mouseup=x=>{this.mouseRotate.dragEnd(x),this.mousePitch&&this.mousePitch.dragEnd(x),this.offTemp()},this.touchstart=x=>{x.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=V.touchPos(this.element,x.targetTouches)[0],this.startTouch(x,this._startPos),V.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),V.addEventListener(window,"touchend",this.touchend))},this.touchmove=x=>{x.targetTouches.length!==1?this.reset():(this._lastPos=V.touchPos(this.element,x.targetTouches)[0],this.moveTouch(x,this._lastPos))},this.touchend=x=>{x.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const c=t.dragRotate._mouseRotate.getClickTolerance(),d=t.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=Lo({clickTolerance:c,enable:!0}),this.touchRotate=(({enable:x,clickTolerance:b,bearingDegreesPerPixelMoved:S=.8})=>{const C=new Ds;return new mo({clickTolerance:b,move:(A,P)=>({bearingDelta:(P.x-A.x)*S}),moveStateManager:C,enable:x,assignEvents:Ka})})({clickTolerance:c,enable:!0}),this.map=t,a&&(this.mousePitch=pr({clickTolerance:d,enable:!0}),this.touchPitch=(({enable:x,clickTolerance:b,pitchDegreesPerPixelMoved:S=-.5})=>{const C=new Ds;return new mo({clickTolerance:b,move:(A,P)=>({pitchDelta:(P.y-A.y)*S}),moveStateManager:C,enable:x,assignEvents:Ka})})({clickTolerance:d,enable:!0})),V.addEventListener(n,"mousedown",this.mousedown),V.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),V.addEventListener(n,"touchcancel",this.reset)}startMouse(t,n){this.mouseRotate.dragStart(t,n),this.mousePitch&&this.mousePitch.dragStart(t,n),V.disableDrag()}startTouch(t,n){this.touchRotate.dragStart(t,n),this.touchPitch&&this.touchPitch.dragStart(t,n),V.disableDrag()}moveMouse(t,n){const a=this.map,{bearingDelta:c}=this.mouseRotate.dragMove(t,n)||{};if(c&&a.setBearing(a.getBearing()+c),this.mousePitch){const{pitchDelta:d}=this.mousePitch.dragMove(t,n)||{};d&&a.setPitch(a.getPitch()+d)}}moveTouch(t,n){const a=this.map,{bearingDelta:c}=this.touchRotate.dragMove(t,n)||{};if(c&&a.setBearing(a.getBearing()+c),this.touchPitch){const{pitchDelta:d}=this.touchPitch.dragMove(t,n)||{};d&&a.setPitch(a.getPitch()+d)}}off(){const t=this.element;V.removeEventListener(t,"mousedown",this.mousedown),V.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),V.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),V.removeEventListener(window,"touchend",this.touchend),V.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){V.enableDrag(),V.removeEventListener(window,"mousemove",this.mousemove),V.removeEventListener(window,"mouseup",this.mouseup),V.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),V.removeEventListener(window,"touchend",this.touchend)}}let br;function Hl(u,t,n){if(u=new s.L(u.lng,u.lat),t){const a=new s.L(u.lng-360,u.lat),c=new s.L(u.lng+360,u.lat),d=n.locationPoint(u).distSqr(t);n.locationPoint(a).distSqr(t)180;){const a=n.locationPoint(u);if(a.x>=0&&a.y>=0&&a.x<=n.width&&a.y<=n.height)break;u.lng>n.center.lng?u.lng-=360:u.lng+=360}return u}const so={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Uc(u,t,n){const a=u.classList;for(const c in so)a.remove(`maplibregl-${n}-anchor-${c}`);a.add(`maplibregl-${n}-anchor-${t}`)}class Os extends s.E{constructor(t){if(super(),this._onKeyPress=n=>{const a=n.code,c=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&c!==32&&c!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,c=this._element;this._popup&&(a===c||c.contains(a))&&this.togglePopup()},this._update=n=>{if(!this._map)return;const a=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!a)&&this._map.once("render",this._update),this._map.transform.renderWorldCopies&&(this._lngLat=Hl(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let d="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?d="rotateX(0deg)":this._pitchAlignment==="map"&&(d=`rotateX(${this._map.getPitch()}deg)`),n&&n.type!=="moveend"||(this._pos=this._pos.round()),V.setTransform(this._element,`${so[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${d} ${c}`),this._map.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout(()=>{const x=this._map.unproject(this._pos),b=40075016686e-3*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=x.distanceTo(this._lngLat)>20*b?"0.2":"1.0",this._opacityTimeout=null},100))},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new s.k("dragstart"))),this.fire(new s.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new s.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment!=="auto"?t.pitchAlignment:this._rotationAlignment,t&&t.element)this._element=t.element,this._offset=s.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=V.create("div"),this._element.setAttribute("aria-label","Map marker");const n=V.createNS("http://www.w3.org/2000/svg","svg"),a=41,c=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${c}px`),n.setAttributeNS(null,"viewBox",`0 0 ${c} ${a}`);const d=V.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"stroke","none"),d.setAttributeNS(null,"stroke-width","1"),d.setAttributeNS(null,"fill","none"),d.setAttributeNS(null,"fill-rule","evenodd");const x=V.createNS("http://www.w3.org/2000/svg","g");x.setAttributeNS(null,"fill-rule","nonzero");const b=V.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"transform","translate(3.0, 29.0)"),b.setAttributeNS(null,"fill","#000000");const S=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const le of S){const _e=V.createNS("http://www.w3.org/2000/svg","ellipse");_e.setAttributeNS(null,"opacity","0.04"),_e.setAttributeNS(null,"cx","10.5"),_e.setAttributeNS(null,"cy","5.80029008"),_e.setAttributeNS(null,"rx",le.rx),_e.setAttributeNS(null,"ry",le.ry),b.appendChild(_e)}const C=V.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"fill",this._color);const A=V.createNS("http://www.w3.org/2000/svg","path");A.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),C.appendChild(A);const P=V.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"opacity","0.25"),P.setAttributeNS(null,"fill","#000000");const O=V.createNS("http://www.w3.org/2000/svg","path");O.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),P.appendChild(O);const H=V.createNS("http://www.w3.org/2000/svg","g");H.setAttributeNS(null,"transform","translate(6.0, 7.0)"),H.setAttributeNS(null,"fill","#FFFFFF");const W=V.createNS("http://www.w3.org/2000/svg","g");W.setAttributeNS(null,"transform","translate(8.0, 8.0)");const K=V.createNS("http://www.w3.org/2000/svg","circle");K.setAttributeNS(null,"fill","#000000"),K.setAttributeNS(null,"opacity","0.25"),K.setAttributeNS(null,"cx","5.5"),K.setAttributeNS(null,"cy","5.5"),K.setAttributeNS(null,"r","5.4999962");const q=V.createNS("http://www.w3.org/2000/svg","circle");q.setAttributeNS(null,"fill","#FFFFFF"),q.setAttributeNS(null,"cx","5.5"),q.setAttributeNS(null,"cy","5.5"),q.setAttributeNS(null,"r","5.4999962"),W.appendChild(K),W.appendChild(q),x.appendChild(b),x.appendChild(C),x.appendChild(P),x.appendChild(H),x.appendChild(W),n.appendChild(x),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",c*this._scale+"px"),this._element.appendChild(n),this._offset=s.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),Uc(this._element,this._anchor,"marker"),t&&t.className)for(const n of t.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),V.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=s.L.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const c=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[c,-1*(38.1-13.5+c)],"bottom-right":[-c,-1*(38.1-13.5+c)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?t.remove():t.addTo(this._map),this):this}getOffset(){return this._offset}setOffset(t){return this._offset=s.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const cr={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let or=0,Ia=!1;const Ja={maxWidth:100,unit:"metric"};function Ya(u,t,n){const a=n&&n.maxWidth||100,c=u._container.clientHeight/2,d=u.unproject([0,c]),x=u.unproject([a,c]),b=d.distanceTo(x);if(n&&n.unit==="imperial"){const S=3.2808*b;S>5280?Bs(t,a,S/5280,u._getUIString("ScaleControl.Miles")):Bs(t,a,S,u._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Bs(t,a,b/1852,u._getUIString("ScaleControl.NauticalMiles")):b>=1e3?Bs(t,a,b/1e3,u._getUIString("ScaleControl.Kilometers")):Bs(t,a,b,u._getUIString("ScaleControl.Meters"))}function Bs(u,t,n,a){const c=function(d){const x=Math.pow(10,`${Math.floor(d)}`.length-1);let b=d/x;return b=b>=10?10:b>=5?5:b>=3?3:b>=2?2:b>=1?1:function(S){const C=Math.pow(10,Math.ceil(-Math.log(S)/Math.LN10));return Math.round(S*C)/C}(b),x*b}(n);u.style.width=t*(c/n)+"px",u.innerHTML=`${c} ${a}`}const Xl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Kl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ea(u){if(u){if(typeof u=="number"){const t=Math.round(Math.abs(u)/Math.SQRT2);return{center:new s.P(0,0),top:new s.P(0,u),"top-left":new s.P(t,t),"top-right":new s.P(-t,t),bottom:new s.P(0,-u),"bottom-left":new s.P(t,-t),"bottom-right":new s.P(-t,-t),left:new s.P(u,0),right:new s.P(-u,0)}}if(u instanceof s.P||Array.isArray(u)){const t=s.P.convert(u);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:s.P.convert(u.center||[0,0]),top:s.P.convert(u.top||[0,0]),"top-left":s.P.convert(u["top-left"]||[0,0]),"top-right":s.P.convert(u["top-right"]||[0,0]),bottom:s.P.convert(u.bottom||[0,0]),"bottom-left":s.P.convert(u["bottom-left"]||[0,0]),"bottom-right":s.P.convert(u["bottom-right"]||[0,0]),left:s.P.convert(u.left||[0,0]),right:s.P.convert(u.right||[0,0])}}return Ea(new s.P(0,0))}const Jl={extend:(u,...t)=>s.e(u,...t),run(u){u()},logToElement(u,t=!1,n="log"){const a=window.document.getElementById(n);a&&(t&&(a.innerHTML=""),a.innerHTML+=`
${u}`)}},Yl=Z;class Si{static get version(){return Yl}static get workerCount(){return Vn.workerCount}static set workerCount(t){Vn.workerCount=t}static get maxParallelImageRequests(){return s.c.MAX_PARALLEL_IMAGE_REQUESTS}static set maxParallelImageRequests(t){s.c.MAX_PARALLEL_IMAGE_REQUESTS=t}static get workerUrl(){return s.c.WORKER_URL}static set workerUrl(t){s.c.WORKER_URL=t}static addProtocol(t,n){s.c.REGISTERED_PROTOCOLS[t]=n}static removeProtocol(t){delete s.c.REGISTERED_PROTOCOLS[t]}}return Si.Map=class extends Oc{constructor(u){if(s.bg.mark(s.bh.create),(u=s.e({},Et,u)).minZoom!=null&&u.maxZoom!=null&&u.minZoom>u.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(u.minPitch!=null&&u.maxPitch!=null&&u.minPitch>u.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(u.minPitch!=null&&u.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(u.maxPitch!=null&&u.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new wa(u.minZoom,u.maxZoom,u.minPitch,u.maxPitch,u.renderWorldCopies),{bearingSnap:u.bearingSnap}),this._cooperativeGesturesOnWheel=t=>{this._onCooperativeGesture(t,t[this._metaKey],1)},this._contextLost=t=>{t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new s.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new s.k("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=u.interactive,this._cooperativeGestures=u.cooperativeGestures,this._metaKey=navigator.platform.indexOf("Mac")===0?"metaKey":"ctrlKey",this._maxTileCacheSize=u.maxTileCacheSize,this._maxTileCacheZoomLevels=u.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=u.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=u.preserveDrawingBuffer,this._antialias=u.antialias,this._trackResize=u.trackResize,this._bearingSnap=u.bearingSnap,this._refreshExpiredTiles=u.refreshExpiredTiles,this._fadeDuration=u.fadeDuration,this._crossSourceCollisions=u.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=u.collectResourceTiming,this._renderTaskQueue=new fl,this._controls=[],this._mapId=s.a2(),this._locale=s.e({},Zl,u.locale),this._clickTolerance=u.clickTolerance,this._overridePixelRatio=u.pixelRatio,this._maxCanvasSize=u.maxCanvasSize,this.transformCameraUpdate=u.transformCameraUpdate,this._imageQueueHandle=De.addThrottleControl(()=>this.isMoving()),this._requestManager=new at(u.transformRequest),typeof u.container=="string"){if(this._container=document.getElementById(u.container),!this._container)throw new Error(`Container '${u.container}' not found.`)}else{if(!(u.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=u.container}if(u.maxBounds&&this.setMaxBounds(u.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let t=!1;const n=de(a=>{this._trackResize&&!this._removed&&this.resize(a)._update()},50);this._resizeObserver=new ResizeObserver(a=>{t?n(a):t=!0}),this._resizeObserver.observe(this._container)}this.handlers=new ql(this,u),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=u.hash&&new we(typeof u.hash=="string"&&u.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:u.center,zoom:u.zoom,bearing:u.bearing,pitch:u.pitch}),u.bounds&&(this.resize(),this.fitBounds(u.bounds,s.e({},u.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=u.localIdeographFontFamily,this._validateStyle=u.validateStyle,u.style&&this.setStyle(u.style,{localIdeographFontFamily:u.localIdeographFontFamily}),u.attributionControl&&this.addControl(new Hn({customAttribution:u.customAttribution})),u.maplibreLogo&&this.addControl(new Yi,u.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update(t.dataType==="style"),this.fire(new s.k(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new s.k(`${t.dataType}dataloading`,t))}),this.on("dataabort",t=>{this.fire(new s.k("sourcedataabort",t))})}_getMapId(){return this._mapId}addControl(u,t){if(t===void 0&&(t=u.getDefaultPosition?u.getDefaultPosition():"top-right"),!u||!u.onAdd)return this.fire(new s.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=u.onAdd(this);this._controls.push(u);const a=this._controlPositions[t];return t.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(u){if(!u||!u.onRemove)return this.fire(new s.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(u);return t>-1&&this._controls.splice(t,1),u.onRemove(this),this}hasControl(u){return this._controls.indexOf(u)>-1}calculateCameraOptionsFromTo(u,t,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(u,t,n,a)}resize(u){var t;const n=this._containerDimensions(),a=n[0],c=n[1],d=this._getClampedPixelRatio(a,c);if(this._resizeCanvas(a,c,d),this.painter.resize(a,c,d),this.painter.overLimit()){const b=this.painter.context.gl;this._maxCanvasSize=[b.drawingBufferWidth,b.drawingBufferHeight];const S=this._getClampedPixelRatio(a,c);this._resizeCanvas(a,c,S),this.painter.resize(a,c,S)}this.transform.resize(a,c),(t=this._requestedCameraState)===null||t===void 0||t.resize(a,c);const x=!this._moving;return x&&(this.stop(),this.fire(new s.k("movestart",u)).fire(new s.k("move",u))),this.fire(new s.k("resize",u)),x&&this.fire(new s.k("moveend",u)),this}_getClampedPixelRatio(u,t){const{0:n,1:a}=this._maxCanvasSize,c=this.getPixelRatio(),d=u*c,x=t*c;return Math.min(d>n?n/d:1,x>a?a/x:1)*c}getPixelRatio(){var u;return(u=this._overridePixelRatio)!==null&&u!==void 0?u:devicePixelRatio}setPixelRatio(u){this._overridePixelRatio=u,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(u){return this.transform.setMaxBounds(Tt.convert(u)),this._update()}setMinZoom(u){if((u=u??-2)>=-2&&u<=this.transform.maxZoom)return this.transform.minZoom=u,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=u,this._update(),this.getZoom()>u&&this.setZoom(u),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(u){if((u=u??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(u>=0&&u<=this.transform.maxPitch)return this.transform.minPitch=u,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(u>=this.transform.minPitch)return this.transform.maxPitch=u,this._update(),this.getPitch()>u&&this.setPitch(u),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(u){return this.transform.renderWorldCopies=u,this._update()}getCooperativeGestures(){return this._cooperativeGestures}setCooperativeGestures(u){return this._cooperativeGestures=u,this._cooperativeGestures?this._setupCooperativeGestures():this._destroyCooperativeGestures(),this}project(u){return this.transform.locationPoint(s.L.convert(u),this.style&&this.terrain)}unproject(u){return this.transform.pointLocation(s.P.convert(u),this.terrain)}isMoving(){var u;return this._moving||((u=this.handlers)===null||u===void 0?void 0:u.isMoving())}isZooming(){var u;return this._zooming||((u=this.handlers)===null||u===void 0?void 0:u.isZooming())}isRotating(){var u;return this._rotating||((u=this.handlers)===null||u===void 0?void 0:u.isRotating())}_createDelegatedListener(u,t,n){if(u==="mouseenter"||u==="mouseover"){let a=!1;return{layer:t,listener:n,delegates:{mousemove:d=>{const x=this.getLayer(t)?this.queryRenderedFeatures(d.point,{layers:[t]}):[];x.length?a||(a=!0,n.call(this,new bi(u,this,d.originalEvent,{features:x}))):a=!1},mouseout:()=>{a=!1}}}}if(u==="mouseleave"||u==="mouseout"){let a=!1;return{layer:t,listener:n,delegates:{mousemove:x=>{(this.getLayer(t)?this.queryRenderedFeatures(x.point,{layers:[t]}):[]).length?a=!0:a&&(a=!1,n.call(this,new bi(u,this,x.originalEvent)))},mouseout:x=>{a&&(a=!1,n.call(this,new bi(u,this,x.originalEvent)))}}}}{const a=c=>{const d=this.getLayer(t)?this.queryRenderedFeatures(c.point,{layers:[t]}):[];d.length&&(c.features=d,n.call(this,c),delete c.features)};return{layer:t,listener:n,delegates:{[u]:a}}}}on(u,t,n){if(n===void 0)return super.on(u,t);const a=this._createDelegatedListener(u,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[u]=this._delegatedListeners[u]||[],this._delegatedListeners[u].push(a);for(const c in a.delegates)this.on(c,a.delegates[c]);return this}once(u,t,n){if(n===void 0)return super.once(u,t);const a=this._createDelegatedListener(u,t,n);for(const c in a.delegates)this.once(c,a.delegates[c]);return this}off(u,t,n){return n===void 0?super.off(u,t):(this._delegatedListeners&&this._delegatedListeners[u]&&(a=>{const c=this._delegatedListeners[u];for(let d=0;dthis._updateStyle(u,t));const n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!u)),u?(this.style=new Er(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof u=="string"?this.style.loadURL(u,t,n):this.style.loadJSON(u,t,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Er(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(u,t){if(typeof u=="string"){const n=this._requestManager.transformRequest(u,Ve.Style);s.f(n,(a,c)=>{a?this.fire(new s.j(a)):c&&this._updateDiff(c,t)})}else typeof u=="object"&&this._updateDiff(u,t)}_updateDiff(u,t){try{this.style.setState(u,t)&&this._update(!0)}catch(n){s.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(u,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():s.w("There is no style added to the map.")}addSource(u,t){return this._lazyInitEmptyStyle(),this.style.addSource(u,t),this._update(!0)}isSourceLoaded(u){const t=this.style&&this.style.sourceCaches[u];if(t!==void 0)return t.loaded();this.fire(new s.j(new Error(`There is no source with ID '${u}'`)))}setTerrain(u){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),u){const t=this.style.sourceCaches[u.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${u.source}`);for(const n in this.style._layers){const a=this.style._layers[n];a.type==="hillshade"&&a.source===u.source&&s.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Vc(this.painter,t,u),this.painter.renderToTexture=new ml(this.painter,this.terrain),this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==u.source||this._elevationFreeze||(this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform._minEleveationForCurrentTile=0,this.transform.elevation=0;return this.fire(new s.k("terrain",{terrain:u})),this}getTerrain(){var u,t;return(t=(u=this.terrain)===null||u===void 0?void 0:u.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const u=this.style&&this.style.sourceCaches;for(const t in u){const n=u[t]._tiles;for(const a in n){const c=n[a];if(c.state!=="loaded"&&c.state!=="errored")return!1}}return!0}addSourceType(u,t,n){return this._lazyInitEmptyStyle(),this.style.addSourceType(u,t,n)}removeSource(u){return this.style.removeSource(u),this._update(!0)}getSource(u){return this.style.getSource(u)}addImage(u,t,n={}){const{pixelRatio:a=1,sdf:c=!1,stretchX:d,stretchY:x,content:b}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||s.a(t))){if(t.width===void 0||t.height===void 0)return this.fire(new s.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:S,height:C,data:A}=t,P=t;return this.style.addImage(u,{data:new s.R({width:S,height:C},new Uint8Array(A)),pixelRatio:a,stretchX:d,stretchY:x,content:b,sdf:c,version:0,userImage:P}),P.onAdd&&P.onAdd(this,u),this}}{const{width:S,height:C,data:A}=s.h.getImageData(t);this.style.addImage(u,{data:new s.R({width:S,height:C},A),pixelRatio:a,stretchX:d,stretchY:x,content:b,sdf:c,version:0})}}updateImage(u,t){const n=this.style.getImage(u);if(!n)return this.fire(new s.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=t instanceof HTMLImageElement||s.a(t)?s.h.getImageData(t):t,{width:c,height:d,data:x}=a;if(c===void 0||d===void 0)return this.fire(new s.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(c!==n.data.width||d!==n.data.height)return this.fire(new s.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const b=!(t instanceof HTMLImageElement||s.a(t));return n.data.replace(x,b),this.style.updateImage(u,n),this}getImage(u){return this.style.getImage(u)}hasImage(u){return u?!!this.style.getImage(u):(this.fire(new s.j(new Error("Missing required image id"))),!1)}removeImage(u){this.style.removeImage(u)}loadImage(u,t){De.getImage(this._requestManager.transformRequest(u,Ve.Image),t)}listImages(){return this.style.listImages()}addLayer(u,t){return this._lazyInitEmptyStyle(),this.style.addLayer(u,t),this._update(!0)}moveLayer(u,t){return this.style.moveLayer(u,t),this._update(!0)}removeLayer(u){return this.style.removeLayer(u),this._update(!0)}getLayer(u){return this.style.getLayer(u)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(u,t,n){return this.style.setLayerZoomRange(u,t,n),this._update(!0)}setFilter(u,t,n={}){return this.style.setFilter(u,t,n),this._update(!0)}getFilter(u){return this.style.getFilter(u)}setPaintProperty(u,t,n,a={}){return this.style.setPaintProperty(u,t,n,a),this._update(!0)}getPaintProperty(u,t){return this.style.getPaintProperty(u,t)}setLayoutProperty(u,t,n,a={}){return this.style.setLayoutProperty(u,t,n,a),this._update(!0)}getLayoutProperty(u,t){return this.style.getLayoutProperty(u,t)}setGlyphs(u,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(u,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(u,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(u,t,n,a=>{a||this._update(!0)}),this}removeSprite(u){return this._lazyInitEmptyStyle(),this.style.removeSprite(u),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(u,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(u,t,n=>{n||this._update(!0)}),this}setLight(u,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(u,t),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(u,t){return this.style.setFeatureState(u,t),this._update()}removeFeatureState(u,t){return this.style.removeFeatureState(u,t),this._update()}getFeatureState(u){return this.style.getFeatureState(u)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let u=0,t=0;return this._container&&(u=this._container.clientWidth||400,t=this._container.clientHeight||300),[u,t]}_setupContainer(){const u=this._container;u.classList.add("maplibregl-map");const t=this._canvasContainer=V.create("div","maplibregl-canvas-container",u);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=V.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const c=this._controlContainer=V.create("div","maplibregl-control-container",u),d=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(x=>{d[x]=V.create("div",`maplibregl-ctrl-${x} `,c)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){this._cooperativeGesturesScreen=V.create("div","maplibregl-cooperative-gesture-screen",this._container);let u=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";navigator.platform.indexOf("Mac")===0&&(u=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use ⌘ + scroll to zoom the map"),this._cooperativeGesturesScreen.innerHTML=`
${u}
${typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.mobileHelpText?this._cooperativeGestures.mobileHelpText:"Use two fingers to move the map"}
- `,this._cooperativeGesturesScreen.setAttribute("aria-hidden","true"),this._canvasContainer.addEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.add("maplibregl-cooperative-gestures")}_destroyCooperativeGestures(){V.remove(this._cooperativeGesturesScreen),this._canvasContainer.removeEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.remove("maplibregl-cooperative-gestures")}_resizeCanvas(u,t,n){this._canvas.width=Math.floor(n*u),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${u}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const u={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let t=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{t={requestedAttributes:u},a&&(t.statusMessage=a.statusMessage,t.type=a.type)},{once:!0});const n=this._canvas.getContext("webgl2",u)||this._canvas.getContext("webgl",u);if(!n){const a="Failed to initialize WebGL";throw t?(t.message=a,new Error(JSON.stringify(t))):new Error(a)}this.painter=new zo(n,this.transform),me.testSupport(n)}_onCooperativeGesture(u,t,n){return!t&&n<2&&(this._cooperativeGesturesScreen.classList.add("maplibregl-show"),setTimeout(()=>{this._cooperativeGesturesScreen.classList.remove("maplibregl-show")},100)),!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(u){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||u,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(u){return this._update(),this._renderTaskQueue.add(u)}_cancelRenderFrame(u){this._renderTaskQueue.remove(u)}_render(u){const t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(u),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const c=this.transform.zoom,d=s.h.now();this.style.zoomHistory.update(c,d);const x=new s.a8(c,{now:d,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),b=x.crossFadingFactor();b===1&&b===this._crossFadingFactor||(n=!0,this._crossFadingFactor=b),this.style.update(x)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform._minEleveationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,t,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,showPadding:this.showPadding}),this.fire(new s.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,s.bg.mark(s.bh.load),this.fire(new s.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new s.k("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,s.bg.mark(s.bh.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){var u;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Ne.removeThrottleControl(this._imageQueueHandle),(u=this._resizeObserver)===null||u===void 0||u.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),V.remove(this._canvasContainer),V.remove(this._controlContainer),this._cooperativeGestures&&this._destroyCooperativeGestures(),this._container.classList.remove("maplibregl-map"),s.bg.clearMetrics(),this._removed=!0,this.fire(new s.k("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=s.h.frame(u=>{s.bg.frame(u),this._frame=null,this._render(u)}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(u){this._showTileBoundaries!==u&&(this._showTileBoundaries=u,this._update())}get showPadding(){return!!this._showPadding}set showPadding(u){this._showPadding!==u&&(this._showPadding=u,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(u){this._showCollisionBoxes!==u&&(this._showCollisionBoxes=u,u?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(u){this._showOverdrawInspector!==u&&(this._showOverdrawInspector=u,this._update())}get repaint(){return!!this._repaint}set repaint(u){this._repaint!==u&&(this._repaint=u,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(u){this._vertices=u,this._update()}get version(){return xt}getCameraTargetElevation(){return this.transform.elevation}},Si.NavigationControl=class{constructor(u){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),a=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t},this._setButtonTitle=(t,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);t.title=a,t.setAttribute("aria-label",a)},this.options=s.e({},ql,u),this._container=V.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),V.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),V.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=V.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(u){return this._map=u,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Zl(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){V.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(u,t){const n=V.create("button",u,this._container);return n.type="button",n.addEventListener("click",t),n}},Si.GeolocateControl=class extends s.E{constructor(u){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new s.k("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(t),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new s.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new s.L(t.coords.longitude,t.coords.latitude),a=t.coords.accuracy,c=this._map.getBearing(),d=s.e({bearing:c},this.options.fitBoundsOptions),x=Tt.fromLngLat(n,a);this._map.fitBounds(x,d,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new s.L(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&Ia)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new s.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=t=>{if(this._map){if(this._container.addEventListener("contextmenu",n=>n.preventDefault()),this._geolocateButton=V.create("button","maplibregl-ctrl-geolocate",this._container),V.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){s.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=V.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Fs({element:this._dotElement}),this._circleElement=V.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Fs({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",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new s.k("trackuserlocationend")))})}},this.options=s.e({},cr,u)}onAdd(u){return this._map=u,this._container=V.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(t,n=!1){br===void 0||n?window.navigator.permissions!==void 0?window.navigator.permissions.query({name:"geolocation"}).then(a=>{br=a.state!=="denied",t(br)}).catch(()=>{br=!!window.navigator.geolocation,t(br)}):(br=!!window.navigator.geolocation,t(br)):t(br)}(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),V.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,or=0,Ia=!1}_isOutOfMapMaxBounds(u){const t=this._map.getMaxBounds(),n=u.coords;return t&&(n.longitudet.getEast()||n.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const u=this._map.getBounds(),t=u.getSouthEast(),n=u.getNorthEast(),a=t.distanceTo(n),c=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${c}px`,this._circleElement.style.height=`${c}px`}trigger(){if(!this._setup)return s.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new s.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":or--,Ia=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new s.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new s.k("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let u;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),or++,or>1?(u={maximumAge:6e5,timeout:0},Ia=!0):(u=this.options.positionOptions,Ia=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,u)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},Si.AttributionControl=Hn,Si.LogoControl=Yi,Si.ScaleControl=class{constructor(u){this._onMove=()=>{Ja(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Ja(this._map,this._container,this.options)},this.options=s.e({},Ka,u)}getDefaultPosition(){return"bottom-left"}onAdd(u){return this._map=u,this._container=V.create("div","maplibregl-ctrl maplibregl-ctrl-scale",u.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){V.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},Si.FullscreenControl=class extends s.E{constructor(u={}){super(),this._onFullscreenChange=()=>{(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,u&&u.container&&(u.container instanceof HTMLElement?this._container=u.container:s.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(u){return this._map=u,this._container||(this._container=this._map.getContainer()),this._controlContainer=V.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){V.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const u=this._fullscreenButton=V.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);V.create("span","maplibregl-ctrl-icon",u).setAttribute("aria-hidden","true"),u.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const u=this._getTitle();this._fullscreenButton.setAttribute("aria-label",u),this._fullscreenButton.title=u}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new s.k("fullscreenstart")),this._map._cooperativeGestures&&(this._prevCooperativeGestures=this._map._cooperativeGestures,this._map.setCooperativeGestures())):(this.fire(new s.k("fullscreenend")),this._prevCooperativeGestures&&(this._map.setCooperativeGestures(this._prevCooperativeGestures),delete this._prevCooperativeGestures))}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},Si.TerrainControl=class{constructor(u){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))},this.options=u}onAdd(u){return this._map=u,this._container=V.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=V.create("button","maplibregl-ctrl-terrain",this._container),V.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){V.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},Si.Popup=class extends s.E{constructor(u){super(),this.remove=()=>(this._content&&V.remove(this._content),this._container&&(V.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new s.k("close")),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=V.create("div","maplibregl-popup",this._map.getContainer()),this._tip=V.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const x of this.options.className.split(" "))this._container.classList.add(x);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Gl(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!t)return;const n=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);let a=this.options.anchor;const c=Ea(this.options.offset);if(!a){const x=this._container.offsetWidth,b=this._container.offsetHeight;let S;S=n.y+c.bottom.ythis._map.transform.height-b?["bottom"]:[],n.xthis._map.transform.width-x/2&&S.push("right"),a=S.length===0?"bottom":S.join("-")}const d=n.add(c[a]).round();V.setTransform(this._container,`${so[a]} translate(${d.x}px,${d.y}px)`),Uc(this._container,a,"popup")},this._onClose=()=>{this.remove()},this.options=s.e(Object.create(Wl),u)}addTo(u){return this._map&&this.remove(),this._map=u,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new s.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(u){return this._lngLat=s.L.convert(u),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(u){return this.setDOMContent(document.createTextNode(u))}setHTML(u){const t=document.createDocumentFragment(),n=document.createElement("body");let a;for(n.innerHTML=u;a=n.firstChild,a;)t.appendChild(a);return this.setDOMContent(t)}getMaxWidth(){var u;return(u=this._container)===null||u===void 0?void 0:u.style.maxWidth}setMaxWidth(u){return this.options.maxWidth=u,this._update(),this}setDOMContent(u){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=V.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(u),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(u){this._container&&this._container.classList.add(u)}removeClassName(u){this._container&&this._container.classList.remove(u)}setOffset(u){return this.options.offset=u,this._update(),this}toggleClassName(u){if(this._container)return this._container.classList.toggle(u)}_createCloseButton(){this.options.closeButton&&(this._closeButton=V.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const u=this._container.querySelector(Hl);u&&u.focus()}},Si.Marker=Fs,Si.Style=Er,Si.LngLat=s.L,Si.LngLatBounds=Tt,Si.Point=s.P,Si.MercatorCoordinate=s.U,Si.Evented=s.E,Si.AJAXError=s.bi,Si.config=s.c,Si.CanvasSource=gr,Si.GeoJSONSource=He,Si.ImageSource=ct,Si.RasterDEMTileSource=Pt,Si.RasterTileSource=Fe,Si.VectorTileSource=Oi,Si.VideoSource=Zi,Si.setRTLTextPlugin=s.bj,Si.getRTLTextPluginStatus=s.bk,Si.prewarm=function(){qo().acquire(ii)},Si.clearPrewarmedResources=function(){const u=Un;u&&(u.isPreloaded()&&u.numActive()===1?(u.release(ii),Un=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()"))},Xl.extend(Si,{isSafari:s.ac,getPerformanceMetrics:s.bg.getPerformanceMetrics}),Si});var B=E;return B})})(Qp);var V_=Qp.exports;const is=Yp(V_);function vp(m){let f;return _=>{if(_)for(let v in _){let E=f==null?void 0:f[v],k=_[v];E!==k&&m(v,k,E)}else if(f)for(let v in f)m(v,void 0,f[v]);f=_}}function U_(m,...f){let _=[m];for(let v of f)if(v)Array.isArray(v)&&v[0]===m?_.push(...v.slice(1)):_.push(v);else continue;if(_.length!==1)return _.length===2?_[1]:_}function j_(m){return m===!0?["has","point_count"]:m===!1?["!",["has","point_count"]]:void 0}function q_(m,f){return["case",["boolean",["feature-state","hover"],!1],f,m]}var yu=Z_;function Z_(m){var f,_,v;if(m){if(Array.isArray(m)){for(f=[],_=m.length,v=0;v<_;v++){var E=m[v];E!=null&&f.push(E)}return f}if(typeof m=="object"){f={};var k=Object.keys(m);for(_=k.length,v=0;v<_;v++){var B=k[v],s=m[B];s!=null&&(f[B]=s)}return f}}}function xp(m){let f=m[0],_,v,E=bp(m);return{c(){E.c(),_=Oa()},m(k,B){E.m(k,B),ci(k,_,B),v=!0},p(k,B){B[0]&1&&Tr(f,f=k[0])?(rs(),St(E,1,1,Ar),ns(),E=bp(k),E.c(),ft(E,1),E.m(_.parentNode,_)):E.p(k,B)},i(k){v||(ft(E),v=!0)},o(k){St(E),v=!1},d(k){k&&si(_),E.d(k)}}}function bp(m){let f;const _=m[37].default,v=Js(_,m,m[36],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k[1]&32)&&Qs(v,_,E,E[36],f?Ys(_,E[36],k,null):$s(E[36]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function G_(m){let f,_,v=m[0]&&xp(m);return{c(){v&&v.c(),f=Oa()},m(E,k){v&&v.m(E,k),ci(E,f,k),_=!0},p(E,k){E[0]?v?(v.p(E,k),k[0]&1&&ft(v,1)):(v=xp(E),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(E)}}}function W_(m,f,_){let v,E,k,B,s,H,V,me,be,ge,De,Ee,{$$slots:Le={},$$scope:Ne}=f,{id:et=Fc("layer")}=f,{source:at=void 0}=f,{sourceLayer:nt=void 0}=f,{beforeId:it=void 0}=f,{beforeLayerType:Vt=void 0}=f,{type:ti}=f,{paint:Xt=void 0}=f,{layout:Nt=void 0}=f,{filter:Yt=void 0}=f,{applyToClusters:At=void 0}=f,{minzoom:ke=void 0}=f,{maxzoom:Ge=void 0}=f,{manageHoverState:Ui=!1}=f,{hovered:Dt=null}=f,{interactive:qt=!0}=f,{hoverCursor:Lt=void 0}=f,{eventsIfTopMost:pi=!1}=f;const Pi=Ih(),{map:en,source:Vr,self:zi,minzoom:Ti,maxzoom:Tt,eventTopMost:fi,layerInfo:Oi}=B_();$r(m,en,He=>_(32,be=He)),$r(m,Vr,He=>_(33,ge=He)),$r(m,zi,He=>_(0,me=He)),$r(m,Ti,He=>_(35,Ee=He)),$r(m,Tt,He=>_(34,De=He)),Ba(()=>{me&&be&&(Oi.delete(me),be==null||be.removeLayer(me))});let Fe,Pt=!0;return m.$$set=He=>{"id"in He&&_(7,et=He.id),"source"in He&&_(8,at=He.source),"sourceLayer"in He&&_(9,nt=He.sourceLayer),"beforeId"in He&&_(10,it=He.beforeId),"beforeLayerType"in He&&_(11,Vt=He.beforeLayerType),"type"in He&&_(12,ti=He.type),"paint"in He&&_(13,Xt=He.paint),"layout"in He&&_(14,Nt=He.layout),"filter"in He&&_(15,Yt=He.filter),"applyToClusters"in He&&_(16,At=He.applyToClusters),"minzoom"in He&&_(17,ke=He.minzoom),"maxzoom"in He&&_(18,Ge=He.maxzoom),"manageHoverState"in He&&_(19,Ui=He.manageHoverState),"hovered"in He&&_(6,Dt=He.hovered),"interactive"in He&&_(20,qt=He.interactive),"hoverCursor"in He&&_(21,Lt=He.hoverCursor),"eventsIfTopMost"in He&&_(22,pi=He.eventsIfTopMost),"$$scope"in He&&_(36,Ne=He.$$scope)},m.$$.update=()=>{if(m.$$.dirty[0]&65536&&_(31,v=j_(At)),m.$$.dirty[0]&32768|m.$$.dirty[1]&1&&_(25,E=U_("all",v,Yt)),m.$$.dirty[0]&131072|m.$$.dirty[1]&16&&_(27,k=ke??Ee),m.$$.dirty[0]&262144|m.$$.dirty[1]&8&&_(26,B=Ge??De),m.$$.dirty[0]&256|m.$$.dirty[1]&4&&_(30,s=at||ge),m.$$.dirty[0]&1324908161|m.$$.dirty[1]&2&&be&&me!==et&&s){let He=function(ct){var Bi,yr;if(!qt||!me||!be||pi&&fi(ct)!==me)return;let Zi=ct.features??[],gr=(yr=(Bi=Zi[0])==null?void 0:Bi.properties)==null?void 0:yr.cluster_id,Ue={event:ct,map:be,clusterId:gr,layer:me,source:s,features:Zi};Pi(ct.type,Ue)};me&&Oi.delete(me);let Gt=it;if(!it&&Vt){let ct=be.getStyle().layers,Zi=typeof Vt=="function"?Vt:Ue=>Ue.type===Vt,gr=ct==null?void 0:ct.find(Zi);gr&&(Gt=gr.id)}nl(zi,me=et,me),be.addLayer(yu({id:me,type:ti,source:s,"source-layer":nt,filter:E,paint:Xt,layout:Nt,minzoom:k,maxzoom:B}),Gt),_(24,Pt=!0),be.on("click",me,He),be.on("dblclick",me,He),be.on("contextmenu",me,He),be.on("mouseenter",me,ct=>{var Bi,yr;if(!qt||!me||!be||pi&&fi(ct)!==me)return;Lt&&(be.getCanvas().style.cursor=Lt);let Zi=ct.features??[];_(6,Dt=Zi[0]??null);let gr=(yr=(Bi=Zi[0])==null?void 0:Bi.properties)==null?void 0:yr.cluster_id;Pi("mouseenter",{event:ct,map:be,clusterId:gr,layer:me,source:s,features:Zi})}),be.on("mousemove",me,ct=>{var Bi,yr,hi;if(!qt)return;if(pi&&fi(ct)!==me){_(6,Dt=null),Ui&&Fe!==void 0&&(be==null||be.setFeatureState({source:s,sourceLayer:nt,id:Fe},{hover:!1}),_(23,Fe=void 0));return}be.getCanvas().style.cursor=Lt;let Zi=ct.features??[],gr=(yr=(Bi=Zi[0])==null?void 0:Bi.properties)==null?void 0:yr.cluster_id,Ue=(hi=Zi[0])==null?void 0:hi.id;Ue!==Fe&&(Ui&&(Fe!==void 0&&(be==null||be.setFeatureState({source:s,id:Fe,sourceLayer:nt},{hover:!1})),be==null||be.setFeatureState({source:s,id:Ue,sourceLayer:nt},{hover:!0})),_(23,Fe=Ue),_(6,Dt=Zi[0]??null)),Pi("mousemove",{event:ct,map:be,clusterId:gr,layer:me,source:s,features:Zi})}),be.on("mouseleave",me,ct=>{if(!(!qt||!me||!be)){if(Lt&&(be.getCanvas().style.cursor=""),_(6,Dt=null),Ui&&Fe!==void 0){const Zi={source:s,id:Fe,sourceLayer:nt};be==null||be.setFeatureState(Zi,{hover:!1}),_(23,Fe=void 0)}Pi("mouseleave",{map:be,layer:me,source:s})}})}m.$$.dirty[0]&1048577&&me&&Oi.set(me,{interactive:qt}),m.$$.dirty[0]&1|m.$$.dirty[1]&2&&_(29,H=me?vp((He,Gt)=>be==null?void 0:be.setPaintProperty(me,He,Gt)):void 0),m.$$.dirty[0]&1|m.$$.dirty[1]&2&&_(28,V=me?vp((He,Gt)=>be==null?void 0:be.setLayoutProperty(me,He,Gt)):void 0),m.$$.dirty[0]&536879104&&(H==null||H(Xt)),m.$$.dirty[0]&268451840&&(V==null||V(Nt)),m.$$.dirty[0]&201326593|m.$$.dirty[1]&2&&me&&(be==null||be.setLayerZoomRange(me,k,B)),m.$$.dirty[0]&50331649|m.$$.dirty[1]&2&&me&&(Pt?_(24,Pt=!1):be==null||be.setFilter(me,E))},[me,en,Vr,zi,Ti,Tt,Dt,et,at,nt,it,Vt,ti,Xt,Nt,Yt,At,ke,Ge,Ui,qt,Lt,pi,Fe,Pt,E,B,k,V,H,s,v,be,ge,De,Ee,Ne,Le]}class Ch extends Wr{constructor(f){super(),Gr(this,f,W_,G_,Tr,{id:7,source:8,sourceLayer:9,beforeId:10,beforeLayerType:11,type:12,paint:13,layout:14,filter:15,applyToClusters:16,minzoom:17,maxzoom:18,manageHoverState:19,hovered:6,interactive:20,hoverCursor:21,eventsIfTopMost:22},null,[-1,-1])}}function H_(m){let f;const _=m[16].default,v=Js(_,m,m[24],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k&16777216)&&Qs(v,_,E,E[24],f?Ys(_,E[24],k,null):$s(E[24]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function X_(m){let f,_,v;function E(B){m[17](B)}let k={id:m[1],type:"circle",source:m[2],sourceLayer:m[3],beforeId:m[4],beforeLayerType:m[5],paint:m[6],layout:m[7],filter:m[8],applyToClusters:m[9],minzoom:m[10],maxzoom:m[11],hoverCursor:m[12],manageHoverState:m[13],eventsIfTopMost:m[14],interactive:m[15],$$slots:{default:[H_]},$$scope:{ctx:m}};return m[0]!==void 0&&(k.hovered=m[0]),f=new Ch({props:k}),ea.push(()=>Dc(f,"hovered",E)),f.$on("click",m[18]),f.$on("dblclick",m[19]),f.$on("contextmenu",m[20]),f.$on("mouseenter",m[21]),f.$on("mousemove",m[22]),f.$on("mouseleave",m[23]),{c(){Ri(f.$$.fragment)},m(B,s){Ai(f,B,s),v=!0},p(B,[s]){const H={};s&2&&(H.id=B[1]),s&4&&(H.source=B[2]),s&8&&(H.sourceLayer=B[3]),s&16&&(H.beforeId=B[4]),s&32&&(H.beforeLayerType=B[5]),s&64&&(H.paint=B[6]),s&128&&(H.layout=B[7]),s&256&&(H.filter=B[8]),s&512&&(H.applyToClusters=B[9]),s&1024&&(H.minzoom=B[10]),s&2048&&(H.maxzoom=B[11]),s&4096&&(H.hoverCursor=B[12]),s&8192&&(H.manageHoverState=B[13]),s&16384&&(H.eventsIfTopMost=B[14]),s&32768&&(H.interactive=B[15]),s&16777216&&(H.$$scope={dirty:s,ctx:B}),!_&&s&1&&(_=!0,H.hovered=B[0],Lc(()=>_=!1)),f.$set(H)},i(B){v||(ft(f.$$.fragment,B),v=!0)},o(B){St(f.$$.fragment,B),v=!1},d(B){ki(f,B)}}}function K_(m,f,_){let{$$slots:v={},$$scope:E}=f,{id:k=Fc("circle")}=f,{source:B=void 0}=f,{sourceLayer:s=void 0}=f,{beforeId:H=void 0}=f,{beforeLayerType:V=void 0}=f,{paint:me}=f,{layout:be=void 0}=f,{filter:ge=void 0}=f,{applyToClusters:De=void 0}=f,{minzoom:Ee=void 0}=f,{maxzoom:Le=void 0}=f,{hoverCursor:Ne=void 0}=f,{manageHoverState:et=!1}=f,{hovered:at=null}=f,{eventsIfTopMost:nt=!1}=f,{interactive:it=!0}=f;function Vt(Ge){at=Ge,_(0,at)}function ti(Ge){pn.call(this,m,Ge)}function Xt(Ge){pn.call(this,m,Ge)}function Nt(Ge){pn.call(this,m,Ge)}function Yt(Ge){pn.call(this,m,Ge)}function At(Ge){pn.call(this,m,Ge)}function ke(Ge){pn.call(this,m,Ge)}return m.$$set=Ge=>{"id"in Ge&&_(1,k=Ge.id),"source"in Ge&&_(2,B=Ge.source),"sourceLayer"in Ge&&_(3,s=Ge.sourceLayer),"beforeId"in Ge&&_(4,H=Ge.beforeId),"beforeLayerType"in Ge&&_(5,V=Ge.beforeLayerType),"paint"in Ge&&_(6,me=Ge.paint),"layout"in Ge&&_(7,be=Ge.layout),"filter"in Ge&&_(8,ge=Ge.filter),"applyToClusters"in Ge&&_(9,De=Ge.applyToClusters),"minzoom"in Ge&&_(10,Ee=Ge.minzoom),"maxzoom"in Ge&&_(11,Le=Ge.maxzoom),"hoverCursor"in Ge&&_(12,Ne=Ge.hoverCursor),"manageHoverState"in Ge&&_(13,et=Ge.manageHoverState),"hovered"in Ge&&_(0,at=Ge.hovered),"eventsIfTopMost"in Ge&&_(14,nt=Ge.eventsIfTopMost),"interactive"in Ge&&_(15,it=Ge.interactive),"$$scope"in Ge&&_(24,E=Ge.$$scope)},[at,k,B,s,H,V,me,be,ge,De,Ee,Le,Ne,et,nt,it,v,Vt,ti,Xt,Nt,Yt,At,ke,E]}class ef extends Wr{constructor(f){super(),Gr(this,f,K_,X_,Tr,{id:1,source:2,sourceLayer:3,beforeId:4,beforeLayerType:5,paint:6,layout:7,filter:8,applyToClusters:9,minzoom:10,maxzoom:11,hoverCursor:12,manageHoverState:13,hovered:0,eventsIfTopMost:14,interactive:15})}}function J_(m){let f;const _=m[15].default,v=Js(_,m,m[23],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k&8388608)&&Qs(v,_,E,E[23],f?Ys(_,E[23],k,null):$s(E[23]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function Y_(m){let f,_,v;function E(B){m[16](B)}let k={id:m[1],type:"fill",source:m[2],sourceLayer:m[3],beforeId:m[4],beforeLayerType:m[5],paint:m[6],layout:m[7],filter:m[8],minzoom:m[9],maxzoom:m[10],hoverCursor:m[11],manageHoverState:m[12],eventsIfTopMost:m[13],interactive:m[14],$$slots:{default:[J_]},$$scope:{ctx:m}};return m[0]!==void 0&&(k.hovered=m[0]),f=new Ch({props:k}),ea.push(()=>Dc(f,"hovered",E)),f.$on("click",m[17]),f.$on("dblclick",m[18]),f.$on("contextmenu",m[19]),f.$on("mouseenter",m[20]),f.$on("mousemove",m[21]),f.$on("mouseleave",m[22]),{c(){Ri(f.$$.fragment)},m(B,s){Ai(f,B,s),v=!0},p(B,[s]){const H={};s&2&&(H.id=B[1]),s&4&&(H.source=B[2]),s&8&&(H.sourceLayer=B[3]),s&16&&(H.beforeId=B[4]),s&32&&(H.beforeLayerType=B[5]),s&64&&(H.paint=B[6]),s&128&&(H.layout=B[7]),s&256&&(H.filter=B[8]),s&512&&(H.minzoom=B[9]),s&1024&&(H.maxzoom=B[10]),s&2048&&(H.hoverCursor=B[11]),s&4096&&(H.manageHoverState=B[12]),s&8192&&(H.eventsIfTopMost=B[13]),s&16384&&(H.interactive=B[14]),s&8388608&&(H.$$scope={dirty:s,ctx:B}),!_&&s&1&&(_=!0,H.hovered=B[0],Lc(()=>_=!1)),f.$set(H)},i(B){v||(ft(f.$$.fragment,B),v=!0)},o(B){St(f.$$.fragment,B),v=!1},d(B){ki(f,B)}}}function Q_(m,f,_){let{$$slots:v={},$$scope:E}=f,{id:k=Fc("fill")}=f,{source:B=void 0}=f,{sourceLayer:s=void 0}=f,{beforeId:H=void 0}=f,{beforeLayerType:V=void 0}=f,{paint:me}=f,{layout:be=void 0}=f,{filter:ge=void 0}=f,{minzoom:De=void 0}=f,{maxzoom:Ee=void 0}=f,{hoverCursor:Le=void 0}=f,{manageHoverState:Ne=!1}=f,{hovered:et=null}=f,{eventsIfTopMost:at=!1}=f,{interactive:nt=!0}=f;function it(ke){et=ke,_(0,et)}function Vt(ke){pn.call(this,m,ke)}function ti(ke){pn.call(this,m,ke)}function Xt(ke){pn.call(this,m,ke)}function Nt(ke){pn.call(this,m,ke)}function Yt(ke){pn.call(this,m,ke)}function At(ke){pn.call(this,m,ke)}return m.$$set=ke=>{"id"in ke&&_(1,k=ke.id),"source"in ke&&_(2,B=ke.source),"sourceLayer"in ke&&_(3,s=ke.sourceLayer),"beforeId"in ke&&_(4,H=ke.beforeId),"beforeLayerType"in ke&&_(5,V=ke.beforeLayerType),"paint"in ke&&_(6,me=ke.paint),"layout"in ke&&_(7,be=ke.layout),"filter"in ke&&_(8,ge=ke.filter),"minzoom"in ke&&_(9,De=ke.minzoom),"maxzoom"in ke&&_(10,Ee=ke.maxzoom),"hoverCursor"in ke&&_(11,Le=ke.hoverCursor),"manageHoverState"in ke&&_(12,Ne=ke.manageHoverState),"hovered"in ke&&_(0,et=ke.hovered),"eventsIfTopMost"in ke&&_(13,at=ke.eventsIfTopMost),"interactive"in ke&&_(14,nt=ke.interactive),"$$scope"in ke&&_(23,E=ke.$$scope)},[et,k,B,s,H,V,me,be,ge,De,Ee,Le,Ne,at,nt,v,it,Vt,ti,Xt,Nt,Yt,At,E]}class tf extends Wr{constructor(f){super(),Gr(this,f,Q_,Y_,Tr,{id:1,source:2,sourceLayer:3,beforeId:4,beforeLayerType:5,paint:6,layout:7,filter:8,minzoom:9,maxzoom:10,hoverCursor:11,manageHoverState:12,hovered:0,eventsIfTopMost:13,interactive:14})}}function $_(m,f,_){let v;const{map:E}=Ll();$r(m,E,H=>_(4,v=H));let{position:k="top-left"}=f,{container:B=void 0}=f,s=null;return Ba(()=>{v!=null&&v.loaded()&&s&&v.removeControl(s)}),m.$$set=H=>{"position"in H&&_(1,k=H.position),"container"in H&&_(2,B=H.container)},m.$$.update=()=>{if(m.$$.dirty&30&&v&&!s){let H;typeof B=="string"?H=document.querySelector(B)??void 0:H=B,_(3,s=new is.FullscreenControl({container:H})),v.addControl(s,k)}},[E,k,B,s,v]}class eg extends Wr{constructor(f){super(),Gr(this,f,$_,null,Tr,{position:1,container:2})}}function tg(m,f,_,v,E){let k=!1;m.getSource(f)&&(k=!0,m.removeSource(f));const B=()=>{v(f)&&(m.addSource(f,_),E())};if(k){const s=()=>{f&&(m.getSource(f)?setTimeout(s,1):B())};s()}else B()}function ig(m,f,_){v_().then(()=>{let v=h_(m);if(!v)return;v.getSource(f)===_&&v.removeSource(f)})}function wp(m){let f=m[0],_,v,E=Sp(m);return{c(){E.c(),_=Oa()},m(k,B){E.m(k,B),ci(k,_,B),v=!0},p(k,B){B&1&&Tr(f,f=k[0])?(rs(),St(E,1,1,Ar),ns(),E=Sp(k),E.c(),ft(E,1),E.m(_.parentNode,_)):E.p(k,B)},i(k){v||(ft(E),v=!0)},o(k){St(E),v=!1},d(k){k&&si(_),E.d(k)}}}function Sp(m){let f;const _=m[15].default,v=Js(_,m,m[14],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k&16384)&&Qs(v,_,E,E[14],f?Ys(_,E[14],k,null):$s(E[14]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function rg(m){let f,_,v=m[0]&&wp(m);return{c(){v&&v.c(),f=Oa()},m(E,k){v&&v.m(E,k),ci(E,f,k),_=!0},p(E,[k]){E[0]?v?(v.p(E,k),k&1&&ft(v,1)):(v=wp(E),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(E)}}}function ng(m,f,_){let v,E,k,{$$slots:B={},$$scope:s}=f,{id:H=Fc("geojson")}=f,{data:V}=f,{generateId:me=!1}=f,{promoteId:be=void 0}=f,{filter:ge=void 0}=f,{lineMetrics:De=void 0}=f,{cluster:Ee=void 0}=f;const{map:Le,cluster:Ne,self:et}=O_();$r(m,Le,it=>_(13,E=it)),$r(m,Ne,it=>_(16,k=it)),$r(m,et,it=>_(0,v=it));let at,nt=!0;return Ba(()=>{v&&at&&E&&(ig(Le,v,at),nl(et,v=null,v),_(11,at=void 0))}),m.$$set=it=>{"id"in it&&_(4,H=it.id),"data"in it&&_(5,V=it.data),"generateId"in it&&_(6,me=it.generateId),"promoteId"in it&&_(7,be=it.promoteId),"filter"in it&&_(8,ge=it.filter),"lineMetrics"in it&&_(9,De=it.lineMetrics),"cluster"in it&&_(10,Ee=it.cluster),"$$scope"in it&&_(14,s=it.$$scope)},m.$$.update=()=>{m.$$.dirty&1024&&nl(Ne,k=Ee,k),m.$$.dirty&12273&&E&&v!==H&&(nl(et,v=H,v),tg(E,v,yu({type:"geojson",data:V,filter:ge,lineMetrics:De,generateId:me,promoteId:be,cluster:!!Ee,clusterMinPoints:Ee==null?void 0:Ee.minPoints,clusterMaxZoom:Ee==null?void 0:Ee.maxZoom,clusterRadius:Ee==null?void 0:Ee.radius,clusterProperties:Ee==null?void 0:Ee.properties}),it=>E&&it===v,()=>{v&&(_(11,at=E==null?void 0:E.getSource(v)),_(12,nt=!0))})),m.$$.dirty&8208&&(E==null||E.on("style.load",()=>{_(11,at=E==null?void 0:E.getSource(H))})),m.$$.dirty&6176&&at&&(nt?_(12,nt=!1):at.setData(V)),m.$$.dirty&3072&&(at==null||at.setClusterOptions(yu({cluster:!!Ee,clusterMaxZoom:Ee==null?void 0:Ee.maxZoom,clusterRadius:Ee==null?void 0:Ee.radius})))},[v,Le,Ne,et,H,V,me,be,ge,De,Ee,at,nt,E,s,B]}class Mh extends Wr{constructor(f){super(),Gr(this,f,ng,rg,Tr,{id:4,data:5,generateId:6,promoteId:7,filter:8,lineMetrics:9,cluster:10})}}function og(m,f,_){let v;const{map:E}=Ll();$r(m,E,ge=>_(8,v=ge));let{position:k="top-left"}=f,{positionOptions:B=void 0}=f,{fitBoundsOptions:s=void 0}=f,{trackUserLocation:H=!1}=f,{showAccuracyCircle:V=!0}=f,{showUserLocation:me=!0}=f,be=null;return Ba(()=>{v!=null&&v.loaded()&&be&&v.removeControl(be)}),m.$$set=ge=>{"position"in ge&&_(1,k=ge.position),"positionOptions"in ge&&_(2,B=ge.positionOptions),"fitBoundsOptions"in ge&&_(3,s=ge.fitBoundsOptions),"trackUserLocation"in ge&&_(4,H=ge.trackUserLocation),"showAccuracyCircle"in ge&&_(5,V=ge.showAccuracyCircle),"showUserLocation"in ge&&_(6,me=ge.showUserLocation)},m.$$.update=()=>{m.$$.dirty&510&&v&&!be&&(_(7,be=new is.GeolocateControl({positionOptions:B,fitBoundsOptions:s,trackUserLocation:H,showAccuracyCircle:V,showUserLocation:me})),v.addControl(be,k))},[E,k,B,s,H,V,me,be,v]}class sg extends Wr{constructor(f){super(),Gr(this,f,og,null,Tr,{position:1,positionOptions:2,fitBoundsOptions:3,trackUserLocation:4,showAccuracyCircle:5,showUserLocation:6})}}function ag(m){let f;const _=m[15].default,v=Js(_,m,m[23],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k&8388608)&&Qs(v,_,E,E[23],f?Ys(_,E[23],k,null):$s(E[23]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function lg(m){let f,_,v;function E(B){m[16](B)}let k={id:m[1],type:"line",source:m[2],sourceLayer:m[3],beforeId:m[4],beforeLayerType:m[5],paint:m[6],layout:m[7],filter:m[8],minzoom:m[9],maxzoom:m[10],hoverCursor:m[11],manageHoverState:m[12],eventsIfTopMost:m[13],interactive:m[14],$$slots:{default:[ag]},$$scope:{ctx:m}};return m[0]!==void 0&&(k.hovered=m[0]),f=new Ch({props:k}),ea.push(()=>Dc(f,"hovered",E)),f.$on("click",m[17]),f.$on("dblclick",m[18]),f.$on("contextmenu",m[19]),f.$on("mouseenter",m[20]),f.$on("mousemove",m[21]),f.$on("mouseleave",m[22]),{c(){Ri(f.$$.fragment)},m(B,s){Ai(f,B,s),v=!0},p(B,[s]){const H={};s&2&&(H.id=B[1]),s&4&&(H.source=B[2]),s&8&&(H.sourceLayer=B[3]),s&16&&(H.beforeId=B[4]),s&32&&(H.beforeLayerType=B[5]),s&64&&(H.paint=B[6]),s&128&&(H.layout=B[7]),s&256&&(H.filter=B[8]),s&512&&(H.minzoom=B[9]),s&1024&&(H.maxzoom=B[10]),s&2048&&(H.hoverCursor=B[11]),s&4096&&(H.manageHoverState=B[12]),s&8192&&(H.eventsIfTopMost=B[13]),s&16384&&(H.interactive=B[14]),s&8388608&&(H.$$scope={dirty:s,ctx:B}),!_&&s&1&&(_=!0,H.hovered=B[0],Lc(()=>_=!1)),f.$set(H)},i(B){v||(ft(f.$$.fragment,B),v=!0)},o(B){St(f.$$.fragment,B),v=!1},d(B){ki(f,B)}}}function cg(m,f,_){let{$$slots:v={},$$scope:E}=f,{id:k=Fc("line")}=f,{source:B=void 0}=f,{sourceLayer:s=void 0}=f,{beforeId:H=void 0}=f,{beforeLayerType:V=void 0}=f,{paint:me}=f,{layout:be=void 0}=f,{filter:ge=void 0}=f,{minzoom:De=void 0}=f,{maxzoom:Ee=void 0}=f,{hoverCursor:Le=void 0}=f,{manageHoverState:Ne=!1}=f,{hovered:et=null}=f,{eventsIfTopMost:at=!1}=f,{interactive:nt=!0}=f;function it(ke){et=ke,_(0,et)}function Vt(ke){pn.call(this,m,ke)}function ti(ke){pn.call(this,m,ke)}function Xt(ke){pn.call(this,m,ke)}function Nt(ke){pn.call(this,m,ke)}function Yt(ke){pn.call(this,m,ke)}function At(ke){pn.call(this,m,ke)}return m.$$set=ke=>{"id"in ke&&_(1,k=ke.id),"source"in ke&&_(2,B=ke.source),"sourceLayer"in ke&&_(3,s=ke.sourceLayer),"beforeId"in ke&&_(4,H=ke.beforeId),"beforeLayerType"in ke&&_(5,V=ke.beforeLayerType),"paint"in ke&&_(6,me=ke.paint),"layout"in ke&&_(7,be=ke.layout),"filter"in ke&&_(8,ge=ke.filter),"minzoom"in ke&&_(9,De=ke.minzoom),"maxzoom"in ke&&_(10,Ee=ke.maxzoom),"hoverCursor"in ke&&_(11,Le=ke.hoverCursor),"manageHoverState"in ke&&_(12,Ne=ke.manageHoverState),"hovered"in ke&&_(0,et=ke.hovered),"eventsIfTopMost"in ke&&_(13,at=ke.eventsIfTopMost),"interactive"in ke&&_(14,nt=ke.interactive),"$$scope"in ke&&_(23,E=ke.$$scope)},[et,k,B,s,H,V,me,be,ge,De,Ee,Le,Ne,at,nt,v,it,Vt,ti,Xt,Nt,Yt,At,E]}class Ah extends Wr{constructor(f){super(),Gr(this,f,cg,lg,Tr,{id:1,source:2,sourceLayer:3,beforeId:4,beforeLayerType:5,paint:6,layout:7,filter:8,minzoom:9,maxzoom:10,hoverCursor:11,manageHoverState:12,hovered:0,eventsIfTopMost:13,interactive:14})}}function ug(m){let f=m.getCenter(),_=Math.round(m.getZoom()*100)/100,v=Math.ceil((_*Math.LN2+Math.log(512/360/.5))/Math.LN10),E=Math.pow(10,v),k=Math.round(f.lat*E)/E,B=Math.round(f.lng*E)/E,s=`${_}/${k}/${B}`,H=m.getBearing(),V=m.getPitch();return(H||V)&&(s+=`/${Math.round(H*10)/10}`),V&&(s+=`/${Math.round(V)}`),`#${s}`}function hg(m){return m.replace("#","").split("/").map(parseFloat)}var hu=kh;function kh(m,f){return m===f||m!==m&&f!==f?!0:typeof m!=typeof f||{}.toString.call(m)!={}.toString.call(f)||m!==Object(m)||!m?!1:Array.isArray(m)?Tp(m,f):{}.toString.call(m)=="[object Set]"?Tp(Array.from(m),Array.from(f)):{}.toString.call(m)=="[object Object]"?pg(m,f):dg(m,f)}function dg(m,f){return m.toString()===f.toString()}function Tp(m,f){var _=m.length;if(_!=f.length)return!1;for(var v=0;v<_;v++)if(!kh(m[v],f[v]))return!1;return!0}function pg(m,f){var _=Object.keys(m),v=_.length;if(v!=Object.keys(f).length)return!1;for(var E=0;E_(6,v=me));let{position:k="top-left"}=f,{showCompass:B=!0}=f,{showZoom:s=!0}=f,{visualizePitch:H=!1}=f,V=null;return Ba(()=>{v!=null&&v.loaded()&&V&&v.removeControl(V)}),m.$$set=me=>{"position"in me&&_(1,k=me.position),"showCompass"in me&&_(2,B=me.showCompass),"showZoom"in me&&_(3,s=me.showZoom),"visualizePitch"in me&&_(4,H=me.visualizePitch)},m.$$.update=()=>{m.$$.dirty&126&&v&&!V&&(_(5,V=new is.NavigationControl({showCompass:B,showZoom:s,visualizePitch:H})),v.addControl(V,k))},[E,k,B,s,H,V,v]}class mg extends Wr{constructor(f){super(),Gr(this,f,fg,null,Tr,{position:1,showCompass:2,showZoom:3,visualizePitch:4})}}function _g(m,f,_){let v;const{map:E}=Ll();$r(m,E,V=>_(5,v=V));let{position:k="bottom-left"}=f,{maxWidth:B=void 0}=f,{unit:s="metric"}=f,H=null;return Ba(()=>{v!=null&&v.loaded()&&H&&v.removeControl(H)}),m.$$set=V=>{"position"in V&&_(1,k=V.position),"maxWidth"in V&&_(2,B=V.maxWidth),"unit"in V&&_(3,s=V.unit)},m.$$.update=()=>{m.$$.dirty&62&&v&&!H&&(_(4,H=new is.ScaleControl({maxWidth:B,unit:s})),v.addControl(H,k))},[E,k,B,s,H,v]}class gg extends Wr{constructor(f){super(),Gr(this,f,_g,null,Tr,{position:1,maxWidth:2,unit:3})}}const yg=m=>({map:m[0]&8,loadedImages:m[0]&16,allImagesLoaded:m[0]&32}),Ip=m=>({map:m[3],loadedImages:m[4],allImagesLoaded:m[5]});function Ep(m){let f,_,v=m[2]&&Cp(m);const E=m[33].default,k=Js(E,m,m[32],Ip);return{c(){v&&v.c(),f=fn(),k&&k.c()},m(B,s){v&&v.m(B,s),ci(B,f,s),k&&k.m(B,s),_=!0},p(B,s){B[2]?v?(v.p(B,s),s[0]&4&&ft(v,1)):(v=Cp(B),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns()),k&&k.p&&(!_||s[0]&56|s[1]&2)&&Qs(k,E,B,B[32],_?Ys(E,B[32],s,yg):$s(B[32]),Ip)},i(B){_||(ft(v),ft(k,B),_=!0)},o(B){St(v),St(k,B),_=!1},d(B){B&&si(f),v&&v.d(B),k&&k.d(B)}}}function Cp(m){let f,_,v,E,k,B,s,H;return f=new mg({props:{position:m[6]}}),v=new sg({props:{position:m[6],fitBoundsOptions:{maxZoom:12}}}),k=new eg({props:{position:m[6]}}),s=new gg({props:{position:m[6]}}),{c(){Ri(f.$$.fragment),_=fn(),Ri(v.$$.fragment),E=fn(),Ri(k.$$.fragment),B=fn(),Ri(s.$$.fragment)},m(V,me){Ai(f,V,me),ci(V,_,me),Ai(v,V,me),ci(V,E,me),Ai(k,V,me),ci(V,B,me),Ai(s,V,me),H=!0},p(V,me){const be={};me[0]&64&&(be.position=V[6]),f.$set(be);const ge={};me[0]&64&&(ge.position=V[6]),v.$set(ge);const De={};me[0]&64&&(De.position=V[6]),k.$set(De);const Ee={};me[0]&64&&(Ee.position=V[6]),s.$set(Ee)},i(V){H||(ft(f.$$.fragment,V),ft(v.$$.fragment,V),ft(k.$$.fragment,V),ft(s.$$.fragment,V),H=!0)},o(V){St(f.$$.fragment,V),St(v.$$.fragment,V),St(k.$$.fragment,V),St(s.$$.fragment,V),H=!1},d(V){V&&(si(_),si(E),si(B)),ki(f,V),ki(v,V),ki(k,V),ki(s,V)}}}function vg(m){let f,_,v,E,k,B=m[3]&&m[0]&&Ep(m);return{c(){f=Zt("div"),B&&B.c(),vs(f,"class",_=fp(m[1])+" svelte-p00lfq"),_p(f,"expand-map",!m[1])},m(s,H){ci(s,f,H),B&&B.m(f,null),v=!0,E||(k=p_(m[9].call(null,f)),E=!0)},p(s,H){s[3]&&s[0]?B?(B.p(s,H),H[0]&9&&ft(B,1)):(B=Ep(s),B.c(),ft(B,1),B.m(f,null)):B&&(rs(),St(B,1,1,()=>{B=null}),ns()),(!v||H[0]&2&&_!==(_=fp(s[1])+" svelte-p00lfq"))&&vs(f,"class",_),(!v||H[0]&2)&&_p(f,"expand-map",!s[1])},i(s){v||(ft(B),v=!0)},o(s){St(B),v=!1},d(s){s&&si(f),B&&B.d(),E=!1,k()}}}function xg(m,f,_){let v,E,k,B,{$$slots:s={},$$scope:H}=f,{map:V=null}=f,{class:me=void 0}=f,{style:be}=f,{diffStyleUpdates:ge=!1}=f,{center:De=void 0}=f,{zoom:Ee=void 0}=f,{pitch:Le=0}=f,{bearing:Ne=0}=f,{bounds:et=void 0}=f,{hash:at=!1}=f,{loaded:nt=!1}=f,{minZoom:it=0}=f,{maxZoom:Vt=22}=f,{zoomOnDoubleClick:ti=!0}=f,{interactive:Xt=!0}=f,{attributionControl:Nt=!0}=f,{preserveDrawingBuffer:Yt=!1}=f,{maxBounds:At=void 0}=f,{images:ke=[]}=f,{standardControls:Ge=!1}=f,{filterLayers:Ui=void 0}=f,{transformRequest:Dt=void 0}=f;const qt=Ih(),{map:Lt,loadedImages:pi}=R_();$r(m,Lt,Fe=>_(3,k=Fe)),$r(m,pi,Fe=>_(4,B=Fe));let Pi=new Set;function en(Fe){k!=null&&k.loaded()&&("url"in Fe?(Pi.add(Fe.id),k.loadImage(Fe.url,(Pt,He)=>{Pi.delete(Fe.id),Pt?qt("error",Pt):He&&(k==null||k.addImage(Fe.id,He,Fe.options),B.add(Fe.id),pi.set(B))})):(k.addImage(Fe.id,Fe.data,Fe.options),B.add(Fe.id),pi.set(B)))}let Vr,zi,Ti,Tt;function fi(Fe){if(at){let Pt=hg(window.location.hash);Pt.length>=3&&(_(11,Ee=Pt[0]),_(10,De=[Pt[2],Pt[1]])),Pt.length==5&&(_(15,Ne=Pt[3]),_(14,Le=Pt[4]))}return nl(Lt,k=new is.Map(yu({container:Fe,style:be,center:De,zoom:Ee,pitch:Le,bearing:Ne,minZoom:it,maxZoom:Vt,interactive:Xt,preserveDrawingBuffer:Yt,maxBounds:At,bounds:et,attributionControl:Nt,transformRequest:Dt})),k),k.on("load",Pt=>{_(0,nt=!0),qt("load",k)}),k.on("error",Pt=>qt("error",{...Pt,map:k})),k.on("movestart",Pt=>qt("movestart",{...Pt,map:k})),k.on("moveend",Pt=>{if(_(10,De=Pt.target.getCenter()),_(11,Ee=Pt.target.getZoom()),_(12,et=Pt.target.getBounds()),qt("moveend",{...Pt,map:k}),at){let He=window.location.href.replace(/(#.+)?$/,ug(k));window.history.replaceState(window.history.state,"",He)}}),k.on("zoomstart",Pt=>qt("zoomstart",{...Pt,map:k})),k.on("zoom",Pt=>{_(11,Ee=Pt.target.getZoom()),qt("zoom",{...Pt,map:k})}),k.on("zoomend",Pt=>{_(11,Ee=Pt.target.getZoom()),qt("zoomend",{...Pt,map:k})}),k.on("style.load",()=>{if(k){const Pt=k.getStyle();if(_(29,Vr=Pt.layers.map(He=>He.id)),_(30,zi=Object.keys(Pt.sources)),Tt)for(const[He,Gt]of Object.entries(Tt))k.addSource(He,Gt);if(Ti)for(const He of Ti)k.addLayer(He)}}),k.on("styledata",Pt=>{if(k&&Ui){const He=k.getStyle().layers;if(He)for(let Gt of He)Ui(Gt)||k.setLayoutProperty(Gt.id,"visibility","none")}qt("styledata",{...Pt,map:k})}),{destroy(){_(0,nt=!1),k==null||k.remove(),nl(Lt,k=null,k)}}}let Oi=be;return m.$$set=Fe=>{"map"in Fe&&_(13,V=Fe.map),"class"in Fe&&_(1,me=Fe.class),"style"in Fe&&_(16,be=Fe.style),"diffStyleUpdates"in Fe&&_(17,ge=Fe.diffStyleUpdates),"center"in Fe&&_(10,De=Fe.center),"zoom"in Fe&&_(11,Ee=Fe.zoom),"pitch"in Fe&&_(14,Le=Fe.pitch),"bearing"in Fe&&_(15,Ne=Fe.bearing),"bounds"in Fe&&_(12,et=Fe.bounds),"hash"in Fe&&_(18,at=Fe.hash),"loaded"in Fe&&_(0,nt=Fe.loaded),"minZoom"in Fe&&_(19,it=Fe.minZoom),"maxZoom"in Fe&&_(20,Vt=Fe.maxZoom),"zoomOnDoubleClick"in Fe&&_(21,ti=Fe.zoomOnDoubleClick),"interactive"in Fe&&_(22,Xt=Fe.interactive),"attributionControl"in Fe&&_(23,Nt=Fe.attributionControl),"preserveDrawingBuffer"in Fe&&_(24,Yt=Fe.preserveDrawingBuffer),"maxBounds"in Fe&&_(25,At=Fe.maxBounds),"images"in Fe&&_(26,ke=Fe.images),"standardControls"in Fe&&_(2,Ge=Fe.standardControls),"filterLayers"in Fe&&_(27,Ui=Fe.filterLayers),"transformRequest"in Fe&&_(28,Dt=Fe.transformRequest),"$$scope"in Fe&&_(32,H=Fe.$$scope)},m.$$.update=()=>{if(m.$$.dirty[0]&4&&_(6,v=typeof Ge=="boolean"?void 0:Ge),m.$$.dirty[0]&8&&_(13,V=k),m.$$.dirty[0]&67108873&&nt&&k!=null&&k.loaded())for(let Fe of ke)!Pi.has(Fe.id)&&!k.hasImage(Fe.id)&&en(Fe);if(m.$$.dirty[0]&67108880&&_(5,E=ke.every(Fe=>B.has(Fe.id))),m.$$.dirty[0]&1610809352|m.$$.dirty[1]&1&&k&&!hu(be,Oi)){const Fe=k.getStyle();if(Vr&&(Ti=Fe.layers.filter(Pt=>!Vr.includes(Pt.id))),zi){const Pt=Object.keys(Fe.sources).filter(He=>!zi.includes(He));Tt={};for(const He of Pt)Tt[He]=Fe.sources[He]}_(31,Oi=be),k.setStyle(be,{diff:ge})}m.$$.dirty[0]&1032&&De&&!hu(De,k==null?void 0:k.getCenter())&&(k==null||k.panTo(De)),m.$$.dirty[0]&2056&&Ee&&!hu(Ee,k==null?void 0:k.getZoom())&&(k==null||k.zoomTo(Ee)),m.$$.dirty[0]&4104&&et&&!hu(et,k==null?void 0:k.getBounds())&&(k==null||k.fitBounds(et)),m.$$.dirty[0]&2097160&&(ti?k==null||k.doubleClickZoom.enable():k==null||k.doubleClickZoom.disable())},[nt,me,Ge,k,B,E,v,Lt,pi,fi,De,Ee,et,V,Le,Ne,be,ge,at,it,Vt,ti,Xt,Nt,Yt,At,ke,Ui,Dt,Vr,zi,Oi,H,s]}class bg extends Wr{constructor(f){super(),Gr(this,f,xg,vg,Tr,{map:13,class:1,style:16,diffStyleUpdates:17,center:10,zoom:11,pitch:14,bearing:15,bounds:12,hash:18,loaded:0,minZoom:19,maxZoom:20,zoomOnDoubleClick:21,interactive:22,attributionControl:23,preserveDrawingBuffer:24,maxBounds:25,images:26,standardControls:2,filterLayers:27,transformRequest:28},null,[-1,-1])}}const wg=m=>({features:m[0]&16,data:m[0]&16,map:m[0]&4,close:m[0]&1}),Mp=m=>{var f;return{features:m[4],data:(f=m[4])==null?void 0:f[0],map:m[2],close:m[31]}};function Ap(m){let f,_,v=(m[4]||m[3]instanceof is.Marker)&&kp(m);return{c(){f=Zt("div"),v&&v.c()},m(E,k){ci(E,f,k),v&&v.m(f,null),m[32](f),_=!0},p(E,k){E[4]||E[3]instanceof is.Marker?v?(v.p(E,k),k[0]&24&&ft(v,1)):(v=kp(E),v.c(),ft(v,1),v.m(f,null)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(),m[32](null)}}}function kp(m){let f;const _=m[30].default,v=Js(_,m,m[29],Mp);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k[0]&536870933)&&Qs(v,_,E,E[29],f?Ys(_,E[29],k,wg):$s(E[29]),Mp)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function Sg(m){let f,_,v=m[9].default&&Ap(m);return{c(){v&&v.c(),f=Oa()},m(E,k){v&&v.m(E,k),ci(E,f,k),_=!0},p(E,k){E[9].default?v?(v.p(E,k),k[0]&512&&ft(v,1)):(v=Ap(E),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(E)}}}function Tg(m,f,_){let v,E,k,B,s,H,{$$slots:V={},$$scope:me}=f;const be=d_(V);let{closeButton:ge=void 0}=f,{closeOnClickOutside:De=!0}=f,{closeOnClickInside:Ee=!1}=f,{closeOnMove:Le=!1}=f,{openOn:Ne="click"}=f,{openIfTopMost:et=!0}=f,{focusAfterOpen:at=!0}=f,{anchor:nt=void 0}=f,{offset:it=void 0}=f,{popupClass:Vt=void 0}=f,{maxWidth:ti=void 0}=f,{lngLat:Xt=void 0}=f,{html:Nt=void 0}=f,{open:Yt=!1}=f;const{map:At,popupTarget:ke,layerEvent:Ge,layer:Ui,eventTopMost:Dt}=Ll();$r(m,At,Ue=>_(2,k=Ue)),$r(m,ke,Ue=>_(3,s=Ue)),$r(m,Ge,Ue=>_(28,B=Ue)),$r(m,Ui,Ue=>_(35,H=Ue));const qt=["click","dblclick","contextmenu"];let Lt,pi=!1,Pi;function en(){if(!Lt)return;let Ue=Lt.getElement();!Ue||Ue===Pi||(Pi=Ue,Ne==="hover"&&(Pi.style.pointerEvents="none"),Pi.addEventListener("mouseenter",()=>{_(24,pi=!0)},{passive:!0}),Pi.addEventListener("mouseleave",()=>{_(24,pi=!1)},{passive:!0}),Pi.addEventListener("click",()=>{Ee&&_(0,Yt=!1)},{passive:!0}))}jp(()=>{if(k)return k.on("click",Gt),k.on("contextmenu",Gt),typeof s=="string"&&(k.on("click",s,Tt),k.on("dblclick",s,Tt),k.on("contextmenu",s,Tt),k.on("mousemove",s,He),k.on("mouseleave",s,Pt),k.on("touchstart",s,Oi),k.on("touchend",s,Fe)),()=>{k!=null&&k.loaded()&&(Lt==null||Lt.remove(),k.off("click",Gt),k.off("contextmenu",Gt),s instanceof is.Marker?s.getPopup()===Lt&&s.setPopup(void 0):typeof s=="string"&&(k.off("click",s,Tt),k.off("dblclick",s,Tt),k.off("contextmenu",s,Tt),k.off("mousemove",s,He),k.off("mouseleave",s,Pt),k.off("touchstart",s,Oi),k.off("touchend",s,Fe)))}});function Vr(Ue){return et?!("marker"in Ue)&&!N_(Ue)&&Dt(Ue)!==H:!1}let zi=null,Ti="normal";function Tt(Ue){Ue.type===Ne&&(Vr(Ue)||("layerType"in Ue?Ue.layerType==="deckgl"?(_(10,Xt=Ue.coordinate),_(4,zi=Ue.object?[Ue.object]:null)):(_(10,Xt=Ue.lngLat),_(4,zi=Ue.features??[])):(_(10,Xt=Ue.lngLat),_(4,zi=Ue.features??[])),setTimeout(()=>_(0,Yt=!0))))}let fi=null;function Oi(Ue){fi=Ue.point}function Fe(Ue){if(!fi||Ne!=="hover")return;let Bi=fi.dist(Ue.point);fi=null,Bi<3&&(_(10,Xt=Ue.lngLat),_(4,zi=Ue.features??[]),Lt.isOpen()?_(25,Ti="justOpened"):(_(25,Ti="opening"),_(0,Yt=!0)))}function Pt(Ue){Ne!=="hover"||fi||Ti!=="normal"||(_(0,Yt=!1),_(4,zi=null))}function He(Ue){if(!(Ne!=="hover"||fi||Ti!=="normal")){if(Vr(Ue)){_(0,Yt=!1),_(4,zi=null);return}_(0,Yt=!0),_(4,zi=Ue.features??[]),_(10,Xt=Ue.lngLat)}}function Gt(Ue){if(Ti==="justOpened"){_(25,Ti="normal");return}if(!De)return;let Bi=[Pi,s instanceof is.Marker?s==null?void 0:s.getElement():null];Yt&&Lt.isOpen()&&!Bi.some(yr=>yr==null?void 0:yr.contains(Ue.originalEvent.target))&&(Ue.type==="contextmenu"&&Ne==="contextmenu"||Ue.type!=="contextmenu")&&_(0,Yt=!1)}let ct;const Zi=()=>_(0,Yt=!1);function gr(Ue){ea[Ue?"unshift":"push"](()=>{ct=Ue,_(1,ct)})}return m.$$set=Ue=>{"closeButton"in Ue&&_(11,ge=Ue.closeButton),"closeOnClickOutside"in Ue&&_(12,De=Ue.closeOnClickOutside),"closeOnClickInside"in Ue&&_(13,Ee=Ue.closeOnClickInside),"closeOnMove"in Ue&&_(14,Le=Ue.closeOnMove),"openOn"in Ue&&_(15,Ne=Ue.openOn),"openIfTopMost"in Ue&&_(16,et=Ue.openIfTopMost),"focusAfterOpen"in Ue&&_(17,at=Ue.focusAfterOpen),"anchor"in Ue&&_(18,nt=Ue.anchor),"offset"in Ue&&_(19,it=Ue.offset),"popupClass"in Ue&&_(20,Vt=Ue.popupClass),"maxWidth"in Ue&&_(21,ti=Ue.maxWidth),"lngLat"in Ue&&_(10,Xt=Ue.lngLat),"html"in Ue&&_(22,Nt=Ue.html),"open"in Ue&&_(0,Yt=Ue.open),"$$scope"in Ue&&_(29,me=Ue.$$scope)},m.$$.update=()=>{if(m.$$.dirty[0]&14336&&_(27,v=ge??(!De&&!Ee)),m.$$.dirty[0]&146685952&&(Lt||(_(23,Lt=new is.Popup({closeButton:v,closeOnClick:!1,closeOnMove:Le,focusAfterOpen:at,maxWidth:ti,className:Vt,anchor:nt,offset:it})),Pi=Lt.getElement(),Lt.on("open",()=>{_(0,Yt=!0),en()}),Lt.on("close",Ue=>{_(0,Yt=!1)}))),m.$$.dirty[0]&8421384&&Lt&&s instanceof is.Marker&&(Ne==="click"?s.setPopup(Lt):s.getPopup()===Lt&&s.setPopup(void 0)),m.$$.dirty[0]&268468224&&qt.includes(Ne)&&(B==null?void 0:B.type)===Ne&&(Tt(B),nl(Ge,B=null,B)),m.$$.dirty[0]&268468224&&_(26,E=Ne==="hover"&&((B==null?void 0:B.type)==="mousemove"||(B==null?void 0:B.type)==="mouseenter")),m.$$.dirty[0]&352354304&&Ne==="hover"&&Ge&&(E&&B&&(B.layerType==="deckgl"?(_(10,Xt=B.coordinate),_(4,zi=B.object?[B.object]:null)):(_(10,Xt=B.lngLat),_(4,zi=B.features??[]))),_(0,Yt=(E||pi)??!1)),m.$$.dirty[0]&12582914&&(ct?Lt.setDOMContent(ct):Nt&&Lt.setHTML(Nt)),m.$$.dirty[0]&8389632&&Xt&&Lt.setLngLat(Xt),m.$$.dirty[0]&41943045&&k){let Ue=Lt.isOpen();Yt&&!Ue?(Lt.addTo(k),Ti==="opening"&&_(25,Ti="justOpened")):!Yt&&Ue&&Lt.remove()}},[Yt,ct,k,s,zi,At,ke,Ge,Ui,be,Xt,ge,De,Ee,Le,Ne,et,at,nt,it,Vt,ti,Nt,Lt,pi,Ti,E,v,B,me,V,Zi,gr]}class Ph extends Wr{constructor(f){super(),Gr(this,f,Tg,Sg,Tr,{closeButton:11,closeOnClickOutside:12,closeOnClickInside:13,closeOnMove:14,openOn:15,openIfTopMost:16,focusAfterOpen:17,anchor:18,offset:19,popupClass:20,maxWidth:21,lngLat:10,html:22,open:0},null,[-1,-1])}}var Rc=Uint8Array,rf=Uint16Array,Ig=Int32Array,Eg=new Rc([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Cg=new Rc([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nf=function(m,f){for(var _=new rf(31),v=0;v<31;++v)_[v]=f+=1<>1|(Fi&21845)<<1,Gs=(Gs&52428)>>2|(Gs&13107)<<2,Gs=(Gs&61680)>>4|(Gs&3855)<<4,kg[Fi]=((Gs&65280)>>8|(Gs&255)<<8)>>1;var Gs,Fi,xu=new Rc(288);for(Fi=0;Fi<144;++Fi)xu[Fi]=8;var Fi;for(Fi=144;Fi<256;++Fi)xu[Fi]=9;var Fi;for(Fi=256;Fi<280;++Fi)xu[Fi]=7;var Fi;for(Fi=280;Fi<288;++Fi)xu[Fi]=8;var Fi,Pg=new Rc(32);for(Fi=0;Fi<32;++Fi)Pg[Fi]=5;var Fi,zg=new Rc(0),Lg=typeof TextDecoder<"u"&&new TextDecoder,Dg=0;try{Lg.decode(zg,{stream:!0}),Dg=1}catch{}const Fg=m=>({}),Pp=m=>({}),Rg=m=>({}),zp=m=>({});function Og(m){let f,_,v,E;const k=m[1].left,B=Js(k,m,m[0],zp),s=m[1].main,H=Js(s,m,m[0],Pp);return{c(){f=Zt("div"),B&&B.c(),_=fn(),v=Zt("div"),H&&H.c(),vs(f,"class","left svelte-6kzmjs"),vs(v,"class","main svelte-6kzmjs")},m(V,me){ci(V,f,me),B&&B.m(f,null),ci(V,_,me),ci(V,v,me),H&&H.m(v,null),E=!0},p(V,[me]){B&&B.p&&(!E||me&1)&&Qs(B,k,V,V[0],E?Ys(k,V[0],me,Rg):$s(V[0]),zp),H&&H.p&&(!E||me&1)&&Qs(H,s,V,V[0],E?Ys(s,V[0],me,Fg):$s(V[0]),Pp)},i(V){E||(ft(B,V),ft(H,V),E=!0)},o(V){St(B,V),St(H,V),E=!1},d(V){V&&(si(f),si(_),si(v)),B&&B.d(V),H&&H.d(V)}}}function Bg(m,f,_){let{$$slots:v={},$$scope:E}=f;return m.$$set=k=>{"$$scope"in k&&_(0,E=k.$$scope)},[E,v]}class Ng extends Wr{constructor(f){super(),Gr(this,f,Bg,Og,Tr,{})}}function Lp(m){let f,_;return{c(){f=Zt("div"),_=sl(m[0]),vs(f,"class","svelte-1uuov7f")},m(v,E){ci(v,f,E),_i(f,_)},p(v,E){E&1&&yh(_,v[0])},d(v){v&&si(f)}}}function Vg(m){let f,_=m[0]&&Lp(m);return{c(){_&&_.c(),f=Oa()},m(v,E){_&&_.m(v,E),ci(v,f,E)},p(v,[E]){v[0]?_?_.p(v,E):(_=Lp(v),_.c(),_.m(f.parentNode,f)):_&&(_.d(1),_=null)},i:Ar,o:Ar,d(v){v&&si(f),_&&_.d(v)}}}function Ug(m,f,_){let{msg:v=null}=f;return m.$$set=E=>{"msg"in E&&_(0,v=E.msg)},[v]}class jg extends Wr{constructor(f){super(),Gr(this,f,Ug,Vg,Tr,{msg:0})}}var sf={exports:{}};(function(m,f){(function(_,v){m.exports=v()})(kl,function(){var _=function(g,I){var O={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},Y={on:function(se,fe,Re){if(O[se]===void 0)throw new Error("Invalid event type: "+se);O[se].push({selector:fe,fn:Re})},render:function(se){I.store.featureChanged(se)}},ne=function(se,fe){for(var Re=O[se],Ve=Re.length;Ve--;){var rt=Re[Ve];if(rt.selector(fe)){rt.fn.call(Y,fe)||I.store.render(),I.ui.updateMapClasses();break}}};return g.start.call(Y),{render:g.render,stop:function(){g.stop&&g.stop()},trash:function(){g.trash&&(g.trash(),I.store.render())},combineFeatures:function(){g.combineFeatures&&g.combineFeatures()},uncombineFeatures:function(){g.uncombineFeatures&&g.uncombineFeatures()},drag:function(se){ne("drag",se)},click:function(se){ne("click",se)},mousemove:function(se){ne("mousemove",se)},mousedown:function(se){ne("mousedown",se)},mouseup:function(se){ne("mouseup",se)},mouseout:function(se){ne("mouseout",se)},keydown:function(se){ne("keydown",se)},keyup:function(se){ne("keyup",se)},touchstart:function(se){ne("touchstart",se)},touchmove:function(se){ne("touchmove",se)},touchend:function(se){ne("touchend",se)},tap:function(se){ne("tap",se)}}};function v(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function E(g){if(g.__esModule)return g;var I=g.default;if(typeof I=="function"){var O=function Y(){if(this instanceof Y){var ne=[null];ne.push.apply(ne,arguments);var se=Function.bind.apply(I,ne);return new se}return I.apply(this,arguments)};O.prototype=I.prototype}else O={};return Object.defineProperty(O,"__esModule",{value:!0}),Object.keys(g).forEach(function(Y){var ne=Object.getOwnPropertyDescriptor(g,Y);Object.defineProperty(O,Y,ne.get?ne:{enumerable:!0,get:function(){return g[Y]}})}),O}var k={},B={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:63567523142e-4},s=B;function H(g){var I=0;if(g&&g.length>0){I+=Math.abs(V(g[0]));for(var O=1;O2){for(fe=0;fe=Math.pow(2,g)?zi(g,I):se};zi.rack=function(g,I,O){var Y=function(se){var fe=0;do{if(fe++>10){if(!O)throw new Error("too many ID collisions, use more bits");g+=O}var Re=zi(g,I)}while(Object.hasOwnProperty.call(ne,Re));return ne[Re]=se,Re},ne=Y.hats={};return Y.get=function(se){return Y.hats[se]},Y.set=function(se,fe){return Y.hats[se]=fe,Y},Y.bits=g||128,Y.base=I||16,Y};var Ti=v(Vr.exports),Tt=function(g,I){this.ctx=g,this.properties=I.properties||{},this.coordinates=I.geometry.coordinates,this.id=I.id||Ti(),this.type=I.geometry.type};Tt.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},Tt.prototype.incomingCoords=function(g){this.setCoordinates(g)},Tt.prototype.setCoordinates=function(g){this.coordinates=g,this.changed()},Tt.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},Tt.prototype.setProperty=function(g,I){this.properties[g]=I},Tt.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:Le.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},Tt.prototype.internal=function(g){var I={id:this.id,meta:nt.FEATURE,"meta:type":this.type,active:it.INACTIVE,mode:g};if(this.ctx.options.userProperties)for(var O in this.properties)I["user_"+O]=this.properties[O];return{type:Le.FEATURE,properties:I,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var fi=function(g,I){Tt.call(this,g,I)};(fi.prototype=Object.create(Tt.prototype)).isValid=function(){return typeof this.coordinates[0]=="number"&&typeof this.coordinates[1]=="number"},fi.prototype.updateCoordinate=function(g,I,O){this.coordinates=arguments.length===3?[I,O]:[g,I],this.changed()},fi.prototype.getCoordinate=function(){return this.getCoordinates()};var Oi=function(g,I){Tt.call(this,g,I)};(Oi.prototype=Object.create(Tt.prototype)).isValid=function(){return this.coordinates.length>1},Oi.prototype.addCoordinate=function(g,I,O){this.changed();var Y=parseInt(g,10);this.coordinates.splice(Y,0,[I,O])},Oi.prototype.getCoordinate=function(g){var I=parseInt(g,10);return JSON.parse(JSON.stringify(this.coordinates[I]))},Oi.prototype.removeCoordinate=function(g){this.changed(),this.coordinates.splice(parseInt(g,10),1)},Oi.prototype.updateCoordinate=function(g,I,O){var Y=parseInt(g,10);this.coordinates[Y]=[I,O],this.changed()};var Fe=function(g,I){Tt.call(this,g,I),this.coordinates=this.coordinates.map(function(O){return O.slice(0,-1)})};(Fe.prototype=Object.create(Tt.prototype)).isValid=function(){return this.coordinates.length!==0&&this.coordinates.every(function(g){return g.length>2})},Fe.prototype.incomingCoords=function(g){this.coordinates=g.map(function(I){return I.slice(0,-1)}),this.changed()},Fe.prototype.setCoordinates=function(g){this.coordinates=g,this.changed()},Fe.prototype.addCoordinate=function(g,I,O){this.changed();var Y=g.split(".").map(function(ne){return parseInt(ne,10)});this.coordinates[Y[0]].splice(Y[1],0,[I,O])},Fe.prototype.removeCoordinate=function(g){this.changed();var I=g.split(".").map(function(Y){return parseInt(Y,10)}),O=this.coordinates[I[0]];O&&(O.splice(I[1],1),O.length<3&&this.coordinates.splice(I[0],1))},Fe.prototype.getCoordinate=function(g){var I=g.split(".").map(function(Y){return parseInt(Y,10)}),O=this.coordinates[I[0]];return JSON.parse(JSON.stringify(O[I[1]]))},Fe.prototype.getCoordinates=function(){return this.coordinates.map(function(g){return g.concat([g[0]])})},Fe.prototype.updateCoordinate=function(g,I,O){this.changed();var Y=g.split("."),ne=parseInt(Y[0],10),se=parseInt(Y[1],10);this.coordinates[ne]===void 0&&(this.coordinates[ne]=[]),this.coordinates[ne][se]=[I,O]};var Pt={MultiPoint:fi,MultiLineString:Oi,MultiPolygon:Fe},He=function(g,I,O,Y,ne){var se=O.split("."),fe=parseInt(se[0],10),Re=se[1]?se.slice(1).join("."):null;return g[fe][I](Re,Y,ne)},Gt=function(g,I){if(Tt.call(this,g,I),delete this.coordinates,this.model=Pt[I.geometry.type],this.model===void 0)throw new TypeError(I.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(I.geometry.coordinates)};function ct(g){this.map=g.map,this.drawConfig=JSON.parse(JSON.stringify(g.options||{})),this._ctx=g}(Gt.prototype=Object.create(Tt.prototype))._coordinatesToFeatures=function(g){var I=this,O=this.model.bind(this);return g.map(function(Y){return new O(I.ctx,{id:Ti(),type:Le.FEATURE,properties:{},geometry:{coordinates:Y,type:I.type.replace("Multi","")}})})},Gt.prototype.isValid=function(){return this.features.every(function(g){return g.isValid()})},Gt.prototype.setCoordinates=function(g){this.features=this._coordinatesToFeatures(g),this.changed()},Gt.prototype.getCoordinate=function(g){return He(this.features,"getCoordinate",g)},Gt.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(function(g){return g.type===Le.POLYGON?g.getCoordinates():g.coordinates})))},Gt.prototype.updateCoordinate=function(g,I,O){He(this.features,"updateCoordinate",g,I,O),this.changed()},Gt.prototype.addCoordinate=function(g,I,O){He(this.features,"addCoordinate",g,I,O),this.changed()},Gt.prototype.removeCoordinate=function(g){He(this.features,"removeCoordinate",g),this.changed()},Gt.prototype.getFeatures=function(){return this.features},ct.prototype.setSelected=function(g){return this._ctx.store.setSelected(g)},ct.prototype.setSelectedCoordinates=function(g){var I=this;this._ctx.store.setSelectedCoordinates(g),g.reduce(function(O,Y){return O[Y.feature_id]===void 0&&(O[Y.feature_id]=!0,I._ctx.store.get(Y.feature_id).changed()),O},{})},ct.prototype.getSelected=function(){return this._ctx.store.getSelected()},ct.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},ct.prototype.isSelected=function(g){return this._ctx.store.isSelected(g)},ct.prototype.getFeature=function(g){return this._ctx.store.get(g)},ct.prototype.select=function(g){return this._ctx.store.select(g)},ct.prototype.deselect=function(g){return this._ctx.store.deselect(g)},ct.prototype.deleteFeature=function(g,I){return I===void 0&&(I={}),this._ctx.store.delete(g,I)},ct.prototype.addFeature=function(g){return this._ctx.store.add(g)},ct.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},ct.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},ct.prototype.setActionableState=function(g){g===void 0&&(g={});var I={trash:g.trash||!1,combineFeatures:g.combineFeatures||!1,uncombineFeatures:g.uncombineFeatures||!1};return this._ctx.events.actionable(I)},ct.prototype.changeMode=function(g,I,O){return I===void 0&&(I={}),O===void 0&&(O={}),this._ctx.events.changeMode(g,I,O)},ct.prototype.updateUIClasses=function(g){return this._ctx.ui.queueMapClasses(g)},ct.prototype.activateUIButton=function(g){return this._ctx.ui.setActiveButton(g)},ct.prototype.featuresAt=function(g,I,O){if(O===void 0&&(O="click"),O!=="click"&&O!=="touch")throw new Error("invalid buffer type");return Dt[O](g,I,this._ctx)},ct.prototype.newFeature=function(g){var I=g.geometry.type;return I===Le.POINT?new fi(this._ctx,g):I===Le.LINE_STRING?new Oi(this._ctx,g):I===Le.POLYGON?new Fe(this._ctx,g):new Gt(this._ctx,g)},ct.prototype.isInstanceOf=function(g,I){if(g===Le.POINT)return I instanceof fi;if(g===Le.LINE_STRING)return I instanceof Oi;if(g===Le.POLYGON)return I instanceof Fe;if(g==="MultiFeature")return I instanceof Gt;throw new Error("Unknown feature class: "+g)},ct.prototype.doRender=function(g){return this._ctx.store.featureChanged(g)},ct.prototype.onSetup=function(){},ct.prototype.onDrag=function(){},ct.prototype.onClick=function(){},ct.prototype.onMouseMove=function(){},ct.prototype.onMouseDown=function(){},ct.prototype.onMouseUp=function(){},ct.prototype.onMouseOut=function(){},ct.prototype.onKeyUp=function(){},ct.prototype.onKeyDown=function(){},ct.prototype.onTouchStart=function(){},ct.prototype.onTouchMove=function(){},ct.prototype.onTouchEnd=function(){},ct.prototype.onTap=function(){},ct.prototype.onStop=function(){},ct.prototype.onTrash=function(){},ct.prototype.onCombineFeature=function(){},ct.prototype.onUncombineFeature=function(){},ct.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var Zi={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},gr=Object.keys(Zi);function Ue(g){var I=Object.keys(g);return function(O,Y){Y===void 0&&(Y={});var ne={},se=I.reduce(function(fe,Re){return fe[Re]=g[Re],fe},new ct(O));return{start:function(){var fe=this;ne=se.onSetup(Y),gr.forEach(function(Re){var Ve,rt=Zi[Re],ot=function(){return!1};g[rt]&&(ot=function(){return!0}),fe.on(Re,ot,(Ve=rt,function(Je){return se[Ve](ne,Je)}))})},stop:function(){se.onStop(ne)},trash:function(){se.onTrash(ne)},combineFeatures:function(){se.onCombineFeatures(ne)},uncombineFeatures:function(){se.onUncombineFeatures(ne)},render:function(fe,Re){se.toDisplayFeatures(ne,fe,Re)}}}}function Bi(g){return[].concat(g).filter(function(I){return I!==void 0})}function yr(){var g=this;if(!(g.ctx.map&&g.ctx.map.getSource(ge.HOT)!==void 0))return Ve();var I=g.ctx.events.currentModeName();g.ctx.ui.queueMapClasses({mode:I});var O=[],Y=[];g.isDirty?Y=g.getAllIds():(O=g.getChangedIds().filter(function(rt){return g.get(rt)!==void 0}),Y=g.sources.hot.filter(function(rt){return rt.properties.id&&O.indexOf(rt.properties.id)===-1&&g.get(rt.properties.id)!==void 0}).map(function(rt){return rt.properties.id})),g.sources.hot=[];var ne=g.sources.cold.length;g.sources.cold=g.isDirty?[]:g.sources.cold.filter(function(rt){var ot=rt.properties.id||rt.properties.parent;return O.indexOf(ot)===-1});var se=ne!==g.sources.cold.length||Y.length>0;function fe(rt,ot){var Je=g.get(rt).internal(I);g.ctx.events.currentModeRender(Je,function(Rt){g.sources[ot].push(Rt)})}if(O.forEach(function(rt){return fe(rt,"hot")}),Y.forEach(function(rt){return fe(rt,"cold")}),se&&g.ctx.map.getSource(ge.COLD).setData({type:Le.FEATURE_COLLECTION,features:g.sources.cold}),g.ctx.map.getSource(ge.HOT).setData({type:Le.FEATURE_COLLECTION,features:g.sources.hot}),g._emitSelectionChange&&(g.ctx.map.fire(et.SELECTION_CHANGE,{features:g.getSelected().map(function(rt){return rt.toGeoJSON()}),points:g.getSelectedCoordinates().map(function(rt){return{type:Le.FEATURE,properties:{},geometry:{type:Le.POINT,coordinates:rt.coordinates}}})}),g._emitSelectionChange=!1),g._deletedFeaturesToEmit.length){var Re=g._deletedFeaturesToEmit.map(function(rt){return rt.toGeoJSON()});g._deletedFeaturesToEmit=[],g.ctx.map.fire(et.DELETE,{features:Re})}function Ve(){g.isDirty=!1,g.clearChangedIds()}Ve(),g.ctx.map.fire(et.RENDER,{})}function hi(g){var I,O=this;this._features={},this._featureIds=new Ge,this._selectedFeatureIds=new Ge,this._selectedCoordinates=[],this._changedFeatureIds=new Ge,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=g,this.sources={hot:[],cold:[]},this.render=function(){I||(I=requestAnimationFrame(function(){I=null,yr.call(O)}))},this.isDirty=!1}function co(g,I){var O=g._selectedCoordinates.filter(function(Y){return g._selectedFeatureIds.has(Y.feature_id)});g._selectedCoordinates.length===O.length||I.silent||(g._emitSelectionChange=!0),g._selectedCoordinates=O}hi.prototype.createRenderBatch=function(){var g=this,I=this.render,O=0;return this.render=function(){O++},function(){g.render=I,O>0&&g.render()}},hi.prototype.setDirty=function(){return this.isDirty=!0,this},hi.prototype.featureChanged=function(g){return this._changedFeatureIds.add(g),this},hi.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},hi.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},hi.prototype.getAllIds=function(){return this._featureIds.values()},hi.prototype.add=function(g){return this.featureChanged(g.id),this._features[g.id]=g,this._featureIds.add(g.id),this},hi.prototype.delete=function(g,I){var O=this;return I===void 0&&(I={}),Bi(g).forEach(function(Y){O._featureIds.has(Y)&&(O._featureIds.delete(Y),O._selectedFeatureIds.delete(Y),I.silent||O._deletedFeaturesToEmit.indexOf(O._features[Y])===-1&&O._deletedFeaturesToEmit.push(O._features[Y]),delete O._features[Y],O.isDirty=!0)}),co(this,I),this},hi.prototype.get=function(g){return this._features[g]},hi.prototype.getAll=function(){var g=this;return Object.keys(this._features).map(function(I){return g._features[I]})},hi.prototype.select=function(g,I){var O=this;return I===void 0&&(I={}),Bi(g).forEach(function(Y){O._selectedFeatureIds.has(Y)||(O._selectedFeatureIds.add(Y),O._changedFeatureIds.add(Y),I.silent||(O._emitSelectionChange=!0))}),this},hi.prototype.deselect=function(g,I){var O=this;return I===void 0&&(I={}),Bi(g).forEach(function(Y){O._selectedFeatureIds.has(Y)&&(O._selectedFeatureIds.delete(Y),O._changedFeatureIds.add(Y),I.silent||(O._emitSelectionChange=!0))}),co(this,I),this},hi.prototype.clearSelected=function(g){return g===void 0&&(g={}),this.deselect(this._selectedFeatureIds.values(),{silent:g.silent}),this},hi.prototype.setSelected=function(g,I){var O=this;return I===void 0&&(I={}),g=Bi(g),this.deselect(this._selectedFeatureIds.values().filter(function(Y){return g.indexOf(Y)===-1}),{silent:I.silent}),this.select(g.filter(function(Y){return!O._selectedFeatureIds.has(Y)}),{silent:I.silent}),this},hi.prototype.setSelectedCoordinates=function(g){return this._selectedCoordinates=g,this._emitSelectionChange=!0,this},hi.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},hi.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},hi.prototype.getSelected=function(){var g=this;return this._selectedFeatureIds.values().map(function(I){return g.get(I)})},hi.prototype.getSelectedCoordinates=function(){var g=this;return this._selectedCoordinates.map(function(I){return{coordinates:g.get(I.feature_id).getCoordinate(I.coord_path)}})},hi.prototype.isSelected=function(g){return this._selectedFeatureIds.has(g)},hi.prototype.setFeatureProperty=function(g,I,O){this.get(g).setProperty(I,O),this.featureChanged(g)},hi.prototype.storeMapConfig=function(){var g=this;Vt.forEach(function(I){g.ctx.map[I]&&(g._mapInitialConfig[I]=g.ctx.map[I].isEnabled())})},hi.prototype.restoreMapConfig=function(){var g=this;Object.keys(this._mapInitialConfig).forEach(function(I){g._mapInitialConfig[I]?g.ctx.map[I].enable():g.ctx.map[I].disable()})},hi.prototype.getInitialConfigValue=function(g){return this._mapInitialConfig[g]===void 0||this._mapInitialConfig[g]};var wo=function(){for(var g=arguments,I={},O=0;O=48&&Pe<=57)};function Ot(Pe,_t,vi){vi===void 0&&(vi={}),Rt.stop();var Xi=Re[Pe];if(Xi===void 0)throw new Error(Pe+" is not valid");Je=Pe;var tr=Xi(fe,_t);Rt=_(tr,fe),vi.silent||fe.map.fire(et.MODE_CHANGE,{mode:Pe}),fe.store.setDirty(),fe.store.render()}ot.keydown=function(Pe){(Pe.srcElement||Pe.target).classList.contains("mapboxgl-canvas")&&(Pe.keyCode!==8&&Pe.keyCode!==46||!fe.options.controls.trash?Hi(Pe.keyCode)?Rt.keydown(Pe):Pe.keyCode===49&&fe.options.controls.point?Ot(Ne.DRAW_POINT):Pe.keyCode===50&&fe.options.controls.line_string?Ot(Ne.DRAW_LINE_STRING):Pe.keyCode===51&&fe.options.controls.polygon&&Ot(Ne.DRAW_POLYGON):(Pe.preventDefault(),Rt.trash()))},ot.keyup=function(Pe){Hi(Pe.keyCode)&&Rt.keyup(Pe)},ot.zoomend=function(){fe.store.changeZoom()},ot.data=function(Pe){if(Pe.dataType==="style"){var _t=fe.setup,vi=fe.map,Xi=fe.options,tr=fe.store;Xi.styles.some(function(nn){return vi.getLayer(nn.id)})||(_t.addLayers(),tr.setDirty(),tr.render())}};var ar={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start:function(){Je=fe.options.defaultMode,Rt=_(Re[Je](fe),fe)},changeMode:Ot,actionable:function(Pe){var _t=!1;Object.keys(Pe).forEach(function(vi){if(ar[vi]===void 0)throw new Error("Invalid action type");ar[vi]!==Pe[vi]&&(_t=!0),ar[vi]=Pe[vi]}),_t&&fe.map.fire(et.ACTIONABLE,{actions:ar})},currentModeName:function(){return Je},currentModeRender:function(Pe,_t){return Rt.render(Pe,_t)},fire:function(Pe,_t){ot[Pe]&&ot[Pe](_t)},addEventListeners:function(){fe.map.on("mousemove",ot.mousemove),fe.map.on("mousedown",ot.mousedown),fe.map.on("mouseup",ot.mouseup),fe.map.on("data",ot.data),fe.map.on("touchmove",ot.touchmove),fe.map.on("touchstart",ot.touchstart),fe.map.on("touchend",ot.touchend),fe.container.addEventListener("mouseout",ot.mouseout),fe.options.keybindings&&(fe.container.addEventListener("keydown",ot.keydown),fe.container.addEventListener("keyup",ot.keyup))},removeEventListeners:function(){fe.map.off("mousemove",ot.mousemove),fe.map.off("mousedown",ot.mousedown),fe.map.off("mouseup",ot.mouseup),fe.map.off("data",ot.data),fe.map.off("touchmove",ot.touchmove),fe.map.off("touchstart",ot.touchstart),fe.map.off("touchend",ot.touchend),fe.container.removeEventListener("mouseout",ot.mouseout),fe.options.keybindings&&(fe.container.removeEventListener("keydown",ot.keydown),fe.container.removeEventListener("keyup",ot.keyup))},trash:function(Pe){Rt.trash(Pe)},combineFeatures:function(){Rt.combineFeatures()},uncombineFeatures:function(){Rt.uncombineFeatures()},getMode:function(){return Je}}}(g),g.ui=function(fe){var Re={},Ve=null,rt={mode:null,feature:null,mouse:null},ot={mode:null,feature:null,mouse:null};function Je(Pe){ot=Se(ot,Pe)}function Rt(){var Pe,_t;if(fe.container){var vi=[],Xi=[];tn.forEach(function(tr){ot[tr]!==rt[tr]&&(vi.push(tr+"-"+rt[tr]),ot[tr]!==null&&Xi.push(tr+"-"+ot[tr]))}),vi.length>0&&(Pe=fe.container.classList).remove.apply(Pe,vi),Xi.length>0&&(_t=fe.container.classList).add.apply(_t,Xi),rt=Se(rt,ot)}}function Hi(Pe,_t){_t===void 0&&(_t={});var vi=document.createElement("button");return vi.className=be.CONTROL_BUTTON+" "+_t.className,vi.setAttribute("title",_t.title),_t.container.appendChild(vi),vi.addEventListener("click",function(Xi){if(Xi.preventDefault(),Xi.stopPropagation(),Xi.target===Ve)return Ot(),void _t.onDeactivate();ar(Pe),_t.onActivate()},!0),vi}function Ot(){Ve&&(Ve.classList.remove(be.ACTIVE_BUTTON),Ve=null)}function ar(Pe){Ot();var _t=Re[Pe];_t&&_t&&Pe!=="trash"&&(_t.classList.add(be.ACTIVE_BUTTON),Ve=_t)}return{setActiveButton:ar,queueMapClasses:Je,updateMapClasses:Rt,clearMapClasses:function(){Je({mode:null,feature:null,mouse:null}),Rt()},addButtons:function(){var Pe=fe.options.controls,_t=document.createElement("div");return _t.className=be.CONTROL_GROUP+" "+be.CONTROL_BASE,Pe&&(Pe[Ee.LINE]&&(Re[Ee.LINE]=Hi(Ee.LINE,{container:_t,className:be.CONTROL_BUTTON_LINE,title:"LineString tool "+(fe.options.keybindings?"(l)":""),onActivate:function(){return fe.events.changeMode(Ne.DRAW_LINE_STRING)},onDeactivate:function(){return fe.events.trash()}})),Pe[Ee.POLYGON]&&(Re[Ee.POLYGON]=Hi(Ee.POLYGON,{container:_t,className:be.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(fe.options.keybindings?"(p)":""),onActivate:function(){return fe.events.changeMode(Ne.DRAW_POLYGON)},onDeactivate:function(){return fe.events.trash()}})),Pe[Ee.POINT]&&(Re[Ee.POINT]=Hi(Ee.POINT,{container:_t,className:be.CONTROL_BUTTON_POINT,title:"Marker tool "+(fe.options.keybindings?"(m)":""),onActivate:function(){return fe.events.changeMode(Ne.DRAW_POINT)},onDeactivate:function(){return fe.events.trash()}})),Pe.trash&&(Re.trash=Hi("trash",{container:_t,className:be.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:function(){fe.events.trash()}})),Pe.combine_features&&(Re.combine_features=Hi("combineFeatures",{container:_t,className:be.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:function(){fe.events.combineFeatures()}})),Pe.uncombine_features&&(Re.uncombine_features=Hi("uncombineFeatures",{container:_t,className:be.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:function(){fe.events.uncombineFeatures()}}))),_t},removeButtons:function(){Object.keys(Re).forEach(function(Pe){var _t=Re[Pe];_t.parentNode&&_t.parentNode.removeChild(_t),delete Re[Pe]})}}}(g),g.container=ne.getContainer(),g.store=new hi(g),I=g.ui.addButtons(),g.options.boxSelect&&(g.boxZoomInitial=ne.boxZoom.isEnabled(),ne.boxZoom.disable(),ne.dragPan.disable(),ne.dragPan.enable()),ne.loaded()?Y.connect():(ne.on("load",Y.connect),O=setInterval(function(){ne.loaded()&&Y.connect()},16)),g.events.start(),I},addLayers:function(){g.map.addSource(ge.COLD,{data:{type:Le.FEATURE_COLLECTION,features:[]},type:"geojson"}),g.map.addSource(ge.HOT,{data:{type:Le.FEATURE_COLLECTION,features:[]},type:"geojson"}),g.options.styles.forEach(function(ne){g.map.addLayer(ne)}),g.store.setDirty(!0),g.store.render()},removeLayers:function(){g.options.styles.forEach(function(ne){g.map.getLayer(ne.id)&&g.map.removeLayer(ne.id)}),g.map.getSource(ge.COLD)&&g.map.removeSource(ge.COLD),g.map.getSource(ge.HOT)&&g.map.removeSource(ge.HOT)}};return g.setup=Y,Y}var Ii=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}];function ii(g){return function(I){var O=I.featureTarget;return!!O&&!!O.properties&&O.properties.meta===g}}function Vn(g){return!!g.originalEvent&&!!g.originalEvent.shiftKey&&g.originalEvent.button===0}function En(g){return!!g.featureTarget&&!!g.featureTarget.properties&&g.featureTarget.properties.active===it.ACTIVE&&g.featureTarget.properties.meta===nt.FEATURE}function Un(g){return!!g.featureTarget&&!!g.featureTarget.properties&&g.featureTarget.properties.active===it.INACTIVE&&g.featureTarget.properties.meta===nt.FEATURE}function qo(g){return g.featureTarget===void 0}function So(g){return!!g.featureTarget&&!!g.featureTarget.properties&&g.featureTarget.properties.meta===nt.FEATURE}function Cn(g){var I=g.featureTarget;return!!I&&!!I.properties&&I.properties.meta===nt.VERTEX}function $n(g){return!!g.originalEvent&&g.originalEvent.shiftKey===!0}function qe(g){return g.keyCode===27}function mn(g){return g.keyCode===13}var er=Object.freeze({__proto__:null,isOfMetaType:ii,isShiftMousedown:Vn,isActiveFeature:En,isInactiveFeature:Un,noTarget:qo,isFeature:So,isVertex:Cn,isShiftDown:$n,isEscapeKey:qe,isEnterKey:mn,isTrue:function(){return!0}}),Zo=rn;function rn(g,I){this.x=g,this.y=I}rn.prototype={clone:function(){return new rn(this.x,this.y)},add:function(g){return this.clone()._add(g)},sub:function(g){return this.clone()._sub(g)},multByPoint:function(g){return this.clone()._multByPoint(g)},divByPoint:function(g){return this.clone()._divByPoint(g)},mult:function(g){return this.clone()._mult(g)},div:function(g){return this.clone()._div(g)},rotate:function(g){return this.clone()._rotate(g)},rotateAround:function(g,I){return this.clone()._rotateAround(g,I)},matMult:function(g){return this.clone()._matMult(g)},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(g){return this.x===g.x&&this.y===g.y},dist:function(g){return Math.sqrt(this.distSqr(g))},distSqr:function(g){var I=g.x-this.x,O=g.y-this.y;return I*I+O*O},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(g){return Math.atan2(this.y-g.y,this.x-g.x)},angleWith:function(g){return this.angleWithSep(g.x,g.y)},angleWithSep:function(g,I){return Math.atan2(this.x*I-this.y*g,this.x*g+this.y*I)},_matMult:function(g){var I=g[0]*this.x+g[1]*this.y,O=g[2]*this.x+g[3]*this.y;return this.x=I,this.y=O,this},_add:function(g){return this.x+=g.x,this.y+=g.y,this},_sub:function(g){return this.x-=g.x,this.y-=g.y,this},_mult:function(g){return this.x*=g,this.y*=g,this},_div:function(g){return this.x/=g,this.y/=g,this},_multByPoint:function(g){return this.x*=g.x,this.y*=g.y,this},_divByPoint:function(g){return this.x/=g.x,this.y/=g.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var g=this.y;return this.y=this.x,this.x=-g,this},_rotate:function(g){var I=Math.cos(g),O=Math.sin(g),Y=I*this.x-O*this.y,ne=O*this.x+I*this.y;return this.x=Y,this.y=ne,this},_rotateAround:function(g,I){var O=Math.cos(g),Y=Math.sin(g),ne=I.x+O*(this.x-I.x)-Y*(this.y-I.y),se=I.y+Y*(this.x-I.x)+O*(this.y-I.y);return this.x=ne,this.y=se,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},rn.convert=function(g){return g instanceof rn?g:Array.isArray(g)?new rn(g[0],g[1]):g};var We=v(Zo);function Bt(g,I){var O=I.getBoundingClientRect();return new We(g.clientX-O.left-(I.clientLeft||0),g.clientY-O.top-(I.clientTop||0))}function Mt(g,I,O,Y){return{type:Le.FEATURE,properties:{meta:nt.VERTEX,parent:g,coord_path:O,active:Y?it.ACTIVE:it.INACTIVE},geometry:{type:Le.POINT,coordinates:I}}}function Ur(g,I,O){var Y=I.geometry.coordinates,ne=O.geometry.coordinates;if(Y[1]>85||Y[1]85||ne[1]=I&&this._bbox[3]>=O},Ut.prototype.intersect=function(g){return this._valid?(I=g instanceof Ut?g.bbox():g,!(this._bbox[0]>I[2]||this._bbox[2]I[3])):null;var I},Ut.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var g="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",g)},Ut.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var ai=function(g){if(!g)return[];var I=Q(J(g)),O=[];return I.features.forEach(function(Y){Y.geometry&&(O=O.concat(he(Y.geometry.coordinates)))}),O},ri=Ft,jr=gi,Ei={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},hr=Object.keys(Ei);function vr(g){for(var I=jr(),O=ai(g),Y=0;YO&&(O=Je),Rtne&&(ne=Rt),JeRe&&(Re=Ot)});var Ve=I;return O+Ve.lat>85&&(Ve.lat=85-O),ne+Ve.lat>90&&(Ve.lat=90-ne),Y+Ve.lat<-85&&(Ve.lat=-85-Y),se+Ve.lat=270&&(Ve.lng-=360*Math.ceil(Math.abs(Ve.lng)/360)),Ve}function Io(g,I){var O=To(g.map(function(Y){return Y.toGeoJSON()}),I);g.forEach(function(Y){var ne,se=Y.getCoordinates(),fe=function(Ve){var rt={lng:Ve[0]+O.lng,lat:Ve[1]+O.lat};return[rt.lng,rt.lat]},Re=function(Ve){return Ve.map(function(rt){return fe(rt)})};Y.type===Le.POINT?ne=fe(se):Y.type===Le.LINE_STRING||Y.type===Le.MULTI_POINT?ne=se.map(fe):Y.type===Le.POLYGON||Y.type===Le.MULTI_LINE_STRING?ne=se.map(Re):Y.type===Le.MULTI_POLYGON&&(ne=se.map(function(Ve){return Ve.map(function(rt){return Re(rt)})})),Y.incomingCoords(ne)})}var xr={onSetup:function(g){var I=this,O={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:g.featureIds||[]};return this.setSelected(O.initiallySelectedFeatureIds.filter(function(Y){return I.getFeature(Y)!==void 0})),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),O},fireUpdate:function(){this.map.fire(et.UPDATE,{action:at.MOVE,features:this.getSelected().map(function(g){return g.toGeoJSON()})})},fireActionable:function(){var g=this,I=this.getSelected(),O=I.filter(function(Re){return g.isInstanceOf("MultiFeature",Re)}),Y=!1;if(I.length>1){Y=!0;var ne=I[0].type.replace("Multi","");I.forEach(function(Re){Re.type.replace("Multi","")!==ne&&(Y=!1)})}var se=O.length>0,fe=I.length>0;this.setActionableState({combineFeatures:Y,uncombineFeatures:se,trash:fe})},getUniqueIds:function(g){return g.length?g.map(function(I){return I.properties.id}).filter(function(I){return I!==void 0}).reduce(function(I,O){return I.add(O),I},new Ge).values():[]},stopExtendedInteractions:function(g){g.boxSelectElement&&(g.boxSelectElement.parentNode&&g.boxSelectElement.parentNode.removeChild(g.boxSelectElement),g.boxSelectElement=null),this.map.dragPan.enable(),g.boxSelecting=!1,g.canBoxSelect=!1,g.dragMoving=!1,g.canDragMove=!1},onStop:function(){It.enable(this)},onMouseMove:function(g,I){return So(I)&&g.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(g),!0},onMouseOut:function(g){return!g.dragMoving||this.fireUpdate()}};xr.onTap=xr.onClick=function(g,I){return qo(I)?this.clickAnywhere(g,I):ii(nt.VERTEX)(I)?this.clickOnVertex(g,I):So(I)?this.clickOnFeature(g,I):void 0},xr.clickAnywhere=function(g){var I=this,O=this.getSelectedIds();O.length&&(this.clearSelectedFeatures(),O.forEach(function(Y){return I.doRender(Y)})),It.enable(this),this.stopExtendedInteractions(g)},xr.clickOnVertex=function(g,I){this.changeMode(Ne.DIRECT_SELECT,{featureId:I.featureTarget.properties.parent,coordPath:I.featureTarget.properties.coord_path,startPos:I.lngLat}),this.updateUIClasses({mouse:De.MOVE})},xr.startOnActiveFeature=function(g,I){this.stopExtendedInteractions(g),this.map.dragPan.disable(),this.doRender(I.featureTarget.properties.id),g.canDragMove=!0,g.dragMoveLocation=I.lngLat},xr.clickOnFeature=function(g,I){var O=this;It.disable(this),this.stopExtendedInteractions(g);var Y=$n(I),ne=this.getSelectedIds(),se=I.featureTarget.properties.id,fe=this.isSelected(se);if(!Y&&fe&&this.getFeature(se).type!==Le.POINT)return this.changeMode(Ne.DIRECT_SELECT,{featureId:se});fe&&Y?(this.deselect(se),this.updateUIClasses({mouse:De.POINTER}),ne.length===1&&It.enable(this)):!fe&&Y?(this.select(se),this.updateUIClasses({mouse:De.MOVE})):fe||Y||(ne.forEach(function(Re){return O.doRender(Re)}),this.setSelected(se),this.updateUIClasses({mouse:De.MOVE})),this.doRender(se)},xr.onMouseDown=function(g,I){return En(I)?this.startOnActiveFeature(g,I):this.drawConfig.boxSelect&&Vn(I)?this.startBoxSelect(g,I):void 0},xr.startBoxSelect=function(g,I){this.stopExtendedInteractions(g),this.map.dragPan.disable(),g.boxSelectStartLocation=Bt(I.originalEvent,this.map.getContainer()),g.canBoxSelect=!0},xr.onTouchStart=function(g,I){if(En(I))return this.startOnActiveFeature(g,I)},xr.onDrag=function(g,I){return g.canDragMove?this.dragMove(g,I):this.drawConfig.boxSelect&&g.canBoxSelect?this.whileBoxSelect(g,I):void 0},xr.whileBoxSelect=function(g,I){g.boxSelecting=!0,this.updateUIClasses({mouse:De.ADD}),g.boxSelectElement||(g.boxSelectElement=document.createElement("div"),g.boxSelectElement.classList.add(be.BOX_SELECT),this.map.getContainer().appendChild(g.boxSelectElement));var O=Bt(I.originalEvent,this.map.getContainer()),Y=Math.min(g.boxSelectStartLocation.x,O.x),ne=Math.max(g.boxSelectStartLocation.x,O.x),se=Math.min(g.boxSelectStartLocation.y,O.y),fe=Math.max(g.boxSelectStartLocation.y,O.y),Re="translate("+Y+"px, "+se+"px)";g.boxSelectElement.style.transform=Re,g.boxSelectElement.style.WebkitTransform=Re,g.boxSelectElement.style.width=ne-Y+"px",g.boxSelectElement.style.height=fe-se+"px"},xr.dragMove=function(g,I){g.dragMoving=!0,I.originalEvent.stopPropagation();var O={lng:I.lngLat.lng-g.dragMoveLocation.lng,lat:I.lngLat.lat-g.dragMoveLocation.lat};Io(this.getSelected(),O),g.dragMoveLocation=I.lngLat},xr.onTouchEnd=xr.onMouseUp=function(g,I){var O=this;if(g.dragMoving)this.fireUpdate();else if(g.boxSelecting){var Y=[g.boxSelectStartLocation,Bt(I.originalEvent,this.map.getContainer())],ne=this.featuresAt(null,Y,"click"),se=this.getUniqueIds(ne).filter(function(fe){return!O.isSelected(fe)});se.length&&(this.select(se),se.forEach(function(fe){return O.doRender(fe)}),this.updateUIClasses({mouse:De.MOVE}))}this.stopExtendedInteractions(g)},xr.toDisplayFeatures=function(g,I,O){I.properties.active=this.isSelected(I.properties.id)?it.ACTIVE:it.INACTIVE,O(I),this.fireActionable(),I.properties.active===it.ACTIVE&&I.geometry.type!==Le.POINT&&_n(I).forEach(O)},xr.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},xr.onCombineFeatures=function(){var g=this.getSelected();if(!(g.length===0||g.length<2)){for(var I=[],O=[],Y=g[0].type.replace("Multi",""),ne=0;ne1){var fe=this.newFeature({type:Le.FEATURE,properties:O[0].properties,geometry:{type:"Multi"+Y,coordinates:I}});this.addFeature(fe),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([fe.id]),this.map.fire(et.COMBINE_FEATURES,{createdFeatures:[fe.toGeoJSON()],deletedFeatures:O})}this.fireActionable()}},xr.onUncombineFeatures=function(){var g=this,I=this.getSelected();if(I.length!==0){for(var O=[],Y=[],ne=function(fe){var Re=I[fe];g.isInstanceOf("MultiFeature",Re)&&(Re.getFeatures().forEach(function(Ve){g.addFeature(Ve),Ve.properties=Re.properties,O.push(Ve.toGeoJSON()),g.select([Ve.id])}),g.deleteFeature(Re.id,{silent:!0}),Y.push(Re.toGeoJSON()))},se=0;se1&&this.map.fire(et.UNCOMBINE_FEATURES,{createdFeatures:O,deletedFeatures:Y}),this.fireActionable()}};var yi=ii(nt.VERTEX),ta=ii(nt.MIDPOINT),jn={fireUpdate:function(){this.map.fire(et.UPDATE,{action:at.CHANGE_COORDINATES,features:this.getSelected().map(function(g){return g.toGeoJSON()})})},fireActionable:function(g){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:g.selectedCoordPaths.length>0})},startDragging:function(g,I){this.map.dragPan.disable(),g.canDragMove=!0,g.dragMoveLocation=I.lngLat},stopDragging:function(g){this.map.dragPan.enable(),g.dragMoving=!1,g.canDragMove=!1,g.dragMoveLocation=null},onVertex:function(g,I){this.startDragging(g,I);var O=I.featureTarget.properties,Y=g.selectedCoordPaths.indexOf(O.coord_path);$n(I)||Y!==-1?$n(I)&&Y===-1&&g.selectedCoordPaths.push(O.coord_path):g.selectedCoordPaths=[O.coord_path];var ne=this.pathsToCoordinates(g.featureId,g.selectedCoordPaths);this.setSelectedCoordinates(ne)},onMidpoint:function(g,I){this.startDragging(g,I);var O=I.featureTarget.properties;g.feature.addCoordinate(O.coord_path,O.lng,O.lat),this.fireUpdate(),g.selectedCoordPaths=[O.coord_path]},pathsToCoordinates:function(g,I){return I.map(function(O){return{feature_id:g,coord_path:O}})},onFeature:function(g,I){g.selectedCoordPaths.length===0?this.startDragging(g,I):this.stopDragging(g)},dragFeature:function(g,I,O){Io(this.getSelected(),O),g.dragMoveLocation=I.lngLat},dragVertex:function(g,I,O){for(var Y=g.selectedCoordPaths.map(function(Re){return g.feature.getCoordinate(Re)}),ne=To(Y.map(function(Re){return{type:Le.FEATURE,properties:{},geometry:{type:Le.POINT,coordinates:Re}}}),O),se=0;se0?this.dragVertex(g,I,O):this.dragFeature(g,I,O),g.dragMoveLocation=I.lngLat}},jn.onClick=function(g,I){return qo(I)?this.clickNoTarget(g,I):En(I)?this.clickActiveFeature(g,I):Un(I)?this.clickInactive(g,I):void this.stopDragging(g)},jn.onTap=function(g,I){return qo(I)?this.clickNoTarget(g,I):En(I)?this.clickActiveFeature(g,I):Un(I)?this.clickInactive(g,I):void 0},jn.onTouchEnd=jn.onMouseUp=function(g){g.dragMoving&&this.fireUpdate(),this.stopDragging(g)};var ji={};function qr(g,I){return!!g.lngLat&&g.lngLat.lng===I[0]&&g.lngLat.lat===I[1]}ji.onSetup=function(){var g=this.newFeature({type:Le.FEATURE,properties:{},geometry:{type:Le.POINT,coordinates:[]}});return this.addFeature(g),this.clearSelectedFeatures(),this.updateUIClasses({mouse:De.ADD}),this.activateUIButton(Ee.POINT),this.setActionableState({trash:!0}),{point:g}},ji.stopDrawingAndRemove=function(g){this.deleteFeature([g.point.id],{silent:!0}),this.changeMode(Ne.SIMPLE_SELECT)},ji.onTap=ji.onClick=function(g,I){this.updateUIClasses({mouse:De.MOVE}),g.point.updateCoordinate("",I.lngLat.lng,I.lngLat.lat),this.map.fire(et.CREATE,{features:[g.point.toGeoJSON()]}),this.changeMode(Ne.SIMPLE_SELECT,{featureIds:[g.point.id]})},ji.onStop=function(g){this.activateUIButton(),g.point.getCoordinate().length||this.deleteFeature([g.point.id],{silent:!0})},ji.toDisplayFeatures=function(g,I,O){var Y=I.properties.id===g.point.id;if(I.properties.active=Y?it.ACTIVE:it.INACTIVE,!Y)return O(I)},ji.onTrash=ji.stopDrawingAndRemove,ji.onKeyUp=function(g,I){if(qe(I)||mn(I))return this.stopDrawingAndRemove(g,I)};var Go={onSetup:function(){var g=this.newFeature({type:Le.FEATURE,properties:{},geometry:{type:Le.POLYGON,coordinates:[[]]}});return this.addFeature(g),this.clearSelectedFeatures(),It.disable(this),this.updateUIClasses({mouse:De.ADD}),this.activateUIButton(Ee.POLYGON),this.setActionableState({trash:!0}),{polygon:g,currentVertexPosition:0}},clickAnywhere:function(g,I){if(g.currentVertexPosition>0&&qr(I,g.polygon.coordinates[0][g.currentVertexPosition-1]))return this.changeMode(Ne.SIMPLE_SELECT,{featureIds:[g.polygon.id]});this.updateUIClasses({mouse:De.ADD}),g.polygon.updateCoordinate("0."+g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat),g.currentVertexPosition++,g.polygon.updateCoordinate("0."+g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat)},clickOnVertex:function(g){return this.changeMode(Ne.SIMPLE_SELECT,{featureIds:[g.polygon.id]})},onMouseMove:function(g,I){g.polygon.updateCoordinate("0."+g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat),Cn(I)&&this.updateUIClasses({mouse:De.POINTER})}};Go.onTap=Go.onClick=function(g,I){return Cn(I)?this.clickOnVertex(g,I):this.clickAnywhere(g,I)},Go.onKeyUp=function(g,I){qe(I)?(this.deleteFeature([g.polygon.id],{silent:!0}),this.changeMode(Ne.SIMPLE_SELECT)):mn(I)&&this.changeMode(Ne.SIMPLE_SELECT,{featureIds:[g.polygon.id]})},Go.onStop=function(g){this.updateUIClasses({mouse:De.NONE}),It.enable(this),this.activateUIButton(),this.getFeature(g.polygon.id)!==void 0&&(g.polygon.removeCoordinate("0."+g.currentVertexPosition),g.polygon.isValid()?this.map.fire(et.CREATE,{features:[g.polygon.toGeoJSON()]}):(this.deleteFeature([g.polygon.id],{silent:!0}),this.changeMode(Ne.SIMPLE_SELECT,{},{silent:!0})))},Go.toDisplayFeatures=function(g,I,O){var Y=I.properties.id===g.polygon.id;if(I.properties.active=Y?it.ACTIVE:it.INACTIVE,!Y)return O(I);if(I.geometry.coordinates.length!==0){var ne=I.geometry.coordinates[0].length;if(!(ne<3)){if(I.properties.meta=nt.FEATURE,O(Mt(g.polygon.id,I.geometry.coordinates[0][0],"0.0",!1)),ne>3){var se=I.geometry.coordinates[0].length-3;O(Mt(g.polygon.id,I.geometry.coordinates[0][se],"0."+se,!1))}if(ne<=4){var fe=[[I.geometry.coordinates[0][0][0],I.geometry.coordinates[0][0][1]],[I.geometry.coordinates[0][1][0],I.geometry.coordinates[0][1][1]]];if(O({type:Le.FEATURE,properties:I.properties,geometry:{coordinates:fe,type:Le.LINE_STRING}}),ne===3)return}return O(I)}}},Go.onTrash=function(g){this.deleteFeature([g.polygon.id],{silent:!0}),this.changeMode(Ne.SIMPLE_SELECT)};var Ir={onSetup:function(g){var I,O,Y=(g=g||{}).featureId,ne="forward";if(Y){if(!(I=this.getFeature(Y)))throw new Error("Could not find a feature with the provided featureId");var se=g.from;if(se&&se.type==="Feature"&&se.geometry&&se.geometry.type==="Point"&&(se=se.geometry),se&&se.type==="Point"&&se.coordinates&&se.coordinates.length===2&&(se=se.coordinates),!se||!Array.isArray(se))throw new Error("Please use the `from` property to indicate which point to continue the line from");var fe=I.coordinates.length-1;if(I.coordinates[fe][0]===se[0]&&I.coordinates[fe][1]===se[1])O=fe+1,I.addCoordinate.apply(I,[O].concat(I.coordinates[fe]));else{if(I.coordinates[0][0]!==se[0]||I.coordinates[0][1]!==se[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");ne="backwards",O=0,I.addCoordinate.apply(I,[O].concat(I.coordinates[0]))}}else I=this.newFeature({type:Le.FEATURE,properties:{},geometry:{type:Le.LINE_STRING,coordinates:[]}}),O=0,this.addFeature(I);return this.clearSelectedFeatures(),It.disable(this),this.updateUIClasses({mouse:De.ADD}),this.activateUIButton(Ee.LINE),this.setActionableState({trash:!0}),{line:I,currentVertexPosition:O,direction:ne}},clickAnywhere:function(g,I){if(g.currentVertexPosition>0&&qr(I,g.line.coordinates[g.currentVertexPosition-1])||g.direction==="backwards"&&qr(I,g.line.coordinates[g.currentVertexPosition+1]))return this.changeMode(Ne.SIMPLE_SELECT,{featureIds:[g.line.id]});this.updateUIClasses({mouse:De.ADD}),g.line.updateCoordinate(g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat),g.direction==="forward"?(g.currentVertexPosition++,g.line.updateCoordinate(g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat)):g.line.addCoordinate(0,I.lngLat.lng,I.lngLat.lat)},clickOnVertex:function(g){return this.changeMode(Ne.SIMPLE_SELECT,{featureIds:[g.line.id]})},onMouseMove:function(g,I){g.line.updateCoordinate(g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat),Cn(I)&&this.updateUIClasses({mouse:De.POINTER})}};Ir.onTap=Ir.onClick=function(g,I){if(Cn(I))return this.clickOnVertex(g,I);this.clickAnywhere(g,I)},Ir.onKeyUp=function(g,I){mn(I)?this.changeMode(Ne.SIMPLE_SELECT,{featureIds:[g.line.id]}):qe(I)&&(this.deleteFeature([g.line.id],{silent:!0}),this.changeMode(Ne.SIMPLE_SELECT))},Ir.onStop=function(g){It.enable(this),this.activateUIButton(),this.getFeature(g.line.id)!==void 0&&(g.line.removeCoordinate(""+g.currentVertexPosition),g.line.isValid()?this.map.fire(et.CREATE,{features:[g.line.toGeoJSON()]}):(this.deleteFeature([g.line.id],{silent:!0}),this.changeMode(Ne.SIMPLE_SELECT,{},{silent:!0})))},Ir.onTrash=function(g){this.deleteFeature([g.line.id],{silent:!0}),this.changeMode(Ne.SIMPLE_SELECT)},Ir.toDisplayFeatures=function(g,I,O){var Y=I.properties.id===g.line.id;if(I.properties.active=Y?it.ACTIVE:it.INACTIVE,!Y)return O(I);I.geometry.coordinates.length<2||(I.properties.meta=nt.FEATURE,O(Mt(g.line.id,I.geometry.coordinates[g.direction==="forward"?I.geometry.coordinates.length-2:1],""+(g.direction==="forward"?I.geometry.coordinates.length-2:1),!1)),O(I))};var Er={simple_select:xr,direct_select:jn,draw_point:ji,draw_polygon:Go,draw_line_string:Ir},ia={defaultMode:Ne.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Ii,modes:Er,controls:{},userProperties:!1},os={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Gi={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function di(g,I){return g.map(function(O){return O.source?O:Se(O,{id:O.id+"."+I,source:I==="hot"?ge.HOT:ge.COLD})})}var uo={exports:{}};(function(g,I){var O="__lodash_hash_undefined__",Y=9007199254740991,ne="[object Arguments]",se="[object Array]",fe="[object Boolean]",Re="[object Date]",Ve="[object Error]",rt="[object Function]",ot="[object Map]",Je="[object Number]",Rt="[object Object]",Hi="[object Promise]",Ot="[object RegExp]",ar="[object Set]",Pe="[object String]",_t="[object Symbol]",vi="[object WeakMap]",Xi="[object ArrayBuffer]",tr="[object DataView]",nn=/^\[object .+?Constructor\]$/,ra=/^(?:0|[1-9]\d*)$/,Ci={};Ci["[object Float32Array]"]=Ci["[object Float64Array]"]=Ci["[object Int8Array]"]=Ci["[object Int16Array]"]=Ci["[object Int32Array]"]=Ci["[object Uint8Array]"]=Ci["[object Uint8ClampedArray]"]=Ci["[object Uint16Array]"]=Ci["[object Uint32Array]"]=!0,Ci[ne]=Ci[se]=Ci[Xi]=Ci[fe]=Ci[tr]=Ci[Re]=Ci[Ve]=Ci[rt]=Ci[ot]=Ci[Je]=Ci[Rt]=Ci[Ot]=Ci[ar]=Ci[Pe]=Ci[vi]=!1;var ss=typeof kl=="object"&&kl&&kl.Object===Object&&kl,na=typeof self=="object"&&self&&self.Object===Object&&self,on=ss||na||Function("return this")(),ho=I&&!I.nodeType&&I,Kt=ho&&g&&!g.nodeType&&g,Ss=Kt&&Kt.exports===ho,Hr=Ss&&ss.process,sn=function(){try{return Hr&&Hr.binding&&Hr.binding("util")}catch{}}(),oa=sn&&sn.isTypedArray;function sa(de,we){for(var Ye=-1,wt=de==null?0:de.length;++Yelr))return!1;var rr=ni.get(de);if(rr&&ni.get(we))return rr==we;var bi=-1,an=!0,no=2&Ye?new ls:void 0;for(ni.set(de,we),ni.set(we,de);++bi-1},gn.prototype.set=function(de,we){var Ye=this.__data__,wt=cs(Ye,de);return wt<0?(++this.size,Ye.push([de,we])):Ye[wt][1]=we,this},Ao.prototype.clear=function(){this.size=0,this.__data__={hash:new xi,map:new(qn||gn),string:new xi}},Ao.prototype.delete=function(de){var we=ya(this,de).delete(de);return this.size-=we?1:0,we},Ao.prototype.get=function(de){return ya(this,de).get(de)},Ao.prototype.has=function(de){return ya(this,de).has(de)},Ao.prototype.set=function(de,we){var Ye=ya(this,de),wt=Ye.size;return Ye.set(de,we),this.size+=Ye.size==wt?0:1,this},ls.prototype.add=ls.prototype.push=function(de){return this.__data__.set(de,O),this},ls.prototype.has=function(de){return this.__data__.has(de)},Zn.prototype.clear=function(){this.__data__=new gn,this.size=0},Zn.prototype.delete=function(de){var we=this.__data__,Ye=we.delete(de);return this.size=we.size,Ye},Zn.prototype.get=function(de){return this.__data__.get(de)},Zn.prototype.has=function(de){return this.__data__.has(de)},Zn.prototype.set=function(de,we){var Ye=this.__data__;if(Ye instanceof gn){var wt=Ye.__data__;if(!qn||wt.length<199)return wt.push([de,we]),this.size=++Ye.size,this;Ye=this.__data__=new Ao(wt)}return Ye.set(de,we),this.size=Ye.size,this};var va=Ho?function(de){return de==null?[]:(de=Object(de),function(we,Ye){for(var wt=-1,Vi=we==null?0:we.length,ni=0,ir=[];++wt-1&&de%1==0&&de-1&&de%1==0&&de<=Y}function Xr(de){var we=typeof de;return de!=null&&(we=="object"||we=="function")}function ro(de){return de!=null&&typeof de=="object"}var ds=oa?function(de){return function(we){return de(we)}}(oa):function(de){return ro(de)&&zo(de.length)&&!!Ci[ko(de)]};function wa(de){return(we=de)!=null&&zo(we.length)&&!Ji(we)?ma(de):As(de);var we}g.exports=function(de,we){return us(de,we)}})(uo,uo.exports);var Wi=v(uo.exports);function bs(g,I){return g.length===I.length&&JSON.stringify(g.map(function(O){return O}).sort())===JSON.stringify(I.map(function(O){return O}).sort())}var kn={Polygon:Fe,LineString:Oi,Point:fi,MultiPolygon:Gt,MultiLineString:Gt,MultiPoint:Gt},Na=Object.freeze({__proto__:null,CommonSelectors:er,constrainFeatureMovement:To,createMidPoint:Ur,createSupplementaryPoints:_n,createVertex:Mt,doubleClickZoom:It,euclideanDistance:pi,featuresAt:Dt,getFeatureAtAndSetCursors:Lt,isClick:Pi,isEventAtCoordinates:qr,isTap:en,mapEventToBoundingBox:ke,ModeHandler:_,moveFeatures:Io,sortFeatures:At,stringSetsAreEqual:bs,StringSet:Ge,theme:Ii,toDenseArray:Bi}),Eo=function(g,I){var O={options:g=function(ne){ne===void 0&&(ne={});var se=Se(ne);return ne.controls||(se.controls={}),ne.displayControlsDefault===!1?se.controls=Se(Gi,ne.controls):se.controls=Se(os,ne.controls),(se=Se(ia,se)).styles=di(se.styles,"cold").concat(di(se.styles,"hot")),se}(g)};I=function(ne,se){return se.modes=Ne,se.getFeatureIdsAt=function(fe){return Dt.click({point:fe},null,ne).map(function(Re){return Re.properties.id})},se.getSelectedIds=function(){return ne.store.getSelectedIds()},se.getSelected=function(){return{type:Le.FEATURE_COLLECTION,features:ne.store.getSelectedIds().map(function(fe){return ne.store.get(fe)}).map(function(fe){return fe.toGeoJSON()})}},se.getSelectedPoints=function(){return{type:Le.FEATURE_COLLECTION,features:ne.store.getSelectedCoordinates().map(function(fe){return{type:Le.FEATURE,properties:{},geometry:{type:Le.POINT,coordinates:fe.coordinates}}})}},se.set=function(fe){if(fe.type===void 0||fe.type!==Le.FEATURE_COLLECTION||!Array.isArray(fe.features))throw new Error("Invalid FeatureCollection");var Re=ne.store.createRenderBatch(),Ve=ne.store.getAllIds().slice(),rt=se.add(fe),ot=new Ge(rt);return(Ve=Ve.filter(function(Je){return!ot.has(Je)})).length&&se.delete(Ve),Re(),rt},se.add=function(fe){var Re=JSON.parse(JSON.stringify(F(fe))).features.map(function(Ve){if(Ve.id=Ve.id||Ti(),Ve.geometry===null)throw new Error("Invalid geometry: null");if(ne.store.get(Ve.id)===void 0||ne.store.get(Ve.id).type!==Ve.geometry.type){var rt=kn[Ve.geometry.type];if(rt===void 0)throw new Error("Invalid geometry type: "+Ve.geometry.type+".");var ot=new rt(ne,Ve);ne.store.add(ot)}else{var Je=ne.store.get(Ve.id);Je.properties=Ve.properties,Wi(Je.properties,Ve.properties)||ne.store.featureChanged(Je.id),Wi(Je.getCoordinates(),Ve.geometry.coordinates)||Je.incomingCoords(Ve.geometry.coordinates)}return Ve.id});return ne.store.render(),Re},se.get=function(fe){var Re=ne.store.get(fe);if(Re)return Re.toGeoJSON()},se.getAll=function(){return{type:Le.FEATURE_COLLECTION,features:ne.store.getAll().map(function(fe){return fe.toGeoJSON()})}},se.delete=function(fe){return ne.store.delete(fe,{silent:!0}),se.getMode()!==Ne.DIRECT_SELECT||ne.store.getSelectedIds().length?ne.store.render():ne.events.changeMode(Ne.SIMPLE_SELECT,void 0,{silent:!0}),se},se.deleteAll=function(){return ne.store.delete(ne.store.getAllIds(),{silent:!0}),se.getMode()===Ne.DIRECT_SELECT?ne.events.changeMode(Ne.SIMPLE_SELECT,void 0,{silent:!0}):ne.store.render(),se},se.changeMode=function(fe,Re){return Re===void 0&&(Re={}),fe===Ne.SIMPLE_SELECT&&se.getMode()===Ne.SIMPLE_SELECT?(bs(Re.featureIds||[],ne.store.getSelectedIds())||(ne.store.setSelected(Re.featureIds,{silent:!0}),ne.store.render()),se):(fe===Ne.DIRECT_SELECT&&se.getMode()===Ne.DIRECT_SELECT&&Re.featureId===ne.store.getSelectedIds()[0]||ne.events.changeMode(fe,Re,{silent:!0}),se)},se.getMode=function(){return ne.events.getMode()},se.trash=function(){return ne.events.trash({silent:!0}),se},se.combineFeatures=function(){return ne.events.combineFeatures({silent:!0}),se},se.uncombineFeatures=function(){return ne.events.uncombineFeatures({silent:!0}),se},se.setFeatureProperty=function(fe,Re,Ve){return ne.store.setFeatureProperty(fe,Re,Ve),se},se}(O,I),O.api=I;var Y=In(O);return I.onAdd=Y.onAdd,I.onRemove=Y.onRemove,I.types=Ee,I.options=g,I};function ws(g){Eo(g,this)}return ws.modes=Er,ws.constants=Xt,ws.lib=Na,ws})})(sf);var qg=sf.exports;const Da=Yp(qg);function Zg(m){let f,_,v;return{c(){f=Zt("button"),f.textContent="Import current view",vs(f,"type","button")},m(E,k){ci(E,f,k),_||(v=Ks(f,"click",m[0]),_=!0)},p:Ar,i:Ar,o:Ar,d(E){E&&si(f),_=!1,v()}}}function Gg(m){let f='poly:"';for(let[v,E]of m.geometry.coordinates[0])f+=`${E} ${v} `;return f=f.slice(0,-1)+'"',`https://overpass-api.de/api/interpreter?data=${`(nwr(${f}); node(w)->.x; <;); out meta;`}`}function _c(m){return[m.lng,m.lat]}function Wg(m,f,_){let{map:v}=f;const E=Ih();let k=null;Ba(()=>{v!=null&&v.loaded()&&k&&v.removeControl(k)});async function B(V){try{E("loading","Loading from Overpass");let be=await(await fetch(Gg(V))).text();E("gotXml",be)}catch(me){E("error",me.toString())}}function s(){let V=v.getBounds();return{type:"Feature",properties:{},geometry:{coordinates:[[_c(V.getSouthWest()),_c(V.getNorthWest()),_c(V.getNorthEast()),_c(V.getSouthEast()),_c(V.getSouthWest())]],type:"Polygon"}}}async function H(){if(v){if(v.getZoom()<13){E("error","Zoom in more to import");return}await B(s())}}return m.$$set=V=>{"map"in V&&_(1,v=V.map)},m.$$.update=()=>{m.$$.dirty&14&&v&&!k&&(_(2,Da.constants.classes.CONTROL_BASE="maplibregl-ctrl",Da),_(2,Da.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",Da),_(2,Da.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group",Da),_(3,k=new Da({displayControlsDefault:!1,controls:{polygon:!0}})),v.addControl(k),v.on("draw.create",async V=>{let me=V.features[0];k.deleteAll(),await B(me)}))},[H,v,Da,k]}class Hg extends Wr{constructor(f){super(),Gr(this,f,Wg,Zg,Tr,{map:1})}}function Dp(m,f,_){const v=m.slice();return v[1]=f[_][0],v[2]=f[_][1],v}function Fp(m){let f,_,v=m[1]+"",E,k,B=m[2]+"",s;return{c(){f=Zt("tr"),_=Zt("td"),E=sl(v),k=Zt("td"),s=sl(B)},m(H,V){ci(H,f,V),_i(f,_),_i(_,E),_i(f,k),_i(k,s)},p(H,V){V&1&&v!==(v=H[1]+"")&&yh(E,v),V&1&&B!==(B=H[2]+"")&&yh(s,B)},d(H){H&&si(f)}}}function Xg(m){let f,_,v=gp(Object.entries(m[0])),E=[];for(let k=0;k{"properties"in E&&_(0,v=E.properties)},[v]}class zh extends Wr{constructor(f){super(),Gr(this,f,Kg,Xg,Tr,{properties:0})}}const af=["==",["geometry-type"],"Polygon"],lf=["==",["geometry-type"],"LineString"],cf=["==",["geometry-type"],"Point"];function Mc(m,f,_){let v=["match",m];for(let[E,k]of Object.entries(f))v.push(E),v.push(k);return v.push(_),v}let zt;const uf=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&uf.decode();let wc=null;function Ac(){return(wc===null||wc.byteLength===0)&&(wc=new Uint8Array(zt.memory.buffer)),wc}function Hs(m,f){return m=m>>>0,uf.decode(Ac().subarray(m,m+f))}const Xs=new Array(128).fill(void 0);Xs.push(void 0,null,!0,!1);let kc=Xs.length;function Qr(m){kc===Xs.length&&Xs.push(Xs.length+1);const f=kc;return kc=Xs[f],Xs[f]=m,f}function li(m){return Xs[m]}function Jg(m){m<132||(Xs[m]=kc,kc=m)}function mu(m){const f=li(m);return Jg(m),f}function _h(m){return m==null}let Sc=null;function Yg(){return(Sc===null||Sc.byteLength===0)&&(Sc=new Float64Array(zt.memory.buffer)),Sc}let Tc=null;function sr(){return(Tc===null||Tc.byteLength===0)&&(Tc=new Int32Array(zt.memory.buffer)),Tc}let Fa=0;const _u=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Qg=typeof _u.encodeInto=="function"?function(m,f){return _u.encodeInto(m,f)}:function(m,f){const _=_u.encode(m);return f.set(_),{read:m.length,written:_.length}};function du(m,f,_){if(_===void 0){const s=_u.encode(m),H=f(s.length,1)>>>0;return Ac().subarray(H,H+s.length).set(s),Fa=s.length,H}let v=m.length,E=f(v,1)>>>0;const k=Ac();let B=0;for(;B127)break;k[E+B]=s}if(B!==v){B!==0&&(m=m.slice(B)),E=_(E,v,v=B+m.length*3,1)>>>0;const s=Ac().subarray(E+B,E+v),H=Qg(m,s);B+=H.written}return Fa=B,E}function Sh(m){const f=typeof m;if(f=="number"||f=="boolean"||m==null)return`${m}`;if(f=="string")return`"${m}"`;if(f=="symbol"){const E=m.description;return E==null?"Symbol":`Symbol(${E})`}if(f=="function"){const E=m.name;return typeof E=="string"&&E.length>0?`Function(${E})`:"Function"}if(Array.isArray(m)){const E=m.length;let k="[";E>0&&(k+=Sh(m[0]));for(let B=1;B1)v=_[1];else return toString.call(m);if(v=="Object")try{return"Object("+JSON.stringify(m)+")"}catch{return"Object"}return m instanceof Error?`${m.name}: ${m.message} -${m.stack}`:v}function $g(m,f){const _=f(m.length*1,1)>>>0;return Ac().set(m,_/1),Fa=m.length,_}function gh(m,f){try{return m.apply(this,f)}catch(_){zt.__wbindgen_exn_store(Qr(_))}}class vu{static __wrap(f){f=f>>>0;const _=Object.create(vu.prototype);return _.__wbg_ptr=f,_}__destroy_into_raw(){const f=this.__wbg_ptr;return this.__wbg_ptr=0,f}free(){const f=this.__destroy_into_raw();zt.__wbg_jsroutesnapper_free(f)}constructor(f){try{const k=zt.__wbindgen_add_to_stack_pointer(-16),B=$g(f,zt.__wbindgen_malloc),s=Fa;zt.jsroutesnapper_new(k,B,s);var _=sr()[k/4+0],v=sr()[k/4+1],E=sr()[k/4+2];if(E)throw mu(v);return vu.__wrap(_)}finally{zt.__wbindgen_add_to_stack_pointer(16)}}setRouteConfig(f){zt.jsroutesnapper_setRouteConfig(this.__wbg_ptr,Qr(f))}setAreaMode(){zt.jsroutesnapper_setAreaMode(this.__wbg_ptr)}getConfig(){let f,_;try{const k=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_getConfig(k,this.__wbg_ptr);var v=sr()[k/4+0],E=sr()[k/4+1];return f=v,_=E,Hs(v,E)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(f,_,1)}}toFinalFeature(){try{const v=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_toFinalFeature(v,this.__wbg_ptr);var f=sr()[v/4+0],_=sr()[v/4+1];let E;return f!==0&&(E=Hs(f,_).slice(),zt.__wbindgen_free(f,_*1)),E}finally{zt.__wbindgen_add_to_stack_pointer(16)}}renderGeojson(){let f,_;try{const k=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_renderGeojson(k,this.__wbg_ptr);var v=sr()[k/4+0],E=sr()[k/4+1];return f=v,_=E,Hs(v,E)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(f,_,1)}}toggleSnapMode(){zt.jsroutesnapper_toggleSnapMode(this.__wbg_ptr)}onMouseMove(f,_,v){return zt.jsroutesnapper_onMouseMove(this.__wbg_ptr,f,_,v)!==0}onClick(){zt.jsroutesnapper_onClick(this.__wbg_ptr)}onDragStart(){return zt.jsroutesnapper_onDragStart(this.__wbg_ptr)!==0}onMouseUp(){return zt.jsroutesnapper_onMouseUp(this.__wbg_ptr)!==0}clearState(){zt.jsroutesnapper_clearState(this.__wbg_ptr)}editExisting(f){try{const E=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_editExisting(E,this.__wbg_ptr,Qr(f));var _=sr()[E/4+0],v=sr()[E/4+1];if(v)throw mu(_)}finally{zt.__wbindgen_add_to_stack_pointer(16)}}debugRenderGraph(){let f,_;try{const k=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_debugRenderGraph(k,this.__wbg_ptr);var v=sr()[k/4+0],E=sr()[k/4+1];return f=v,_=E,Hs(v,E)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(f,_,1)}}routeNameForWaypoints(f){let _,v;try{const me=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_routeNameForWaypoints(me,this.__wbg_ptr,Qr(f));var E=sr()[me/4+0],k=sr()[me/4+1],B=sr()[me/4+2],s=sr()[me/4+3],H=E,V=k;if(s)throw H=0,V=0,mu(B);return _=H,v=V,Hs(H,V)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(_,v,1)}}addSnappedWaypoint(f,_){zt.jsroutesnapper_addSnappedWaypoint(this.__wbg_ptr,f,_)}undo(){zt.jsroutesnapper_undo(this.__wbg_ptr)}}async function ey(m,f){if(typeof Response=="function"&&m instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(m,f)}catch(v){if(m.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",v);else throw v}const _=await m.arrayBuffer();return await WebAssembly.instantiate(_,f)}else{const _=await WebAssembly.instantiate(m,f);return _ instanceof WebAssembly.Instance?{instance:_,module:m}:_}}function ty(){const m={};return m.wbg={},m.wbg.__wbindgen_string_new=function(f,_){const v=Hs(f,_);return Qr(v)},m.wbg.__wbindgen_object_drop_ref=function(f){mu(f)},m.wbg.__wbindgen_error_new=function(f,_){const v=new Error(Hs(f,_));return Qr(v)},m.wbg.__wbindgen_is_object=function(f){const _=li(f);return typeof _=="object"&&_!==null},m.wbg.__wbindgen_is_undefined=function(f){return li(f)===void 0},m.wbg.__wbindgen_in=function(f,_){return li(f)in li(_)},m.wbg.__wbindgen_boolean_get=function(f){const _=li(f);return typeof _=="boolean"?_?1:0:2},m.wbg.__wbindgen_number_get=function(f,_){const v=li(_),E=typeof v=="number"?v:void 0;Yg()[f/8+1]=_h(E)?0:E,sr()[f/4+0]=!_h(E)},m.wbg.__wbindgen_object_clone_ref=function(f){const _=li(f);return Qr(_)},m.wbg.__wbindgen_jsval_loose_eq=function(f,_){return li(f)==li(_)},m.wbg.__wbindgen_string_get=function(f,_){const v=li(_),E=typeof v=="string"?v:void 0;var k=_h(E)?0:du(E,zt.__wbindgen_malloc,zt.__wbindgen_realloc),B=Fa;sr()[f/4+1]=B,sr()[f/4+0]=k},m.wbg.__wbg_String_4370c5505c674d30=function(f,_){const v=String(li(_)),E=du(v,zt.__wbindgen_malloc,zt.__wbindgen_realloc),k=Fa;sr()[f/4+1]=k,sr()[f/4+0]=E},m.wbg.__wbg_getwithrefkey_d1f0d12f1f1b63ea=function(f,_){const v=li(f)[li(_)];return Qr(v)},m.wbg.__wbg_new_abda76e883ba8a5f=function(){const f=new Error;return Qr(f)},m.wbg.__wbg_stack_658279fe44541cf6=function(f,_){const v=li(_).stack,E=du(v,zt.__wbindgen_malloc,zt.__wbindgen_realloc),k=Fa;sr()[f/4+1]=k,sr()[f/4+0]=E},m.wbg.__wbg_error_f851667af71bcfc6=function(f,_){let v,E;try{v=f,E=_,console.error(Hs(f,_))}finally{zt.__wbindgen_free(v,E,1)}},m.wbg.__wbg_debug_9a6b3243fbbebb61=function(f){console.debug(li(f))},m.wbg.__wbg_error_788ae33f81d3b84b=function(f){console.error(li(f))},m.wbg.__wbg_info_2e30e8204b29d91d=function(f){console.info(li(f))},m.wbg.__wbg_log_1d3ae0273d8f4f8a=function(f){console.log(li(f))},m.wbg.__wbg_warn_d60e832f9882c1b2=function(f){console.warn(li(f))},m.wbg.__wbg_get_44be0491f933a435=function(f,_){const v=li(f)[_>>>0];return Qr(v)},m.wbg.__wbg_length_fff51ee6522a1a18=function(f){return li(f).length},m.wbg.__wbindgen_is_function=function(f){return typeof li(f)=="function"},m.wbg.__wbg_next_526fc47e980da008=function(f){const _=li(f).next;return Qr(_)},m.wbg.__wbg_next_ddb3312ca1c4e32a=function(){return gh(function(f){const _=li(f).next();return Qr(_)},arguments)},m.wbg.__wbg_done_5c1f01fb660d73b5=function(f){return li(f).done},m.wbg.__wbg_value_1695675138684bd5=function(f){const _=li(f).value;return Qr(_)},m.wbg.__wbg_iterator_97f0c81209c6c35a=function(){return Qr(Symbol.iterator)},m.wbg.__wbg_get_97b561fb56f034b5=function(){return gh(function(f,_){const v=Reflect.get(li(f),li(_));return Qr(v)},arguments)},m.wbg.__wbg_call_cb65541d95d71282=function(){return gh(function(f,_){const v=li(f).call(li(_));return Qr(v)},arguments)},m.wbg.__wbg_isArray_4c24b343cb13cfb1=function(f){return Array.isArray(li(f))},m.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb=function(f){let _;try{_=li(f)instanceof ArrayBuffer}catch{_=!1}return _},m.wbg.__wbg_buffer_085ec1f694018c4f=function(f){const _=li(f).buffer;return Qr(_)},m.wbg.__wbg_new_8125e318e6245eed=function(f){const _=new Uint8Array(li(f));return Qr(_)},m.wbg.__wbg_set_5cf90238115182c3=function(f,_,v){li(f).set(li(_),v>>>0)},m.wbg.__wbg_length_72e2208bbc0efc61=function(f){return li(f).length},m.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4=function(f){let _;try{_=li(f)instanceof Uint8Array}catch{_=!1}return _},m.wbg.__wbindgen_debug_string=function(f,_){const v=Sh(li(_)),E=du(v,zt.__wbindgen_malloc,zt.__wbindgen_realloc),k=Fa;sr()[f/4+1]=k,sr()[f/4+0]=E},m.wbg.__wbindgen_throw=function(f,_){throw new Error(Hs(f,_))},m.wbg.__wbindgen_memory=function(){const f=zt.memory;return Qr(f)},m}function iy(m,f){return zt=m.exports,hf.__wbindgen_wasm_module=f,Sc=null,Tc=null,wc=null,zt}async function hf(m){if(zt!==void 0)return zt;typeof m>"u"&&(m="/ltn/assets/route_snapper_bg.wasm");const f=ty();(typeof m=="string"||typeof Request=="function"&&m instanceof Request||typeof URL=="function"&&m instanceof URL)&&(m=fetch(m));const{instance:_,module:v}=await ey(await m,f);return iy(_,v)}const df=bo({type:"FeatureCollection",features:[]}),ry=bo(!0),ny=bo(0),oy=30;class sy{constructor(f,_){Nn(this,"map");Nn(this,"inner");Nn(this,"active");Nn(this,"eventListenersSuccess");Nn(this,"eventListenersUpdated");Nn(this,"eventListenersFailure");Nn(this,"onMouseMove",f=>{if(!this.active)return;const _=[f.point.x-oy,f.point.y],v=this.map.unproject(f.point).distanceTo(this.map.unproject(_));this.inner.onMouseMove(f.lngLat.lng,f.lngLat.lat,v)&&(this.redraw(),this.dataUpdated())});Nn(this,"onClick",()=>{this.active&&(this.inner.onClick(),this.redraw(),this.dataUpdated())});Nn(this,"onDoubleClick",f=>{this.active&&(f.preventDefault(),this.inner.onClick(),this.finish())});Nn(this,"onDragStart",()=>{this.active&&this.inner.onDragStart()&&this.map.dragPan.disable()});Nn(this,"onMouseUp",()=>{this.active&&this.inner.onMouseUp()&&this.map.dragPan.enable()});Nn(this,"onKeyDown",f=>{this.active&&f.key=="Escape"&&(f.stopPropagation(),this.cancel())});Nn(this,"onKeyPress",f=>{this.active&&f.target.tagName!="INPUT"&&(f.key=="Enter"?(f.stopPropagation(),this.finish()):f.key=="s"?(f.stopPropagation(),this.inner.toggleSnapMode(),this.redraw()):f.key=="z"&&f.ctrlKey&&this.undo())});this.map=f,console.time("Deserialize and setup JsRouteSnapper"),this.inner=new vu(_),console.timeEnd("Deserialize and setup JsRouteSnapper"),this.active=!1,this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[],this.map.on("mousemove",this.onMouseMove),this.map.on("click",this.onClick),this.map.on("dblclick",this.onDoubleClick),this.map.on("dragstart",this.onDragStart),this.map.on("mouseup",this.onMouseUp),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keypress",this.onKeyPress)}tearDown(){this.map.off("mousemove",this.onMouseMove),this.map.off("click",this.onClick),this.map.off("dblclick",this.onDoubleClick),this.map.off("dragstart",this.onDragStart),this.map.off("mouseup",this.onMouseUp),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keypress",this.onKeyPress)}startRoute(){this.active||(this.active=!0,this.map.boxZoom.disable(),this.map.doubleClickZoom.disable())}startArea(){this.active||(this.inner.setAreaMode(),this.active=!0,this.map.boxZoom.disable(),this.map.doubleClickZoom.disable())}stop(){this.active=!1,this.inner.clearState(),this.redraw(),this.map.boxZoom.enable(),this.map.doubleClickZoom.enable()}editExistingRoute(f){this.active&&window.alert("Bug: editExistingRoute called when tool is already active"),f.properties.waypoints||(f.properties.waypoints=[{lon:f.geometry.coordinates[0][0],lat:f.geometry.coordinates[0][1],snapped:!0},{lon:f.geometry.coordinates[f.geometry.coordinates.length-1][0],lat:f.geometry.coordinates[f.geometry.coordinates.length-1][1],snapped:!0}]),this.startRoute(),this.inner.editExisting(f.properties.waypoints),this.redraw()}editExistingArea(f){this.active&&window.alert("Bug: editExistingArea called when tool is already active"),f.properties.waypoints||window.alert("Bug: editExistingArea called for a polygon not produced by the route-snapper"),this.startArea(),this.inner.editExisting(f.properties.waypoints),this.redraw()}addEventListenerSuccess(f){this.eventListenersSuccess.push(f)}addEventListenerUpdated(f){this.eventListenersUpdated.push(f)}addEventListenerFailure(f){this.eventListenersFailure.push(f)}clearEventListeners(){this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[]}isActive(){return this.active}finish(){let f=this.inner.toFinalFeature();if(f)for(let _ of this.eventListenersSuccess)_(JSON.parse(f));else for(let _ of this.eventListenersFailure)_();this.stop()}cancel(){this.inner.clearState(),this.finish()}setRouteConfig(f){this.inner.setRouteConfig(f),this.redraw()}addSnappedWaypoint(f){this.inner.addSnappedWaypoint(f[0],f[1]),this.redraw()}undo(){this.inner.undo(),this.redraw()}redraw(){let f=JSON.parse(this.inner.renderGeojson());df.set(f),this.map.getCanvas().style.cursor=f.cursor,ry.set(f.snap_mode),ny.set(f.undo_length)}dataUpdated(){let f=this.inner.toFinalFeature();if(f)for(let _ of this.eventListenersUpdated)_(JSON.parse(f))}}function ay(m){let f,_,v,E,k,B;return f=new ef({props:{filter:cf,paint:{"circle-color":Mc(["get","type"],{"snapped-waypoint":"red","free-waypoint":"blue"},"black"),"circle-opacity":["case",["has","hovered"],.5,1],"circle-radius":Mc(["get","type"],{node:Rp/2},Rp)}}}),v=new Ah({props:{filter:lf,paint:{"line-color":["case",["get","snapped"],"red","blue"],"line-width":2.5}}}),k=new tf({props:{filter:af,paint:{"fill-color":"black","fill-opacity":.5}}}),{c(){Ri(f.$$.fragment),_=fn(),Ri(v.$$.fragment),E=fn(),Ri(k.$$.fragment)},m(s,H){Ai(f,s,H),ci(s,_,H),Ai(v,s,H),ci(s,E,H),Ai(k,s,H),B=!0},p:Ar,i(s){B||(ft(f.$$.fragment,s),ft(v.$$.fragment,s),ft(k.$$.fragment,s),B=!0)},o(s){St(f.$$.fragment,s),St(v.$$.fragment,s),St(k.$$.fragment,s),B=!1},d(s){s&&(si(_),si(E)),ki(f,s),ki(v,s),ki(k,s)}}}function ly(m){let f,_;return f=new Mh({props:{data:m[0],$$slots:{default:[ay]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,[E]){const k={};E&1&&(k.data=v[0]),E&2&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}const Rp=10;function cy(m,f,_){let v;return $r(m,df,E=>_(0,v=E)),[v]}class uy extends Wr{constructor(f){super(),Gr(this,f,cy,ly,Tr,{})}}function hy(m){let f,_,v,E,k,B,s,H,V,me,be,ge,De,Ee,Le,Ne,et,at,nt,it,Vt,ti,Xt,Nt,Yt,At,ke,Ge,Ui;return f=new jg({props:{msg:m[2]}}),At=new Hg({props:{map:m[0]}}),At.$on("gotXml",m[5]),At.$on("loading",m[9]),At.$on("error",m[10]),{c(){Ri(f.$$.fragment),_=fn(),v=Zt("div"),E=Zt("div"),k=Zt("label"),B=sl(`Load an osm.xml or a .pbf file: - `),s=Zt("input"),H=fn(),V=Zt("div"),me=Zt("label"),be=sl(`Or load an example: - `),ge=Zt("select"),De=Zt("option"),De.textContent="Custom file loaded",Ee=Zt("option"),Ee.textContent="Akihabara",Le=Zt("option"),Le.textContent="Hanegi Park",Ne=Zt("option"),Ne.textContent="Harujuku",et=Zt("option"),et.textContent="Taipei main station",at=Zt("option"),at.textContent="Ximending",nt=Zt("option"),nt.textContent="Hong Kong",it=Zt("option"),it.textContent="Kowloon",Vt=Zt("option"),Vt.textContent="Bristol",ti=Zt("option"),ti.textContent="Elephant & Castle",Xt=Zt("option"),Xt.textContent="Westminster",Nt=Zt("option"),Nt.textContent="Montlake",Yt=fn(),Ri(At.$$.fragment),vs(s,"type","file"),De.__value="",Uo(De,De.__value),Ee.__value="akihabara",Uo(Ee,Ee.__value),Le.__value="hanegi",Uo(Le,Le.__value),Ne.__value="harujuku",Uo(Ne,Ne.__value),et.__value="taipei_main_station",Uo(et,et.__value),at.__value="ximending",Uo(at,at.__value),nt.__value="hong_kong",Uo(nt,nt.__value),it.__value="kowloon",Uo(it,it.__value),Vt.__value="bristol",Uo(Vt,Vt.__value),ti.__value="elephant_castle",Uo(ti,ti.__value),Xt.__value="westminster",Uo(Xt,Xt.__value),Nt.__value="montlake",Uo(Nt,Nt.__value),m[1]===void 0&&gu(()=>m[8].call(ge)),Ic(v,"border","1px solid black"),Ic(v,"padding","8px")},m(Dt,qt){Ai(f,Dt,qt),ci(Dt,_,qt),ci(Dt,v,qt),_i(v,E),_i(E,k),_i(k,B),_i(k,s),m[7](s),_i(v,H),_i(v,V),_i(V,me),_i(me,be),_i(me,ge),_i(ge,De),_i(ge,Ee),_i(ge,Le),_i(ge,Ne),_i(ge,et),_i(ge,at),_i(ge,nt),_i(ge,it),_i(ge,Vt),_i(ge,ti),_i(ge,Xt),_i(ge,Nt),mp(ge,m[1],!0),_i(v,Yt),Ai(At,v,null),ke=!0,Ge||(Ui=[Ks(s,"change",m[4]),Ks(ge,"change",m[8])],Ge=!0)},p(Dt,[qt]){const Lt={};qt&4&&(Lt.msg=Dt[2]),f.$set(Lt),qt&2&&mp(ge,Dt[1]);const pi={};qt&1&&(pi.map=Dt[0]),At.$set(pi)},i(Dt){ke||(ft(f.$$.fragment,Dt),ft(At.$$.fragment,Dt),ke=!0)},o(Dt){St(f.$$.fragment,Dt),St(At.$$.fragment,Dt),ke=!1},d(Dt){Dt&&(si(_),si(v)),ki(f,Dt),m[7](null),ki(At),Ge=!1,Ra(Ui)}}}function dy(m,f,_){let{app:v=void 0}=f,{map:E}=f,k="",B=null,s=!1;jp(async()=>{await Kp(),await hf();try{s=(await fetch("/kowloon.pbf",{method:"HEAD"})).ok,console.log("Using local cache, not od2net.org"),ge("bristol")}catch{}});let H;async function V(at){try{me(await H.files[0].arrayBuffer()),_(1,k="")}catch(nt){window.alert(`Couldn't open this file: ${nt}`)}_(2,B=null)}function me(at){_(2,B="Building map model from OSM input"),console.time("load"),_(6,v=new k_(new Uint8Array(at))),console.timeEnd("load")}function be(at){try{me(new TextEncoder().encode(at.detail)),_(1,k="")}catch(nt){window.alert(`Couldn't import from Overpass: ${nt}`)}_(2,B=null)}async function ge(at){at!=""&&(s?await De(`/${at}.pbf`):await De(`https://assets.od2net.org/severance_pbfs/${at}.pbf`))}async function De(at){try{_(2,B=`Downloading ${at}`);let nt=await fetch(at);me(await nt.arrayBuffer())}catch(nt){window.alert(`Couldn't open from URL ${at}: ${nt}`)}_(2,B=null)}function Ee(at){ea[at?"unshift":"push"](()=>{H=at,_(3,H)})}function Le(){k=__(this),_(1,k)}const Ne=at=>_(2,B=at.detail),et=at=>window.alert(at.detail);return m.$$set=at=>{"app"in at&&_(6,v=at.app),"map"in at&&_(0,E=at.map)},m.$$.update=()=>{m.$$.dirty&2&&ge(k)},[E,k,B,H,V,be,v,Ee,Le,Ne,et]}class py extends Wr{constructor(f){super(),Gr(this,f,dy,hy,Tr,{app:6,map:0})}}function fy(m){let f,_;return f=new zh({props:{properties:m[11].properties}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&2048&&(k.properties=v[11].properties),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function my(m){let f,_;return f=new Ph({props:{openOn:"hover",$$slots:{default:[fy,({data:v})=>({11:v}),({data:v})=>v?2048:0]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&6144&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function _y(m){let f,_;return f=new zh({props:{properties:m[11].properties}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&2048&&(k.properties=v[11].properties),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function gy(m){let f,_;return f=new Ph({props:{openOn:"hover",$$slots:{default:[_y,({data:v})=>({11:v}),({data:v})=>v?2048:0]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&6144&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function yy(m){let f,_,v,E,k,B;return f=new Ah({props:{filter:lf,paint:{"line-width":5,"line-color":Mc(["get","kind"],{interior_road:["interpolate-hcl",["linear"],["get","shortcuts"],0,"#F19A93",m[1],"#A32015"],crosses:"blue"},"red")},hoverCursor:"pointer",$$slots:{default:[my]},$$scope:{ctx:m}}}),f.$on("click",m[6]),v=new ef({props:{filter:cf,paint:{"circle-radius":15,"circle-color":Mc(["get","kind"],{border_intersection:"green",modal_filter:"white"},"red")},$$slots:{default:[gy]},$$scope:{ctx:m}}}),k=new tf({props:{beforeId:"Building",filter:af,manageHoverState:!0,paint:{"fill-color":["get","color"],"fill-opacity":q_(.6,1)}}}),{c(){Ri(f.$$.fragment),_=fn(),Ri(v.$$.fragment),E=fn(),Ri(k.$$.fragment)},m(s,H){Ai(f,s,H),ci(s,_,H),Ai(v,s,H),ci(s,E,H),Ai(k,s,H),B=!0},p(s,H){const V={};H&2&&(V.paint={"line-width":5,"line-color":Mc(["get","kind"],{interior_road:["interpolate-hcl",["linear"],["get","shortcuts"],0,"#F19A93",s[1],"#A32015"],crosses:"blue"},"red")}),H&4096&&(V.$$scope={dirty:H,ctx:s}),f.$set(V);const me={};H&4096&&(me.$$scope={dirty:H,ctx:s}),v.$set(me)},i(s){B||(ft(f.$$.fragment,s),ft(v.$$.fragment,s),ft(k.$$.fragment,s),B=!0)},o(s){St(f.$$.fragment,s),St(v.$$.fragment,s),St(k.$$.fragment,s),B=!1},d(s){s&&(si(_),si(E)),ki(f,s),ki(v,s),ki(k,s)}}}function vy(m){let f,_;return f=new Mh({props:{data:m[0],generateId:!0,$$slots:{default:[yy]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,[E]){const k={};E&1&&(k.data=v[0]),E&4098&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function xy(m,f,_){let{map:v}=f,{app:E}=f,{boundary:k}=f,{addingFilter:B=!1}=f,s=["#8dd3c7","#ffffb3","#bebada","#80b1d3","#fdb462","#b3de69","#fccde5","#bc80bd","#ccebc5","#ffed6f"],H,V;me(JSON.parse(E.analyzeNeighbourhood(k)));function me(Ee){_(1,V=Math.max(...Ee.features.map(Le=>Le.properties.shortcuts??0)));for(let Le of Ee.features)Le.properties.color=="disconnected"?Le.properties.color="red":Object.hasOwn(Le.properties,"color")&&(Le.properties.color=s[Le.properties.color%s.length]);_(0,H=Ee)}Ba(()=>{ge(),E.unsetNeighbourhood()});function be(Ee){me(JSON.parse(E.addModalFilter(Ee.lngLat))),ge()}function ge(){_(3,B=!1),v.off("click",be),_(2,v.style.cursor="inherit",v)}const De=Ee=>window.open(Ee.detail.features[0].properties.way,"_blank");return m.$$set=Ee=>{"map"in Ee&&_(2,v=Ee.map),"app"in Ee&&_(4,E=Ee.app),"boundary"in Ee&&_(5,k=Ee.boundary),"addingFilter"in Ee&&_(3,B=Ee.addingFilter)},m.$$.update=()=>{m.$$.dirty&12&&B&&(v.on("click",be),_(2,v.style.cursor="crosshair",v))},[H,V,v,B,E,k,De]}class by extends Wr{constructor(f){super(),Gr(this,f,xy,vy,Tr,{map:2,app:4,boundary:5,addingFilter:3})}}function wy(m){let f,_;return f=new zh({props:{properties:m[2].properties}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&4&&(k.properties=v[2].properties),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Sy(m){let f,_;return f=new Ph({props:{openOn:"hover",$$slots:{default:[wy,({data:v})=>({2:v}),({data:v})=>v?4:0]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&12&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Ty(m){let f,_;return f=new Ah({props:{id:"network",paint:{"line-width":5,"line-color":"black"},hoverCursor:"pointer",$$slots:{default:[Sy]},$$scope:{ctx:m}}}),f.$on("click",m[1]),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&8&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Iy(m){let f,_;return f=new Mh({props:{data:JSON.parse(m[0].render()),$$slots:{default:[Ty]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,[E]){const k={};E&1&&(k.data=JSON.parse(v[0].render())),E&8&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Ey(m,f,_){let{app:v}=f;const E=k=>window.open(k.detail.features[0].properties.way,"_blank");return m.$$set=k=>{"app"in k&&_(0,v=k.app)},[v,E]}class Cy extends Wr{constructor(f){super(),Gr(this,f,Ey,Iy,Tr,{app:0})}}function Op(m){let f,_,v;function E(B){m[8](B)}let k={map:m[2]};return m[0]!==void 0&&(k.app=m[0]),f=new py({props:k}),ea.push(()=>Dc(f,"app",E)),{c(){Ri(f.$$.fragment)},m(B,s){Ai(f,B,s),v=!0},p(B,s){const H={};s&4&&(H.map=B[2]),!_&&s&1&&(_=!0,H.app=B[0],Lc(()=>_=!1)),f.$set(H)},i(B){v||(ft(f.$$.fragment,B),v=!0)},o(B){St(f.$$.fragment,B),v=!1},d(B){ki(f,B)}}}function My(m){let f,_,v,E,k,B,s,H,V,me,be,ge;return{c(){f=Zt("div"),_=Zt("button"),_.textContent="Reset",v=fn(),E=Zt("div"),k=Zt("button"),k.textContent="Edit boundary",B=fn(),s=Zt("div"),H=Zt("button"),H.textContent="Add a modal filter",V=fn(),me=Zt("p"),me.textContent="Analyze and edit now"},m(De,Ee){ci(De,f,Ee),_i(f,_),ci(De,v,Ee),ci(De,E,Ee),_i(E,k),ci(De,B,Ee),ci(De,s,Ee),_i(s,H),ci(De,V,Ee),ci(De,me,Ee),be||(ge=[Ks(_,"click",m[6]),Ks(k,"click",m[4]),Ks(H,"click",m[9])],be=!0)},p:Ar,d(De){De&&(si(f),si(v),si(E),si(B),si(s),si(V),si(me)),be=!1,Ra(ge)}}}function Ay(m){let f;return{c(){f=Zt("p"),f.textContent="Draw the boundary..."},m(_,v){ci(_,f,v)},p:Ar,d(_){_&&si(f)}}}function ky(m){let f,_,v,E,k,B,s;return{c(){f=Zt("div"),_=Zt("button"),_.textContent="Set boundary",v=fn(),E=Zt("div"),k=Zt("button"),k.textContent="Quickset boundary (dev)"},m(H,V){ci(H,f,V),_i(f,_),ci(H,v,V),ci(H,E,V),_i(E,k),B||(s=[Ks(_,"click",m[4]),Ks(k,"click",m[5])],B=!0)},p:Ar,d(H){H&&(si(f),si(v),si(E)),B=!1,Ra(s)}}}function Py(m){let f,_,v,E,k,B,s,H,V=m[2]&&Op(m);function me(De,Ee){if(De[1].mode=="network"&&De[0])return ky;if(De[1].mode=="set-boundary")return Ay;if(De[1].mode=="neighbourhood")return My}let be=me(m),ge=be&&be(m);return{c(){f=Zt("div"),V&&V.c(),_=fn(),v=Zt("div"),E=Zt("button"),E.textContent="Zoom to fit",k=fn(),ge&&ge.c(),vs(f,"slot","left")},m(De,Ee){ci(De,f,Ee),V&&V.m(f,null),_i(f,_),_i(f,v),_i(v,E),_i(f,k),ge&&ge.m(f,null),B=!0,s||(H=Ks(E,"click",m[3]),s=!0)},p(De,Ee){De[2]?V?(V.p(De,Ee),Ee&4&&ft(V,1)):(V=Op(De),V.c(),ft(V,1),V.m(f,_)):V&&(rs(),St(V,1,1,()=>{V=null}),ns()),be===(be=me(De))&&ge?ge.p(De,Ee):(ge&&ge.d(1),ge=be&&be(De),ge&&(ge.c(),ge.m(f,null)))},i(De){B||(ft(V),B=!0)},o(De){St(V),B=!1},d(De){De&&si(f),V&&V.d(),ge&&ge.d(),s=!1,H()}}}function Bp(m){let f,_,v,E;const k=[Dy,Ly,zy],B=[];function s(H,V){return H[1].mode=="network"?0:H[1].mode=="set-boundary"?1:H[1].mode=="neighbourhood"?2:-1}return~(f=s(m))&&(_=B[f]=k[f](m)),{c(){_&&_.c(),v=Oa()},m(H,V){~f&&B[f].m(H,V),ci(H,v,V),E=!0},p(H,V){let me=f;f=s(H),f===me?~f&&B[f].p(H,V):(_&&(rs(),St(B[me],1,1,()=>{B[me]=null}),ns()),~f?(_=B[f],_?_.p(H,V):(_=B[f]=k[f](H),_.c()),ft(_,1),_.m(v.parentNode,v)):_=null)},i(H){E||(ft(_),E=!0)},o(H){St(_),E=!1},d(H){H&&si(v),~f&&B[f].d(H)}}}function zy(m){let f,_;return f=new by({props:{map:m[2],app:m[0],boundary:m[1].boundary,addingFilter:m[1].addingFilter}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&4&&(k.map=v[2]),E&1&&(k.app=v[0]),E&2&&(k.boundary=v[1].boundary),E&2&&(k.addingFilter=v[1].addingFilter),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Ly(m){let f,_;return f=new uy({}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p:Ar,i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Dy(m){let f,_;return f=new Cy({props:{app:m[0]}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&1&&(k.app=v[0]),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Fy(m){let f,_,v=m[0]&&Bp(m);return{c(){v&&v.c(),f=Oa()},m(E,k){v&&v.m(E,k),ci(E,f,k),_=!0},p(E,k){E[0]?v?(v.p(E,k),k&1&&ft(v,1)):(v=Bp(E),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(E)}}}function Ry(m){let f,_,v,E;function k(s){m[7](s)}let B={style:"https://api.maptiler.com/maps/dataviz/style.json?key=MZEJTanw3WpxRvt7qDfo",standardControls:!0,hash:!0,$$slots:{default:[Fy]},$$scope:{ctx:m}};return m[2]!==void 0&&(B.map=m[2]),_=new bg({props:B}),ea.push(()=>Dc(_,"map",k)),{c(){f=Zt("div"),Ri(_.$$.fragment),vs(f,"slot","main"),Ic(f,"position","relative"),Ic(f,"width","100%"),Ic(f,"height","100vh")},m(s,H){ci(s,f,H),Ai(_,f,null),E=!0},p(s,H){const V={};H&4103&&(V.$$scope={dirty:H,ctx:s}),!v&&H&4&&(v=!0,V.map=s[2],Lc(()=>v=!1)),_.$set(V)},i(s){E||(ft(_.$$.fragment,s),E=!0)},o(s){St(_.$$.fragment,s),E=!1},d(s){s&&si(f),ki(_)}}}function Oy(m){let f,_;return f=new Ng({props:{$$slots:{main:[Ry],left:[Py]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,[E]){const k={};E&4103&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function By(m,f,_){let v={mode:"network"},E,k,B;function s(){if(B&&E){let Le=bh(JSON.parse(E.render()));B.fitBounds(Le,{animate:!1})}}function H(Le){E&&(console.log("New map model loaded"),s(),_(1,v={mode:"network"}),k=new sy(B,E.toRouteSnapper()))}function V(){v.mode=="network"?k.startArea():v.mode=="neighbourhood"&&k.editExistingArea(v.boundary),_(1,v={mode:"set-boundary"}),k.addEventListenerSuccess(Le=>{_(1,v={mode:"neighbourhood",boundary:Le,addingFilter:!1}),k.clearEventListeners()}),k.addEventListenerFailure(()=>{_(1,v={mode:"network"}),k.clearEventListeners()})}function me(){_(1,v={mode:"neighbourhood",boundary:{geometry:{coordinates:[[[-2.582766,51.455751],[-2.582715,51.455655],[-2.582477,51.455207],[-2.582446,51.455157],[-2.582409,51.455129],[-2.582334,51.455111],[-2.58226,51.455115],[-2.582174,51.455113],[-2.582115,51.455126],[-2.581976,51.454882],[-2.581812,51.454602],[-2.582181,51.454505],[-2.582091,51.454224],[-2.582071,51.454159],[-2.582042,51.454073],[-2.581915,51.453674],[-2.581972,51.453287],[-2.581714,51.45322],[-2.58169,51.453214],[-2.581866,51.452966],[-2.581588,51.45288],[-2.581521,51.45281],[-2.581584,51.452731],[-2.581401,51.452671],[-2.581103,51.452566],[-2.579862,51.452092],[-2.579808,51.452069],[-2.579753,51.452045],[-2.579074,51.451752],[-2.578228,51.45135],[-2.578131,51.451293],[-2.578066,51.451251],[-2.577641,51.450924],[-2.577504,51.450818],[-2.577228,51.450628],[-2.576815,51.450348],[-2.576749,51.450294],[-2.576487,51.450084],[-2.57599,51.449653],[-2.575886,51.449685],[-2.575807,51.449709],[-2.575324,51.44978],[-2.574139,51.449954],[-2.573887,51.450007],[-2.573699,51.450097],[-2.573534,51.450262],[-2.573415,51.450398],[-2.573305,51.45055],[-2.573286,51.450604],[-2.573279,51.450637],[-2.573275,51.45066],[-2.57327,51.450705],[-2.573278,51.450761],[-2.573366,51.451076],[-2.573491,51.451385],[-2.573553,51.451514],[-2.573591,51.451605],[-2.573635,51.451726],[-2.573785,51.451943],[-2.573862,51.452052],[-2.574029,51.452215],[-2.574301,51.452438],[-2.573889,51.452598],[-2.572852,51.452994],[-2.57186,51.453341],[-2.571252,51.453557],[-2.571012,51.45364],[-2.570853,51.453697],[-2.5705,51.453823],[-2.570369,51.45387],[-2.570287,51.453901],[-2.570078,51.453977],[-2.569972,51.454016],[-2.569803,51.454082],[-2.569713,51.454115],[-2.569632,51.454144],[-2.569501,51.454184],[-2.569137,51.454304],[-2.568791,51.454436],[-2.568648,51.454505],[-2.568666,51.454525],[-2.568674,51.454548],[-2.56867,51.454571],[-2.568656,51.454593],[-2.568632,51.454611],[-2.568601,51.454623],[-2.568688,51.454756],[-2.568967,51.454972],[-2.569021,51.455014],[-2.568715,51.455271],[-2.568646,51.455327],[-2.568374,51.455559],[-2.568108,51.455772],[-2.567496,51.456239],[-2.567414,51.456319],[-2.567628,51.456492],[-2.567643,51.456517],[-2.567649,51.456526],[-2.567656,51.456544],[-2.567659,51.456553],[-2.567655,51.456589],[-2.56766,51.456617],[-2.567688,51.456643],[-2.567726,51.456662],[-2.567757,51.456684],[-2.567783,51.456719],[-2.567793,51.456739],[-2.567796,51.456747],[-2.56779,51.456775],[-2.567829,51.456783],[-2.567946,51.456871],[-2.568049,51.456948],[-2.568176,51.457057],[-2.568213,51.457083],[-2.568322,51.45716],[-2.568414,51.457216],[-2.56846,51.457251],[-2.568445,51.457292],[-2.567621,51.457946],[-2.567536,51.457943],[-2.567354,51.458066],[-2.567316,51.458148],[-2.567406,51.458165],[-2.567764,51.458232],[-2.568027,51.458276],[-2.568076,51.458283],[-2.568358,51.458287],[-2.568442,51.45829],[-2.568972,51.458337],[-2.56919,51.458356],[-2.569451,51.458365],[-2.569642,51.458363],[-2.569759,51.458354],[-2.570133,51.458292],[-2.570486,51.458208],[-2.570908,51.458114],[-2.571103,51.458103],[-2.57128,51.458116],[-2.571551,51.458175],[-2.571638,51.458205],[-2.571745,51.458247],[-2.571982,51.45828],[-2.572208,51.458286],[-2.573275,51.458227],[-2.573563,51.458208],[-2.573671,51.458195],[-2.573724,51.458183],[-2.573781,51.458175],[-2.573895,51.458156],[-2.573943,51.458146],[-2.576163,51.457686],[-2.576531,51.457615],[-2.576651,51.457592],[-2.576817,51.457539],[-2.57706,51.4574],[-2.577425,51.457222],[-2.577781,51.457082],[-2.578035,51.456998],[-2.578202,51.456951],[-2.578496,51.456874],[-2.578585,51.456849],[-2.578781,51.456795],[-2.579666,51.456548],[-2.579847,51.456493],[-2.579937,51.456464],[-2.580159,51.456403],[-2.580275,51.456396],[-2.580319,51.456385],[-2.580442,51.456351],[-2.580625,51.456286],[-2.580716,51.456255],[-2.580822,51.456205],[-2.580925,51.45617],[-2.581018,51.456139],[-2.581116,51.456108],[-2.581297,51.456054],[-2.581424,51.456018],[-2.581562,51.455983],[-2.581716,51.455949],[-2.581883,51.455913],[-2.582016,51.455898],[-2.582766,51.455751]]],type:"Polygon"},properties:{waypoints:[{lat:51.455751,lon:-2.582766,snapped:!0},{lat:51.449653,lon:-2.57599,snapped:!0},{lat:51.457083,lon:-2.568213,snapped:!0},{lat:51.455751,lon:-2.582766,snapped:!0}]},type:"Feature"},addingFilter:!1})}function be(){_(1,v={mode:"network"})}function ge(Le){B=Le,_(2,B)}function De(Le){E=Le,_(0,E)}const Ee=()=>_(1,v.addingFilter=!0,v);return m.$$.update=()=>{m.$$.dirty&1&&H()},[E,v,B,s,V,me,be,ge,De,Ee]}class Ny extends Wr{constructor(f){super(),Gr(this,f,By,Oy,Tr,{})}}new Ny({target:document.getElementById("app")}); + `,this._cooperativeGesturesScreen.setAttribute("aria-hidden","true"),this._canvasContainer.addEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.add("maplibregl-cooperative-gestures")}_destroyCooperativeGestures(){V.remove(this._cooperativeGesturesScreen),this._canvasContainer.removeEventListener("wheel",this._cooperativeGesturesOnWheel,!1),this._canvasContainer.classList.remove("maplibregl-cooperative-gestures")}_resizeCanvas(u,t,n){this._canvas.width=Math.floor(n*u),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${u}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const u={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let t=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{t={requestedAttributes:u},a&&(t.statusMessage=a.statusMessage,t.type=a.type)},{once:!0});const n=this._canvas.getContext("webgl2",u)||this._canvas.getContext("webgl",u);if(!n){const a="Failed to initialize WebGL";throw t?(t.message=a,new Error(JSON.stringify(t))):new Error(a)}this.painter=new zo(n,this.transform),me.testSupport(n)}_onCooperativeGesture(u,t,n){return!t&&n<2&&(this._cooperativeGesturesScreen.classList.add("maplibregl-show"),setTimeout(()=>{this._cooperativeGesturesScreen.classList.remove("maplibregl-show")},100)),!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(u){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||u,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(u){return this._update(),this._renderTaskQueue.add(u)}_cancelRenderFrame(u){this._renderTaskQueue.remove(u)}_render(u){const t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(u),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const c=this.transform.zoom,d=s.h.now();this.style.zoomHistory.update(c,d);const x=new s.a8(c,{now:d,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),b=x.crossFadingFactor();b===1&&b===this._crossFadingFactor||(n=!0,this._crossFadingFactor=b),this.style.update(x)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform._minEleveationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform._minEleveationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,t,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,showPadding:this.showPadding}),this.fire(new s.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,s.bg.mark(s.bh.load),this.fire(new s.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new s.k("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,s.bg.mark(s.bh.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){var u;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),De.removeThrottleControl(this._imageQueueHandle),(u=this._resizeObserver)===null||u===void 0||u.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),V.remove(this._canvasContainer),V.remove(this._controlContainer),this._cooperativeGestures&&this._destroyCooperativeGestures(),this._container.classList.remove("maplibregl-map"),s.bg.clearMetrics(),this._removed=!0,this.fire(new s.k("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=s.h.frame(u=>{s.bg.frame(u),this._frame=null,this._render(u)}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(u){this._showTileBoundaries!==u&&(this._showTileBoundaries=u,this._update())}get showPadding(){return!!this._showPadding}set showPadding(u){this._showPadding!==u&&(this._showPadding=u,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(u){this._showCollisionBoxes!==u&&(this._showCollisionBoxes=u,u?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(u){this._showOverdrawInspector!==u&&(this._showOverdrawInspector=u,this._update())}get repaint(){return!!this._repaint}set repaint(u){this._repaint!==u&&(this._repaint=u,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(u){this._vertices=u,this._update()}get version(){return xt}getCameraTargetElevation(){return this.transform.elevation}},Si.NavigationControl=class{constructor(u){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),a=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t},this._setButtonTitle=(t,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);t.title=a,t.setAttribute("aria-label",a)},this.options=s.e({},Gl,u),this._container=V.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),V.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),V.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=V.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(u){return this._map=u,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Wl(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){V.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(u,t){const n=V.create("button",u,this._container);return n.type="button",n.addEventListener("click",t),n}},Si.GeolocateControl=class extends s.E{constructor(u){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new s.k("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(t),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new s.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new s.L(t.coords.longitude,t.coords.latitude),a=t.coords.accuracy,c=this._map.getBearing(),d=s.e({bearing:c},this.options.fitBoundsOptions),x=Tt.fromLngLat(n,a);this._map.fitBounds(x,d,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new s.L(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&Ia)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new s.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=t=>{if(this._map){if(this._container.addEventListener("contextmenu",n=>n.preventDefault()),this._geolocateButton=V.create("button","maplibregl-ctrl-geolocate",this._container),V.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){s.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=V.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Os({element:this._dotElement}),this._circleElement=V.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Os({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",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new s.k("trackuserlocationend")))})}},this.options=s.e({},cr,u)}onAdd(u){return this._map=u,this._container=V.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(t,n=!1){br===void 0||n?window.navigator.permissions!==void 0?window.navigator.permissions.query({name:"geolocation"}).then(a=>{br=a.state!=="denied",t(br)}).catch(()=>{br=!!window.navigator.geolocation,t(br)}):(br=!!window.navigator.geolocation,t(br)):t(br)}(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),V.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,or=0,Ia=!1}_isOutOfMapMaxBounds(u){const t=this._map.getMaxBounds(),n=u.coords;return t&&(n.longitudet.getEast()||n.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const u=this._map.getBounds(),t=u.getSouthEast(),n=u.getNorthEast(),a=t.distanceTo(n),c=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${c}px`,this._circleElement.style.height=`${c}px`}trigger(){if(!this._setup)return s.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new s.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":or--,Ia=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new s.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new s.k("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let u;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),or++,or>1?(u={maximumAge:6e5,timeout:0},Ia=!0):(u=this.options.positionOptions,Ia=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,u)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},Si.AttributionControl=Hn,Si.LogoControl=Yi,Si.ScaleControl=class{constructor(u){this._onMove=()=>{Ya(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Ya(this._map,this._container,this.options)},this.options=s.e({},Ja,u)}getDefaultPosition(){return"bottom-left"}onAdd(u){return this._map=u,this._container=V.create("div","maplibregl-ctrl maplibregl-ctrl-scale",u.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){V.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},Si.FullscreenControl=class extends s.E{constructor(u={}){super(),this._onFullscreenChange=()=>{(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,u&&u.container&&(u.container instanceof HTMLElement?this._container=u.container:s.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(u){return this._map=u,this._container||(this._container=this._map.getContainer()),this._controlContainer=V.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){V.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const u=this._fullscreenButton=V.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);V.create("span","maplibregl-ctrl-icon",u).setAttribute("aria-hidden","true"),u.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const u=this._getTitle();this._fullscreenButton.setAttribute("aria-label",u),this._fullscreenButton.title=u}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new s.k("fullscreenstart")),this._map._cooperativeGestures&&(this._prevCooperativeGestures=this._map._cooperativeGestures,this._map.setCooperativeGestures())):(this.fire(new s.k("fullscreenend")),this._prevCooperativeGestures&&(this._map.setCooperativeGestures(this._prevCooperativeGestures),delete this._prevCooperativeGestures))}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},Si.TerrainControl=class{constructor(u){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))},this.options=u}onAdd(u){return this._map=u,this._container=V.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=V.create("button","maplibregl-ctrl-terrain",this._container),V.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){V.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},Si.Popup=class extends s.E{constructor(u){super(),this.remove=()=>(this._content&&V.remove(this._content),this._container&&(V.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new s.k("close")),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=V.create("div","maplibregl-popup",this._map.getContainer()),this._tip=V.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const x of this.options.className.split(" "))this._container.classList.add(x);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Hl(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!t)return;const n=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);let a=this.options.anchor;const c=Ea(this.options.offset);if(!a){const x=this._container.offsetWidth,b=this._container.offsetHeight;let S;S=n.y+c.bottom.ythis._map.transform.height-b?["bottom"]:[],n.xthis._map.transform.width-x/2&&S.push("right"),a=S.length===0?"bottom":S.join("-")}const d=n.add(c[a]).round();V.setTransform(this._container,`${so[a]} translate(${d.x}px,${d.y}px)`),Uc(this._container,a,"popup")},this._onClose=()=>{this.remove()},this.options=s.e(Object.create(Xl),u)}addTo(u){return this._map&&this.remove(),this._map=u,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new s.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(u){return this._lngLat=s.L.convert(u),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(u){return this.setDOMContent(document.createTextNode(u))}setHTML(u){const t=document.createDocumentFragment(),n=document.createElement("body");let a;for(n.innerHTML=u;a=n.firstChild,a;)t.appendChild(a);return this.setDOMContent(t)}getMaxWidth(){var u;return(u=this._container)===null||u===void 0?void 0:u.style.maxWidth}setMaxWidth(u){return this.options.maxWidth=u,this._update(),this}setDOMContent(u){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=V.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(u),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(u){this._container&&this._container.classList.add(u)}removeClassName(u){this._container&&this._container.classList.remove(u)}setOffset(u){return this.options.offset=u,this._update(),this}toggleClassName(u){if(this._container)return this._container.classList.toggle(u)}_createCloseButton(){this.options.closeButton&&(this._closeButton=V.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const u=this._container.querySelector(Kl);u&&u.focus()}},Si.Marker=Os,Si.Style=Er,Si.LngLat=s.L,Si.LngLatBounds=Tt,Si.Point=s.P,Si.MercatorCoordinate=s.U,Si.Evented=s.E,Si.AJAXError=s.bi,Si.config=s.c,Si.CanvasSource=gr,Si.GeoJSONSource=Xe,Si.ImageSource=ct,Si.RasterDEMTileSource=Pt,Si.RasterTileSource=Fe,Si.VectorTileSource=Oi,Si.VideoSource=Zi,Si.setRTLTextPlugin=s.bj,Si.getRTLTextPluginStatus=s.bk,Si.prewarm=function(){qo().acquire(ii)},Si.clearPrewarmedResources=function(){const u=Un;u&&(u.isPreloaded()&&u.numActive()===1?(u.release(ii),Un=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()"))},Jl.extend(Si,{isSafari:s.ac,getPerformanceMetrics:s.bg.getPerformanceMetrics}),Si});var F=E;return F})})(Qp);var V_=Qp.exports;const is=Yp(V_);function vp(m){let f;return _=>{if(_)for(let v in _){let E=f==null?void 0:f[v],k=_[v];E!==k&&m(v,k,E)}else if(f)for(let v in f)m(v,void 0,f[v]);f=_}}function U_(m,...f){let _=[m];for(let v of f)if(v)Array.isArray(v)&&v[0]===m?_.push(...v.slice(1)):_.push(v);else continue;if(_.length!==1)return _.length===2?_[1]:_}function j_(m){return m===!0?["has","point_count"]:m===!1?["!",["has","point_count"]]:void 0}function q_(m,f){return["case",["boolean",["feature-state","hover"],!1],f,m]}var yu=Z_;function Z_(m){var f,_,v;if(m){if(Array.isArray(m)){for(f=[],_=m.length,v=0;v<_;v++){var E=m[v];E!=null&&f.push(E)}return f}if(typeof m=="object"){f={};var k=Object.keys(m);for(_=k.length,v=0;v<_;v++){var F=k[v],s=m[F];s!=null&&(f[F]=s)}return f}}}function xp(m){let f=m[0],_,v,E=bp(m);return{c(){E.c(),_=Ba()},m(k,F){E.m(k,F),ci(k,_,F),v=!0},p(k,F){F[0]&1&&Tr(f,f=k[0])?(rs(),St(E,1,1,Nr),ns(),E=bp(k),E.c(),ft(E,1),E.m(_.parentNode,_)):E.p(k,F)},i(k){v||(ft(E),v=!0)},o(k){St(E),v=!1},d(k){k&&si(_),E.d(k)}}}function bp(m){let f;const _=m[37].default,v=Ys(_,m,m[36],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k[1]&32)&&$s(v,_,E,E[36],f?Qs(_,E[36],k,null):ea(E[36]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function G_(m){let f,_,v=m[0]&&xp(m);return{c(){v&&v.c(),f=Ba()},m(E,k){v&&v.m(E,k),ci(E,f,k),_=!0},p(E,k){E[0]?v?(v.p(E,k),k[0]&1&&ft(v,1)):(v=xp(E),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(E)}}}function W_(m,f,_){let v,E,k,F,s,Z,V,me,be,ge,Oe,ke,{$$slots:Pe={},$$scope:De}=f,{id:Ve=Fc("layer")}=f,{source:at=void 0}=f,{sourceLayer:nt=void 0}=f,{beforeId:it=void 0}=f,{beforeLayerType:Vt=void 0}=f,{type:ti}=f,{paint:Xt=void 0}=f,{layout:Nt=void 0}=f,{filter:Yt=void 0}=f,{applyToClusters:At=void 0}=f,{minzoom:Ae=void 0}=f,{maxzoom:We=void 0}=f,{manageHoverState:Ui=!1}=f,{hovered:Dt=null}=f,{interactive:qt=!0}=f,{hoverCursor:Lt=void 0}=f,{eventsIfTopMost:fi=!1}=f;const Pi=Ih(),{map:en,source:Vr,self:zi,minzoom:Ti,maxzoom:Tt,eventTopMost:mi,layerInfo:Oi}=B_();$r(m,en,Xe=>_(32,be=Xe)),$r(m,Vr,Xe=>_(33,ge=Xe)),$r(m,zi,Xe=>_(0,me=Xe)),$r(m,Ti,Xe=>_(35,ke=Xe)),$r(m,Tt,Xe=>_(34,Oe=Xe)),Na(()=>{me&&be&&(Oi.delete(me),be==null||be.removeLayer(me))});let Fe,Pt=!0;return m.$$set=Xe=>{"id"in Xe&&_(7,Ve=Xe.id),"source"in Xe&&_(8,at=Xe.source),"sourceLayer"in Xe&&_(9,nt=Xe.sourceLayer),"beforeId"in Xe&&_(10,it=Xe.beforeId),"beforeLayerType"in Xe&&_(11,Vt=Xe.beforeLayerType),"type"in Xe&&_(12,ti=Xe.type),"paint"in Xe&&_(13,Xt=Xe.paint),"layout"in Xe&&_(14,Nt=Xe.layout),"filter"in Xe&&_(15,Yt=Xe.filter),"applyToClusters"in Xe&&_(16,At=Xe.applyToClusters),"minzoom"in Xe&&_(17,Ae=Xe.minzoom),"maxzoom"in Xe&&_(18,We=Xe.maxzoom),"manageHoverState"in Xe&&_(19,Ui=Xe.manageHoverState),"hovered"in Xe&&_(6,Dt=Xe.hovered),"interactive"in Xe&&_(20,qt=Xe.interactive),"hoverCursor"in Xe&&_(21,Lt=Xe.hoverCursor),"eventsIfTopMost"in Xe&&_(22,fi=Xe.eventsIfTopMost),"$$scope"in Xe&&_(36,De=Xe.$$scope)},m.$$.update=()=>{if(m.$$.dirty[0]&65536&&_(31,v=j_(At)),m.$$.dirty[0]&32768|m.$$.dirty[1]&1&&_(25,E=U_("all",v,Yt)),m.$$.dirty[0]&131072|m.$$.dirty[1]&16&&_(27,k=Ae??ke),m.$$.dirty[0]&262144|m.$$.dirty[1]&8&&_(26,F=We??Oe),m.$$.dirty[0]&256|m.$$.dirty[1]&4&&_(30,s=at||ge),m.$$.dirty[0]&1324908161|m.$$.dirty[1]&2&&be&&me!==Ve&&s){let Xe=function(ct){var Bi,yr;if(!qt||!me||!be||fi&&mi(ct)!==me)return;let Zi=ct.features??[],gr=(yr=(Bi=Zi[0])==null?void 0:Bi.properties)==null?void 0:yr.cluster_id,je={event:ct,map:be,clusterId:gr,layer:me,source:s,features:Zi};Pi(ct.type,je)};me&&Oi.delete(me);let Gt=it;if(!it&&Vt){let ct=be.getStyle().layers,Zi=typeof Vt=="function"?Vt:je=>je.type===Vt,gr=ct==null?void 0:ct.find(Zi);gr&&(Gt=gr.id)}ol(zi,me=Ve,me),be.addLayer(yu({id:me,type:ti,source:s,"source-layer":nt,filter:E,paint:Xt,layout:Nt,minzoom:k,maxzoom:F}),Gt),_(24,Pt=!0),be.on("click",me,Xe),be.on("dblclick",me,Xe),be.on("contextmenu",me,Xe),be.on("mouseenter",me,ct=>{var Bi,yr;if(!qt||!me||!be||fi&&mi(ct)!==me)return;Lt&&(be.getCanvas().style.cursor=Lt);let Zi=ct.features??[];_(6,Dt=Zi[0]??null);let gr=(yr=(Bi=Zi[0])==null?void 0:Bi.properties)==null?void 0:yr.cluster_id;Pi("mouseenter",{event:ct,map:be,clusterId:gr,layer:me,source:s,features:Zi})}),be.on("mousemove",me,ct=>{var Bi,yr,hi;if(!qt)return;if(fi&&mi(ct)!==me){_(6,Dt=null),Ui&&Fe!==void 0&&(be==null||be.setFeatureState({source:s,sourceLayer:nt,id:Fe},{hover:!1}),_(23,Fe=void 0));return}be.getCanvas().style.cursor=Lt;let Zi=ct.features??[],gr=(yr=(Bi=Zi[0])==null?void 0:Bi.properties)==null?void 0:yr.cluster_id,je=(hi=Zi[0])==null?void 0:hi.id;je!==Fe&&(Ui&&(Fe!==void 0&&(be==null||be.setFeatureState({source:s,id:Fe,sourceLayer:nt},{hover:!1})),be==null||be.setFeatureState({source:s,id:je,sourceLayer:nt},{hover:!0})),_(23,Fe=je),_(6,Dt=Zi[0]??null)),Pi("mousemove",{event:ct,map:be,clusterId:gr,layer:me,source:s,features:Zi})}),be.on("mouseleave",me,ct=>{if(!(!qt||!me||!be)){if(Lt&&(be.getCanvas().style.cursor=""),_(6,Dt=null),Ui&&Fe!==void 0){const Zi={source:s,id:Fe,sourceLayer:nt};be==null||be.setFeatureState(Zi,{hover:!1}),_(23,Fe=void 0)}Pi("mouseleave",{map:be,layer:me,source:s})}})}m.$$.dirty[0]&1048577&&me&&Oi.set(me,{interactive:qt}),m.$$.dirty[0]&1|m.$$.dirty[1]&2&&_(29,Z=me?vp((Xe,Gt)=>be==null?void 0:be.setPaintProperty(me,Xe,Gt)):void 0),m.$$.dirty[0]&1|m.$$.dirty[1]&2&&_(28,V=me?vp((Xe,Gt)=>be==null?void 0:be.setLayoutProperty(me,Xe,Gt)):void 0),m.$$.dirty[0]&536879104&&(Z==null||Z(Xt)),m.$$.dirty[0]&268451840&&(V==null||V(Nt)),m.$$.dirty[0]&201326593|m.$$.dirty[1]&2&&me&&(be==null||be.setLayerZoomRange(me,k,F)),m.$$.dirty[0]&50331649|m.$$.dirty[1]&2&&me&&(Pt?_(24,Pt=!1):be==null||be.setFilter(me,E))},[me,en,Vr,zi,Ti,Tt,Dt,Ve,at,nt,it,Vt,ti,Xt,Nt,Yt,At,Ae,We,Ui,qt,Lt,fi,Fe,Pt,E,F,k,V,Z,s,v,be,ge,Oe,ke,De,Pe]}class Ch extends Wr{constructor(f){super(),Gr(this,f,W_,G_,Tr,{id:7,source:8,sourceLayer:9,beforeId:10,beforeLayerType:11,type:12,paint:13,layout:14,filter:15,applyToClusters:16,minzoom:17,maxzoom:18,manageHoverState:19,hovered:6,interactive:20,hoverCursor:21,eventsIfTopMost:22},null,[-1,-1])}}function H_(m){let f;const _=m[16].default,v=Ys(_,m,m[24],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k&16777216)&&$s(v,_,E,E[24],f?Qs(_,E[24],k,null):ea(E[24]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function X_(m){let f,_,v;function E(F){m[17](F)}let k={id:m[1],type:"circle",source:m[2],sourceLayer:m[3],beforeId:m[4],beforeLayerType:m[5],paint:m[6],layout:m[7],filter:m[8],applyToClusters:m[9],minzoom:m[10],maxzoom:m[11],hoverCursor:m[12],manageHoverState:m[13],eventsIfTopMost:m[14],interactive:m[15],$$slots:{default:[H_]},$$scope:{ctx:m}};return m[0]!==void 0&&(k.hovered=m[0]),f=new Ch({props:k}),bs.push(()=>Dl(f,"hovered",E)),f.$on("click",m[18]),f.$on("dblclick",m[19]),f.$on("contextmenu",m[20]),f.$on("mouseenter",m[21]),f.$on("mousemove",m[22]),f.$on("mouseleave",m[23]),{c(){Ri(f.$$.fragment)},m(F,s){Ai(f,F,s),v=!0},p(F,[s]){const Z={};s&2&&(Z.id=F[1]),s&4&&(Z.source=F[2]),s&8&&(Z.sourceLayer=F[3]),s&16&&(Z.beforeId=F[4]),s&32&&(Z.beforeLayerType=F[5]),s&64&&(Z.paint=F[6]),s&128&&(Z.layout=F[7]),s&256&&(Z.filter=F[8]),s&512&&(Z.applyToClusters=F[9]),s&1024&&(Z.minzoom=F[10]),s&2048&&(Z.maxzoom=F[11]),s&4096&&(Z.hoverCursor=F[12]),s&8192&&(Z.manageHoverState=F[13]),s&16384&&(Z.eventsIfTopMost=F[14]),s&32768&&(Z.interactive=F[15]),s&16777216&&(Z.$$scope={dirty:s,ctx:F}),!_&&s&1&&(_=!0,Z.hovered=F[0],Ll(()=>_=!1)),f.$set(Z)},i(F){v||(ft(f.$$.fragment,F),v=!0)},o(F){St(f.$$.fragment,F),v=!1},d(F){ki(f,F)}}}function K_(m,f,_){let{$$slots:v={},$$scope:E}=f,{id:k=Fc("circle")}=f,{source:F=void 0}=f,{sourceLayer:s=void 0}=f,{beforeId:Z=void 0}=f,{beforeLayerType:V=void 0}=f,{paint:me}=f,{layout:be=void 0}=f,{filter:ge=void 0}=f,{applyToClusters:Oe=void 0}=f,{minzoom:ke=void 0}=f,{maxzoom:Pe=void 0}=f,{hoverCursor:De=void 0}=f,{manageHoverState:Ve=!1}=f,{hovered:at=null}=f,{eventsIfTopMost:nt=!1}=f,{interactive:it=!0}=f;function Vt(We){at=We,_(0,at)}function ti(We){pn.call(this,m,We)}function Xt(We){pn.call(this,m,We)}function Nt(We){pn.call(this,m,We)}function Yt(We){pn.call(this,m,We)}function At(We){pn.call(this,m,We)}function Ae(We){pn.call(this,m,We)}return m.$$set=We=>{"id"in We&&_(1,k=We.id),"source"in We&&_(2,F=We.source),"sourceLayer"in We&&_(3,s=We.sourceLayer),"beforeId"in We&&_(4,Z=We.beforeId),"beforeLayerType"in We&&_(5,V=We.beforeLayerType),"paint"in We&&_(6,me=We.paint),"layout"in We&&_(7,be=We.layout),"filter"in We&&_(8,ge=We.filter),"applyToClusters"in We&&_(9,Oe=We.applyToClusters),"minzoom"in We&&_(10,ke=We.minzoom),"maxzoom"in We&&_(11,Pe=We.maxzoom),"hoverCursor"in We&&_(12,De=We.hoverCursor),"manageHoverState"in We&&_(13,Ve=We.manageHoverState),"hovered"in We&&_(0,at=We.hovered),"eventsIfTopMost"in We&&_(14,nt=We.eventsIfTopMost),"interactive"in We&&_(15,it=We.interactive),"$$scope"in We&&_(24,E=We.$$scope)},[at,k,F,s,Z,V,me,be,ge,Oe,ke,Pe,De,Ve,nt,it,v,Vt,ti,Xt,Nt,Yt,At,Ae,E]}class ef extends Wr{constructor(f){super(),Gr(this,f,K_,X_,Tr,{id:1,source:2,sourceLayer:3,beforeId:4,beforeLayerType:5,paint:6,layout:7,filter:8,applyToClusters:9,minzoom:10,maxzoom:11,hoverCursor:12,manageHoverState:13,hovered:0,eventsIfTopMost:14,interactive:15})}}function J_(m){let f;const _=m[15].default,v=Ys(_,m,m[23],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k&8388608)&&$s(v,_,E,E[23],f?Qs(_,E[23],k,null):ea(E[23]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function Y_(m){let f,_,v;function E(F){m[16](F)}let k={id:m[1],type:"fill",source:m[2],sourceLayer:m[3],beforeId:m[4],beforeLayerType:m[5],paint:m[6],layout:m[7],filter:m[8],minzoom:m[9],maxzoom:m[10],hoverCursor:m[11],manageHoverState:m[12],eventsIfTopMost:m[13],interactive:m[14],$$slots:{default:[J_]},$$scope:{ctx:m}};return m[0]!==void 0&&(k.hovered=m[0]),f=new Ch({props:k}),bs.push(()=>Dl(f,"hovered",E)),f.$on("click",m[17]),f.$on("dblclick",m[18]),f.$on("contextmenu",m[19]),f.$on("mouseenter",m[20]),f.$on("mousemove",m[21]),f.$on("mouseleave",m[22]),{c(){Ri(f.$$.fragment)},m(F,s){Ai(f,F,s),v=!0},p(F,[s]){const Z={};s&2&&(Z.id=F[1]),s&4&&(Z.source=F[2]),s&8&&(Z.sourceLayer=F[3]),s&16&&(Z.beforeId=F[4]),s&32&&(Z.beforeLayerType=F[5]),s&64&&(Z.paint=F[6]),s&128&&(Z.layout=F[7]),s&256&&(Z.filter=F[8]),s&512&&(Z.minzoom=F[9]),s&1024&&(Z.maxzoom=F[10]),s&2048&&(Z.hoverCursor=F[11]),s&4096&&(Z.manageHoverState=F[12]),s&8192&&(Z.eventsIfTopMost=F[13]),s&16384&&(Z.interactive=F[14]),s&8388608&&(Z.$$scope={dirty:s,ctx:F}),!_&&s&1&&(_=!0,Z.hovered=F[0],Ll(()=>_=!1)),f.$set(Z)},i(F){v||(ft(f.$$.fragment,F),v=!0)},o(F){St(f.$$.fragment,F),v=!1},d(F){ki(f,F)}}}function Q_(m,f,_){let{$$slots:v={},$$scope:E}=f,{id:k=Fc("fill")}=f,{source:F=void 0}=f,{sourceLayer:s=void 0}=f,{beforeId:Z=void 0}=f,{beforeLayerType:V=void 0}=f,{paint:me}=f,{layout:be=void 0}=f,{filter:ge=void 0}=f,{minzoom:Oe=void 0}=f,{maxzoom:ke=void 0}=f,{hoverCursor:Pe=void 0}=f,{manageHoverState:De=!1}=f,{hovered:Ve=null}=f,{eventsIfTopMost:at=!1}=f,{interactive:nt=!0}=f;function it(Ae){Ve=Ae,_(0,Ve)}function Vt(Ae){pn.call(this,m,Ae)}function ti(Ae){pn.call(this,m,Ae)}function Xt(Ae){pn.call(this,m,Ae)}function Nt(Ae){pn.call(this,m,Ae)}function Yt(Ae){pn.call(this,m,Ae)}function At(Ae){pn.call(this,m,Ae)}return m.$$set=Ae=>{"id"in Ae&&_(1,k=Ae.id),"source"in Ae&&_(2,F=Ae.source),"sourceLayer"in Ae&&_(3,s=Ae.sourceLayer),"beforeId"in Ae&&_(4,Z=Ae.beforeId),"beforeLayerType"in Ae&&_(5,V=Ae.beforeLayerType),"paint"in Ae&&_(6,me=Ae.paint),"layout"in Ae&&_(7,be=Ae.layout),"filter"in Ae&&_(8,ge=Ae.filter),"minzoom"in Ae&&_(9,Oe=Ae.minzoom),"maxzoom"in Ae&&_(10,ke=Ae.maxzoom),"hoverCursor"in Ae&&_(11,Pe=Ae.hoverCursor),"manageHoverState"in Ae&&_(12,De=Ae.manageHoverState),"hovered"in Ae&&_(0,Ve=Ae.hovered),"eventsIfTopMost"in Ae&&_(13,at=Ae.eventsIfTopMost),"interactive"in Ae&&_(14,nt=Ae.interactive),"$$scope"in Ae&&_(23,E=Ae.$$scope)},[Ve,k,F,s,Z,V,me,be,ge,Oe,ke,Pe,De,at,nt,v,it,Vt,ti,Xt,Nt,Yt,At,E]}class tf extends Wr{constructor(f){super(),Gr(this,f,Q_,Y_,Tr,{id:1,source:2,sourceLayer:3,beforeId:4,beforeLayerType:5,paint:6,layout:7,filter:8,minzoom:9,maxzoom:10,hoverCursor:11,manageHoverState:12,hovered:0,eventsIfTopMost:13,interactive:14})}}function $_(m,f,_){let v;const{map:E}=Fl();$r(m,E,Z=>_(4,v=Z));let{position:k="top-left"}=f,{container:F=void 0}=f,s=null;return Na(()=>{v!=null&&v.loaded()&&s&&v.removeControl(s)}),m.$$set=Z=>{"position"in Z&&_(1,k=Z.position),"container"in Z&&_(2,F=Z.container)},m.$$.update=()=>{if(m.$$.dirty&30&&v&&!s){let Z;typeof F=="string"?Z=document.querySelector(F)??void 0:Z=F,_(3,s=new is.FullscreenControl({container:Z})),v.addControl(s,k)}},[E,k,F,s,v]}class eg extends Wr{constructor(f){super(),Gr(this,f,$_,null,Tr,{position:1,container:2})}}function tg(m,f,_,v,E){let k=!1;m.getSource(f)&&(k=!0,m.removeSource(f));const F=()=>{v(f)&&(m.addSource(f,_),E())};if(k){const s=()=>{f&&(m.getSource(f)?setTimeout(s,1):F())};s()}else F()}function ig(m,f,_){v_().then(()=>{let v=h_(m);if(!v)return;v.getSource(f)===_&&v.removeSource(f)})}function wp(m){let f=m[0],_,v,E=Sp(m);return{c(){E.c(),_=Ba()},m(k,F){E.m(k,F),ci(k,_,F),v=!0},p(k,F){F&1&&Tr(f,f=k[0])?(rs(),St(E,1,1,Nr),ns(),E=Sp(k),E.c(),ft(E,1),E.m(_.parentNode,_)):E.p(k,F)},i(k){v||(ft(E),v=!0)},o(k){St(E),v=!1},d(k){k&&si(_),E.d(k)}}}function Sp(m){let f;const _=m[15].default,v=Ys(_,m,m[14],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k&16384)&&$s(v,_,E,E[14],f?Qs(_,E[14],k,null):ea(E[14]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function rg(m){let f,_,v=m[0]&&wp(m);return{c(){v&&v.c(),f=Ba()},m(E,k){v&&v.m(E,k),ci(E,f,k),_=!0},p(E,[k]){E[0]?v?(v.p(E,k),k&1&&ft(v,1)):(v=wp(E),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(E)}}}function ng(m,f,_){let v,E,k,{$$slots:F={},$$scope:s}=f,{id:Z=Fc("geojson")}=f,{data:V}=f,{generateId:me=!1}=f,{promoteId:be=void 0}=f,{filter:ge=void 0}=f,{lineMetrics:Oe=void 0}=f,{cluster:ke=void 0}=f;const{map:Pe,cluster:De,self:Ve}=O_();$r(m,Pe,it=>_(13,E=it)),$r(m,De,it=>_(16,k=it)),$r(m,Ve,it=>_(0,v=it));let at,nt=!0;return Na(()=>{v&&at&&E&&(ig(Pe,v,at),ol(Ve,v=null,v),_(11,at=void 0))}),m.$$set=it=>{"id"in it&&_(4,Z=it.id),"data"in it&&_(5,V=it.data),"generateId"in it&&_(6,me=it.generateId),"promoteId"in it&&_(7,be=it.promoteId),"filter"in it&&_(8,ge=it.filter),"lineMetrics"in it&&_(9,Oe=it.lineMetrics),"cluster"in it&&_(10,ke=it.cluster),"$$scope"in it&&_(14,s=it.$$scope)},m.$$.update=()=>{m.$$.dirty&1024&&ol(De,k=ke,k),m.$$.dirty&12273&&E&&v!==Z&&(ol(Ve,v=Z,v),tg(E,v,yu({type:"geojson",data:V,filter:ge,lineMetrics:Oe,generateId:me,promoteId:be,cluster:!!ke,clusterMinPoints:ke==null?void 0:ke.minPoints,clusterMaxZoom:ke==null?void 0:ke.maxZoom,clusterRadius:ke==null?void 0:ke.radius,clusterProperties:ke==null?void 0:ke.properties}),it=>E&&it===v,()=>{v&&(_(11,at=E==null?void 0:E.getSource(v)),_(12,nt=!0))})),m.$$.dirty&8208&&(E==null||E.on("style.load",()=>{_(11,at=E==null?void 0:E.getSource(Z))})),m.$$.dirty&6176&&at&&(nt?_(12,nt=!1):at.setData(V)),m.$$.dirty&3072&&(at==null||at.setClusterOptions(yu({cluster:!!ke,clusterMaxZoom:ke==null?void 0:ke.maxZoom,clusterRadius:ke==null?void 0:ke.radius})))},[v,Pe,De,Ve,Z,V,me,be,ge,Oe,ke,at,nt,E,s,F]}class Mh extends Wr{constructor(f){super(),Gr(this,f,ng,rg,Tr,{id:4,data:5,generateId:6,promoteId:7,filter:8,lineMetrics:9,cluster:10})}}function og(m,f,_){let v;const{map:E}=Fl();$r(m,E,ge=>_(8,v=ge));let{position:k="top-left"}=f,{positionOptions:F=void 0}=f,{fitBoundsOptions:s=void 0}=f,{trackUserLocation:Z=!1}=f,{showAccuracyCircle:V=!0}=f,{showUserLocation:me=!0}=f,be=null;return Na(()=>{v!=null&&v.loaded()&&be&&v.removeControl(be)}),m.$$set=ge=>{"position"in ge&&_(1,k=ge.position),"positionOptions"in ge&&_(2,F=ge.positionOptions),"fitBoundsOptions"in ge&&_(3,s=ge.fitBoundsOptions),"trackUserLocation"in ge&&_(4,Z=ge.trackUserLocation),"showAccuracyCircle"in ge&&_(5,V=ge.showAccuracyCircle),"showUserLocation"in ge&&_(6,me=ge.showUserLocation)},m.$$.update=()=>{m.$$.dirty&510&&v&&!be&&(_(7,be=new is.GeolocateControl({positionOptions:F,fitBoundsOptions:s,trackUserLocation:Z,showAccuracyCircle:V,showUserLocation:me})),v.addControl(be,k))},[E,k,F,s,Z,V,me,be,v]}class sg extends Wr{constructor(f){super(),Gr(this,f,og,null,Tr,{position:1,positionOptions:2,fitBoundsOptions:3,trackUserLocation:4,showAccuracyCircle:5,showUserLocation:6})}}function ag(m){let f;const _=m[15].default,v=Ys(_,m,m[23],null);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k&8388608)&&$s(v,_,E,E[23],f?Qs(_,E[23],k,null):ea(E[23]),null)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function lg(m){let f,_,v;function E(F){m[16](F)}let k={id:m[1],type:"line",source:m[2],sourceLayer:m[3],beforeId:m[4],beforeLayerType:m[5],paint:m[6],layout:m[7],filter:m[8],minzoom:m[9],maxzoom:m[10],hoverCursor:m[11],manageHoverState:m[12],eventsIfTopMost:m[13],interactive:m[14],$$slots:{default:[ag]},$$scope:{ctx:m}};return m[0]!==void 0&&(k.hovered=m[0]),f=new Ch({props:k}),bs.push(()=>Dl(f,"hovered",E)),f.$on("click",m[17]),f.$on("dblclick",m[18]),f.$on("contextmenu",m[19]),f.$on("mouseenter",m[20]),f.$on("mousemove",m[21]),f.$on("mouseleave",m[22]),{c(){Ri(f.$$.fragment)},m(F,s){Ai(f,F,s),v=!0},p(F,[s]){const Z={};s&2&&(Z.id=F[1]),s&4&&(Z.source=F[2]),s&8&&(Z.sourceLayer=F[3]),s&16&&(Z.beforeId=F[4]),s&32&&(Z.beforeLayerType=F[5]),s&64&&(Z.paint=F[6]),s&128&&(Z.layout=F[7]),s&256&&(Z.filter=F[8]),s&512&&(Z.minzoom=F[9]),s&1024&&(Z.maxzoom=F[10]),s&2048&&(Z.hoverCursor=F[11]),s&4096&&(Z.manageHoverState=F[12]),s&8192&&(Z.eventsIfTopMost=F[13]),s&16384&&(Z.interactive=F[14]),s&8388608&&(Z.$$scope={dirty:s,ctx:F}),!_&&s&1&&(_=!0,Z.hovered=F[0],Ll(()=>_=!1)),f.$set(Z)},i(F){v||(ft(f.$$.fragment,F),v=!0)},o(F){St(f.$$.fragment,F),v=!1},d(F){ki(f,F)}}}function cg(m,f,_){let{$$slots:v={},$$scope:E}=f,{id:k=Fc("line")}=f,{source:F=void 0}=f,{sourceLayer:s=void 0}=f,{beforeId:Z=void 0}=f,{beforeLayerType:V=void 0}=f,{paint:me}=f,{layout:be=void 0}=f,{filter:ge=void 0}=f,{minzoom:Oe=void 0}=f,{maxzoom:ke=void 0}=f,{hoverCursor:Pe=void 0}=f,{manageHoverState:De=!1}=f,{hovered:Ve=null}=f,{eventsIfTopMost:at=!1}=f,{interactive:nt=!0}=f;function it(Ae){Ve=Ae,_(0,Ve)}function Vt(Ae){pn.call(this,m,Ae)}function ti(Ae){pn.call(this,m,Ae)}function Xt(Ae){pn.call(this,m,Ae)}function Nt(Ae){pn.call(this,m,Ae)}function Yt(Ae){pn.call(this,m,Ae)}function At(Ae){pn.call(this,m,Ae)}return m.$$set=Ae=>{"id"in Ae&&_(1,k=Ae.id),"source"in Ae&&_(2,F=Ae.source),"sourceLayer"in Ae&&_(3,s=Ae.sourceLayer),"beforeId"in Ae&&_(4,Z=Ae.beforeId),"beforeLayerType"in Ae&&_(5,V=Ae.beforeLayerType),"paint"in Ae&&_(6,me=Ae.paint),"layout"in Ae&&_(7,be=Ae.layout),"filter"in Ae&&_(8,ge=Ae.filter),"minzoom"in Ae&&_(9,Oe=Ae.minzoom),"maxzoom"in Ae&&_(10,ke=Ae.maxzoom),"hoverCursor"in Ae&&_(11,Pe=Ae.hoverCursor),"manageHoverState"in Ae&&_(12,De=Ae.manageHoverState),"hovered"in Ae&&_(0,Ve=Ae.hovered),"eventsIfTopMost"in Ae&&_(13,at=Ae.eventsIfTopMost),"interactive"in Ae&&_(14,nt=Ae.interactive),"$$scope"in Ae&&_(23,E=Ae.$$scope)},[Ve,k,F,s,Z,V,me,be,ge,Oe,ke,Pe,De,at,nt,v,it,Vt,ti,Xt,Nt,Yt,At,E]}class Ah extends Wr{constructor(f){super(),Gr(this,f,cg,lg,Tr,{id:1,source:2,sourceLayer:3,beforeId:4,beforeLayerType:5,paint:6,layout:7,filter:8,minzoom:9,maxzoom:10,hoverCursor:11,manageHoverState:12,hovered:0,eventsIfTopMost:13,interactive:14})}}function ug(m){let f=m.getCenter(),_=Math.round(m.getZoom()*100)/100,v=Math.ceil((_*Math.LN2+Math.log(512/360/.5))/Math.LN10),E=Math.pow(10,v),k=Math.round(f.lat*E)/E,F=Math.round(f.lng*E)/E,s=`${_}/${k}/${F}`,Z=m.getBearing(),V=m.getPitch();return(Z||V)&&(s+=`/${Math.round(Z*10)/10}`),V&&(s+=`/${Math.round(V)}`),`#${s}`}function hg(m){return m.replace("#","").split("/").map(parseFloat)}var hu=kh;function kh(m,f){return m===f||m!==m&&f!==f?!0:typeof m!=typeof f||{}.toString.call(m)!={}.toString.call(f)||m!==Object(m)||!m?!1:Array.isArray(m)?Tp(m,f):{}.toString.call(m)=="[object Set]"?Tp(Array.from(m),Array.from(f)):{}.toString.call(m)=="[object Object]"?pg(m,f):dg(m,f)}function dg(m,f){return m.toString()===f.toString()}function Tp(m,f){var _=m.length;if(_!=f.length)return!1;for(var v=0;v<_;v++)if(!kh(m[v],f[v]))return!1;return!0}function pg(m,f){var _=Object.keys(m),v=_.length;if(v!=Object.keys(f).length)return!1;for(var E=0;E_(6,v=me));let{position:k="top-left"}=f,{showCompass:F=!0}=f,{showZoom:s=!0}=f,{visualizePitch:Z=!1}=f,V=null;return Na(()=>{v!=null&&v.loaded()&&V&&v.removeControl(V)}),m.$$set=me=>{"position"in me&&_(1,k=me.position),"showCompass"in me&&_(2,F=me.showCompass),"showZoom"in me&&_(3,s=me.showZoom),"visualizePitch"in me&&_(4,Z=me.visualizePitch)},m.$$.update=()=>{m.$$.dirty&126&&v&&!V&&(_(5,V=new is.NavigationControl({showCompass:F,showZoom:s,visualizePitch:Z})),v.addControl(V,k))},[E,k,F,s,Z,V,v]}class mg extends Wr{constructor(f){super(),Gr(this,f,fg,null,Tr,{position:1,showCompass:2,showZoom:3,visualizePitch:4})}}function _g(m,f,_){let v;const{map:E}=Fl();$r(m,E,V=>_(5,v=V));let{position:k="bottom-left"}=f,{maxWidth:F=void 0}=f,{unit:s="metric"}=f,Z=null;return Na(()=>{v!=null&&v.loaded()&&Z&&v.removeControl(Z)}),m.$$set=V=>{"position"in V&&_(1,k=V.position),"maxWidth"in V&&_(2,F=V.maxWidth),"unit"in V&&_(3,s=V.unit)},m.$$.update=()=>{m.$$.dirty&62&&v&&!Z&&(_(4,Z=new is.ScaleControl({maxWidth:F,unit:s})),v.addControl(Z,k))},[E,k,F,s,Z,v]}class gg extends Wr{constructor(f){super(),Gr(this,f,_g,null,Tr,{position:1,maxWidth:2,unit:3})}}const yg=m=>({map:m[0]&8,loadedImages:m[0]&16,allImagesLoaded:m[0]&32}),Ip=m=>({map:m[3],loadedImages:m[4],allImagesLoaded:m[5]});function Ep(m){let f,_,v=m[2]&&Cp(m);const E=m[33].default,k=Ys(E,m,m[32],Ip);return{c(){v&&v.c(),f=fn(),k&&k.c()},m(F,s){v&&v.m(F,s),ci(F,f,s),k&&k.m(F,s),_=!0},p(F,s){F[2]?v?(v.p(F,s),s[0]&4&&ft(v,1)):(v=Cp(F),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns()),k&&k.p&&(!_||s[0]&56|s[1]&2)&&$s(k,E,F,F[32],_?Qs(E,F[32],s,yg):ea(F[32]),Ip)},i(F){_||(ft(v),ft(k,F),_=!0)},o(F){St(v),St(k,F),_=!1},d(F){F&&si(f),v&&v.d(F),k&&k.d(F)}}}function Cp(m){let f,_,v,E,k,F,s,Z;return f=new mg({props:{position:m[6]}}),v=new sg({props:{position:m[6],fitBoundsOptions:{maxZoom:12}}}),k=new eg({props:{position:m[6]}}),s=new gg({props:{position:m[6]}}),{c(){Ri(f.$$.fragment),_=fn(),Ri(v.$$.fragment),E=fn(),Ri(k.$$.fragment),F=fn(),Ri(s.$$.fragment)},m(V,me){Ai(f,V,me),ci(V,_,me),Ai(v,V,me),ci(V,E,me),Ai(k,V,me),ci(V,F,me),Ai(s,V,me),Z=!0},p(V,me){const be={};me[0]&64&&(be.position=V[6]),f.$set(be);const ge={};me[0]&64&&(ge.position=V[6]),v.$set(ge);const Oe={};me[0]&64&&(Oe.position=V[6]),k.$set(Oe);const ke={};me[0]&64&&(ke.position=V[6]),s.$set(ke)},i(V){Z||(ft(f.$$.fragment,V),ft(v.$$.fragment,V),ft(k.$$.fragment,V),ft(s.$$.fragment,V),Z=!0)},o(V){St(f.$$.fragment,V),St(v.$$.fragment,V),St(k.$$.fragment,V),St(s.$$.fragment,V),Z=!1},d(V){V&&(si(_),si(E),si(F)),ki(f,V),ki(v,V),ki(k,V),ki(s,V)}}}function vg(m){let f,_,v,E,k,F=m[3]&&m[0]&&Ep(m);return{c(){f=Zt("div"),F&&F.c(),xs(f,"class",_=fp(m[1])+" svelte-p00lfq"),_p(f,"expand-map",!m[1])},m(s,Z){ci(s,f,Z),F&&F.m(f,null),v=!0,E||(k=p_(m[9].call(null,f)),E=!0)},p(s,Z){s[3]&&s[0]?F?(F.p(s,Z),Z[0]&9&&ft(F,1)):(F=Ep(s),F.c(),ft(F,1),F.m(f,null)):F&&(rs(),St(F,1,1,()=>{F=null}),ns()),(!v||Z[0]&2&&_!==(_=fp(s[1])+" svelte-p00lfq"))&&xs(f,"class",_),(!v||Z[0]&2)&&_p(f,"expand-map",!s[1])},i(s){v||(ft(F),v=!0)},o(s){St(F),v=!1},d(s){s&&si(f),F&&F.d(),E=!1,k()}}}function xg(m,f,_){let v,E,k,F,{$$slots:s={},$$scope:Z}=f,{map:V=null}=f,{class:me=void 0}=f,{style:be}=f,{diffStyleUpdates:ge=!1}=f,{center:Oe=void 0}=f,{zoom:ke=void 0}=f,{pitch:Pe=0}=f,{bearing:De=0}=f,{bounds:Ve=void 0}=f,{hash:at=!1}=f,{loaded:nt=!1}=f,{minZoom:it=0}=f,{maxZoom:Vt=22}=f,{zoomOnDoubleClick:ti=!0}=f,{interactive:Xt=!0}=f,{attributionControl:Nt=!0}=f,{preserveDrawingBuffer:Yt=!1}=f,{maxBounds:At=void 0}=f,{images:Ae=[]}=f,{standardControls:We=!1}=f,{filterLayers:Ui=void 0}=f,{transformRequest:Dt=void 0}=f;const qt=Ih(),{map:Lt,loadedImages:fi}=R_();$r(m,Lt,Fe=>_(3,k=Fe)),$r(m,fi,Fe=>_(4,F=Fe));let Pi=new Set;function en(Fe){k!=null&&k.loaded()&&("url"in Fe?(Pi.add(Fe.id),k.loadImage(Fe.url,(Pt,Xe)=>{Pi.delete(Fe.id),Pt?qt("error",Pt):Xe&&(k==null||k.addImage(Fe.id,Xe,Fe.options),F.add(Fe.id),fi.set(F))})):(k.addImage(Fe.id,Fe.data,Fe.options),F.add(Fe.id),fi.set(F)))}let Vr,zi,Ti,Tt;function mi(Fe){if(at){let Pt=hg(window.location.hash);Pt.length>=3&&(_(11,ke=Pt[0]),_(10,Oe=[Pt[2],Pt[1]])),Pt.length==5&&(_(15,De=Pt[3]),_(14,Pe=Pt[4]))}return ol(Lt,k=new is.Map(yu({container:Fe,style:be,center:Oe,zoom:ke,pitch:Pe,bearing:De,minZoom:it,maxZoom:Vt,interactive:Xt,preserveDrawingBuffer:Yt,maxBounds:At,bounds:Ve,attributionControl:Nt,transformRequest:Dt})),k),k.on("load",Pt=>{_(0,nt=!0),qt("load",k)}),k.on("error",Pt=>qt("error",{...Pt,map:k})),k.on("movestart",Pt=>qt("movestart",{...Pt,map:k})),k.on("moveend",Pt=>{if(_(10,Oe=Pt.target.getCenter()),_(11,ke=Pt.target.getZoom()),_(12,Ve=Pt.target.getBounds()),qt("moveend",{...Pt,map:k}),at){let Xe=window.location.href.replace(/(#.+)?$/,ug(k));window.history.replaceState(window.history.state,"",Xe)}}),k.on("zoomstart",Pt=>qt("zoomstart",{...Pt,map:k})),k.on("zoom",Pt=>{_(11,ke=Pt.target.getZoom()),qt("zoom",{...Pt,map:k})}),k.on("zoomend",Pt=>{_(11,ke=Pt.target.getZoom()),qt("zoomend",{...Pt,map:k})}),k.on("style.load",()=>{if(k){const Pt=k.getStyle();if(_(29,Vr=Pt.layers.map(Xe=>Xe.id)),_(30,zi=Object.keys(Pt.sources)),Tt)for(const[Xe,Gt]of Object.entries(Tt))k.addSource(Xe,Gt);if(Ti)for(const Xe of Ti)k.addLayer(Xe)}}),k.on("styledata",Pt=>{if(k&&Ui){const Xe=k.getStyle().layers;if(Xe)for(let Gt of Xe)Ui(Gt)||k.setLayoutProperty(Gt.id,"visibility","none")}qt("styledata",{...Pt,map:k})}),{destroy(){_(0,nt=!1),k==null||k.remove(),ol(Lt,k=null,k)}}}let Oi=be;return m.$$set=Fe=>{"map"in Fe&&_(13,V=Fe.map),"class"in Fe&&_(1,me=Fe.class),"style"in Fe&&_(16,be=Fe.style),"diffStyleUpdates"in Fe&&_(17,ge=Fe.diffStyleUpdates),"center"in Fe&&_(10,Oe=Fe.center),"zoom"in Fe&&_(11,ke=Fe.zoom),"pitch"in Fe&&_(14,Pe=Fe.pitch),"bearing"in Fe&&_(15,De=Fe.bearing),"bounds"in Fe&&_(12,Ve=Fe.bounds),"hash"in Fe&&_(18,at=Fe.hash),"loaded"in Fe&&_(0,nt=Fe.loaded),"minZoom"in Fe&&_(19,it=Fe.minZoom),"maxZoom"in Fe&&_(20,Vt=Fe.maxZoom),"zoomOnDoubleClick"in Fe&&_(21,ti=Fe.zoomOnDoubleClick),"interactive"in Fe&&_(22,Xt=Fe.interactive),"attributionControl"in Fe&&_(23,Nt=Fe.attributionControl),"preserveDrawingBuffer"in Fe&&_(24,Yt=Fe.preserveDrawingBuffer),"maxBounds"in Fe&&_(25,At=Fe.maxBounds),"images"in Fe&&_(26,Ae=Fe.images),"standardControls"in Fe&&_(2,We=Fe.standardControls),"filterLayers"in Fe&&_(27,Ui=Fe.filterLayers),"transformRequest"in Fe&&_(28,Dt=Fe.transformRequest),"$$scope"in Fe&&_(32,Z=Fe.$$scope)},m.$$.update=()=>{if(m.$$.dirty[0]&4&&_(6,v=typeof We=="boolean"?void 0:We),m.$$.dirty[0]&8&&_(13,V=k),m.$$.dirty[0]&67108873&&nt&&k!=null&&k.loaded())for(let Fe of Ae)!Pi.has(Fe.id)&&!k.hasImage(Fe.id)&&en(Fe);if(m.$$.dirty[0]&67108880&&_(5,E=Ae.every(Fe=>F.has(Fe.id))),m.$$.dirty[0]&1610809352|m.$$.dirty[1]&1&&k&&!hu(be,Oi)){const Fe=k.getStyle();if(Vr&&(Ti=Fe.layers.filter(Pt=>!Vr.includes(Pt.id))),zi){const Pt=Object.keys(Fe.sources).filter(Xe=>!zi.includes(Xe));Tt={};for(const Xe of Pt)Tt[Xe]=Fe.sources[Xe]}_(31,Oi=be),k.setStyle(be,{diff:ge})}m.$$.dirty[0]&1032&&Oe&&!hu(Oe,k==null?void 0:k.getCenter())&&(k==null||k.panTo(Oe)),m.$$.dirty[0]&2056&&ke&&!hu(ke,k==null?void 0:k.getZoom())&&(k==null||k.zoomTo(ke)),m.$$.dirty[0]&4104&&Ve&&!hu(Ve,k==null?void 0:k.getBounds())&&(k==null||k.fitBounds(Ve)),m.$$.dirty[0]&2097160&&(ti?k==null||k.doubleClickZoom.enable():k==null||k.doubleClickZoom.disable())},[nt,me,We,k,F,E,v,Lt,fi,mi,Oe,ke,Ve,V,Pe,De,be,ge,at,it,Vt,ti,Xt,Nt,Yt,At,Ae,Ui,Dt,Vr,zi,Oi,Z,s]}class bg extends Wr{constructor(f){super(),Gr(this,f,xg,vg,Tr,{map:13,class:1,style:16,diffStyleUpdates:17,center:10,zoom:11,pitch:14,bearing:15,bounds:12,hash:18,loaded:0,minZoom:19,maxZoom:20,zoomOnDoubleClick:21,interactive:22,attributionControl:23,preserveDrawingBuffer:24,maxBounds:25,images:26,standardControls:2,filterLayers:27,transformRequest:28},null,[-1,-1])}}const wg=m=>({features:m[0]&16,data:m[0]&16,map:m[0]&4,close:m[0]&1}),Mp=m=>{var f;return{features:m[4],data:(f=m[4])==null?void 0:f[0],map:m[2],close:m[31]}};function Ap(m){let f,_,v=(m[4]||m[3]instanceof is.Marker)&&kp(m);return{c(){f=Zt("div"),v&&v.c()},m(E,k){ci(E,f,k),v&&v.m(f,null),m[32](f),_=!0},p(E,k){E[4]||E[3]instanceof is.Marker?v?(v.p(E,k),k[0]&24&&ft(v,1)):(v=kp(E),v.c(),ft(v,1),v.m(f,null)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(),m[32](null)}}}function kp(m){let f;const _=m[30].default,v=Ys(_,m,m[29],Mp);return{c(){v&&v.c()},m(E,k){v&&v.m(E,k),f=!0},p(E,k){v&&v.p&&(!f||k[0]&536870933)&&$s(v,_,E,E[29],f?Qs(_,E[29],k,wg):ea(E[29]),Mp)},i(E){f||(ft(v,E),f=!0)},o(E){St(v,E),f=!1},d(E){v&&v.d(E)}}}function Sg(m){let f,_,v=m[9].default&&Ap(m);return{c(){v&&v.c(),f=Ba()},m(E,k){v&&v.m(E,k),ci(E,f,k),_=!0},p(E,k){E[9].default?v?(v.p(E,k),k[0]&512&&ft(v,1)):(v=Ap(E),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(E)}}}function Tg(m,f,_){let v,E,k,F,s,Z,{$$slots:V={},$$scope:me}=f;const be=d_(V);let{closeButton:ge=void 0}=f,{closeOnClickOutside:Oe=!0}=f,{closeOnClickInside:ke=!1}=f,{closeOnMove:Pe=!1}=f,{openOn:De="click"}=f,{openIfTopMost:Ve=!0}=f,{focusAfterOpen:at=!0}=f,{anchor:nt=void 0}=f,{offset:it=void 0}=f,{popupClass:Vt=void 0}=f,{maxWidth:ti=void 0}=f,{lngLat:Xt=void 0}=f,{html:Nt=void 0}=f,{open:Yt=!1}=f;const{map:At,popupTarget:Ae,layerEvent:We,layer:Ui,eventTopMost:Dt}=Fl();$r(m,At,je=>_(2,k=je)),$r(m,Ae,je=>_(3,s=je)),$r(m,We,je=>_(28,F=je)),$r(m,Ui,je=>_(35,Z=je));const qt=["click","dblclick","contextmenu"];let Lt,fi=!1,Pi;function en(){if(!Lt)return;let je=Lt.getElement();!je||je===Pi||(Pi=je,De==="hover"&&(Pi.style.pointerEvents="none"),Pi.addEventListener("mouseenter",()=>{_(24,fi=!0)},{passive:!0}),Pi.addEventListener("mouseleave",()=>{_(24,fi=!1)},{passive:!0}),Pi.addEventListener("click",()=>{ke&&_(0,Yt=!1)},{passive:!0}))}jp(()=>{if(k)return k.on("click",Gt),k.on("contextmenu",Gt),typeof s=="string"&&(k.on("click",s,Tt),k.on("dblclick",s,Tt),k.on("contextmenu",s,Tt),k.on("mousemove",s,Xe),k.on("mouseleave",s,Pt),k.on("touchstart",s,Oi),k.on("touchend",s,Fe)),()=>{k!=null&&k.loaded()&&(Lt==null||Lt.remove(),k.off("click",Gt),k.off("contextmenu",Gt),s instanceof is.Marker?s.getPopup()===Lt&&s.setPopup(void 0):typeof s=="string"&&(k.off("click",s,Tt),k.off("dblclick",s,Tt),k.off("contextmenu",s,Tt),k.off("mousemove",s,Xe),k.off("mouseleave",s,Pt),k.off("touchstart",s,Oi),k.off("touchend",s,Fe)))}});function Vr(je){return Ve?!("marker"in je)&&!N_(je)&&Dt(je)!==Z:!1}let zi=null,Ti="normal";function Tt(je){je.type===De&&(Vr(je)||("layerType"in je?je.layerType==="deckgl"?(_(10,Xt=je.coordinate),_(4,zi=je.object?[je.object]:null)):(_(10,Xt=je.lngLat),_(4,zi=je.features??[])):(_(10,Xt=je.lngLat),_(4,zi=je.features??[])),setTimeout(()=>_(0,Yt=!0))))}let mi=null;function Oi(je){mi=je.point}function Fe(je){if(!mi||De!=="hover")return;let Bi=mi.dist(je.point);mi=null,Bi<3&&(_(10,Xt=je.lngLat),_(4,zi=je.features??[]),Lt.isOpen()?_(25,Ti="justOpened"):(_(25,Ti="opening"),_(0,Yt=!0)))}function Pt(je){De!=="hover"||mi||Ti!=="normal"||(_(0,Yt=!1),_(4,zi=null))}function Xe(je){if(!(De!=="hover"||mi||Ti!=="normal")){if(Vr(je)){_(0,Yt=!1),_(4,zi=null);return}_(0,Yt=!0),_(4,zi=je.features??[]),_(10,Xt=je.lngLat)}}function Gt(je){if(Ti==="justOpened"){_(25,Ti="normal");return}if(!Oe)return;let Bi=[Pi,s instanceof is.Marker?s==null?void 0:s.getElement():null];Yt&&Lt.isOpen()&&!Bi.some(yr=>yr==null?void 0:yr.contains(je.originalEvent.target))&&(je.type==="contextmenu"&&De==="contextmenu"||je.type!=="contextmenu")&&_(0,Yt=!1)}let ct;const Zi=()=>_(0,Yt=!1);function gr(je){bs[je?"unshift":"push"](()=>{ct=je,_(1,ct)})}return m.$$set=je=>{"closeButton"in je&&_(11,ge=je.closeButton),"closeOnClickOutside"in je&&_(12,Oe=je.closeOnClickOutside),"closeOnClickInside"in je&&_(13,ke=je.closeOnClickInside),"closeOnMove"in je&&_(14,Pe=je.closeOnMove),"openOn"in je&&_(15,De=je.openOn),"openIfTopMost"in je&&_(16,Ve=je.openIfTopMost),"focusAfterOpen"in je&&_(17,at=je.focusAfterOpen),"anchor"in je&&_(18,nt=je.anchor),"offset"in je&&_(19,it=je.offset),"popupClass"in je&&_(20,Vt=je.popupClass),"maxWidth"in je&&_(21,ti=je.maxWidth),"lngLat"in je&&_(10,Xt=je.lngLat),"html"in je&&_(22,Nt=je.html),"open"in je&&_(0,Yt=je.open),"$$scope"in je&&_(29,me=je.$$scope)},m.$$.update=()=>{if(m.$$.dirty[0]&14336&&_(27,v=ge??(!Oe&&!ke)),m.$$.dirty[0]&146685952&&(Lt||(_(23,Lt=new is.Popup({closeButton:v,closeOnClick:!1,closeOnMove:Pe,focusAfterOpen:at,maxWidth:ti,className:Vt,anchor:nt,offset:it})),Pi=Lt.getElement(),Lt.on("open",()=>{_(0,Yt=!0),en()}),Lt.on("close",je=>{_(0,Yt=!1)}))),m.$$.dirty[0]&8421384&&Lt&&s instanceof is.Marker&&(De==="click"?s.setPopup(Lt):s.getPopup()===Lt&&s.setPopup(void 0)),m.$$.dirty[0]&268468224&&qt.includes(De)&&(F==null?void 0:F.type)===De&&(Tt(F),ol(We,F=null,F)),m.$$.dirty[0]&268468224&&_(26,E=De==="hover"&&((F==null?void 0:F.type)==="mousemove"||(F==null?void 0:F.type)==="mouseenter")),m.$$.dirty[0]&352354304&&De==="hover"&&We&&(E&&F&&(F.layerType==="deckgl"?(_(10,Xt=F.coordinate),_(4,zi=F.object?[F.object]:null)):(_(10,Xt=F.lngLat),_(4,zi=F.features??[]))),_(0,Yt=(E||fi)??!1)),m.$$.dirty[0]&12582914&&(ct?Lt.setDOMContent(ct):Nt&&Lt.setHTML(Nt)),m.$$.dirty[0]&8389632&&Xt&&Lt.setLngLat(Xt),m.$$.dirty[0]&41943045&&k){let je=Lt.isOpen();Yt&&!je?(Lt.addTo(k),Ti==="opening"&&_(25,Ti="justOpened")):!Yt&&je&&Lt.remove()}},[Yt,ct,k,s,zi,At,Ae,We,Ui,be,Xt,ge,Oe,ke,Pe,De,Ve,at,nt,it,Vt,ti,Nt,Lt,fi,Ti,E,v,F,me,V,Zi,gr]}class Ph extends Wr{constructor(f){super(),Gr(this,f,Tg,Sg,Tr,{closeButton:11,closeOnClickOutside:12,closeOnClickInside:13,closeOnMove:14,openOn:15,openIfTopMost:16,focusAfterOpen:17,anchor:18,offset:19,popupClass:20,maxWidth:21,lngLat:10,html:22,open:0},null,[-1,-1])}}var Rc=Uint8Array,rf=Uint16Array,Ig=Int32Array,Eg=new Rc([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Cg=new Rc([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nf=function(m,f){for(var _=new rf(31),v=0;v<31;++v)_[v]=f+=1<>1|(Fi&21845)<<1,Hs=(Hs&52428)>>2|(Hs&13107)<<2,Hs=(Hs&61680)>>4|(Hs&3855)<<4,kg[Fi]=((Hs&65280)>>8|(Hs&255)<<8)>>1;var Hs,Fi,xu=new Rc(288);for(Fi=0;Fi<144;++Fi)xu[Fi]=8;var Fi;for(Fi=144;Fi<256;++Fi)xu[Fi]=9;var Fi;for(Fi=256;Fi<280;++Fi)xu[Fi]=7;var Fi;for(Fi=280;Fi<288;++Fi)xu[Fi]=8;var Fi,Pg=new Rc(32);for(Fi=0;Fi<32;++Fi)Pg[Fi]=5;var Fi,zg=new Rc(0),Lg=typeof TextDecoder<"u"&&new TextDecoder,Dg=0;try{Lg.decode(zg,{stream:!0}),Dg=1}catch{}const Fg=m=>({}),Pp=m=>({}),Rg=m=>({}),zp=m=>({});function Og(m){let f,_,v,E;const k=m[1].left,F=Ys(k,m,m[0],zp),s=m[1].main,Z=Ys(s,m,m[0],Pp);return{c(){f=Zt("div"),F&&F.c(),_=fn(),v=Zt("div"),Z&&Z.c(),xs(f,"class","left svelte-6kzmjs"),xs(v,"class","main svelte-6kzmjs")},m(V,me){ci(V,f,me),F&&F.m(f,null),ci(V,_,me),ci(V,v,me),Z&&Z.m(v,null),E=!0},p(V,[me]){F&&F.p&&(!E||me&1)&&$s(F,k,V,V[0],E?Qs(k,V[0],me,Rg):ea(V[0]),zp),Z&&Z.p&&(!E||me&1)&&$s(Z,s,V,V[0],E?Qs(s,V[0],me,Fg):ea(V[0]),Pp)},i(V){E||(ft(F,V),ft(Z,V),E=!0)},o(V){St(F,V),St(Z,V),E=!1},d(V){V&&(si(f),si(_),si(v)),F&&F.d(V),Z&&Z.d(V)}}}function Bg(m,f,_){let{$$slots:v={},$$scope:E}=f;return m.$$set=k=>{"$$scope"in k&&_(0,E=k.$$scope)},[E,v]}class Ng extends Wr{constructor(f){super(),Gr(this,f,Bg,Og,Tr,{})}}function Lp(m){let f,_;return{c(){f=Zt("div"),_=Ra(m[0]),xs(f,"class","svelte-1uuov7f")},m(v,E){ci(v,f,E),pi(f,_)},p(v,E){E&1&&yh(_,v[0])},d(v){v&&si(f)}}}function Vg(m){let f,_=m[0]&&Lp(m);return{c(){_&&_.c(),f=Ba()},m(v,E){_&&_.m(v,E),ci(v,f,E)},p(v,[E]){v[0]?_?_.p(v,E):(_=Lp(v),_.c(),_.m(f.parentNode,f)):_&&(_.d(1),_=null)},i:Nr,o:Nr,d(v){v&&si(f),_&&_.d(v)}}}function Ug(m,f,_){let{msg:v=null}=f;return m.$$set=E=>{"msg"in E&&_(0,v=E.msg)},[v]}class jg extends Wr{constructor(f){super(),Gr(this,f,Ug,Vg,Tr,{msg:0})}}var sf={exports:{}};(function(m,f){(function(_,v){m.exports=v()})(kl,function(){var _=function(g,I){var B={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},Y={on:function(se,fe,Re){if(B[se]===void 0)throw new Error("Invalid event type: "+se);B[se].push({selector:fe,fn:Re})},render:function(se){I.store.featureChanged(se)}},ne=function(se,fe){for(var Re=B[se],Ue=Re.length;Ue--;){var rt=Re[Ue];if(rt.selector(fe)){rt.fn.call(Y,fe)||I.store.render(),I.ui.updateMapClasses();break}}};return g.start.call(Y),{render:g.render,stop:function(){g.stop&&g.stop()},trash:function(){g.trash&&(g.trash(),I.store.render())},combineFeatures:function(){g.combineFeatures&&g.combineFeatures()},uncombineFeatures:function(){g.uncombineFeatures&&g.uncombineFeatures()},drag:function(se){ne("drag",se)},click:function(se){ne("click",se)},mousemove:function(se){ne("mousemove",se)},mousedown:function(se){ne("mousedown",se)},mouseup:function(se){ne("mouseup",se)},mouseout:function(se){ne("mouseout",se)},keydown:function(se){ne("keydown",se)},keyup:function(se){ne("keyup",se)},touchstart:function(se){ne("touchstart",se)},touchmove:function(se){ne("touchmove",se)},touchend:function(se){ne("touchend",se)},tap:function(se){ne("tap",se)}}};function v(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function E(g){if(g.__esModule)return g;var I=g.default;if(typeof I=="function"){var B=function Y(){if(this instanceof Y){var ne=[null];ne.push.apply(ne,arguments);var se=Function.bind.apply(I,ne);return new se}return I.apply(this,arguments)};B.prototype=I.prototype}else B={};return Object.defineProperty(B,"__esModule",{value:!0}),Object.keys(g).forEach(function(Y){var ne=Object.getOwnPropertyDescriptor(g,Y);Object.defineProperty(B,Y,ne.get?ne:{enumerable:!0,get:function(){return g[Y]}})}),B}var k={},F={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:63567523142e-4},s=F;function Z(g){var I=0;if(g&&g.length>0){I+=Math.abs(V(g[0]));for(var B=1;B2){for(fe=0;fe=Math.pow(2,g)?zi(g,I):se};zi.rack=function(g,I,B){var Y=function(se){var fe=0;do{if(fe++>10){if(!B)throw new Error("too many ID collisions, use more bits");g+=B}var Re=zi(g,I)}while(Object.hasOwnProperty.call(ne,Re));return ne[Re]=se,Re},ne=Y.hats={};return Y.get=function(se){return Y.hats[se]},Y.set=function(se,fe){return Y.hats[se]=fe,Y},Y.bits=g||128,Y.base=I||16,Y};var Ti=v(Vr.exports),Tt=function(g,I){this.ctx=g,this.properties=I.properties||{},this.coordinates=I.geometry.coordinates,this.id=I.id||Ti(),this.type=I.geometry.type};Tt.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},Tt.prototype.incomingCoords=function(g){this.setCoordinates(g)},Tt.prototype.setCoordinates=function(g){this.coordinates=g,this.changed()},Tt.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},Tt.prototype.setProperty=function(g,I){this.properties[g]=I},Tt.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:Pe.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},Tt.prototype.internal=function(g){var I={id:this.id,meta:nt.FEATURE,"meta:type":this.type,active:it.INACTIVE,mode:g};if(this.ctx.options.userProperties)for(var B in this.properties)I["user_"+B]=this.properties[B];return{type:Pe.FEATURE,properties:I,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var mi=function(g,I){Tt.call(this,g,I)};(mi.prototype=Object.create(Tt.prototype)).isValid=function(){return typeof this.coordinates[0]=="number"&&typeof this.coordinates[1]=="number"},mi.prototype.updateCoordinate=function(g,I,B){this.coordinates=arguments.length===3?[I,B]:[g,I],this.changed()},mi.prototype.getCoordinate=function(){return this.getCoordinates()};var Oi=function(g,I){Tt.call(this,g,I)};(Oi.prototype=Object.create(Tt.prototype)).isValid=function(){return this.coordinates.length>1},Oi.prototype.addCoordinate=function(g,I,B){this.changed();var Y=parseInt(g,10);this.coordinates.splice(Y,0,[I,B])},Oi.prototype.getCoordinate=function(g){var I=parseInt(g,10);return JSON.parse(JSON.stringify(this.coordinates[I]))},Oi.prototype.removeCoordinate=function(g){this.changed(),this.coordinates.splice(parseInt(g,10),1)},Oi.prototype.updateCoordinate=function(g,I,B){var Y=parseInt(g,10);this.coordinates[Y]=[I,B],this.changed()};var Fe=function(g,I){Tt.call(this,g,I),this.coordinates=this.coordinates.map(function(B){return B.slice(0,-1)})};(Fe.prototype=Object.create(Tt.prototype)).isValid=function(){return this.coordinates.length!==0&&this.coordinates.every(function(g){return g.length>2})},Fe.prototype.incomingCoords=function(g){this.coordinates=g.map(function(I){return I.slice(0,-1)}),this.changed()},Fe.prototype.setCoordinates=function(g){this.coordinates=g,this.changed()},Fe.prototype.addCoordinate=function(g,I,B){this.changed();var Y=g.split(".").map(function(ne){return parseInt(ne,10)});this.coordinates[Y[0]].splice(Y[1],0,[I,B])},Fe.prototype.removeCoordinate=function(g){this.changed();var I=g.split(".").map(function(Y){return parseInt(Y,10)}),B=this.coordinates[I[0]];B&&(B.splice(I[1],1),B.length<3&&this.coordinates.splice(I[0],1))},Fe.prototype.getCoordinate=function(g){var I=g.split(".").map(function(Y){return parseInt(Y,10)}),B=this.coordinates[I[0]];return JSON.parse(JSON.stringify(B[I[1]]))},Fe.prototype.getCoordinates=function(){return this.coordinates.map(function(g){return g.concat([g[0]])})},Fe.prototype.updateCoordinate=function(g,I,B){this.changed();var Y=g.split("."),ne=parseInt(Y[0],10),se=parseInt(Y[1],10);this.coordinates[ne]===void 0&&(this.coordinates[ne]=[]),this.coordinates[ne][se]=[I,B]};var Pt={MultiPoint:mi,MultiLineString:Oi,MultiPolygon:Fe},Xe=function(g,I,B,Y,ne){var se=B.split("."),fe=parseInt(se[0],10),Re=se[1]?se.slice(1).join("."):null;return g[fe][I](Re,Y,ne)},Gt=function(g,I){if(Tt.call(this,g,I),delete this.coordinates,this.model=Pt[I.geometry.type],this.model===void 0)throw new TypeError(I.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(I.geometry.coordinates)};function ct(g){this.map=g.map,this.drawConfig=JSON.parse(JSON.stringify(g.options||{})),this._ctx=g}(Gt.prototype=Object.create(Tt.prototype))._coordinatesToFeatures=function(g){var I=this,B=this.model.bind(this);return g.map(function(Y){return new B(I.ctx,{id:Ti(),type:Pe.FEATURE,properties:{},geometry:{coordinates:Y,type:I.type.replace("Multi","")}})})},Gt.prototype.isValid=function(){return this.features.every(function(g){return g.isValid()})},Gt.prototype.setCoordinates=function(g){this.features=this._coordinatesToFeatures(g),this.changed()},Gt.prototype.getCoordinate=function(g){return Xe(this.features,"getCoordinate",g)},Gt.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(function(g){return g.type===Pe.POLYGON?g.getCoordinates():g.coordinates})))},Gt.prototype.updateCoordinate=function(g,I,B){Xe(this.features,"updateCoordinate",g,I,B),this.changed()},Gt.prototype.addCoordinate=function(g,I,B){Xe(this.features,"addCoordinate",g,I,B),this.changed()},Gt.prototype.removeCoordinate=function(g){Xe(this.features,"removeCoordinate",g),this.changed()},Gt.prototype.getFeatures=function(){return this.features},ct.prototype.setSelected=function(g){return this._ctx.store.setSelected(g)},ct.prototype.setSelectedCoordinates=function(g){var I=this;this._ctx.store.setSelectedCoordinates(g),g.reduce(function(B,Y){return B[Y.feature_id]===void 0&&(B[Y.feature_id]=!0,I._ctx.store.get(Y.feature_id).changed()),B},{})},ct.prototype.getSelected=function(){return this._ctx.store.getSelected()},ct.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},ct.prototype.isSelected=function(g){return this._ctx.store.isSelected(g)},ct.prototype.getFeature=function(g){return this._ctx.store.get(g)},ct.prototype.select=function(g){return this._ctx.store.select(g)},ct.prototype.deselect=function(g){return this._ctx.store.deselect(g)},ct.prototype.deleteFeature=function(g,I){return I===void 0&&(I={}),this._ctx.store.delete(g,I)},ct.prototype.addFeature=function(g){return this._ctx.store.add(g)},ct.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},ct.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},ct.prototype.setActionableState=function(g){g===void 0&&(g={});var I={trash:g.trash||!1,combineFeatures:g.combineFeatures||!1,uncombineFeatures:g.uncombineFeatures||!1};return this._ctx.events.actionable(I)},ct.prototype.changeMode=function(g,I,B){return I===void 0&&(I={}),B===void 0&&(B={}),this._ctx.events.changeMode(g,I,B)},ct.prototype.updateUIClasses=function(g){return this._ctx.ui.queueMapClasses(g)},ct.prototype.activateUIButton=function(g){return this._ctx.ui.setActiveButton(g)},ct.prototype.featuresAt=function(g,I,B){if(B===void 0&&(B="click"),B!=="click"&&B!=="touch")throw new Error("invalid buffer type");return Dt[B](g,I,this._ctx)},ct.prototype.newFeature=function(g){var I=g.geometry.type;return I===Pe.POINT?new mi(this._ctx,g):I===Pe.LINE_STRING?new Oi(this._ctx,g):I===Pe.POLYGON?new Fe(this._ctx,g):new Gt(this._ctx,g)},ct.prototype.isInstanceOf=function(g,I){if(g===Pe.POINT)return I instanceof mi;if(g===Pe.LINE_STRING)return I instanceof Oi;if(g===Pe.POLYGON)return I instanceof Fe;if(g==="MultiFeature")return I instanceof Gt;throw new Error("Unknown feature class: "+g)},ct.prototype.doRender=function(g){return this._ctx.store.featureChanged(g)},ct.prototype.onSetup=function(){},ct.prototype.onDrag=function(){},ct.prototype.onClick=function(){},ct.prototype.onMouseMove=function(){},ct.prototype.onMouseDown=function(){},ct.prototype.onMouseUp=function(){},ct.prototype.onMouseOut=function(){},ct.prototype.onKeyUp=function(){},ct.prototype.onKeyDown=function(){},ct.prototype.onTouchStart=function(){},ct.prototype.onTouchMove=function(){},ct.prototype.onTouchEnd=function(){},ct.prototype.onTap=function(){},ct.prototype.onStop=function(){},ct.prototype.onTrash=function(){},ct.prototype.onCombineFeature=function(){},ct.prototype.onUncombineFeature=function(){},ct.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var Zi={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},gr=Object.keys(Zi);function je(g){var I=Object.keys(g);return function(B,Y){Y===void 0&&(Y={});var ne={},se=I.reduce(function(fe,Re){return fe[Re]=g[Re],fe},new ct(B));return{start:function(){var fe=this;ne=se.onSetup(Y),gr.forEach(function(Re){var Ue,rt=Zi[Re],ot=function(){return!1};g[rt]&&(ot=function(){return!0}),fe.on(Re,ot,(Ue=rt,function(Ye){return se[Ue](ne,Ye)}))})},stop:function(){se.onStop(ne)},trash:function(){se.onTrash(ne)},combineFeatures:function(){se.onCombineFeatures(ne)},uncombineFeatures:function(){se.onUncombineFeatures(ne)},render:function(fe,Re){se.toDisplayFeatures(ne,fe,Re)}}}}function Bi(g){return[].concat(g).filter(function(I){return I!==void 0})}function yr(){var g=this;if(!(g.ctx.map&&g.ctx.map.getSource(ge.HOT)!==void 0))return Ue();var I=g.ctx.events.currentModeName();g.ctx.ui.queueMapClasses({mode:I});var B=[],Y=[];g.isDirty?Y=g.getAllIds():(B=g.getChangedIds().filter(function(rt){return g.get(rt)!==void 0}),Y=g.sources.hot.filter(function(rt){return rt.properties.id&&B.indexOf(rt.properties.id)===-1&&g.get(rt.properties.id)!==void 0}).map(function(rt){return rt.properties.id})),g.sources.hot=[];var ne=g.sources.cold.length;g.sources.cold=g.isDirty?[]:g.sources.cold.filter(function(rt){var ot=rt.properties.id||rt.properties.parent;return B.indexOf(ot)===-1});var se=ne!==g.sources.cold.length||Y.length>0;function fe(rt,ot){var Ye=g.get(rt).internal(I);g.ctx.events.currentModeRender(Ye,function(Rt){g.sources[ot].push(Rt)})}if(B.forEach(function(rt){return fe(rt,"hot")}),Y.forEach(function(rt){return fe(rt,"cold")}),se&&g.ctx.map.getSource(ge.COLD).setData({type:Pe.FEATURE_COLLECTION,features:g.sources.cold}),g.ctx.map.getSource(ge.HOT).setData({type:Pe.FEATURE_COLLECTION,features:g.sources.hot}),g._emitSelectionChange&&(g.ctx.map.fire(Ve.SELECTION_CHANGE,{features:g.getSelected().map(function(rt){return rt.toGeoJSON()}),points:g.getSelectedCoordinates().map(function(rt){return{type:Pe.FEATURE,properties:{},geometry:{type:Pe.POINT,coordinates:rt.coordinates}}})}),g._emitSelectionChange=!1),g._deletedFeaturesToEmit.length){var Re=g._deletedFeaturesToEmit.map(function(rt){return rt.toGeoJSON()});g._deletedFeaturesToEmit=[],g.ctx.map.fire(Ve.DELETE,{features:Re})}function Ue(){g.isDirty=!1,g.clearChangedIds()}Ue(),g.ctx.map.fire(Ve.RENDER,{})}function hi(g){var I,B=this;this._features={},this._featureIds=new We,this._selectedFeatureIds=new We,this._selectedCoordinates=[],this._changedFeatureIds=new We,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=g,this.sources={hot:[],cold:[]},this.render=function(){I||(I=requestAnimationFrame(function(){I=null,yr.call(B)}))},this.isDirty=!1}function co(g,I){var B=g._selectedCoordinates.filter(function(Y){return g._selectedFeatureIds.has(Y.feature_id)});g._selectedCoordinates.length===B.length||I.silent||(g._emitSelectionChange=!0),g._selectedCoordinates=B}hi.prototype.createRenderBatch=function(){var g=this,I=this.render,B=0;return this.render=function(){B++},function(){g.render=I,B>0&&g.render()}},hi.prototype.setDirty=function(){return this.isDirty=!0,this},hi.prototype.featureChanged=function(g){return this._changedFeatureIds.add(g),this},hi.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},hi.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},hi.prototype.getAllIds=function(){return this._featureIds.values()},hi.prototype.add=function(g){return this.featureChanged(g.id),this._features[g.id]=g,this._featureIds.add(g.id),this},hi.prototype.delete=function(g,I){var B=this;return I===void 0&&(I={}),Bi(g).forEach(function(Y){B._featureIds.has(Y)&&(B._featureIds.delete(Y),B._selectedFeatureIds.delete(Y),I.silent||B._deletedFeaturesToEmit.indexOf(B._features[Y])===-1&&B._deletedFeaturesToEmit.push(B._features[Y]),delete B._features[Y],B.isDirty=!0)}),co(this,I),this},hi.prototype.get=function(g){return this._features[g]},hi.prototype.getAll=function(){var g=this;return Object.keys(this._features).map(function(I){return g._features[I]})},hi.prototype.select=function(g,I){var B=this;return I===void 0&&(I={}),Bi(g).forEach(function(Y){B._selectedFeatureIds.has(Y)||(B._selectedFeatureIds.add(Y),B._changedFeatureIds.add(Y),I.silent||(B._emitSelectionChange=!0))}),this},hi.prototype.deselect=function(g,I){var B=this;return I===void 0&&(I={}),Bi(g).forEach(function(Y){B._selectedFeatureIds.has(Y)&&(B._selectedFeatureIds.delete(Y),B._changedFeatureIds.add(Y),I.silent||(B._emitSelectionChange=!0))}),co(this,I),this},hi.prototype.clearSelected=function(g){return g===void 0&&(g={}),this.deselect(this._selectedFeatureIds.values(),{silent:g.silent}),this},hi.prototype.setSelected=function(g,I){var B=this;return I===void 0&&(I={}),g=Bi(g),this.deselect(this._selectedFeatureIds.values().filter(function(Y){return g.indexOf(Y)===-1}),{silent:I.silent}),this.select(g.filter(function(Y){return!B._selectedFeatureIds.has(Y)}),{silent:I.silent}),this},hi.prototype.setSelectedCoordinates=function(g){return this._selectedCoordinates=g,this._emitSelectionChange=!0,this},hi.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},hi.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},hi.prototype.getSelected=function(){var g=this;return this._selectedFeatureIds.values().map(function(I){return g.get(I)})},hi.prototype.getSelectedCoordinates=function(){var g=this;return this._selectedCoordinates.map(function(I){return{coordinates:g.get(I.feature_id).getCoordinate(I.coord_path)}})},hi.prototype.isSelected=function(g){return this._selectedFeatureIds.has(g)},hi.prototype.setFeatureProperty=function(g,I,B){this.get(g).setProperty(I,B),this.featureChanged(g)},hi.prototype.storeMapConfig=function(){var g=this;Vt.forEach(function(I){g.ctx.map[I]&&(g._mapInitialConfig[I]=g.ctx.map[I].isEnabled())})},hi.prototype.restoreMapConfig=function(){var g=this;Object.keys(this._mapInitialConfig).forEach(function(I){g._mapInitialConfig[I]?g.ctx.map[I].enable():g.ctx.map[I].disable()})},hi.prototype.getInitialConfigValue=function(g){return this._mapInitialConfig[g]===void 0||this._mapInitialConfig[g]};var wo=function(){for(var g=arguments,I={},B=0;B=48&&ze<=57)};function Ot(ze,_t,vi){vi===void 0&&(vi={}),Rt.stop();var Xi=Re[ze];if(Xi===void 0)throw new Error(ze+" is not valid");Ye=ze;var tr=Xi(fe,_t);Rt=_(tr,fe),vi.silent||fe.map.fire(Ve.MODE_CHANGE,{mode:ze}),fe.store.setDirty(),fe.store.render()}ot.keydown=function(ze){(ze.srcElement||ze.target).classList.contains("mapboxgl-canvas")&&(ze.keyCode!==8&&ze.keyCode!==46||!fe.options.controls.trash?Hi(ze.keyCode)?Rt.keydown(ze):ze.keyCode===49&&fe.options.controls.point?Ot(De.DRAW_POINT):ze.keyCode===50&&fe.options.controls.line_string?Ot(De.DRAW_LINE_STRING):ze.keyCode===51&&fe.options.controls.polygon&&Ot(De.DRAW_POLYGON):(ze.preventDefault(),Rt.trash()))},ot.keyup=function(ze){Hi(ze.keyCode)&&Rt.keyup(ze)},ot.zoomend=function(){fe.store.changeZoom()},ot.data=function(ze){if(ze.dataType==="style"){var _t=fe.setup,vi=fe.map,Xi=fe.options,tr=fe.store;Xi.styles.some(function(nn){return vi.getLayer(nn.id)})||(_t.addLayers(),tr.setDirty(),tr.render())}};var ar={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start:function(){Ye=fe.options.defaultMode,Rt=_(Re[Ye](fe),fe)},changeMode:Ot,actionable:function(ze){var _t=!1;Object.keys(ze).forEach(function(vi){if(ar[vi]===void 0)throw new Error("Invalid action type");ar[vi]!==ze[vi]&&(_t=!0),ar[vi]=ze[vi]}),_t&&fe.map.fire(Ve.ACTIONABLE,{actions:ar})},currentModeName:function(){return Ye},currentModeRender:function(ze,_t){return Rt.render(ze,_t)},fire:function(ze,_t){ot[ze]&&ot[ze](_t)},addEventListeners:function(){fe.map.on("mousemove",ot.mousemove),fe.map.on("mousedown",ot.mousedown),fe.map.on("mouseup",ot.mouseup),fe.map.on("data",ot.data),fe.map.on("touchmove",ot.touchmove),fe.map.on("touchstart",ot.touchstart),fe.map.on("touchend",ot.touchend),fe.container.addEventListener("mouseout",ot.mouseout),fe.options.keybindings&&(fe.container.addEventListener("keydown",ot.keydown),fe.container.addEventListener("keyup",ot.keyup))},removeEventListeners:function(){fe.map.off("mousemove",ot.mousemove),fe.map.off("mousedown",ot.mousedown),fe.map.off("mouseup",ot.mouseup),fe.map.off("data",ot.data),fe.map.off("touchmove",ot.touchmove),fe.map.off("touchstart",ot.touchstart),fe.map.off("touchend",ot.touchend),fe.container.removeEventListener("mouseout",ot.mouseout),fe.options.keybindings&&(fe.container.removeEventListener("keydown",ot.keydown),fe.container.removeEventListener("keyup",ot.keyup))},trash:function(ze){Rt.trash(ze)},combineFeatures:function(){Rt.combineFeatures()},uncombineFeatures:function(){Rt.uncombineFeatures()},getMode:function(){return Ye}}}(g),g.ui=function(fe){var Re={},Ue=null,rt={mode:null,feature:null,mouse:null},ot={mode:null,feature:null,mouse:null};function Ye(ze){ot=Se(ot,ze)}function Rt(){var ze,_t;if(fe.container){var vi=[],Xi=[];tn.forEach(function(tr){ot[tr]!==rt[tr]&&(vi.push(tr+"-"+rt[tr]),ot[tr]!==null&&Xi.push(tr+"-"+ot[tr]))}),vi.length>0&&(ze=fe.container.classList).remove.apply(ze,vi),Xi.length>0&&(_t=fe.container.classList).add.apply(_t,Xi),rt=Se(rt,ot)}}function Hi(ze,_t){_t===void 0&&(_t={});var vi=document.createElement("button");return vi.className=be.CONTROL_BUTTON+" "+_t.className,vi.setAttribute("title",_t.title),_t.container.appendChild(vi),vi.addEventListener("click",function(Xi){if(Xi.preventDefault(),Xi.stopPropagation(),Xi.target===Ue)return Ot(),void _t.onDeactivate();ar(ze),_t.onActivate()},!0),vi}function Ot(){Ue&&(Ue.classList.remove(be.ACTIVE_BUTTON),Ue=null)}function ar(ze){Ot();var _t=Re[ze];_t&&_t&&ze!=="trash"&&(_t.classList.add(be.ACTIVE_BUTTON),Ue=_t)}return{setActiveButton:ar,queueMapClasses:Ye,updateMapClasses:Rt,clearMapClasses:function(){Ye({mode:null,feature:null,mouse:null}),Rt()},addButtons:function(){var ze=fe.options.controls,_t=document.createElement("div");return _t.className=be.CONTROL_GROUP+" "+be.CONTROL_BASE,ze&&(ze[ke.LINE]&&(Re[ke.LINE]=Hi(ke.LINE,{container:_t,className:be.CONTROL_BUTTON_LINE,title:"LineString tool "+(fe.options.keybindings?"(l)":""),onActivate:function(){return fe.events.changeMode(De.DRAW_LINE_STRING)},onDeactivate:function(){return fe.events.trash()}})),ze[ke.POLYGON]&&(Re[ke.POLYGON]=Hi(ke.POLYGON,{container:_t,className:be.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(fe.options.keybindings?"(p)":""),onActivate:function(){return fe.events.changeMode(De.DRAW_POLYGON)},onDeactivate:function(){return fe.events.trash()}})),ze[ke.POINT]&&(Re[ke.POINT]=Hi(ke.POINT,{container:_t,className:be.CONTROL_BUTTON_POINT,title:"Marker tool "+(fe.options.keybindings?"(m)":""),onActivate:function(){return fe.events.changeMode(De.DRAW_POINT)},onDeactivate:function(){return fe.events.trash()}})),ze.trash&&(Re.trash=Hi("trash",{container:_t,className:be.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:function(){fe.events.trash()}})),ze.combine_features&&(Re.combine_features=Hi("combineFeatures",{container:_t,className:be.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:function(){fe.events.combineFeatures()}})),ze.uncombine_features&&(Re.uncombine_features=Hi("uncombineFeatures",{container:_t,className:be.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:function(){fe.events.uncombineFeatures()}}))),_t},removeButtons:function(){Object.keys(Re).forEach(function(ze){var _t=Re[ze];_t.parentNode&&_t.parentNode.removeChild(_t),delete Re[ze]})}}}(g),g.container=ne.getContainer(),g.store=new hi(g),I=g.ui.addButtons(),g.options.boxSelect&&(g.boxZoomInitial=ne.boxZoom.isEnabled(),ne.boxZoom.disable(),ne.dragPan.disable(),ne.dragPan.enable()),ne.loaded()?Y.connect():(ne.on("load",Y.connect),B=setInterval(function(){ne.loaded()&&Y.connect()},16)),g.events.start(),I},addLayers:function(){g.map.addSource(ge.COLD,{data:{type:Pe.FEATURE_COLLECTION,features:[]},type:"geojson"}),g.map.addSource(ge.HOT,{data:{type:Pe.FEATURE_COLLECTION,features:[]},type:"geojson"}),g.options.styles.forEach(function(ne){g.map.addLayer(ne)}),g.store.setDirty(!0),g.store.render()},removeLayers:function(){g.options.styles.forEach(function(ne){g.map.getLayer(ne.id)&&g.map.removeLayer(ne.id)}),g.map.getSource(ge.COLD)&&g.map.removeSource(ge.COLD),g.map.getSource(ge.HOT)&&g.map.removeSource(ge.HOT)}};return g.setup=Y,Y}var Ii=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}];function ii(g){return function(I){var B=I.featureTarget;return!!B&&!!B.properties&&B.properties.meta===g}}function Vn(g){return!!g.originalEvent&&!!g.originalEvent.shiftKey&&g.originalEvent.button===0}function En(g){return!!g.featureTarget&&!!g.featureTarget.properties&&g.featureTarget.properties.active===it.ACTIVE&&g.featureTarget.properties.meta===nt.FEATURE}function Un(g){return!!g.featureTarget&&!!g.featureTarget.properties&&g.featureTarget.properties.active===it.INACTIVE&&g.featureTarget.properties.meta===nt.FEATURE}function qo(g){return g.featureTarget===void 0}function So(g){return!!g.featureTarget&&!!g.featureTarget.properties&&g.featureTarget.properties.meta===nt.FEATURE}function Cn(g){var I=g.featureTarget;return!!I&&!!I.properties&&I.properties.meta===nt.VERTEX}function $n(g){return!!g.originalEvent&&g.originalEvent.shiftKey===!0}function Ze(g){return g.keyCode===27}function mn(g){return g.keyCode===13}var er=Object.freeze({__proto__:null,isOfMetaType:ii,isShiftMousedown:Vn,isActiveFeature:En,isInactiveFeature:Un,noTarget:qo,isFeature:So,isVertex:Cn,isShiftDown:$n,isEscapeKey:Ze,isEnterKey:mn,isTrue:function(){return!0}}),Zo=rn;function rn(g,I){this.x=g,this.y=I}rn.prototype={clone:function(){return new rn(this.x,this.y)},add:function(g){return this.clone()._add(g)},sub:function(g){return this.clone()._sub(g)},multByPoint:function(g){return this.clone()._multByPoint(g)},divByPoint:function(g){return this.clone()._divByPoint(g)},mult:function(g){return this.clone()._mult(g)},div:function(g){return this.clone()._div(g)},rotate:function(g){return this.clone()._rotate(g)},rotateAround:function(g,I){return this.clone()._rotateAround(g,I)},matMult:function(g){return this.clone()._matMult(g)},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(g){return this.x===g.x&&this.y===g.y},dist:function(g){return Math.sqrt(this.distSqr(g))},distSqr:function(g){var I=g.x-this.x,B=g.y-this.y;return I*I+B*B},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(g){return Math.atan2(this.y-g.y,this.x-g.x)},angleWith:function(g){return this.angleWithSep(g.x,g.y)},angleWithSep:function(g,I){return Math.atan2(this.x*I-this.y*g,this.x*g+this.y*I)},_matMult:function(g){var I=g[0]*this.x+g[1]*this.y,B=g[2]*this.x+g[3]*this.y;return this.x=I,this.y=B,this},_add:function(g){return this.x+=g.x,this.y+=g.y,this},_sub:function(g){return this.x-=g.x,this.y-=g.y,this},_mult:function(g){return this.x*=g,this.y*=g,this},_div:function(g){return this.x/=g,this.y/=g,this},_multByPoint:function(g){return this.x*=g.x,this.y*=g.y,this},_divByPoint:function(g){return this.x/=g.x,this.y/=g.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var g=this.y;return this.y=this.x,this.x=-g,this},_rotate:function(g){var I=Math.cos(g),B=Math.sin(g),Y=I*this.x-B*this.y,ne=B*this.x+I*this.y;return this.x=Y,this.y=ne,this},_rotateAround:function(g,I){var B=Math.cos(g),Y=Math.sin(g),ne=I.x+B*(this.x-I.x)-Y*(this.y-I.y),se=I.y+Y*(this.x-I.x)+B*(this.y-I.y);return this.x=ne,this.y=se,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},rn.convert=function(g){return g instanceof rn?g:Array.isArray(g)?new rn(g[0],g[1]):g};var He=v(Zo);function Bt(g,I){var B=I.getBoundingClientRect();return new He(g.clientX-B.left-(I.clientLeft||0),g.clientY-B.top-(I.clientTop||0))}function Mt(g,I,B,Y){return{type:Pe.FEATURE,properties:{meta:nt.VERTEX,parent:g,coord_path:B,active:Y?it.ACTIVE:it.INACTIVE},geometry:{type:Pe.POINT,coordinates:I}}}function Ur(g,I,B){var Y=I.geometry.coordinates,ne=B.geometry.coordinates;if(Y[1]>85||Y[1]85||ne[1]=I&&this._bbox[3]>=B},Ut.prototype.intersect=function(g){return this._valid?(I=g instanceof Ut?g.bbox():g,!(this._bbox[0]>I[2]||this._bbox[2]I[3])):null;var I},Ut.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var g="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",g)},Ut.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var ai=function(g){if(!g)return[];var I=Q(J(g)),B=[];return I.features.forEach(function(Y){Y.geometry&&(B=B.concat(he(Y.geometry.coordinates)))}),B},ri=Ft,jr=gi,Ei={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},hr=Object.keys(Ei);function vr(g){for(var I=jr(),B=ai(g),Y=0;YB&&(B=Ye),Rtne&&(ne=Rt),YeRe&&(Re=Ot)});var Ue=I;return B+Ue.lat>85&&(Ue.lat=85-B),ne+Ue.lat>90&&(Ue.lat=90-ne),Y+Ue.lat<-85&&(Ue.lat=-85-Y),se+Ue.lat=270&&(Ue.lng-=360*Math.ceil(Math.abs(Ue.lng)/360)),Ue}function Io(g,I){var B=To(g.map(function(Y){return Y.toGeoJSON()}),I);g.forEach(function(Y){var ne,se=Y.getCoordinates(),fe=function(Ue){var rt={lng:Ue[0]+B.lng,lat:Ue[1]+B.lat};return[rt.lng,rt.lat]},Re=function(Ue){return Ue.map(function(rt){return fe(rt)})};Y.type===Pe.POINT?ne=fe(se):Y.type===Pe.LINE_STRING||Y.type===Pe.MULTI_POINT?ne=se.map(fe):Y.type===Pe.POLYGON||Y.type===Pe.MULTI_LINE_STRING?ne=se.map(Re):Y.type===Pe.MULTI_POLYGON&&(ne=se.map(function(Ue){return Ue.map(function(rt){return Re(rt)})})),Y.incomingCoords(ne)})}var xr={onSetup:function(g){var I=this,B={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:g.featureIds||[]};return this.setSelected(B.initiallySelectedFeatureIds.filter(function(Y){return I.getFeature(Y)!==void 0})),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),B},fireUpdate:function(){this.map.fire(Ve.UPDATE,{action:at.MOVE,features:this.getSelected().map(function(g){return g.toGeoJSON()})})},fireActionable:function(){var g=this,I=this.getSelected(),B=I.filter(function(Re){return g.isInstanceOf("MultiFeature",Re)}),Y=!1;if(I.length>1){Y=!0;var ne=I[0].type.replace("Multi","");I.forEach(function(Re){Re.type.replace("Multi","")!==ne&&(Y=!1)})}var se=B.length>0,fe=I.length>0;this.setActionableState({combineFeatures:Y,uncombineFeatures:se,trash:fe})},getUniqueIds:function(g){return g.length?g.map(function(I){return I.properties.id}).filter(function(I){return I!==void 0}).reduce(function(I,B){return I.add(B),I},new We).values():[]},stopExtendedInteractions:function(g){g.boxSelectElement&&(g.boxSelectElement.parentNode&&g.boxSelectElement.parentNode.removeChild(g.boxSelectElement),g.boxSelectElement=null),this.map.dragPan.enable(),g.boxSelecting=!1,g.canBoxSelect=!1,g.dragMoving=!1,g.canDragMove=!1},onStop:function(){It.enable(this)},onMouseMove:function(g,I){return So(I)&&g.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(g),!0},onMouseOut:function(g){return!g.dragMoving||this.fireUpdate()}};xr.onTap=xr.onClick=function(g,I){return qo(I)?this.clickAnywhere(g,I):ii(nt.VERTEX)(I)?this.clickOnVertex(g,I):So(I)?this.clickOnFeature(g,I):void 0},xr.clickAnywhere=function(g){var I=this,B=this.getSelectedIds();B.length&&(this.clearSelectedFeatures(),B.forEach(function(Y){return I.doRender(Y)})),It.enable(this),this.stopExtendedInteractions(g)},xr.clickOnVertex=function(g,I){this.changeMode(De.DIRECT_SELECT,{featureId:I.featureTarget.properties.parent,coordPath:I.featureTarget.properties.coord_path,startPos:I.lngLat}),this.updateUIClasses({mouse:Oe.MOVE})},xr.startOnActiveFeature=function(g,I){this.stopExtendedInteractions(g),this.map.dragPan.disable(),this.doRender(I.featureTarget.properties.id),g.canDragMove=!0,g.dragMoveLocation=I.lngLat},xr.clickOnFeature=function(g,I){var B=this;It.disable(this),this.stopExtendedInteractions(g);var Y=$n(I),ne=this.getSelectedIds(),se=I.featureTarget.properties.id,fe=this.isSelected(se);if(!Y&&fe&&this.getFeature(se).type!==Pe.POINT)return this.changeMode(De.DIRECT_SELECT,{featureId:se});fe&&Y?(this.deselect(se),this.updateUIClasses({mouse:Oe.POINTER}),ne.length===1&&It.enable(this)):!fe&&Y?(this.select(se),this.updateUIClasses({mouse:Oe.MOVE})):fe||Y||(ne.forEach(function(Re){return B.doRender(Re)}),this.setSelected(se),this.updateUIClasses({mouse:Oe.MOVE})),this.doRender(se)},xr.onMouseDown=function(g,I){return En(I)?this.startOnActiveFeature(g,I):this.drawConfig.boxSelect&&Vn(I)?this.startBoxSelect(g,I):void 0},xr.startBoxSelect=function(g,I){this.stopExtendedInteractions(g),this.map.dragPan.disable(),g.boxSelectStartLocation=Bt(I.originalEvent,this.map.getContainer()),g.canBoxSelect=!0},xr.onTouchStart=function(g,I){if(En(I))return this.startOnActiveFeature(g,I)},xr.onDrag=function(g,I){return g.canDragMove?this.dragMove(g,I):this.drawConfig.boxSelect&&g.canBoxSelect?this.whileBoxSelect(g,I):void 0},xr.whileBoxSelect=function(g,I){g.boxSelecting=!0,this.updateUIClasses({mouse:Oe.ADD}),g.boxSelectElement||(g.boxSelectElement=document.createElement("div"),g.boxSelectElement.classList.add(be.BOX_SELECT),this.map.getContainer().appendChild(g.boxSelectElement));var B=Bt(I.originalEvent,this.map.getContainer()),Y=Math.min(g.boxSelectStartLocation.x,B.x),ne=Math.max(g.boxSelectStartLocation.x,B.x),se=Math.min(g.boxSelectStartLocation.y,B.y),fe=Math.max(g.boxSelectStartLocation.y,B.y),Re="translate("+Y+"px, "+se+"px)";g.boxSelectElement.style.transform=Re,g.boxSelectElement.style.WebkitTransform=Re,g.boxSelectElement.style.width=ne-Y+"px",g.boxSelectElement.style.height=fe-se+"px"},xr.dragMove=function(g,I){g.dragMoving=!0,I.originalEvent.stopPropagation();var B={lng:I.lngLat.lng-g.dragMoveLocation.lng,lat:I.lngLat.lat-g.dragMoveLocation.lat};Io(this.getSelected(),B),g.dragMoveLocation=I.lngLat},xr.onTouchEnd=xr.onMouseUp=function(g,I){var B=this;if(g.dragMoving)this.fireUpdate();else if(g.boxSelecting){var Y=[g.boxSelectStartLocation,Bt(I.originalEvent,this.map.getContainer())],ne=this.featuresAt(null,Y,"click"),se=this.getUniqueIds(ne).filter(function(fe){return!B.isSelected(fe)});se.length&&(this.select(se),se.forEach(function(fe){return B.doRender(fe)}),this.updateUIClasses({mouse:Oe.MOVE}))}this.stopExtendedInteractions(g)},xr.toDisplayFeatures=function(g,I,B){I.properties.active=this.isSelected(I.properties.id)?it.ACTIVE:it.INACTIVE,B(I),this.fireActionable(),I.properties.active===it.ACTIVE&&I.geometry.type!==Pe.POINT&&_n(I).forEach(B)},xr.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},xr.onCombineFeatures=function(){var g=this.getSelected();if(!(g.length===0||g.length<2)){for(var I=[],B=[],Y=g[0].type.replace("Multi",""),ne=0;ne1){var fe=this.newFeature({type:Pe.FEATURE,properties:B[0].properties,geometry:{type:"Multi"+Y,coordinates:I}});this.addFeature(fe),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([fe.id]),this.map.fire(Ve.COMBINE_FEATURES,{createdFeatures:[fe.toGeoJSON()],deletedFeatures:B})}this.fireActionable()}},xr.onUncombineFeatures=function(){var g=this,I=this.getSelected();if(I.length!==0){for(var B=[],Y=[],ne=function(fe){var Re=I[fe];g.isInstanceOf("MultiFeature",Re)&&(Re.getFeatures().forEach(function(Ue){g.addFeature(Ue),Ue.properties=Re.properties,B.push(Ue.toGeoJSON()),g.select([Ue.id])}),g.deleteFeature(Re.id,{silent:!0}),Y.push(Re.toGeoJSON()))},se=0;se1&&this.map.fire(Ve.UNCOMBINE_FEATURES,{createdFeatures:B,deletedFeatures:Y}),this.fireActionable()}};var yi=ii(nt.VERTEX),ta=ii(nt.MIDPOINT),jn={fireUpdate:function(){this.map.fire(Ve.UPDATE,{action:at.CHANGE_COORDINATES,features:this.getSelected().map(function(g){return g.toGeoJSON()})})},fireActionable:function(g){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:g.selectedCoordPaths.length>0})},startDragging:function(g,I){this.map.dragPan.disable(),g.canDragMove=!0,g.dragMoveLocation=I.lngLat},stopDragging:function(g){this.map.dragPan.enable(),g.dragMoving=!1,g.canDragMove=!1,g.dragMoveLocation=null},onVertex:function(g,I){this.startDragging(g,I);var B=I.featureTarget.properties,Y=g.selectedCoordPaths.indexOf(B.coord_path);$n(I)||Y!==-1?$n(I)&&Y===-1&&g.selectedCoordPaths.push(B.coord_path):g.selectedCoordPaths=[B.coord_path];var ne=this.pathsToCoordinates(g.featureId,g.selectedCoordPaths);this.setSelectedCoordinates(ne)},onMidpoint:function(g,I){this.startDragging(g,I);var B=I.featureTarget.properties;g.feature.addCoordinate(B.coord_path,B.lng,B.lat),this.fireUpdate(),g.selectedCoordPaths=[B.coord_path]},pathsToCoordinates:function(g,I){return I.map(function(B){return{feature_id:g,coord_path:B}})},onFeature:function(g,I){g.selectedCoordPaths.length===0?this.startDragging(g,I):this.stopDragging(g)},dragFeature:function(g,I,B){Io(this.getSelected(),B),g.dragMoveLocation=I.lngLat},dragVertex:function(g,I,B){for(var Y=g.selectedCoordPaths.map(function(Re){return g.feature.getCoordinate(Re)}),ne=To(Y.map(function(Re){return{type:Pe.FEATURE,properties:{},geometry:{type:Pe.POINT,coordinates:Re}}}),B),se=0;se0?this.dragVertex(g,I,B):this.dragFeature(g,I,B),g.dragMoveLocation=I.lngLat}},jn.onClick=function(g,I){return qo(I)?this.clickNoTarget(g,I):En(I)?this.clickActiveFeature(g,I):Un(I)?this.clickInactive(g,I):void this.stopDragging(g)},jn.onTap=function(g,I){return qo(I)?this.clickNoTarget(g,I):En(I)?this.clickActiveFeature(g,I):Un(I)?this.clickInactive(g,I):void 0},jn.onTouchEnd=jn.onMouseUp=function(g){g.dragMoving&&this.fireUpdate(),this.stopDragging(g)};var ji={};function qr(g,I){return!!g.lngLat&&g.lngLat.lng===I[0]&&g.lngLat.lat===I[1]}ji.onSetup=function(){var g=this.newFeature({type:Pe.FEATURE,properties:{},geometry:{type:Pe.POINT,coordinates:[]}});return this.addFeature(g),this.clearSelectedFeatures(),this.updateUIClasses({mouse:Oe.ADD}),this.activateUIButton(ke.POINT),this.setActionableState({trash:!0}),{point:g}},ji.stopDrawingAndRemove=function(g){this.deleteFeature([g.point.id],{silent:!0}),this.changeMode(De.SIMPLE_SELECT)},ji.onTap=ji.onClick=function(g,I){this.updateUIClasses({mouse:Oe.MOVE}),g.point.updateCoordinate("",I.lngLat.lng,I.lngLat.lat),this.map.fire(Ve.CREATE,{features:[g.point.toGeoJSON()]}),this.changeMode(De.SIMPLE_SELECT,{featureIds:[g.point.id]})},ji.onStop=function(g){this.activateUIButton(),g.point.getCoordinate().length||this.deleteFeature([g.point.id],{silent:!0})},ji.toDisplayFeatures=function(g,I,B){var Y=I.properties.id===g.point.id;if(I.properties.active=Y?it.ACTIVE:it.INACTIVE,!Y)return B(I)},ji.onTrash=ji.stopDrawingAndRemove,ji.onKeyUp=function(g,I){if(Ze(I)||mn(I))return this.stopDrawingAndRemove(g,I)};var Go={onSetup:function(){var g=this.newFeature({type:Pe.FEATURE,properties:{},geometry:{type:Pe.POLYGON,coordinates:[[]]}});return this.addFeature(g),this.clearSelectedFeatures(),It.disable(this),this.updateUIClasses({mouse:Oe.ADD}),this.activateUIButton(ke.POLYGON),this.setActionableState({trash:!0}),{polygon:g,currentVertexPosition:0}},clickAnywhere:function(g,I){if(g.currentVertexPosition>0&&qr(I,g.polygon.coordinates[0][g.currentVertexPosition-1]))return this.changeMode(De.SIMPLE_SELECT,{featureIds:[g.polygon.id]});this.updateUIClasses({mouse:Oe.ADD}),g.polygon.updateCoordinate("0."+g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat),g.currentVertexPosition++,g.polygon.updateCoordinate("0."+g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat)},clickOnVertex:function(g){return this.changeMode(De.SIMPLE_SELECT,{featureIds:[g.polygon.id]})},onMouseMove:function(g,I){g.polygon.updateCoordinate("0."+g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat),Cn(I)&&this.updateUIClasses({mouse:Oe.POINTER})}};Go.onTap=Go.onClick=function(g,I){return Cn(I)?this.clickOnVertex(g,I):this.clickAnywhere(g,I)},Go.onKeyUp=function(g,I){Ze(I)?(this.deleteFeature([g.polygon.id],{silent:!0}),this.changeMode(De.SIMPLE_SELECT)):mn(I)&&this.changeMode(De.SIMPLE_SELECT,{featureIds:[g.polygon.id]})},Go.onStop=function(g){this.updateUIClasses({mouse:Oe.NONE}),It.enable(this),this.activateUIButton(),this.getFeature(g.polygon.id)!==void 0&&(g.polygon.removeCoordinate("0."+g.currentVertexPosition),g.polygon.isValid()?this.map.fire(Ve.CREATE,{features:[g.polygon.toGeoJSON()]}):(this.deleteFeature([g.polygon.id],{silent:!0}),this.changeMode(De.SIMPLE_SELECT,{},{silent:!0})))},Go.toDisplayFeatures=function(g,I,B){var Y=I.properties.id===g.polygon.id;if(I.properties.active=Y?it.ACTIVE:it.INACTIVE,!Y)return B(I);if(I.geometry.coordinates.length!==0){var ne=I.geometry.coordinates[0].length;if(!(ne<3)){if(I.properties.meta=nt.FEATURE,B(Mt(g.polygon.id,I.geometry.coordinates[0][0],"0.0",!1)),ne>3){var se=I.geometry.coordinates[0].length-3;B(Mt(g.polygon.id,I.geometry.coordinates[0][se],"0."+se,!1))}if(ne<=4){var fe=[[I.geometry.coordinates[0][0][0],I.geometry.coordinates[0][0][1]],[I.geometry.coordinates[0][1][0],I.geometry.coordinates[0][1][1]]];if(B({type:Pe.FEATURE,properties:I.properties,geometry:{coordinates:fe,type:Pe.LINE_STRING}}),ne===3)return}return B(I)}}},Go.onTrash=function(g){this.deleteFeature([g.polygon.id],{silent:!0}),this.changeMode(De.SIMPLE_SELECT)};var Ir={onSetup:function(g){var I,B,Y=(g=g||{}).featureId,ne="forward";if(Y){if(!(I=this.getFeature(Y)))throw new Error("Could not find a feature with the provided featureId");var se=g.from;if(se&&se.type==="Feature"&&se.geometry&&se.geometry.type==="Point"&&(se=se.geometry),se&&se.type==="Point"&&se.coordinates&&se.coordinates.length===2&&(se=se.coordinates),!se||!Array.isArray(se))throw new Error("Please use the `from` property to indicate which point to continue the line from");var fe=I.coordinates.length-1;if(I.coordinates[fe][0]===se[0]&&I.coordinates[fe][1]===se[1])B=fe+1,I.addCoordinate.apply(I,[B].concat(I.coordinates[fe]));else{if(I.coordinates[0][0]!==se[0]||I.coordinates[0][1]!==se[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");ne="backwards",B=0,I.addCoordinate.apply(I,[B].concat(I.coordinates[0]))}}else I=this.newFeature({type:Pe.FEATURE,properties:{},geometry:{type:Pe.LINE_STRING,coordinates:[]}}),B=0,this.addFeature(I);return this.clearSelectedFeatures(),It.disable(this),this.updateUIClasses({mouse:Oe.ADD}),this.activateUIButton(ke.LINE),this.setActionableState({trash:!0}),{line:I,currentVertexPosition:B,direction:ne}},clickAnywhere:function(g,I){if(g.currentVertexPosition>0&&qr(I,g.line.coordinates[g.currentVertexPosition-1])||g.direction==="backwards"&&qr(I,g.line.coordinates[g.currentVertexPosition+1]))return this.changeMode(De.SIMPLE_SELECT,{featureIds:[g.line.id]});this.updateUIClasses({mouse:Oe.ADD}),g.line.updateCoordinate(g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat),g.direction==="forward"?(g.currentVertexPosition++,g.line.updateCoordinate(g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat)):g.line.addCoordinate(0,I.lngLat.lng,I.lngLat.lat)},clickOnVertex:function(g){return this.changeMode(De.SIMPLE_SELECT,{featureIds:[g.line.id]})},onMouseMove:function(g,I){g.line.updateCoordinate(g.currentVertexPosition,I.lngLat.lng,I.lngLat.lat),Cn(I)&&this.updateUIClasses({mouse:Oe.POINTER})}};Ir.onTap=Ir.onClick=function(g,I){if(Cn(I))return this.clickOnVertex(g,I);this.clickAnywhere(g,I)},Ir.onKeyUp=function(g,I){mn(I)?this.changeMode(De.SIMPLE_SELECT,{featureIds:[g.line.id]}):Ze(I)&&(this.deleteFeature([g.line.id],{silent:!0}),this.changeMode(De.SIMPLE_SELECT))},Ir.onStop=function(g){It.enable(this),this.activateUIButton(),this.getFeature(g.line.id)!==void 0&&(g.line.removeCoordinate(""+g.currentVertexPosition),g.line.isValid()?this.map.fire(Ve.CREATE,{features:[g.line.toGeoJSON()]}):(this.deleteFeature([g.line.id],{silent:!0}),this.changeMode(De.SIMPLE_SELECT,{},{silent:!0})))},Ir.onTrash=function(g){this.deleteFeature([g.line.id],{silent:!0}),this.changeMode(De.SIMPLE_SELECT)},Ir.toDisplayFeatures=function(g,I,B){var Y=I.properties.id===g.line.id;if(I.properties.active=Y?it.ACTIVE:it.INACTIVE,!Y)return B(I);I.geometry.coordinates.length<2||(I.properties.meta=nt.FEATURE,B(Mt(g.line.id,I.geometry.coordinates[g.direction==="forward"?I.geometry.coordinates.length-2:1],""+(g.direction==="forward"?I.geometry.coordinates.length-2:1),!1)),B(I))};var Er={simple_select:xr,direct_select:jn,draw_point:ji,draw_polygon:Go,draw_line_string:Ir},ia={defaultMode:De.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Ii,modes:Er,controls:{},userProperties:!1},os={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Gi={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function di(g,I){return g.map(function(B){return B.source?B:Se(B,{id:B.id+"."+I,source:I==="hot"?ge.HOT:ge.COLD})})}var uo={exports:{}};(function(g,I){var B="__lodash_hash_undefined__",Y=9007199254740991,ne="[object Arguments]",se="[object Array]",fe="[object Boolean]",Re="[object Date]",Ue="[object Error]",rt="[object Function]",ot="[object Map]",Ye="[object Number]",Rt="[object Object]",Hi="[object Promise]",Ot="[object RegExp]",ar="[object Set]",ze="[object String]",_t="[object Symbol]",vi="[object WeakMap]",Xi="[object ArrayBuffer]",tr="[object DataView]",nn=/^\[object .+?Constructor\]$/,ra=/^(?:0|[1-9]\d*)$/,Ci={};Ci["[object Float32Array]"]=Ci["[object Float64Array]"]=Ci["[object Int8Array]"]=Ci["[object Int16Array]"]=Ci["[object Int32Array]"]=Ci["[object Uint8Array]"]=Ci["[object Uint8ClampedArray]"]=Ci["[object Uint16Array]"]=Ci["[object Uint32Array]"]=!0,Ci[ne]=Ci[se]=Ci[Xi]=Ci[fe]=Ci[tr]=Ci[Re]=Ci[Ue]=Ci[rt]=Ci[ot]=Ci[Ye]=Ci[Rt]=Ci[Ot]=Ci[ar]=Ci[ze]=Ci[vi]=!1;var ss=typeof kl=="object"&&kl&&kl.Object===Object&&kl,na=typeof self=="object"&&self&&self.Object===Object&&self,on=ss||na||Function("return this")(),ho=I&&!I.nodeType&&I,Kt=ho&&g&&!g.nodeType&&g,Is=Kt&&Kt.exports===ho,Hr=Is&&ss.process,sn=function(){try{return Hr&&Hr.binding&&Hr.binding("util")}catch{}}(),oa=sn&&sn.isTypedArray;function sa(de,we){for(var Qe=-1,wt=de==null?0:de.length;++Qelr))return!1;var rr=ni.get(de);if(rr&&ni.get(we))return rr==we;var bi=-1,an=!0,no=2&Qe?new ls:void 0;for(ni.set(de,we),ni.set(we,de);++bi-1},gn.prototype.set=function(de,we){var Qe=this.__data__,wt=cs(Qe,de);return wt<0?(++this.size,Qe.push([de,we])):Qe[wt][1]=we,this},Ao.prototype.clear=function(){this.size=0,this.__data__={hash:new xi,map:new(qn||gn),string:new xi}},Ao.prototype.delete=function(de){var we=ya(this,de).delete(de);return this.size-=we?1:0,we},Ao.prototype.get=function(de){return ya(this,de).get(de)},Ao.prototype.has=function(de){return ya(this,de).has(de)},Ao.prototype.set=function(de,we){var Qe=ya(this,de),wt=Qe.size;return Qe.set(de,we),this.size+=Qe.size==wt?0:1,this},ls.prototype.add=ls.prototype.push=function(de){return this.__data__.set(de,B),this},ls.prototype.has=function(de){return this.__data__.has(de)},Zn.prototype.clear=function(){this.__data__=new gn,this.size=0},Zn.prototype.delete=function(de){var we=this.__data__,Qe=we.delete(de);return this.size=we.size,Qe},Zn.prototype.get=function(de){return this.__data__.get(de)},Zn.prototype.has=function(de){return this.__data__.has(de)},Zn.prototype.set=function(de,we){var Qe=this.__data__;if(Qe instanceof gn){var wt=Qe.__data__;if(!qn||wt.length<199)return wt.push([de,we]),this.size=++Qe.size,this;Qe=this.__data__=new Ao(wt)}return Qe.set(de,we),this.size=Qe.size,this};var va=Ho?function(de){return de==null?[]:(de=Object(de),function(we,Qe){for(var wt=-1,Vi=we==null?0:we.length,ni=0,ir=[];++wt-1&&de%1==0&&de-1&&de%1==0&&de<=Y}function Xr(de){var we=typeof de;return de!=null&&(we=="object"||we=="function")}function ro(de){return de!=null&&typeof de=="object"}var ds=oa?function(de){return function(we){return de(we)}}(oa):function(de){return ro(de)&&zo(de.length)&&!!Ci[ko(de)]};function wa(de){return(we=de)!=null&&zo(we.length)&&!Ji(we)?ma(de):Ps(de);var we}g.exports=function(de,we){return us(de,we)}})(uo,uo.exports);var Wi=v(uo.exports);function Ss(g,I){return g.length===I.length&&JSON.stringify(g.map(function(B){return B}).sort())===JSON.stringify(I.map(function(B){return B}).sort())}var kn={Polygon:Fe,LineString:Oi,Point:mi,MultiPolygon:Gt,MultiLineString:Gt,MultiPoint:Gt},Va=Object.freeze({__proto__:null,CommonSelectors:er,constrainFeatureMovement:To,createMidPoint:Ur,createSupplementaryPoints:_n,createVertex:Mt,doubleClickZoom:It,euclideanDistance:fi,featuresAt:Dt,getFeatureAtAndSetCursors:Lt,isClick:Pi,isEventAtCoordinates:qr,isTap:en,mapEventToBoundingBox:Ae,ModeHandler:_,moveFeatures:Io,sortFeatures:At,stringSetsAreEqual:Ss,StringSet:We,theme:Ii,toDenseArray:Bi}),Eo=function(g,I){var B={options:g=function(ne){ne===void 0&&(ne={});var se=Se(ne);return ne.controls||(se.controls={}),ne.displayControlsDefault===!1?se.controls=Se(Gi,ne.controls):se.controls=Se(os,ne.controls),(se=Se(ia,se)).styles=di(se.styles,"cold").concat(di(se.styles,"hot")),se}(g)};I=function(ne,se){return se.modes=De,se.getFeatureIdsAt=function(fe){return Dt.click({point:fe},null,ne).map(function(Re){return Re.properties.id})},se.getSelectedIds=function(){return ne.store.getSelectedIds()},se.getSelected=function(){return{type:Pe.FEATURE_COLLECTION,features:ne.store.getSelectedIds().map(function(fe){return ne.store.get(fe)}).map(function(fe){return fe.toGeoJSON()})}},se.getSelectedPoints=function(){return{type:Pe.FEATURE_COLLECTION,features:ne.store.getSelectedCoordinates().map(function(fe){return{type:Pe.FEATURE,properties:{},geometry:{type:Pe.POINT,coordinates:fe.coordinates}}})}},se.set=function(fe){if(fe.type===void 0||fe.type!==Pe.FEATURE_COLLECTION||!Array.isArray(fe.features))throw new Error("Invalid FeatureCollection");var Re=ne.store.createRenderBatch(),Ue=ne.store.getAllIds().slice(),rt=se.add(fe),ot=new We(rt);return(Ue=Ue.filter(function(Ye){return!ot.has(Ye)})).length&&se.delete(Ue),Re(),rt},se.add=function(fe){var Re=JSON.parse(JSON.stringify(R(fe))).features.map(function(Ue){if(Ue.id=Ue.id||Ti(),Ue.geometry===null)throw new Error("Invalid geometry: null");if(ne.store.get(Ue.id)===void 0||ne.store.get(Ue.id).type!==Ue.geometry.type){var rt=kn[Ue.geometry.type];if(rt===void 0)throw new Error("Invalid geometry type: "+Ue.geometry.type+".");var ot=new rt(ne,Ue);ne.store.add(ot)}else{var Ye=ne.store.get(Ue.id);Ye.properties=Ue.properties,Wi(Ye.properties,Ue.properties)||ne.store.featureChanged(Ye.id),Wi(Ye.getCoordinates(),Ue.geometry.coordinates)||Ye.incomingCoords(Ue.geometry.coordinates)}return Ue.id});return ne.store.render(),Re},se.get=function(fe){var Re=ne.store.get(fe);if(Re)return Re.toGeoJSON()},se.getAll=function(){return{type:Pe.FEATURE_COLLECTION,features:ne.store.getAll().map(function(fe){return fe.toGeoJSON()})}},se.delete=function(fe){return ne.store.delete(fe,{silent:!0}),se.getMode()!==De.DIRECT_SELECT||ne.store.getSelectedIds().length?ne.store.render():ne.events.changeMode(De.SIMPLE_SELECT,void 0,{silent:!0}),se},se.deleteAll=function(){return ne.store.delete(ne.store.getAllIds(),{silent:!0}),se.getMode()===De.DIRECT_SELECT?ne.events.changeMode(De.SIMPLE_SELECT,void 0,{silent:!0}):ne.store.render(),se},se.changeMode=function(fe,Re){return Re===void 0&&(Re={}),fe===De.SIMPLE_SELECT&&se.getMode()===De.SIMPLE_SELECT?(Ss(Re.featureIds||[],ne.store.getSelectedIds())||(ne.store.setSelected(Re.featureIds,{silent:!0}),ne.store.render()),se):(fe===De.DIRECT_SELECT&&se.getMode()===De.DIRECT_SELECT&&Re.featureId===ne.store.getSelectedIds()[0]||ne.events.changeMode(fe,Re,{silent:!0}),se)},se.getMode=function(){return ne.events.getMode()},se.trash=function(){return ne.events.trash({silent:!0}),se},se.combineFeatures=function(){return ne.events.combineFeatures({silent:!0}),se},se.uncombineFeatures=function(){return ne.events.uncombineFeatures({silent:!0}),se},se.setFeatureProperty=function(fe,Re,Ue){return ne.store.setFeatureProperty(fe,Re,Ue),se},se}(B,I),B.api=I;var Y=In(B);return I.onAdd=Y.onAdd,I.onRemove=Y.onRemove,I.types=ke,I.options=g,I};function Ts(g){Eo(g,this)}return Ts.modes=Er,Ts.constants=Xt,Ts.lib=Va,Ts})})(sf);var qg=sf.exports;const Da=Yp(qg);function Zg(m){let f,_,v;return{c(){f=Zt("button"),f.textContent="Import current view",xs(f,"type","button")},m(E,k){ci(E,f,k),_||(v=vs(f,"click",m[0]),_=!0)},p:Nr,i:Nr,o:Nr,d(E){E&&si(f),_=!1,v()}}}function Gg(m){let f='poly:"';for(let[v,E]of m.geometry.coordinates[0])f+=`${E} ${v} `;return f=f.slice(0,-1)+'"',`https://overpass-api.de/api/interpreter?data=${`(nwr(${f}); node(w)->.x; <;); out meta;`}`}function yc(m){return[m.lng,m.lat]}function Wg(m,f,_){let{map:v}=f;const E=Ih();let k=null;Na(()=>{v!=null&&v.loaded()&&k&&v.removeControl(k)});async function F(V){try{E("loading","Loading from Overpass");let be=await(await fetch(Gg(V))).text();E("gotXml",be)}catch(me){E("error",me.toString())}}function s(){let V=v.getBounds();return{type:"Feature",properties:{},geometry:{coordinates:[[yc(V.getSouthWest()),yc(V.getNorthWest()),yc(V.getNorthEast()),yc(V.getSouthEast()),yc(V.getSouthWest())]],type:"Polygon"}}}async function Z(){if(v){if(v.getZoom()<13){E("error","Zoom in more to import");return}await F(s())}}return m.$$set=V=>{"map"in V&&_(1,v=V.map)},m.$$.update=()=>{m.$$.dirty&14&&v&&!k&&(_(2,Da.constants.classes.CONTROL_BASE="maplibregl-ctrl",Da),_(2,Da.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",Da),_(2,Da.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group",Da),_(3,k=new Da({displayControlsDefault:!1,controls:{polygon:!0}})),v.addControl(k),v.on("draw.create",async V=>{let me=V.features[0];k.deleteAll(),await F(me)}))},[Z,v,Da,k]}class Hg extends Wr{constructor(f){super(),Gr(this,f,Wg,Zg,Tr,{map:1})}}function Dp(m,f,_){const v=m.slice();return v[1]=f[_][0],v[2]=f[_][1],v}function Fp(m){let f,_,v=m[1]+"",E,k,F=m[2]+"",s;return{c(){f=Zt("tr"),_=Zt("td"),E=Ra(v),k=Zt("td"),s=Ra(F)},m(Z,V){ci(Z,f,V),pi(f,_),pi(_,E),pi(f,k),pi(k,s)},p(Z,V){V&1&&v!==(v=Z[1]+"")&&yh(E,v),V&1&&F!==(F=Z[2]+"")&&yh(s,F)},d(Z){Z&&si(f)}}}function Xg(m){let f,_,v=gp(Object.entries(m[0])),E=[];for(let k=0;k{"properties"in E&&_(0,v=E.properties)},[v]}class zh extends Wr{constructor(f){super(),Gr(this,f,Kg,Xg,Tr,{properties:0})}}const af=["==",["geometry-type"],"Polygon"],lf=["==",["geometry-type"],"LineString"],cf=["==",["geometry-type"],"Point"];function kc(m,f,_){let v=["match",m];for(let[E,k]of Object.entries(f))v.push(E),v.push(k);return v.push(_),v}let zt;const uf=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&uf.decode();let Tc=null;function Pc(){return(Tc===null||Tc.byteLength===0)&&(Tc=new Uint8Array(zt.memory.buffer)),Tc}function Ks(m,f){return m=m>>>0,uf.decode(Pc().subarray(m,m+f))}const Js=new Array(128).fill(void 0);Js.push(void 0,null,!0,!1);let zc=Js.length;function Qr(m){zc===Js.length&&Js.push(Js.length+1);const f=zc;return zc=Js[f],Js[f]=m,f}function li(m){return Js[m]}function Jg(m){m<132||(Js[m]=zc,zc=m)}function mu(m){const f=li(m);return Jg(m),f}function _h(m){return m==null}let Ic=null;function Yg(){return(Ic===null||Ic.byteLength===0)&&(Ic=new Float64Array(zt.memory.buffer)),Ic}let Ec=null;function sr(){return(Ec===null||Ec.byteLength===0)&&(Ec=new Int32Array(zt.memory.buffer)),Ec}let Fa=0;const _u=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},Qg=typeof _u.encodeInto=="function"?function(m,f){return _u.encodeInto(m,f)}:function(m,f){const _=_u.encode(m);return f.set(_),{read:m.length,written:_.length}};function du(m,f,_){if(_===void 0){const s=_u.encode(m),Z=f(s.length,1)>>>0;return Pc().subarray(Z,Z+s.length).set(s),Fa=s.length,Z}let v=m.length,E=f(v,1)>>>0;const k=Pc();let F=0;for(;F127)break;k[E+F]=s}if(F!==v){F!==0&&(m=m.slice(F)),E=_(E,v,v=F+m.length*3,1)>>>0;const s=Pc().subarray(E+F,E+v),Z=Qg(m,s);F+=Z.written}return Fa=F,E}function Sh(m){const f=typeof m;if(f=="number"||f=="boolean"||m==null)return`${m}`;if(f=="string")return`"${m}"`;if(f=="symbol"){const E=m.description;return E==null?"Symbol":`Symbol(${E})`}if(f=="function"){const E=m.name;return typeof E=="string"&&E.length>0?`Function(${E})`:"Function"}if(Array.isArray(m)){const E=m.length;let k="[";E>0&&(k+=Sh(m[0]));for(let F=1;F1)v=_[1];else return toString.call(m);if(v=="Object")try{return"Object("+JSON.stringify(m)+")"}catch{return"Object"}return m instanceof Error?`${m.name}: ${m.message} +${m.stack}`:v}function $g(m,f){const _=f(m.length*1,1)>>>0;return Pc().set(m,_/1),Fa=m.length,_}function gh(m,f){try{return m.apply(this,f)}catch(_){zt.__wbindgen_exn_store(Qr(_))}}class vu{static __wrap(f){f=f>>>0;const _=Object.create(vu.prototype);return _.__wbg_ptr=f,_}__destroy_into_raw(){const f=this.__wbg_ptr;return this.__wbg_ptr=0,f}free(){const f=this.__destroy_into_raw();zt.__wbg_jsroutesnapper_free(f)}constructor(f){try{const k=zt.__wbindgen_add_to_stack_pointer(-16),F=$g(f,zt.__wbindgen_malloc),s=Fa;zt.jsroutesnapper_new(k,F,s);var _=sr()[k/4+0],v=sr()[k/4+1],E=sr()[k/4+2];if(E)throw mu(v);return vu.__wrap(_)}finally{zt.__wbindgen_add_to_stack_pointer(16)}}setRouteConfig(f){zt.jsroutesnapper_setRouteConfig(this.__wbg_ptr,Qr(f))}setAreaMode(){zt.jsroutesnapper_setAreaMode(this.__wbg_ptr)}getConfig(){let f,_;try{const k=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_getConfig(k,this.__wbg_ptr);var v=sr()[k/4+0],E=sr()[k/4+1];return f=v,_=E,Ks(v,E)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(f,_,1)}}toFinalFeature(){try{const v=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_toFinalFeature(v,this.__wbg_ptr);var f=sr()[v/4+0],_=sr()[v/4+1];let E;return f!==0&&(E=Ks(f,_).slice(),zt.__wbindgen_free(f,_*1)),E}finally{zt.__wbindgen_add_to_stack_pointer(16)}}renderGeojson(){let f,_;try{const k=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_renderGeojson(k,this.__wbg_ptr);var v=sr()[k/4+0],E=sr()[k/4+1];return f=v,_=E,Ks(v,E)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(f,_,1)}}toggleSnapMode(){zt.jsroutesnapper_toggleSnapMode(this.__wbg_ptr)}onMouseMove(f,_,v){return zt.jsroutesnapper_onMouseMove(this.__wbg_ptr,f,_,v)!==0}onClick(){zt.jsroutesnapper_onClick(this.__wbg_ptr)}onDragStart(){return zt.jsroutesnapper_onDragStart(this.__wbg_ptr)!==0}onMouseUp(){return zt.jsroutesnapper_onMouseUp(this.__wbg_ptr)!==0}clearState(){zt.jsroutesnapper_clearState(this.__wbg_ptr)}editExisting(f){try{const E=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_editExisting(E,this.__wbg_ptr,Qr(f));var _=sr()[E/4+0],v=sr()[E/4+1];if(v)throw mu(_)}finally{zt.__wbindgen_add_to_stack_pointer(16)}}debugRenderGraph(){let f,_;try{const k=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_debugRenderGraph(k,this.__wbg_ptr);var v=sr()[k/4+0],E=sr()[k/4+1];return f=v,_=E,Ks(v,E)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(f,_,1)}}routeNameForWaypoints(f){let _,v;try{const me=zt.__wbindgen_add_to_stack_pointer(-16);zt.jsroutesnapper_routeNameForWaypoints(me,this.__wbg_ptr,Qr(f));var E=sr()[me/4+0],k=sr()[me/4+1],F=sr()[me/4+2],s=sr()[me/4+3],Z=E,V=k;if(s)throw Z=0,V=0,mu(F);return _=Z,v=V,Ks(Z,V)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(_,v,1)}}addSnappedWaypoint(f,_){zt.jsroutesnapper_addSnappedWaypoint(this.__wbg_ptr,f,_)}undo(){zt.jsroutesnapper_undo(this.__wbg_ptr)}}async function ey(m,f){if(typeof Response=="function"&&m instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(m,f)}catch(v){if(m.headers.get("Content-Type")!="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",v);else throw v}const _=await m.arrayBuffer();return await WebAssembly.instantiate(_,f)}else{const _=await WebAssembly.instantiate(m,f);return _ instanceof WebAssembly.Instance?{instance:_,module:m}:_}}function ty(){const m={};return m.wbg={},m.wbg.__wbindgen_string_new=function(f,_){const v=Ks(f,_);return Qr(v)},m.wbg.__wbindgen_object_drop_ref=function(f){mu(f)},m.wbg.__wbindgen_error_new=function(f,_){const v=new Error(Ks(f,_));return Qr(v)},m.wbg.__wbindgen_is_object=function(f){const _=li(f);return typeof _=="object"&&_!==null},m.wbg.__wbindgen_is_undefined=function(f){return li(f)===void 0},m.wbg.__wbindgen_in=function(f,_){return li(f)in li(_)},m.wbg.__wbindgen_boolean_get=function(f){const _=li(f);return typeof _=="boolean"?_?1:0:2},m.wbg.__wbindgen_number_get=function(f,_){const v=li(_),E=typeof v=="number"?v:void 0;Yg()[f/8+1]=_h(E)?0:E,sr()[f/4+0]=!_h(E)},m.wbg.__wbindgen_object_clone_ref=function(f){const _=li(f);return Qr(_)},m.wbg.__wbindgen_jsval_loose_eq=function(f,_){return li(f)==li(_)},m.wbg.__wbindgen_string_get=function(f,_){const v=li(_),E=typeof v=="string"?v:void 0;var k=_h(E)?0:du(E,zt.__wbindgen_malloc,zt.__wbindgen_realloc),F=Fa;sr()[f/4+1]=F,sr()[f/4+0]=k},m.wbg.__wbg_String_4370c5505c674d30=function(f,_){const v=String(li(_)),E=du(v,zt.__wbindgen_malloc,zt.__wbindgen_realloc),k=Fa;sr()[f/4+1]=k,sr()[f/4+0]=E},m.wbg.__wbg_getwithrefkey_d1f0d12f1f1b63ea=function(f,_){const v=li(f)[li(_)];return Qr(v)},m.wbg.__wbg_new_abda76e883ba8a5f=function(){const f=new Error;return Qr(f)},m.wbg.__wbg_stack_658279fe44541cf6=function(f,_){const v=li(_).stack,E=du(v,zt.__wbindgen_malloc,zt.__wbindgen_realloc),k=Fa;sr()[f/4+1]=k,sr()[f/4+0]=E},m.wbg.__wbg_error_f851667af71bcfc6=function(f,_){let v,E;try{v=f,E=_,console.error(Ks(f,_))}finally{zt.__wbindgen_free(v,E,1)}},m.wbg.__wbg_debug_9a6b3243fbbebb61=function(f){console.debug(li(f))},m.wbg.__wbg_error_788ae33f81d3b84b=function(f){console.error(li(f))},m.wbg.__wbg_info_2e30e8204b29d91d=function(f){console.info(li(f))},m.wbg.__wbg_log_1d3ae0273d8f4f8a=function(f){console.log(li(f))},m.wbg.__wbg_warn_d60e832f9882c1b2=function(f){console.warn(li(f))},m.wbg.__wbg_get_44be0491f933a435=function(f,_){const v=li(f)[_>>>0];return Qr(v)},m.wbg.__wbg_length_fff51ee6522a1a18=function(f){return li(f).length},m.wbg.__wbindgen_is_function=function(f){return typeof li(f)=="function"},m.wbg.__wbg_next_526fc47e980da008=function(f){const _=li(f).next;return Qr(_)},m.wbg.__wbg_next_ddb3312ca1c4e32a=function(){return gh(function(f){const _=li(f).next();return Qr(_)},arguments)},m.wbg.__wbg_done_5c1f01fb660d73b5=function(f){return li(f).done},m.wbg.__wbg_value_1695675138684bd5=function(f){const _=li(f).value;return Qr(_)},m.wbg.__wbg_iterator_97f0c81209c6c35a=function(){return Qr(Symbol.iterator)},m.wbg.__wbg_get_97b561fb56f034b5=function(){return gh(function(f,_){const v=Reflect.get(li(f),li(_));return Qr(v)},arguments)},m.wbg.__wbg_call_cb65541d95d71282=function(){return gh(function(f,_){const v=li(f).call(li(_));return Qr(v)},arguments)},m.wbg.__wbg_isArray_4c24b343cb13cfb1=function(f){return Array.isArray(li(f))},m.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb=function(f){let _;try{_=li(f)instanceof ArrayBuffer}catch{_=!1}return _},m.wbg.__wbg_buffer_085ec1f694018c4f=function(f){const _=li(f).buffer;return Qr(_)},m.wbg.__wbg_new_8125e318e6245eed=function(f){const _=new Uint8Array(li(f));return Qr(_)},m.wbg.__wbg_set_5cf90238115182c3=function(f,_,v){li(f).set(li(_),v>>>0)},m.wbg.__wbg_length_72e2208bbc0efc61=function(f){return li(f).length},m.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4=function(f){let _;try{_=li(f)instanceof Uint8Array}catch{_=!1}return _},m.wbg.__wbindgen_debug_string=function(f,_){const v=Sh(li(_)),E=du(v,zt.__wbindgen_malloc,zt.__wbindgen_realloc),k=Fa;sr()[f/4+1]=k,sr()[f/4+0]=E},m.wbg.__wbindgen_throw=function(f,_){throw new Error(Ks(f,_))},m.wbg.__wbindgen_memory=function(){const f=zt.memory;return Qr(f)},m}function iy(m,f){return zt=m.exports,hf.__wbindgen_wasm_module=f,Ic=null,Ec=null,Tc=null,zt}async function hf(m){if(zt!==void 0)return zt;typeof m>"u"&&(m="/ltn/assets/route_snapper_bg.wasm");const f=ty();(typeof m=="string"||typeof Request=="function"&&m instanceof Request||typeof URL=="function"&&m instanceof URL)&&(m=fetch(m));const{instance:_,module:v}=await ey(await m,f);return iy(_,v)}const df=bo({type:"FeatureCollection",features:[]}),ry=bo(!0),ny=bo(0),oy=30;class sy{constructor(f,_){Nn(this,"map");Nn(this,"inner");Nn(this,"active");Nn(this,"eventListenersSuccess");Nn(this,"eventListenersUpdated");Nn(this,"eventListenersFailure");Nn(this,"onMouseMove",f=>{if(!this.active)return;const _=[f.point.x-oy,f.point.y],v=this.map.unproject(f.point).distanceTo(this.map.unproject(_));this.inner.onMouseMove(f.lngLat.lng,f.lngLat.lat,v)&&(this.redraw(),this.dataUpdated())});Nn(this,"onClick",()=>{this.active&&(this.inner.onClick(),this.redraw(),this.dataUpdated())});Nn(this,"onDoubleClick",f=>{this.active&&(f.preventDefault(),this.inner.onClick(),this.finish())});Nn(this,"onDragStart",()=>{this.active&&this.inner.onDragStart()&&this.map.dragPan.disable()});Nn(this,"onMouseUp",()=>{this.active&&this.inner.onMouseUp()&&this.map.dragPan.enable()});Nn(this,"onKeyDown",f=>{this.active&&f.key=="Escape"&&(f.stopPropagation(),this.cancel())});Nn(this,"onKeyPress",f=>{this.active&&f.target.tagName!="INPUT"&&(f.key=="Enter"?(f.stopPropagation(),this.finish()):f.key=="s"?(f.stopPropagation(),this.inner.toggleSnapMode(),this.redraw()):f.key=="z"&&f.ctrlKey&&this.undo())});this.map=f,console.time("Deserialize and setup JsRouteSnapper"),this.inner=new vu(_),console.timeEnd("Deserialize and setup JsRouteSnapper"),this.active=!1,this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[],this.map.on("mousemove",this.onMouseMove),this.map.on("click",this.onClick),this.map.on("dblclick",this.onDoubleClick),this.map.on("dragstart",this.onDragStart),this.map.on("mouseup",this.onMouseUp),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keypress",this.onKeyPress)}tearDown(){this.map.off("mousemove",this.onMouseMove),this.map.off("click",this.onClick),this.map.off("dblclick",this.onDoubleClick),this.map.off("dragstart",this.onDragStart),this.map.off("mouseup",this.onMouseUp),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keypress",this.onKeyPress)}startRoute(){this.active||(this.active=!0,this.map.boxZoom.disable(),this.map.doubleClickZoom.disable())}startArea(){this.active||(this.inner.setAreaMode(),this.active=!0,this.map.boxZoom.disable(),this.map.doubleClickZoom.disable())}stop(){this.active=!1,this.inner.clearState(),this.redraw(),this.map.boxZoom.enable(),this.map.doubleClickZoom.enable()}editExistingRoute(f){this.active&&window.alert("Bug: editExistingRoute called when tool is already active"),f.properties.waypoints||(f.properties.waypoints=[{lon:f.geometry.coordinates[0][0],lat:f.geometry.coordinates[0][1],snapped:!0},{lon:f.geometry.coordinates[f.geometry.coordinates.length-1][0],lat:f.geometry.coordinates[f.geometry.coordinates.length-1][1],snapped:!0}]),this.startRoute(),this.inner.editExisting(f.properties.waypoints),this.redraw()}editExistingArea(f){this.active&&window.alert("Bug: editExistingArea called when tool is already active"),f.properties.waypoints||window.alert("Bug: editExistingArea called for a polygon not produced by the route-snapper"),this.startArea(),this.inner.editExisting(f.properties.waypoints),this.redraw()}addEventListenerSuccess(f){this.eventListenersSuccess.push(f)}addEventListenerUpdated(f){this.eventListenersUpdated.push(f)}addEventListenerFailure(f){this.eventListenersFailure.push(f)}clearEventListeners(){this.eventListenersSuccess=[],this.eventListenersUpdated=[],this.eventListenersFailure=[]}isActive(){return this.active}finish(){let f=this.inner.toFinalFeature();if(f)for(let _ of this.eventListenersSuccess)_(JSON.parse(f));else for(let _ of this.eventListenersFailure)_();this.stop()}cancel(){this.inner.clearState(),this.finish()}setRouteConfig(f){this.inner.setRouteConfig(f),this.redraw()}addSnappedWaypoint(f){this.inner.addSnappedWaypoint(f[0],f[1]),this.redraw()}undo(){this.inner.undo(),this.redraw()}redraw(){let f=JSON.parse(this.inner.renderGeojson());df.set(f),this.map.getCanvas().style.cursor=f.cursor,ry.set(f.snap_mode),ny.set(f.undo_length)}dataUpdated(){let f=this.inner.toFinalFeature();if(f)for(let _ of this.eventListenersUpdated)_(JSON.parse(f))}}function ay(m){let f,_,v,E,k,F;return f=new ef({props:{filter:cf,paint:{"circle-color":kc(["get","type"],{"snapped-waypoint":"red","free-waypoint":"blue"},"black"),"circle-opacity":["case",["has","hovered"],.5,1],"circle-radius":kc(["get","type"],{node:Rp/2},Rp)}}}),v=new Ah({props:{filter:lf,paint:{"line-color":["case",["get","snapped"],"red","blue"],"line-width":2.5}}}),k=new tf({props:{filter:af,paint:{"fill-color":"black","fill-opacity":.5}}}),{c(){Ri(f.$$.fragment),_=fn(),Ri(v.$$.fragment),E=fn(),Ri(k.$$.fragment)},m(s,Z){Ai(f,s,Z),ci(s,_,Z),Ai(v,s,Z),ci(s,E,Z),Ai(k,s,Z),F=!0},p:Nr,i(s){F||(ft(f.$$.fragment,s),ft(v.$$.fragment,s),ft(k.$$.fragment,s),F=!0)},o(s){St(f.$$.fragment,s),St(v.$$.fragment,s),St(k.$$.fragment,s),F=!1},d(s){s&&(si(_),si(E)),ki(f,s),ki(v,s),ki(k,s)}}}function ly(m){let f,_;return f=new Mh({props:{data:m[0],$$slots:{default:[ay]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,[E]){const k={};E&1&&(k.data=v[0]),E&2&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}const Rp=10;function cy(m,f,_){let v;return $r(m,df,E=>_(0,v=E)),[v]}class uy extends Wr{constructor(f){super(),Gr(this,f,cy,ly,Tr,{})}}function hy(m){let f,_,v,E,k,F,s,Z,V,me,be,ge,Oe,ke,Pe,De,Ve,at,nt,it,Vt,ti,Xt,Nt,Yt,At,Ae,We,Ui;return f=new jg({props:{msg:m[2]}}),At=new Hg({props:{map:m[0]}}),At.$on("gotXml",m[5]),At.$on("loading",m[9]),At.$on("error",m[10]),{c(){Ri(f.$$.fragment),_=fn(),v=Zt("div"),E=Zt("div"),k=Zt("label"),F=Ra(`Load an osm.xml or a .pbf file: + `),s=Zt("input"),Z=fn(),V=Zt("div"),me=Zt("label"),be=Ra(`Or load an example: + `),ge=Zt("select"),Oe=Zt("option"),Oe.textContent="Custom file loaded",ke=Zt("option"),ke.textContent="Akihabara",Pe=Zt("option"),Pe.textContent="Hanegi Park",De=Zt("option"),De.textContent="Harujuku",Ve=Zt("option"),Ve.textContent="Taipei main station",at=Zt("option"),at.textContent="Ximending",nt=Zt("option"),nt.textContent="Hong Kong",it=Zt("option"),it.textContent="Kowloon",Vt=Zt("option"),Vt.textContent="Bristol",ti=Zt("option"),ti.textContent="Elephant & Castle",Xt=Zt("option"),Xt.textContent="Westminster",Nt=Zt("option"),Nt.textContent="Montlake",Yt=fn(),Ri(At.$$.fragment),xs(s,"type","file"),Oe.__value="",Uo(Oe,Oe.__value),ke.__value="akihabara",Uo(ke,ke.__value),Pe.__value="hanegi",Uo(Pe,Pe.__value),De.__value="harujuku",Uo(De,De.__value),Ve.__value="taipei_main_station",Uo(Ve,Ve.__value),at.__value="ximending",Uo(at,at.__value),nt.__value="hong_kong",Uo(nt,nt.__value),it.__value="kowloon",Uo(it,it.__value),Vt.__value="bristol",Uo(Vt,Vt.__value),ti.__value="elephant_castle",Uo(ti,ti.__value),Xt.__value="westminster",Uo(Xt,Xt.__value),Nt.__value="montlake",Uo(Nt,Nt.__value),m[1]===void 0&&gu(()=>m[8].call(ge)),Cc(v,"border","1px solid black"),Cc(v,"padding","8px")},m(Dt,qt){Ai(f,Dt,qt),ci(Dt,_,qt),ci(Dt,v,qt),pi(v,E),pi(E,k),pi(k,F),pi(k,s),m[7](s),pi(v,Z),pi(v,V),pi(V,me),pi(me,be),pi(me,ge),pi(ge,Oe),pi(ge,ke),pi(ge,Pe),pi(ge,De),pi(ge,Ve),pi(ge,at),pi(ge,nt),pi(ge,it),pi(ge,Vt),pi(ge,ti),pi(ge,Xt),pi(ge,Nt),mp(ge,m[1],!0),pi(v,Yt),Ai(At,v,null),Ae=!0,We||(Ui=[vs(s,"change",m[4]),vs(ge,"change",m[8])],We=!0)},p(Dt,[qt]){const Lt={};qt&4&&(Lt.msg=Dt[2]),f.$set(Lt),qt&2&&mp(ge,Dt[1]);const fi={};qt&1&&(fi.map=Dt[0]),At.$set(fi)},i(Dt){Ae||(ft(f.$$.fragment,Dt),ft(At.$$.fragment,Dt),Ae=!0)},o(Dt){St(f.$$.fragment,Dt),St(At.$$.fragment,Dt),Ae=!1},d(Dt){Dt&&(si(_),si(v)),ki(f,Dt),m[7](null),ki(At),We=!1,Oa(Ui)}}}function dy(m,f,_){let{app:v=void 0}=f,{map:E}=f,k="",F=null,s=!1;jp(async()=>{await Kp(),await hf();try{s=(await fetch("/kowloon.pbf",{method:"HEAD"})).ok,console.log("Using local cache, not od2net.org"),ge("bristol")}catch{}});let Z;async function V(at){try{me(await Z.files[0].arrayBuffer()),_(1,k="")}catch(nt){window.alert(`Couldn't open this file: ${nt}`)}_(2,F=null)}function me(at){_(2,F="Building map model from OSM input"),console.time("load"),_(6,v=new k_(new Uint8Array(at))),console.timeEnd("load")}function be(at){try{me(new TextEncoder().encode(at.detail)),_(1,k="")}catch(nt){window.alert(`Couldn't import from Overpass: ${nt}`)}_(2,F=null)}async function ge(at){at!=""&&(s?await Oe(`/${at}.pbf`):await Oe(`https://assets.od2net.org/severance_pbfs/${at}.pbf`))}async function Oe(at){try{_(2,F=`Downloading ${at}`);let nt=await fetch(at);me(await nt.arrayBuffer())}catch(nt){window.alert(`Couldn't open from URL ${at}: ${nt}`)}_(2,F=null)}function ke(at){bs[at?"unshift":"push"](()=>{Z=at,_(3,Z)})}function Pe(){k=__(this),_(1,k)}const De=at=>_(2,F=at.detail),Ve=at=>window.alert(at.detail);return m.$$set=at=>{"app"in at&&_(6,v=at.app),"map"in at&&_(0,E=at.map)},m.$$.update=()=>{m.$$.dirty&2&&ge(k)},[E,k,F,Z,V,be,v,ke,Pe,De,Ve]}class py extends Wr{constructor(f){super(),Gr(this,f,dy,hy,Tr,{app:6,map:0})}}function fy(m){let f,_;return f=new zh({props:{properties:m[11].properties}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&2048&&(k.properties=v[11].properties),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function my(m){let f,_;return f=new Ph({props:{openOn:"hover",$$slots:{default:[fy,({data:v})=>({11:v}),({data:v})=>v?2048:0]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&6144&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function _y(m){let f,_;return f=new zh({props:{properties:m[11].properties}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&2048&&(k.properties=v[11].properties),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function gy(m){let f,_;return f=new Ph({props:{openOn:"hover",$$slots:{default:[_y,({data:v})=>({11:v}),({data:v})=>v?2048:0]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&6144&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function yy(m){let f,_,v,E,k,F;return f=new Ah({props:{filter:lf,paint:{"line-width":5,"line-color":kc(["get","kind"],{interior_road:["interpolate-hcl",["linear"],["get","shortcuts"],0,"#F19A93",m[1],"#A32015"],crosses:"blue"},"red")},hoverCursor:"pointer",$$slots:{default:[my]},$$scope:{ctx:m}}}),f.$on("click",m[6]),v=new ef({props:{filter:cf,paint:{"circle-radius":15,"circle-color":kc(["get","kind"],{border_intersection:"green",modal_filter:"white"},"red")},$$slots:{default:[gy]},$$scope:{ctx:m}}}),k=new tf({props:{beforeId:"Building",filter:af,manageHoverState:!0,paint:{"fill-color":["get","color"],"fill-opacity":q_(.6,1)}}}),{c(){Ri(f.$$.fragment),_=fn(),Ri(v.$$.fragment),E=fn(),Ri(k.$$.fragment)},m(s,Z){Ai(f,s,Z),ci(s,_,Z),Ai(v,s,Z),ci(s,E,Z),Ai(k,s,Z),F=!0},p(s,Z){const V={};Z&2&&(V.paint={"line-width":5,"line-color":kc(["get","kind"],{interior_road:["interpolate-hcl",["linear"],["get","shortcuts"],0,"#F19A93",s[1],"#A32015"],crosses:"blue"},"red")}),Z&4096&&(V.$$scope={dirty:Z,ctx:s}),f.$set(V);const me={};Z&4096&&(me.$$scope={dirty:Z,ctx:s}),v.$set(me)},i(s){F||(ft(f.$$.fragment,s),ft(v.$$.fragment,s),ft(k.$$.fragment,s),F=!0)},o(s){St(f.$$.fragment,s),St(v.$$.fragment,s),St(k.$$.fragment,s),F=!1},d(s){s&&(si(_),si(E)),ki(f,s),ki(v,s),ki(k,s)}}}function vy(m){let f,_;return f=new Mh({props:{data:m[0],generateId:!0,$$slots:{default:[yy]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,[E]){const k={};E&1&&(k.data=v[0]),E&4098&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function xy(m,f,_){let{map:v}=f,{app:E}=f,{boundary:k}=f,{addingFilter:F=!1}=f,s=["#8dd3c7","#ffffb3","#bebada","#80b1d3","#fdb462","#b3de69","#fccde5","#bc80bd","#ccebc5","#ffed6f"],Z,V;me(JSON.parse(E.analyzeNeighbourhood(k)));function me(ke){_(1,V=Math.max(...ke.features.map(Pe=>Pe.properties.shortcuts??0)));for(let Pe of ke.features)Pe.properties.color=="disconnected"?Pe.properties.color="red":Object.hasOwn(Pe.properties,"color")&&(Pe.properties.color=s[Pe.properties.color%s.length]);_(0,Z=ke)}Na(()=>{ge(),E.unsetNeighbourhood()});function be(ke){me(JSON.parse(E.addModalFilter(ke.lngLat))),ge()}function ge(){_(3,F=!1),v.off("click",be),_(2,v.style.cursor="inherit",v)}const Oe=ke=>window.open(ke.detail.features[0].properties.way,"_blank");return m.$$set=ke=>{"map"in ke&&_(2,v=ke.map),"app"in ke&&_(4,E=ke.app),"boundary"in ke&&_(5,k=ke.boundary),"addingFilter"in ke&&_(3,F=ke.addingFilter)},m.$$.update=()=>{m.$$.dirty&12&&F&&(v.on("click",be),_(2,v.style.cursor="crosshair",v))},[Z,V,v,F,E,k,Oe]}class by extends Wr{constructor(f){super(),Gr(this,f,xy,vy,Tr,{map:2,app:4,boundary:5,addingFilter:3})}}function wy(m){let f,_;return f=new zh({props:{properties:m[2].properties}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&4&&(k.properties=v[2].properties),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Sy(m){let f,_;return f=new Ph({props:{openOn:"hover",$$slots:{default:[wy,({data:v})=>({2:v}),({data:v})=>v?4:0]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&12&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Ty(m){let f,_;return f=new Ah({props:{id:"network",paint:{"line-width":5,"line-color":"black"},hoverCursor:"pointer",$$slots:{default:[Sy]},$$scope:{ctx:m}}}),f.$on("click",m[1]),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&8&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Iy(m){let f,_;return f=new Mh({props:{data:JSON.parse(m[0].render()),$$slots:{default:[Ty]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,[E]){const k={};E&1&&(k.data=JSON.parse(v[0].render())),E&8&&(k.$$scope={dirty:E,ctx:v}),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Ey(m,f,_){let{app:v}=f;const E=k=>window.open(k.detail.features[0].properties.way,"_blank");return m.$$set=k=>{"app"in k&&_(0,v=k.app)},[v,E]}class Cy extends Wr{constructor(f){super(),Gr(this,f,Ey,Iy,Tr,{app:0})}}function Op(m){let f,_,v;function E(F){m[10](F)}let k={map:m[2]};return m[0]!==void 0&&(k.app=m[0]),f=new py({props:k}),bs.push(()=>Dl(f,"app",E)),{c(){Ri(f.$$.fragment)},m(F,s){Ai(f,F,s),v=!0},p(F,s){const Z={};s&4&&(Z.map=F[2]),!_&&s&1&&(_=!0,Z.app=F[0],Ll(()=>_=!1)),f.$set(Z)},i(F){v||(ft(f.$$.fragment,F),v=!0)},o(F){St(f.$$.fragment,F),v=!1},d(F){ki(f,F)}}}function My(m){let f,_,v,E,k,F,s,Z,V,me,be,ge,Oe,ke;return{c(){f=Zt("div"),_=Zt("button"),_.textContent="Reset",v=fn(),E=Zt("div"),k=Zt("button"),k.textContent="Edit boundary",F=fn(),s=Zt("div"),Z=Zt("button"),V=Ra("Add a modal filter"),be=fn(),ge=Zt("p"),ge.textContent="Analyze and edit now",Z.disabled=me=m[1].addingFilter},m(Pe,De){ci(Pe,f,De),pi(f,_),ci(Pe,v,De),ci(Pe,E,De),pi(E,k),ci(Pe,F,De),ci(Pe,s,De),pi(s,Z),pi(Z,V),ci(Pe,be,De),ci(Pe,ge,De),Oe||(ke=[vs(_,"click",m[6]),vs(k,"click",m[4]),vs(Z,"click",m[11])],Oe=!0)},p(Pe,De){De&2&&me!==(me=Pe[1].addingFilter)&&(Z.disabled=me)},d(Pe){Pe&&(si(f),si(v),si(E),si(F),si(s),si(be),si(ge)),Oe=!1,Oa(ke)}}}function Ay(m){let f;return{c(){f=Zt("p"),f.textContent="Draw the boundary..."},m(_,v){ci(_,f,v)},p:Nr,d(_){_&&si(f)}}}function ky(m){let f,_,v,E,k,F,s;return{c(){f=Zt("div"),_=Zt("button"),_.textContent="Set boundary",v=fn(),E=Zt("div"),k=Zt("button"),k.textContent="Quickset boundary (dev)"},m(Z,V){ci(Z,f,V),pi(f,_),ci(Z,v,V),ci(Z,E,V),pi(E,k),F||(s=[vs(_,"click",m[4]),vs(k,"click",m[5])],F=!0)},p:Nr,d(Z){Z&&(si(f),si(v),si(E)),F=!1,Oa(s)}}}function Py(m){let f,_,v,E,k,F,s,Z,V=m[2]&&Op(m);function me(Oe,ke){if(Oe[1].mode=="network"&&Oe[0])return ky;if(Oe[1].mode=="set-boundary")return Ay;if(Oe[1].mode=="neighbourhood")return My}let be=me(m),ge=be&&be(m);return{c(){f=Zt("div"),V&&V.c(),_=fn(),v=Zt("div"),E=Zt("button"),E.textContent="Zoom to fit",k=fn(),ge&&ge.c(),xs(f,"slot","left")},m(Oe,ke){ci(Oe,f,ke),V&&V.m(f,null),pi(f,_),pi(f,v),pi(v,E),pi(f,k),ge&&ge.m(f,null),F=!0,s||(Z=vs(E,"click",m[3]),s=!0)},p(Oe,ke){Oe[2]?V?(V.p(Oe,ke),ke&4&&ft(V,1)):(V=Op(Oe),V.c(),ft(V,1),V.m(f,_)):V&&(rs(),St(V,1,1,()=>{V=null}),ns()),be===(be=me(Oe))&&ge?ge.p(Oe,ke):(ge&&ge.d(1),ge=be&&be(Oe),ge&&(ge.c(),ge.m(f,null)))},i(Oe){F||(ft(V),F=!0)},o(Oe){St(V),F=!1},d(Oe){Oe&&si(f),V&&V.d(),ge&&ge.d(),s=!1,Z()}}}function Bp(m){let f,_,v,E;const k=[Dy,Ly,zy],F=[];function s(Z,V){return Z[1].mode=="network"?0:Z[1].mode=="set-boundary"?1:Z[1].mode=="neighbourhood"?2:-1}return~(f=s(m))&&(_=F[f]=k[f](m)),{c(){_&&_.c(),v=Ba()},m(Z,V){~f&&F[f].m(Z,V),ci(Z,v,V),E=!0},p(Z,V){let me=f;f=s(Z),f===me?~f&&F[f].p(Z,V):(_&&(rs(),St(F[me],1,1,()=>{F[me]=null}),ns()),~f?(_=F[f],_?_.p(Z,V):(_=F[f]=k[f](Z),_.c()),ft(_,1),_.m(v.parentNode,v)):_=null)},i(Z){E||(ft(_),E=!0)},o(Z){St(_),E=!1},d(Z){Z&&si(v),~f&&F[f].d(Z)}}}function zy(m){let f,_,v;function E(F){m[8](F)}let k={map:m[2],app:m[0],boundary:m[1].boundary};return m[1].addingFilter!==void 0&&(k.addingFilter=m[1].addingFilter),f=new by({props:k}),bs.push(()=>Dl(f,"addingFilter",E)),{c(){Ri(f.$$.fragment)},m(F,s){Ai(f,F,s),v=!0},p(F,s){const Z={};s&4&&(Z.map=F[2]),s&1&&(Z.app=F[0]),s&2&&(Z.boundary=F[1].boundary),!_&&s&2&&(_=!0,Z.addingFilter=F[1].addingFilter,Ll(()=>_=!1)),f.$set(Z)},i(F){v||(ft(f.$$.fragment,F),v=!0)},o(F){St(f.$$.fragment,F),v=!1},d(F){ki(f,F)}}}function Ly(m){let f,_;return f=new uy({}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p:Nr,i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Dy(m){let f,_;return f=new Cy({props:{app:m[0]}}),{c(){Ri(f.$$.fragment)},m(v,E){Ai(f,v,E),_=!0},p(v,E){const k={};E&1&&(k.app=v[0]),f.$set(k)},i(v){_||(ft(f.$$.fragment,v),_=!0)},o(v){St(f.$$.fragment,v),_=!1},d(v){ki(f,v)}}}function Fy(m){let f,_,v=m[0]&&Bp(m);return{c(){v&&v.c(),f=Ba()},m(E,k){v&&v.m(E,k),ci(E,f,k),_=!0},p(E,k){E[0]?v?(v.p(E,k),k&1&&ft(v,1)):(v=Bp(E),v.c(),ft(v,1),v.m(f.parentNode,f)):v&&(rs(),St(v,1,1,()=>{v=null}),ns())},i(E){_||(ft(v),_=!0)},o(E){St(v),_=!1},d(E){E&&si(f),v&&v.d(E)}}}function Ry(m){let f,_,v,E;function k(s){m[9](s)}let F={style:"https://api.maptiler.com/maps/dataviz/style.json?key=MZEJTanw3WpxRvt7qDfo",standardControls:!0,hash:!0,$$slots:{default:[Fy]},$$scope:{ctx:m}};return m[2]!==void 0&&(F.map=m[2]),_=new bg({props:F}),bs.push(()=>Dl(_,"map",k)),{c(){f=Zt("div"),Ri(_.$$.fragment),xs(f,"slot","main"),Cc(f,"position","relative"),Cc(f,"width","100%"),Cc(f,"height","100vh")},m(s,Z){ci(s,f,Z),Ai(_,f,null),E=!0},p(s,Z){const V={};Z&16391&&(V.$$scope={dirty:Z,ctx:s}),!v&&Z&4&&(v=!0,V.map=s[2],Ll(()=>v=!1)),_.$set(V)},i(s){E||(ft(_.$$.fragment,s),E=!0)},o(s){St(_.$$.fragment,s),E=!1},d(s){s&&si(f),ki(_)}}}function Oy(m){let f,_,v,E;return f=new Ng({props:{$$slots:{main:[Ry],left:[Py]},$$scope:{ctx:m}}}),{c(){Ri(f.$$.fragment)},m(k,F){Ai(f,k,F),_=!0,v||(E=vs(window,"keydown",m[7]),v=!0)},p(k,[F]){const s={};F&16391&&(s.$$scope={dirty:F,ctx:k}),f.$set(s)},i(k){_||(ft(f.$$.fragment,k),_=!0)},o(k){St(f.$$.fragment,k),_=!1},d(k){ki(f,k),v=!1,E()}}}function By(m,f,_){let v={mode:"network"},E,k,F;function s(){if(F&&E){let Ve=bh(JSON.parse(E.render()));F.fitBounds(Ve,{animate:!1})}}function Z(Ve){E&&(console.log("New map model loaded"),s(),_(1,v={mode:"network"}),k=new sy(F,E.toRouteSnapper()))}function V(){v.mode=="network"?k.startArea():v.mode=="neighbourhood"&&k.editExistingArea(v.boundary),_(1,v={mode:"set-boundary"}),k.addEventListenerSuccess(Ve=>{_(1,v={mode:"neighbourhood",boundary:Ve,addingFilter:!1}),k.clearEventListeners()}),k.addEventListenerFailure(()=>{_(1,v={mode:"network"}),k.clearEventListeners()})}function me(){_(1,v={mode:"neighbourhood",boundary:{geometry:{coordinates:[[[-2.582766,51.455751],[-2.582715,51.455655],[-2.582477,51.455207],[-2.582446,51.455157],[-2.582409,51.455129],[-2.582334,51.455111],[-2.58226,51.455115],[-2.582174,51.455113],[-2.582115,51.455126],[-2.581976,51.454882],[-2.581812,51.454602],[-2.582181,51.454505],[-2.582091,51.454224],[-2.582071,51.454159],[-2.582042,51.454073],[-2.581915,51.453674],[-2.581972,51.453287],[-2.581714,51.45322],[-2.58169,51.453214],[-2.581866,51.452966],[-2.581588,51.45288],[-2.581521,51.45281],[-2.581584,51.452731],[-2.581401,51.452671],[-2.581103,51.452566],[-2.579862,51.452092],[-2.579808,51.452069],[-2.579753,51.452045],[-2.579074,51.451752],[-2.578228,51.45135],[-2.578131,51.451293],[-2.578066,51.451251],[-2.577641,51.450924],[-2.577504,51.450818],[-2.577228,51.450628],[-2.576815,51.450348],[-2.576749,51.450294],[-2.576487,51.450084],[-2.57599,51.449653],[-2.575886,51.449685],[-2.575807,51.449709],[-2.575324,51.44978],[-2.574139,51.449954],[-2.573887,51.450007],[-2.573699,51.450097],[-2.573534,51.450262],[-2.573415,51.450398],[-2.573305,51.45055],[-2.573286,51.450604],[-2.573279,51.450637],[-2.573275,51.45066],[-2.57327,51.450705],[-2.573278,51.450761],[-2.573366,51.451076],[-2.573491,51.451385],[-2.573553,51.451514],[-2.573591,51.451605],[-2.573635,51.451726],[-2.573785,51.451943],[-2.573862,51.452052],[-2.574029,51.452215],[-2.574301,51.452438],[-2.573889,51.452598],[-2.572852,51.452994],[-2.57186,51.453341],[-2.571252,51.453557],[-2.571012,51.45364],[-2.570853,51.453697],[-2.5705,51.453823],[-2.570369,51.45387],[-2.570287,51.453901],[-2.570078,51.453977],[-2.569972,51.454016],[-2.569803,51.454082],[-2.569713,51.454115],[-2.569632,51.454144],[-2.569501,51.454184],[-2.569137,51.454304],[-2.568791,51.454436],[-2.568648,51.454505],[-2.568666,51.454525],[-2.568674,51.454548],[-2.56867,51.454571],[-2.568656,51.454593],[-2.568632,51.454611],[-2.568601,51.454623],[-2.568688,51.454756],[-2.568967,51.454972],[-2.569021,51.455014],[-2.568715,51.455271],[-2.568646,51.455327],[-2.568374,51.455559],[-2.568108,51.455772],[-2.567496,51.456239],[-2.567414,51.456319],[-2.567628,51.456492],[-2.567643,51.456517],[-2.567649,51.456526],[-2.567656,51.456544],[-2.567659,51.456553],[-2.567655,51.456589],[-2.56766,51.456617],[-2.567688,51.456643],[-2.567726,51.456662],[-2.567757,51.456684],[-2.567783,51.456719],[-2.567793,51.456739],[-2.567796,51.456747],[-2.56779,51.456775],[-2.567829,51.456783],[-2.567946,51.456871],[-2.568049,51.456948],[-2.568176,51.457057],[-2.568213,51.457083],[-2.568322,51.45716],[-2.568414,51.457216],[-2.56846,51.457251],[-2.568445,51.457292],[-2.567621,51.457946],[-2.567536,51.457943],[-2.567354,51.458066],[-2.567316,51.458148],[-2.567406,51.458165],[-2.567764,51.458232],[-2.568027,51.458276],[-2.568076,51.458283],[-2.568358,51.458287],[-2.568442,51.45829],[-2.568972,51.458337],[-2.56919,51.458356],[-2.569451,51.458365],[-2.569642,51.458363],[-2.569759,51.458354],[-2.570133,51.458292],[-2.570486,51.458208],[-2.570908,51.458114],[-2.571103,51.458103],[-2.57128,51.458116],[-2.571551,51.458175],[-2.571638,51.458205],[-2.571745,51.458247],[-2.571982,51.45828],[-2.572208,51.458286],[-2.573275,51.458227],[-2.573563,51.458208],[-2.573671,51.458195],[-2.573724,51.458183],[-2.573781,51.458175],[-2.573895,51.458156],[-2.573943,51.458146],[-2.576163,51.457686],[-2.576531,51.457615],[-2.576651,51.457592],[-2.576817,51.457539],[-2.57706,51.4574],[-2.577425,51.457222],[-2.577781,51.457082],[-2.578035,51.456998],[-2.578202,51.456951],[-2.578496,51.456874],[-2.578585,51.456849],[-2.578781,51.456795],[-2.579666,51.456548],[-2.579847,51.456493],[-2.579937,51.456464],[-2.580159,51.456403],[-2.580275,51.456396],[-2.580319,51.456385],[-2.580442,51.456351],[-2.580625,51.456286],[-2.580716,51.456255],[-2.580822,51.456205],[-2.580925,51.45617],[-2.581018,51.456139],[-2.581116,51.456108],[-2.581297,51.456054],[-2.581424,51.456018],[-2.581562,51.455983],[-2.581716,51.455949],[-2.581883,51.455913],[-2.582016,51.455898],[-2.582766,51.455751]]],type:"Polygon"},properties:{waypoints:[{lat:51.455751,lon:-2.582766,snapped:!0},{lat:51.449653,lon:-2.57599,snapped:!0},{lat:51.457083,lon:-2.568213,snapped:!0},{lat:51.455751,lon:-2.582766,snapped:!0}]},type:"Feature"},addingFilter:!1})}function be(){_(1,v={mode:"network"})}function ge(Ve){Ve.key=="a"&&v.mode=="neighbourhood"&&!v.addingFilter&&_(1,v.addingFilter=!0,v)}function Oe(Ve){m.$$.not_equal(v.addingFilter,Ve)&&(v.addingFilter=Ve,_(1,v))}function ke(Ve){F=Ve,_(2,F)}function Pe(Ve){E=Ve,_(0,E)}const De=()=>_(1,v.addingFilter=!0,v);return m.$$.update=()=>{m.$$.dirty&1&&Z()},[E,v,F,s,V,me,be,ge,Oe,ke,Pe,De]}class Ny extends Wr{constructor(f){super(),Gr(this,f,By,Oy,Tr,{})}}new Ny({target:document.getElementById("app")}); diff --git a/index.html b/index.html index 9138bc9..59e61e7 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ LTN from scratch - +