var O3=Object.defineProperty;var N3=(u,e,t)=>e in u?O3(u,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):u[e]=t;var Q3=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports);var Qi=(u,e,t)=>(N3(u,typeof e!="symbol"?e+"":e,t),t);var CH=Q3(k_=>{function SS(u,e){for(var t=0;tr[c]})}}}return Object.freeze(Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const p of c)if(p.type==="childList")for(const y of p.addedNodes)y.tagName==="LINK"&&y.rel==="modulepreload"&&r(y)}).observe(document,{childList:!0,subtree:!0});function t(c){const p={};return c.integrity&&(p.integrity=c.integrity),c.referrerpolicy&&(p.referrerPolicy=c.referrerpolicy),c.crossorigin==="use-credentials"?p.credentials="include":c.crossorigin==="anonymous"?p.credentials="omit":p.credentials="same-origin",p}function r(c){if(c.ep)return;c.ep=!0;const p=t(c);fetch(c.href,p)}})();if(typeof window<"u"){let u=function(){var e=document.body,t=document.getElementById("__svg__icons__dom__");t||(t=document.createElementNS("http://www.w3.org/2000/svg","svg"),t.style.position="absolute",t.style.width="0",t.style.height="0",t.id="__svg__icons__dom__",t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("xmlns:link","http://www.w3.org/1999/xlink")),t.innerHTML='',e.insertBefore(t,e.lastChild)};var loadSvg=u;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()}class V3{constructor(e){Qi(this,"_CompEventChain");Qi(this,"_parentUnit");this._CompEventChain=e}get parentUnit(){return this._parentUnit}setParentUnit(e){return this._parentUnit=e,this}get CompEventChain(){return this._CompEventChain}addEvent(e){return this._CompEventChain.push(e),this}setCompEvent(e){return this._CompEventChain}remoteCompEvent(e){return this._CompEventChain}setCompEventChain(e){return this._CompEventChain=e,this._CompEventChain}clearCompEvent(){return this._CompEventChain=[],this._CompEventChain}}class H3{constructor(e){Qi(this,"_id");Qi(this,"_position");Qi(this,"_info");Qi(this,"_eventchain",new V3([]).setParentUnit(this));return this._id=e,this}get id(){return this._id}setId(e){return this._id=e,this}get position(){return this._position}setPosition(e){return this._position=e,this}get info(){return this._info}setInfo(e){return this._info=e,this}get eventchain(){return this._eventchain}setEventchain(e){return this._eventchain=e.setParentUnit(this),this}addEvent(e){return this._eventchain.addEvent(e),this}async eventStart(){}}var Nu=(u=>(u.stop="stop",u.run="run",u.pause="pause",u))(Nu||{});class G3{constructor(){Qi(this,"_FnQueue",[]);Qi(this,"_index",0);Qi(this,"_QueueStatus",Nu.stop)}get FnQueue(){return this._FnQueue}formatEventChain2Queue(e,t=()=>{}){let r=0,c=0;for(let p of e.ids)if(r+=p.eventchain.CompEventChain.length,p.eventchain.CompEventChain.length>0){let y=p.eventchain.parentUnit;for(let i of p.eventchain.CompEventChain){c+=1;let C={fn:i.Fn,args:Object.assign(y,{args:i.args}),prepare:i.prepareTime,delay:i.delayTime};this._FnQueue.push(C),t((c/r).toFixed(1))}}return this}async start(e,t=()=>{}){if(this._QueueStatus===Nu.stop?(this._index=-1,this._QueueStatus=Nu.run):this._QueueStatus===Nu.pause?this._QueueStatus=Nu.run:(this._index=-1,this._QueueStatus=Nu.run),this._FnQueue.length!==0)for(let r in this._FnQueue)if(this._QueueStatus===Nu.run){if(parseInt(r)>this._index){let c=this._FnQueue[r];this._index=parseInt(r),await this.runFun(c),this._index+1===this._FnQueue.length&&t(this._index)}}else break}async runPrepare(e){return new Promise(async(t,r)=>{await setTimeout(()=>{t()},e.prepare)})}async runFun(e){return await this.runPrepare(e),new Promise(async(t,r)=>{await e.fn(e.args),await setTimeout(()=>{t()},e.delay)})}stop(){this._QueueStatus=Nu.stop}pause(){this._QueueStatus=Nu.pause}}class q1{constructor(){Qi(this,"_ids",[]);Qi(this,"_queue");Qi(this,"_loop");Qi(this,"_loopIndex",0);Qi(this,"_loopDone",()=>{});this._queue=new G3}setLoop(e,t=()=>{}){return this._loop=e,this._loopDone=t,this}destory(){this._ids=[],this._queue=null}get queue(){return this._queue}get ids(){return this._ids}start(){this.queue.start({},this.queneEndOnceLoop.bind(this))}stop(){this.queue.stop()}pause(){this.queue.pause()}queneEndOnceLoop(e){this._loopIndex+=1,this._loop===-1?this.start():this._loop>this._loopIndex?this.start():this._loopDone()}addUnit(e){return this._ids.push(e),this}removeUnit(e){let t=[];for(let r in this._ids){let c=this._ids[r];c.id!==e&&t.push(c)}return this._ids=t,this}clearUnit(){return this._ids=[],this}buildQueue(e){return this.queue.formatEventChain2Queue(this,e),this}}var MS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof{}<"u"?{}:typeof self<"u"?self:{},P_={},W3=u=>encodeURIComponent(u).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),IS="%[a-f0-9]{2}",UC=new RegExp("("+IS+")|([^%]+?)","gi"),RC=new RegExp("("+IS+")+","gi");function ab(u,e){try{return[decodeURIComponent(u.join(""))]}catch{}if(u.length===1)return u;e=e||1;var t=u.slice(0,e),r=u.slice(e);return Array.prototype.concat.call([],ab(t),ab(r))}function j3(u){try{return decodeURIComponent(u)}catch{for(var e=u.match(UC)||[],t=1;t{if(!(typeof u=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[u];const t=u.indexOf(e);return t===-1?[u]:[u.slice(0,t),u.slice(t+e.length)]},X3=function(u,e){for(var t={},r=Object.keys(u),c=Array.isArray(e),p=0;pae==null;function y(ae){switch(ae.arrayFormat){case"index":return ce=>(Ae,we)=>{const me=Ae.length;return we===void 0||ae.skipNull&&we===null||ae.skipEmptyString&&we===""?Ae:we===null?[...Ae,[D(ce,ae),"[",me,"]"].join("")]:[...Ae,[D(ce,ae),"[",D(me,ae),"]=",D(we,ae)].join("")]};case"bracket":return ce=>(Ae,we)=>we===void 0||ae.skipNull&&we===null||ae.skipEmptyString&&we===""?Ae:we===null?[...Ae,[D(ce,ae),"[]"].join("")]:[...Ae,[D(ce,ae),"[]=",D(we,ae)].join("")];case"comma":case"separator":return ce=>(Ae,we)=>we==null||we.length===0?Ae:Ae.length===0?[[D(ce,ae),"=",D(we,ae)].join("")]:[[Ae,D(we,ae)].join(ae.arrayFormatSeparator)];default:return ce=>(Ae,we)=>we===void 0||ae.skipNull&&we===null||ae.skipEmptyString&&we===""?Ae:we===null?[...Ae,D(ce,ae)]:[...Ae,[D(ce,ae),"=",D(we,ae)].join("")]}}function i(ae){let ce;switch(ae.arrayFormat){case"index":return(Ae,we,me)=>{if(ce=/\[(\d*)\]$/.exec(Ae),Ae=Ae.replace(/\[\d*\]$/,""),!ce){me[Ae]=we;return}me[Ae]===void 0&&(me[Ae]={}),me[Ae][ce[1]]=we};case"bracket":return(Ae,we,me)=>{if(ce=/(\[\])$/.exec(Ae),Ae=Ae.replace(/\[\]$/,""),!ce){me[Ae]=we;return}if(me[Ae]===void 0){me[Ae]=[we];return}me[Ae]=[].concat(me[Ae],we)};case"comma":case"separator":return(Ae,we,me)=>{const De=typeof we=="string"&&we.includes(ae.arrayFormatSeparator),Je=typeof we=="string"&&!De&&R(we,ae).includes(ae.arrayFormatSeparator);we=Je?R(we,ae):we;const Fe=De||Je?we.split(ae.arrayFormatSeparator).map(Ge=>R(Ge,ae)):we===null?we:R(we,ae);me[Ae]=Fe};default:return(Ae,we,me)=>{if(me[Ae]===void 0){me[Ae]=we;return}me[Ae]=[].concat(me[Ae],we)}}}function C(ae){if(typeof ae!="string"||ae.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function D(ae,ce){return ce.encode?ce.strict?e(ae):encodeURIComponent(ae):ae}function R(ae,ce){return ce.decode?t(ae):ae}function Q(ae){return Array.isArray(ae)?ae.sort():typeof ae=="object"?Q(Object.keys(ae)).sort((ce,Ae)=>Number(ce)-Number(Ae)).map(ce=>ae[ce]):ae}function z(ae){const ce=ae.indexOf("#");return ce!==-1&&(ae=ae.slice(0,ce)),ae}function G(ae){let ce="";const Ae=ae.indexOf("#");return Ae!==-1&&(ce=ae.slice(Ae)),ce}function J(ae){ae=z(ae);const ce=ae.indexOf("?");return ce===-1?"":ae.slice(ce+1)}function Y(ae,ce){return ce.parseNumbers&&!Number.isNaN(Number(ae))&&typeof ae=="string"&&ae.trim()!==""?ae=Number(ae):ce.parseBooleans&&ae!==null&&(ae.toLowerCase()==="true"||ae.toLowerCase()==="false")&&(ae=ae.toLowerCase()==="true"),ae}function B(ae,ce){ce=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},ce),C(ce.arrayFormatSeparator);const Ae=i(ce),we=Object.create(null);if(typeof ae!="string"||(ae=ae.trim().replace(/^[?#&]/,""),!ae))return we;for(const me of ae.split("&")){if(me==="")continue;let[De,Je]=r(ce.decode?me.replace(/\+/g," "):me,"=");Je=Je===void 0?null:["comma","separator"].includes(ce.arrayFormat)?Je:R(Je,ce),Ae(R(De,ce),Je,we)}for(const me of Object.keys(we)){const De=we[me];if(typeof De=="object"&&De!==null)for(const Je of Object.keys(De))De[Je]=Y(De[Je],ce);else we[me]=Y(De,ce)}return ce.sort===!1?we:(ce.sort===!0?Object.keys(we).sort():Object.keys(we).sort(ce.sort)).reduce((me,De)=>{const Je=we[De];return Boolean(Je)&&typeof Je=="object"&&!Array.isArray(Je)?me[De]=Q(Je):me[De]=Je,me},Object.create(null))}u.extract=J,u.parse=B,u.stringify=(ae,ce)=>{if(!ae)return"";ce=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},ce),C(ce.arrayFormatSeparator);const Ae=Je=>ce.skipNull&&p(ae[Je])||ce.skipEmptyString&&ae[Je]==="",we=y(ce),me={};for(const Je of Object.keys(ae))Ae(Je)||(me[Je]=ae[Je]);const De=Object.keys(me);return ce.sort!==!1&&De.sort(ce.sort),De.map(Je=>{const Fe=ae[Je];return Fe===void 0?"":Fe===null?D(Je,ce):Array.isArray(Fe)?Fe.reduce(we(Je),[]).join("&"):D(Je,ce)+"="+D(Fe,ce)}).filter(Je=>Je.length>0).join("&")},u.parseUrl=(ae,ce)=>{ce=Object.assign({decode:!0},ce);const[Ae,we]=r(ae,"#");return Object.assign({url:Ae.split("?")[0]||"",query:B(J(ae),ce)},ce&&ce.parseFragmentIdentifier&&we?{fragmentIdentifier:R(we,ce)}:{})},u.stringifyUrl=(ae,ce)=>{ce=Object.assign({encode:!0,strict:!0},ce);const Ae=z(ae.url).split("?")[0]||"",we=u.extract(ae.url),me=u.parse(we,{sort:!1}),De=Object.assign(me,ae.query);let Je=u.stringify(De,ce);Je&&(Je=`?${Je}`);let Fe=G(ae.url);return ae.fragmentIdentifier&&(Fe=`#${D(ae.fragmentIdentifier,ce)}`),`${Ae}${Je}${Fe}`},u.pick=(ae,ce,Ae)=>{Ae=Object.assign({parseFragmentIdentifier:!0},Ae);const{url:we,query:me,fragmentIdentifier:De}=u.parseUrl(ae,Ae);return u.stringifyUrl({url:we,query:c(me,ce),fragmentIdentifier:De},Ae)},u.exclude=(ae,ce,Ae)=>{const we=Array.isArray(ce)?me=>!ce.includes(me):(me,De)=>!ce(me,De);return u.pick(ae,we,Ae)}})(P_);const q3=SS({__proto__:null,default:P_},[P_]);/*! * html2canvas 1.4.1 * Copyright (c) 2022 Niklas von Hertzen * Released under MIT License *//*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var lb=function(u,e){return lb=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var c in r)Object.prototype.hasOwnProperty.call(r,c)&&(t[c]=r[c])},lb(u,e)};function Au(u,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");lb(u,e);function t(){this.constructor=u}u.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var cb=function(){return cb=Object.assign||function(e){for(var t,r=1,c=arguments.length;r0&&p[p.length-1])&&(D[0]===6||D[0]===2)){t=0;continue}if(D[0]===3&&(!p||D[1]>p[0]&&D[1]=55296&&c<=56319&&t>10)+55296,y%1024+56320)),(c+1===t||r.length>16384)&&(p+=String.fromCharCode.apply(String,r),r.length=0)}return p},zC="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J3=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var S0=0;S0"u"?[]:new Uint8Array(256);for(var M0=0;M0>4,R[c++]=(y&15)<<4|i>>2,R[c++]=(i&3)<<6|C&63;return D},tL=function(u){for(var e=u.length,t=[],r=0;r>lf,rL=1<>lf,oL=FS+sL,aL=oL,lL=32,cL=aL+lL,hL=65536>>B2,uL=1<=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>lf],t=(t<>lf)],t=(t<>B2),t=this.index[t],t+=e>>lf&AL,t=this.index[t],t=(t<"u"?[]:new Uint8Array(256);for(var I0=0;I0QC?(c.push(!0),i-=QC):c.push(!1),["normal","auto","loose"].indexOf(e)!==-1&&[8208,8211,12316,12448].indexOf(p)!==-1)return r.push(y),t.push(Ab);if(i===yL||i===hb){if(y===0)return r.push(y),t.push(Zp);var C=t[y-1];return TL.indexOf(C)===-1?(r.push(r[y-1]),t.push(C)):(r.push(y),t.push(Zp))}if(r.push(y),i===BL)return t.push(e==="strict"?db:U_);if(i===US||i===bL)return t.push(Zp);if(i===CL)return p>=131072&&p<=196605||p>=196608&&p<=262141?t.push(U_):t.push(Zp);t.push(i)}),[r,t,c]},iw=function(u,e,t,r){var c=r[t];if(Array.isArray(u)?u.indexOf(c)!==-1:u===c)for(var p=t;p<=r.length;){p++;var y=r[p];if(y===e)return!0;if(y!==Kd)break}if(c===Kd)for(var p=t;p>0;){p--;var i=r[p];if(Array.isArray(u)?u.indexOf(i)!==-1:u===i)for(var C=t;C<=r.length;){C++;var y=r[C];if(y===e)return!0;if(y!==Kd)break}if(i!==Kd)break}return!1},$C=function(u,e){for(var t=u;t>=0;){var r=e[t];if(r===Kd)t--;else return r}return 0},IL=function(u,e,t,r,c){if(t[r]===0)return Kr;var p=r-1;if(Array.isArray(c)&&c[p]===!0)return Kr;var y=p-1,i=p+1,C=e[p],D=y>=0?e[y]:0,R=e[i];if(C===LS&&R===DS)return Kr;if(yb.indexOf(C)!==-1)return RS;if(yb.indexOf(R)!==-1||zS.indexOf(R)!==-1)return Kr;if($C(p,e)===PS)return P0;if(_b.get(u[p])===hb||(C===L0||C===D0)&&_b.get(u[i])===hb||C===VC||R===VC||C===HC||[Kd,ub,p_].indexOf(C)===-1&&R===HC||[F0,qg,wL,im,nm].indexOf(R)!==-1||$C(p,e)===Yg||iw(ew,Yg,p,e)||iw([F0,qg],db,p,e)||iw(GC,GC,p,e))return Kr;if(C===Kd)return P0;if(C===ew||R===ew)return Kr;if(R===Ab||C===Ab)return P0;if([ub,p_,db].indexOf(R)!==-1||C===vL||D===mb&&SL.indexOf(C)!==-1||C===nm&&R===mb||R===WC||PA.indexOf(R)!==-1&&C===Ic||PA.indexOf(C)!==-1&&R===Ic||C===m_&&[U_,L0,D0].indexOf(R)!==-1||[U_,L0,D0].indexOf(C)!==-1&&R===f_||PA.indexOf(C)!==-1&&jC.indexOf(R)!==-1||jC.indexOf(C)!==-1&&PA.indexOf(R)!==-1||[m_,f_].indexOf(C)!==-1&&(R===Ic||[Yg,p_].indexOf(R)!==-1&&e[i+1]===Ic)||[Yg,p_].indexOf(C)!==-1&&R===Ic||C===Ic&&[Ic,nm,im].indexOf(R)!==-1)return Kr;if([Ic,nm,im,F0,qg].indexOf(R)!==-1)for(var Q=p;Q>=0;){var z=e[Q];if(z===Ic)return Kr;if([nm,im].indexOf(z)!==-1)Q--;else break}if([m_,f_].indexOf(R)!==-1)for(var Q=[F0,qg].indexOf(C)!==-1?y:p;Q>=0;){var z=e[Q];if(z===Ic)return Kr;if([nm,im].indexOf(z)!==-1)Q--;else break}if(gb===C&&[gb,Nx,pb,fb].indexOf(R)!==-1||[Nx,pb].indexOf(C)!==-1&&[Nx,Qx].indexOf(R)!==-1||[Qx,fb].indexOf(C)!==-1&&R===Qx||KC.indexOf(C)!==-1&&[WC,f_].indexOf(R)!==-1||KC.indexOf(R)!==-1&&C===m_||PA.indexOf(C)!==-1&&PA.indexOf(R)!==-1||C===im&&PA.indexOf(R)!==-1||PA.concat(Ic).indexOf(C)!==-1&&R===Yg&&EL.indexOf(u[i])===-1||PA.concat(Ic).indexOf(R)!==-1&&C===qg)return Kr;if(C===tw&&R===tw){for(var G=t[p],J=1;G>0&&(G--,e[G]===tw);)J++;if(J%2!==0)return Kr}return C===L0&&R===D0?Kr:P0},FL=function(u,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=ML(u,e.lineBreak),r=t[0],c=t[1],p=t[2];(e.wordBreak==="break-all"||e.wordBreak==="break-word")&&(c=c.map(function(i){return[Ic,Zp,US].indexOf(i)!==-1?U_:i}));var y=e.wordBreak==="keep-all"?p.map(function(i,C){return i&&u[C]>=19968&&u[C]<=40959}):void 0;return[r,c,y]},LL=function(){function u(e,t,r,c){this.codePoints=e,this.required=t===RS,this.start=r,this.end=c}return u.prototype.slice=function(){return Bo.apply(void 0,this.codePoints.slice(this.start,this.end))},u}(),DL=function(u,e){var t=Sv(u),r=FL(t,e),c=r[0],p=r[1],y=r[2],i=t.length,C=0,D=0;return{next:function(){if(D>=i)return{done:!0,value:null};for(var R=Kr;D=kS&&u<=57},dD=function(u){return u>=55296&&u<=57343},rm=function(u){return il(u)||u>=QS&&u<=HS||u>=OS&&u<=lD},pD=function(u){return u>=OS&&u<=hD},fD=function(u){return u>=QS&&u<=AD},mD=function(u){return pD(u)||fD(u)},gD=function(u){return u>=YL},O0=function(u){return u===ev||u===RL||u===zL},tv=function(u){return mD(u)||gD(u)||u===QL},JC=function(u){return tv(u)||il(u)||u===nc},_D=function(u){return u>=iD&&u<=nD||u===rD||u>=sD&&u<=oD||u===aD},Wd=function(u,e){return u!==w_?!1:e!==ev},N0=function(u,e,t){return u===nc?tv(e)||Wd(e,t):tv(u)?!0:!!(u===w_&&Wd(u,e))},rw=function(u,e,t){return u===nf||u===nc?il(e)?!0:e===R_&&il(t):il(u===R_?e:u)},yD=function(u){var e=0,t=1;(u[e]===nf||u[e]===nc)&&(u[e]===nc&&(t=-1),e++);for(var r=[];il(u[e]);)r.push(u[e++]);var c=r.length?parseInt(Bo.apply(void 0,r),10):0;u[e]===R_&&e++;for(var p=[];il(u[e]);)p.push(u[e++]);var y=p.length,i=y?parseInt(Bo.apply(void 0,p),10):0;(u[e]===VS||u[e]===NS)&&e++;var C=1;(u[e]===nf||u[e]===nc)&&(u[e]===nc&&(C=-1),e++);for(var D=[];il(u[e]);)D.push(u[e++]);var R=D.length?parseInt(Bo.apply(void 0,D),10):0;return t*(c+i*Math.pow(10,-y))*Math.pow(10,C*R)},xD={type:2},vD={type:3},wD={type:4},bD={type:13},BD={type:8},CD={type:21},ED={type:9},TD={type:10},SD={type:11},MD={type:12},ID={type:14},Q0={type:23},FD={type:1},LD={type:25},DD={type:24},PD={type:26},UD={type:27},RD={type:28},zD={type:29},kD={type:31},xb={type:32},GS=function(){function u(){this._value=[]}return u.prototype.write=function(e){this._value=this._value.concat(Sv(e))},u.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==xb;)e.push(t),t=this.consumeToken();return e},u.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case U0:return this.consumeStringToken(U0);case kL:var t=this.peekCodePoint(0),r=this.peekCodePoint(1),c=this.peekCodePoint(2);if(JC(t)||Wd(r,c)){var p=N0(t,r,c)?UL:PL,y=this.consumeName();return{type:5,value:y,flags:p}}break;case OL:if(this.peekCodePoint(0)===Jg)return this.consumeCodePoint(),bD;break;case R0:return this.consumeStringToken(R0);case z0:return xD;case e_:return vD;case nw:if(this.peekCodePoint(0)===Jg)return this.consumeCodePoint(),ID;break;case nf:if(rw(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case JL:return wD;case nc:var i=e,C=this.peekCodePoint(0),D=this.peekCodePoint(1);if(rw(i,C,D))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(N0(i,C,D))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(C===nc&&D===GL)return this.consumeCodePoint(),this.consumeCodePoint(),DD;break;case R_:if(rw(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case XC:if(this.peekCodePoint(0)===nw)for(this.consumeCodePoint();;){var R=this.consumeCodePoint();if(R===nw&&(R=this.consumeCodePoint(),R===XC))return this.consumeToken();if(R===zu)return this.consumeToken()}break;case eD:return PD;case tD:return UD;case HL:if(this.peekCodePoint(0)===VL&&this.peekCodePoint(1)===nc&&this.peekCodePoint(2)===nc)return this.consumeCodePoint(),this.consumeCodePoint(),LD;break;case WL:var Q=this.peekCodePoint(0),z=this.peekCodePoint(1),G=this.peekCodePoint(2);if(N0(Q,z,G)){var y=this.consumeName();return{type:7,value:y}}break;case jL:return RD;case w_:if(Wd(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case KL:return zD;case $L:if(this.peekCodePoint(0)===Jg)return this.consumeCodePoint(),BD;break;case ZL:return SD;case XL:return MD;case cD:case uD:var J=this.peekCodePoint(0),Y=this.peekCodePoint(1);return J===nf&&(rm(Y)||Y===k0)&&(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case qC:if(this.peekCodePoint(0)===Jg)return this.consumeCodePoint(),ED;if(this.peekCodePoint(0)===qC)return this.consumeCodePoint(),CD;break;case qL:if(this.peekCodePoint(0)===Jg)return this.consumeCodePoint(),TD;break;case zu:return xb}return O0(e)?(this.consumeWhiteSpace(),kD):il(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):tv(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:Bo(e)}},u.prototype.consumeCodePoint=function(){var e=this._value.shift();return typeof e>"u"?-1:e},u.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},u.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},u.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();rm(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var r=!1;t===k0&&e.length<6;)e.push(t),t=this.consumeCodePoint(),r=!0;if(r){var c=parseInt(Bo.apply(void 0,e.map(function(C){return C===k0?kS:C})),16),p=parseInt(Bo.apply(void 0,e.map(function(C){return C===k0?HS:C})),16);return{type:30,start:c,end:p}}var y=parseInt(Bo.apply(void 0,e),16);if(this.peekCodePoint(0)===nc&&rm(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var i=[];rm(t)&&i.length<6;)i.push(t),t=this.consumeCodePoint();var p=parseInt(Bo.apply(void 0,i),16);return{type:30,start:y,end:p}}else return{type:30,start:y,end:y}},u.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return e.toLowerCase()==="url"&&this.peekCodePoint(0)===z0?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===z0?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},u.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===zu)return{type:22,value:""};var t=this.peekCodePoint(0);if(t===R0||t===U0){var r=this.consumeStringToken(this.consumeCodePoint());return r.type===0&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===zu||this.peekCodePoint(0)===e_)?(this.consumeCodePoint(),{type:22,value:r.value}):(this.consumeBadUrlRemnants(),Q0)}for(;;){var c=this.consumeCodePoint();if(c===zu||c===e_)return{type:22,value:Bo.apply(void 0,e)};if(O0(c))return this.consumeWhiteSpace(),this.peekCodePoint(0)===zu||this.peekCodePoint(0)===e_?(this.consumeCodePoint(),{type:22,value:Bo.apply(void 0,e)}):(this.consumeBadUrlRemnants(),Q0);if(c===U0||c===R0||c===z0||_D(c))return this.consumeBadUrlRemnants(),Q0;if(c===w_)if(Wd(c,this.peekCodePoint(0)))e.push(this.consumeEscapedCodePoint());else return this.consumeBadUrlRemnants(),Q0;else e.push(c)}},u.prototype.consumeWhiteSpace=function(){for(;O0(this.peekCodePoint(0));)this.consumeCodePoint()},u.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===e_||e===zu)return;Wd(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},u.prototype.consumeStringSlice=function(e){for(var t=5e4,r="";e>0;){var c=Math.min(t,e);r+=Bo.apply(void 0,this._value.splice(0,c)),e-=c}return this._value.shift(),r},u.prototype.consumeStringToken=function(e){var t="",r=0;do{var c=this._value[r];if(c===zu||c===void 0||c===e)return t+=this.consumeStringSlice(r),{type:0,value:t};if(c===ev)return this._value.splice(0,r),FD;if(c===w_){var p=this._value[r+1];p!==zu&&p!==void 0&&(p===ev?(t+=this.consumeStringSlice(r),r=-1,this._value.shift()):Wd(c,p)&&(t+=this.consumeStringSlice(r),t+=Bo(this.consumeEscapedCodePoint()),r=-1))}r++}while(!0)},u.prototype.consumeNumber=function(){var e=[],t=oy,r=this.peekCodePoint(0);for((r===nf||r===nc)&&e.push(this.consumeCodePoint());il(this.peekCodePoint(0));)e.push(this.consumeCodePoint());r=this.peekCodePoint(0);var c=this.peekCodePoint(1);if(r===R_&&il(c))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=ZC;il(this.peekCodePoint(0));)e.push(this.consumeCodePoint());r=this.peekCodePoint(0),c=this.peekCodePoint(1);var p=this.peekCodePoint(2);if((r===VS||r===NS)&&((c===nf||c===nc)&&il(p)||il(c)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=ZC;il(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[yD(e),t]},u.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],r=e[1],c=this.peekCodePoint(0),p=this.peekCodePoint(1),y=this.peekCodePoint(2);if(N0(c,p,y)){var i=this.consumeName();return{type:15,number:t,flags:r,unit:i}}return c===NL?(this.consumeCodePoint(),{type:16,number:t,flags:r}):{type:17,number:t,flags:r}},u.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(rm(e)){for(var t=Bo(e);rm(this.peekCodePoint(0))&&t.length<6;)t+=Bo(this.consumeCodePoint());O0(this.peekCodePoint(0))&&this.consumeCodePoint();var r=parseInt(t,16);return r===0||dD(r)||r>1114111?YC:r}return e===zu?YC:e},u.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(JC(t))e+=Bo(t);else if(Wd(t,this.peekCodePoint(0)))e+=Bo(this.consumeEscapedCodePoint());else return this.reconsumeCodePoint(t),e}},u}(),WS=function(){function u(e){this._tokens=e}return u.create=function(e){var t=new GS;return t.write(e),new u(t.read())},u.parseValue=function(e){return u.create(e).parseComponentValue()},u.parseValues=function(e){return u.create(e).parseComponentValues()},u.prototype.parseComponentValue=function(){for(var e=this.consumeToken();e.type===31;)e=this.consumeToken();if(e.type===32)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do e=this.consumeToken();while(e.type===31);if(e.type===32)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},u.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(t.type===32)return e;e.push(t),e.push()}},u.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},u.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},r=this.consumeToken();;){if(r.type===32||ND(r,e))return t;this.reconsumeToken(r),t.values.push(this.consumeComponentValue()),r=this.consumeToken()}},u.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var r=this.consumeToken();if(r.type===32||r.type===3)return t;this.reconsumeToken(r),t.values.push(this.consumeComponentValue())}},u.prototype.consumeToken=function(){var e=this._tokens.shift();return typeof e>"u"?xb:e},u.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},u}(),ay=function(u){return u.type===15},Xm=function(u){return u.type===17},Ss=function(u){return u.type===20},OD=function(u){return u.type===0},vb=function(u,e){return Ss(u)&&u.value===e},jS=function(u){return u.type!==31},Hm=function(u){return u.type!==31&&u.type!==4},$u=function(u){var e=[],t=[];return u.forEach(function(r){if(r.type===4){if(t.length===0)throw new Error("Error parsing function args, zero tokens for arg");e.push(t),t=[];return}r.type!==31&&t.push(r)}),t.length&&e.push(t),e},ND=function(u,e){return e===11&&u.type===12||e===28&&u.type===29?!0:e===2&&u.type===3},np=function(u){return u.type===17||u.type===15},zo=function(u){return u.type===16||np(u)},KS=function(u){return u.length>1?[u[0],u[1]]:[u[0]]},ka={type:17,number:0,flags:oy},C2={type:16,number:50,flags:oy},$d={type:16,number:100,flags:oy},g_=function(u,e,t){var r=u[0],c=u[1];return[Gs(r,e),Gs(typeof c<"u"?c:r,t)]},Gs=function(u,e){if(u.type===16)return u.number/100*e;if(ay(u))switch(u.unit){case"rem":case"em":return 16*u.number;case"px":default:return u.number}return u.number},$S="deg",ZS="grad",XS="rad",qS="turn",Mv={name:"angle",parse:function(u,e){if(e.type===15)switch(e.unit){case $S:return Math.PI*e.number/180;case ZS:return Math.PI/200*e.number;case XS:return e.number;case qS:return Math.PI*2*e.number}throw new Error("Unsupported angle type")}},YS=function(u){return u.type===15&&(u.unit===$S||u.unit===ZS||u.unit===XS||u.unit===qS)},JS=function(u){var e=u.filter(Ss).map(function(t){return t.value}).join(" ");switch(e){case"to bottom right":case"to right bottom":case"left top":case"top left":return[ka,ka];case"to top":case"bottom":return bh(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[ka,$d];case"to right":case"left":return bh(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[$d,$d];case"to bottom":case"top":return bh(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[$d,ka];case"to left":case"right":return bh(270)}return 0},bh=function(u){return Math.PI*u/180},Yd={name:"color",parse:function(u,e){if(e.type===18){var t=QD[e.name];if(typeof t>"u")throw new Error('Attempting to parse an unsupported color function "'+e.name+'"');return t(u,e.values)}if(e.type===5){if(e.value.length===3){var r=e.value.substring(0,1),c=e.value.substring(1,2),p=e.value.substring(2,3);return Zd(parseInt(r+r,16),parseInt(c+c,16),parseInt(p+p,16),1)}if(e.value.length===4){var r=e.value.substring(0,1),c=e.value.substring(1,2),p=e.value.substring(2,3),y=e.value.substring(3,4);return Zd(parseInt(r+r,16),parseInt(c+c,16),parseInt(p+p,16),parseInt(y+y,16)/255)}if(e.value.length===6){var r=e.value.substring(0,2),c=e.value.substring(2,4),p=e.value.substring(4,6);return Zd(parseInt(r,16),parseInt(c,16),parseInt(p,16),1)}if(e.value.length===8){var r=e.value.substring(0,2),c=e.value.substring(2,4),p=e.value.substring(4,6),y=e.value.substring(6,8);return Zd(parseInt(r,16),parseInt(c,16),parseInt(p,16),parseInt(y,16)/255)}}if(e.type===20){var i=jA[e.value.toUpperCase()];if(typeof i<"u")return i}return jA.TRANSPARENT}},Jd=function(u){return(255&u)===0},ma=function(u){var e=255&u,t=255&u>>8,r=255&u>>16,c=255&u>>24;return e<255?"rgba("+c+","+r+","+t+","+e/255+")":"rgb("+c+","+r+","+t+")"},Zd=function(u,e,t,r){return(u<<24|e<<16|t<<8|Math.round(r*255)<<0)>>>0},eE=function(u,e){if(u.type===17)return u.number;if(u.type===16){var t=e===3?1:255;return e===3?u.number/100*t:Math.round(u.number/100*t)}return 0},tE=function(u,e){var t=e.filter(Hm);if(t.length===3){var r=t.map(eE),c=r[0],p=r[1],y=r[2];return Zd(c,p,y,1)}if(t.length===4){var i=t.map(eE),c=i[0],p=i[1],y=i[2],C=i[3];return Zd(c,p,y,C)}return 0};function sw(u,e,t){return t<0&&(t+=1),t>=1&&(t-=1),t<1/6?(e-u)*t*6+u:t<1/2?e:t<2/3?(e-u)*6*(2/3-t)+u:u}var iE=function(u,e){var t=e.filter(Hm),r=t[0],c=t[1],p=t[2],y=t[3],i=(r.type===17?bh(r.number):Mv.parse(u,r))/(Math.PI*2),C=zo(c)?c.number/100:0,D=zo(p)?p.number/100:0,R=typeof y<"u"&&zo(y)?Gs(y,1):1;if(C===0)return Zd(D*255,D*255,D*255,1);var Q=D<=.5?D*(C+1):D+C-D*C,z=D*2-Q,G=sw(z,Q,i+1/3),J=sw(z,Q,i),Y=sw(z,Q,i-1/3);return Zd(G*255,J*255,Y*255,R)},QD={hsl:iE,hsla:iE,rgb:tE,rgba:tE},b_=function(u,e){return Yd.parse(u,WS.create(e).parseComponentValue())},jA={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},VD={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(u,e){return e.map(function(t){if(Ss(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},HD={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},Iv=function(u,e){var t=Yd.parse(u,e[0]),r=e[1];return r&&zo(r)?{color:t,stop:r}:{color:t,stop:null}},nE=function(u,e){var t=u[0],r=u[u.length-1];t.stop===null&&(t.stop=ka),r.stop===null&&(r.stop=$d);for(var c=[],p=0,y=0;yp?c.push(C):c.push(p),p=C}else c.push(null)}for(var D=null,y=0;yy.optimumDistance)?{optimumCorner:i,optimumDistance:R}:y},{optimumDistance:c?1/0:-1/0,optimumCorner:null}).optimumCorner},jD=function(u,e,t,r,c){var p=0,y=0;switch(u.size){case 0:u.shape===0?p=y=Math.min(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-c)):u.shape===1&&(p=Math.min(Math.abs(e),Math.abs(e-r)),y=Math.min(Math.abs(t),Math.abs(t-c)));break;case 2:if(u.shape===0)p=y=Math.min(lu(e,t),lu(e,t-c),lu(e-r,t),lu(e-r,t-c));else if(u.shape===1){var i=Math.min(Math.abs(t),Math.abs(t-c))/Math.min(Math.abs(e),Math.abs(e-r)),C=rE(r,c,e,t,!0),D=C[0],R=C[1];p=lu(D-e,(R-t)/i),y=i*p}break;case 1:u.shape===0?p=y=Math.max(Math.abs(e),Math.abs(e-r),Math.abs(t),Math.abs(t-c)):u.shape===1&&(p=Math.max(Math.abs(e),Math.abs(e-r)),y=Math.max(Math.abs(t),Math.abs(t-c)));break;case 3:if(u.shape===0)p=y=Math.max(lu(e,t),lu(e,t-c),lu(e-r,t),lu(e-r,t-c));else if(u.shape===1){var i=Math.max(Math.abs(t),Math.abs(t-c))/Math.max(Math.abs(e),Math.abs(e-r)),Q=rE(r,c,e,t,!1),D=Q[0],R=Q[1];p=lu(D-e,(R-t)/i),y=i*p}break}return Array.isArray(u.size)&&(p=Gs(u.size[0],r),y=u.size.length===2?Gs(u.size[1],c):p),[p,y]},KD=function(u,e){var t=bh(180),r=[];return $u(e).forEach(function(c,p){if(p===0){var y=c[0];if(y.type===20&&y.value==="to"){t=JS(c);return}else if(YS(y)){t=Mv.parse(u,y);return}}var i=Iv(u,c);r.push(i)}),{angle:t,stops:r,type:1}},V0=function(u,e){var t=bh(180),r=[];return $u(e).forEach(function(c,p){if(p===0){var y=c[0];if(y.type===20&&["top","left","right","bottom"].indexOf(y.value)!==-1){t=JS(c);return}else if(YS(y)){t=(Mv.parse(u,y)+bh(270))%bh(360);return}}var i=Iv(u,c);r.push(i)}),{angle:t,stops:r,type:1}},$D=function(u,e){var t=bh(180),r=[],c=1,p=0,y=3,i=[];return $u(e).forEach(function(C,D){var R=C[0];if(D===0){if(Ss(R)&&R.value==="linear"){c=1;return}else if(Ss(R)&&R.value==="radial"){c=2;return}}if(R.type===18){if(R.name==="from"){var Q=Yd.parse(u,R.values[0]);r.push({stop:ka,color:Q})}else if(R.name==="to"){var Q=Yd.parse(u,R.values[0]);r.push({stop:$d,color:Q})}else if(R.name==="color-stop"){var z=R.values.filter(Hm);if(z.length===2){var Q=Yd.parse(u,z[1]),G=z[0];Xm(G)&&r.push({stop:{type:16,number:G.number*100,flags:G.flags},color:Q})}}}}),c===1?{angle:(t+bh(180))%bh(360),stops:r,type:c}:{size:y,shape:p,stops:r,position:i,type:c}},eM="closest-side",tM="farthest-side",iM="closest-corner",nM="farthest-corner",rM="circle",sM="ellipse",oM="cover",aM="contain",ZD=function(u,e){var t=0,r=3,c=[],p=[];return $u(e).forEach(function(y,i){var C=!0;if(i===0){var D=!1;C=y.reduce(function(Q,z){if(D)if(Ss(z))switch(z.value){case"center":return p.push(C2),Q;case"top":case"left":return p.push(ka),Q;case"right":case"bottom":return p.push($d),Q}else(zo(z)||np(z))&&p.push(z);else if(Ss(z))switch(z.value){case rM:return t=0,!1;case sM:return t=1,!1;case"at":return D=!0,!1;case eM:return r=0,!1;case oM:case tM:return r=1,!1;case aM:case iM:return r=2,!1;case nM:return r=3,!1}else if(np(z)||zo(z))return Array.isArray(r)||(r=[]),r.push(z),!1;return Q},C)}if(C){var R=Iv(u,y);c.push(R)}}),{size:r,shape:t,stops:c,position:p,type:2}},H0=function(u,e){var t=0,r=3,c=[],p=[];return $u(e).forEach(function(y,i){var C=!0;if(i===0?C=y.reduce(function(R,Q){if(Ss(Q))switch(Q.value){case"center":return p.push(C2),!1;case"top":case"left":return p.push(ka),!1;case"right":case"bottom":return p.push($d),!1}else if(zo(Q)||np(Q))return p.push(Q),!1;return R},C):i===1&&(C=y.reduce(function(R,Q){if(Ss(Q))switch(Q.value){case rM:return t=0,!1;case sM:return t=1,!1;case aM:case eM:return r=0,!1;case tM:return r=1,!1;case iM:return r=2,!1;case oM:case nM:return r=3,!1}else if(np(Q)||zo(Q))return Array.isArray(r)||(r=[]),r.push(Q),!1;return R},C)),C){var D=Iv(u,y);c.push(D)}}),{size:r,shape:t,stops:c,position:p,type:2}},XD=function(u){return u.type===1},qD=function(u){return u.type===2},E2={name:"image",parse:function(u,e){if(e.type===22){var t={url:e.value,type:0};return u.cache.addImage(e.value),t}if(e.type===18){var r=lM[e.name];if(typeof r>"u")throw new Error('Attempting to parse an unsupported image function "'+e.name+'"');return r(u,e.values)}throw new Error("Unsupported image type "+e.type)}};function YD(u){return!(u.type===20&&u.value==="none")&&(u.type!==18||!!lM[u.name])}var lM={"linear-gradient":KD,"-moz-linear-gradient":V0,"-ms-linear-gradient":V0,"-o-linear-gradient":V0,"-webkit-linear-gradient":V0,"radial-gradient":ZD,"-moz-radial-gradient":H0,"-ms-radial-gradient":H0,"-o-radial-gradient":H0,"-webkit-radial-gradient":H0,"-webkit-gradient":$D},JD={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(u,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e.filter(function(r){return Hm(r)&&YD(r)}).map(function(r){return E2.parse(u,r)})}},eP={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(u,e){return e.map(function(t){if(Ss(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},tP={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(u,e){return $u(e).map(function(t){return t.filter(zo)}).map(KS)}},iP={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(u,e){return $u(e).map(function(t){return t.filter(Ss).map(function(r){return r.value}).join(" ")}).map(nP)}},nP=function(u){switch(u){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;case"repeat":default:return 0}},Om;(function(u){u.AUTO="auto",u.CONTAIN="contain",u.COVER="cover"})(Om||(Om={}));var rP={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(u,e){return $u(e).map(function(t){return t.filter(sP)})}},sP=function(u){return Ss(u)||zo(u)},Fv=function(u){return{name:"border-"+u+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},oP=Fv("top"),aP=Fv("right"),lP=Fv("bottom"),cP=Fv("left"),Lv=function(u){return{name:"border-radius-"+u,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return KS(t.filter(zo))}}},hP=Lv("top-left"),uP=Lv("top-right"),AP=Lv("bottom-right"),dP=Lv("bottom-left"),Dv=function(u){return{name:"border-"+u+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},pP=Dv("top"),fP=Dv("right"),mP=Dv("bottom"),gP=Dv("left"),Pv=function(u){return{name:"border-"+u+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return ay(t)?t.number:0}}},_P=Pv("top"),yP=Pv("right"),xP=Pv("bottom"),vP=Pv("left"),wP={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},bP={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(u,e){switch(e){case"rtl":return 1;case"ltr":default:return 0}}},BP={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(u,e){return e.filter(Ss).reduce(function(t,r){return t|CP(r.value)},0)}},CP=function(u){switch(u){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},EP={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(u,e){switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},TP={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(u,e){return e.type===20&&e.value==="normal"?0:e.type===17||e.type===15?e.number:0}},iv;(function(u){u.NORMAL="normal",u.STRICT="strict"})(iv||(iv={}));var SP={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(u,e){switch(e){case"strict":return iv.STRICT;case"normal":default:return iv.NORMAL}}},MP={name:"line-height",initialValue:"normal",prefix:!1,type:4},sE=function(u,e){return Ss(u)&&u.value==="normal"?1.2*e:u.type===17?e*u.number:zo(u)?Gs(u,e):e},IP={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(u,e){return e.type===20&&e.value==="none"?null:E2.parse(u,e)}},FP={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(u,e){switch(e){case"inside":return 0;case"outside":default:return 1}}},wb={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(u,e){switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":return 22;case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;case"none":default:return-1}}},Uv=function(u){return{name:"margin-"+u,initialValue:"0",prefix:!1,type:4}},LP=Uv("top"),DP=Uv("right"),PP=Uv("bottom"),UP=Uv("left"),RP={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(u,e){return e.filter(Ss).map(function(t){switch(t.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;case"visible":default:return 0}})}},zP={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(u,e){switch(e){case"break-word":return"break-word";case"normal":default:return"normal"}}},Rv=function(u){return{name:"padding-"+u,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},kP=Rv("top"),OP=Rv("right"),NP=Rv("bottom"),QP=Rv("left"),VP={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(u,e){switch(e){case"right":return 2;case"center":case"justify":return 1;case"left":default:return 0}}},HP={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(u,e){switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},GP={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(u,e){return e.length===1&&vb(e[0],"none")?[]:$u(e).map(function(t){for(var r={color:jA.TRANSPARENT,offsetX:ka,offsetY:ka,blur:ka},c=0,p=0;p"u")throw new Error('Attempting to parse an unsupported transform function "'+e.name+'"');return t(e.values)}return null}},KP=function(u){var e=u.filter(function(t){return t.type===17}).map(function(t){return t.number});return e.length===6?e:null},$P=function(u){var e=u.filter(function(C){return C.type===17}).map(function(C){return C.number}),t=e[0],r=e[1];e[2],e[3];var c=e[4],p=e[5];e[6],e[7],e[8],e[9],e[10],e[11];var y=e[12],i=e[13];return e[14],e[15],e.length===16?[t,r,c,p,y,i]:null},ZP={matrix:KP,matrix3d:$P},oE={type:16,number:50,flags:oy},XP=[oE,oE],qP={name:"transform-origin",initialValue:"50% 50%",prefix:!0,type:1,parse:function(u,e){var t=e.filter(zo);return t.length!==2?XP:[t[0],t[1]]}},YP={name:"visible",initialValue:"none",prefix:!1,type:2,parse:function(u,e){switch(e){case"hidden":return 1;case"collapse":return 2;case"visible":default:return 0}}},B_;(function(u){u.NORMAL="normal",u.BREAK_ALL="break-all",u.KEEP_ALL="keep-all"})(B_||(B_={}));var JP={name:"word-break",initialValue:"normal",prefix:!1,type:2,parse:function(u,e){switch(e){case"break-all":return B_.BREAK_ALL;case"keep-all":return B_.KEEP_ALL;case"normal":default:return B_.NORMAL}}},eU={name:"z-index",initialValue:"auto",prefix:!1,type:0,parse:function(u,e){if(e.type===20)return{auto:!0,order:0};if(Xm(e))return{auto:!1,order:e.number};throw new Error("Invalid z-index number parsed")}},cM={name:"time",parse:function(u,e){if(e.type===15)switch(e.unit.toLowerCase()){case"s":return 1e3*e.number;case"ms":return e.number}throw new Error("Unsupported time type")}},tU={name:"opacity",initialValue:"1",type:0,prefix:!1,parse:function(u,e){return Xm(e)?e.number:1}},iU={name:"text-decoration-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},nU={name:"text-decoration-line",initialValue:"none",prefix:!1,type:1,parse:function(u,e){return e.filter(Ss).map(function(t){switch(t.value){case"underline":return 1;case"overline":return 2;case"line-through":return 3;case"none":return 4}return 0}).filter(function(t){return t!==0})}},rU={name:"font-family",initialValue:"",prefix:!1,type:1,parse:function(u,e){var t=[],r=[];return e.forEach(function(c){switch(c.type){case 20:case 0:t.push(c.value);break;case 17:t.push(c.number.toString());break;case 4:r.push(t.join(" ")),t.length=0;break}}),t.length&&r.push(t.join(" ")),r.map(function(c){return c.indexOf(" ")===-1?c:"'"+c+"'"})}},sU={name:"font-size",initialValue:"0",prefix:!1,type:3,format:"length"},oU={name:"font-weight",initialValue:"normal",type:0,prefix:!1,parse:function(u,e){if(Xm(e))return e.number;if(Ss(e))switch(e.value){case"bold":return 700;case"normal":default:return 400}return 400}},aU={name:"font-variant",initialValue:"none",type:1,prefix:!1,parse:function(u,e){return e.filter(Ss).map(function(t){return t.value})}},lU={name:"font-style",initialValue:"normal",prefix:!1,type:2,parse:function(u,e){switch(e){case"oblique":return"oblique";case"italic":return"italic";case"normal":default:return"normal"}}},na=function(u,e){return(u&e)!==0},cU={name:"content",initialValue:"none",type:1,prefix:!1,parse:function(u,e){if(e.length===0)return[];var t=e[0];return t.type===20&&t.value==="none"?[]:e}},hU={name:"counter-increment",initialValue:"none",prefix:!0,type:1,parse:function(u,e){if(e.length===0)return null;var t=e[0];if(t.type===20&&t.value==="none")return null;for(var r=[],c=e.filter(jS),p=0;p1?1:0],this.overflowWrap=Nn(e,zP,t.overflowWrap),this.paddingTop=Nn(e,kP,t.paddingTop),this.paddingRight=Nn(e,OP,t.paddingRight),this.paddingBottom=Nn(e,NP,t.paddingBottom),this.paddingLeft=Nn(e,QP,t.paddingLeft),this.paintOrder=Nn(e,fU,t.paintOrder),this.position=Nn(e,HP,t.position),this.textAlign=Nn(e,VP,t.textAlign),this.textDecorationColor=Nn(e,iU,(r=t.textDecorationColor)!==null&&r!==void 0?r:t.color),this.textDecorationLine=Nn(e,nU,(c=t.textDecorationLine)!==null&&c!==void 0?c:t.textDecoration),this.textShadow=Nn(e,GP,t.textShadow),this.textTransform=Nn(e,WP,t.textTransform),this.transform=Nn(e,jP,t.transform),this.transformOrigin=Nn(e,qP,t.transformOrigin),this.visibility=Nn(e,YP,t.visibility),this.webkitTextStrokeColor=Nn(e,mU,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=Nn(e,gU,t.webkitTextStrokeWidth),this.wordBreak=Nn(e,JP,t.wordBreak),this.zIndex=Nn(e,eU,t.zIndex)}return u.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&this.visibility===0},u.prototype.isTransparent=function(){return Jd(this.backgroundColor)},u.prototype.isTransformed=function(){return this.transform!==null},u.prototype.isPositioned=function(){return this.position!==0},u.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},u.prototype.isFloating=function(){return this.float!==0},u.prototype.isInlineLevel=function(){return na(this.display,4)||na(this.display,33554432)||na(this.display,268435456)||na(this.display,536870912)||na(this.display,67108864)||na(this.display,134217728)},u}(),yU=function(){function u(e,t){this.content=Nn(e,cU,t.content),this.quotes=Nn(e,dU,t.quotes)}return u}(),lE=function(){function u(e,t){this.counterIncrement=Nn(e,hU,t.counterIncrement),this.counterReset=Nn(e,uU,t.counterReset)}return u}(),Nn=function(u,e,t){var r=new GS,c=t!==null&&typeof t<"u"?t.toString():e.initialValue;r.write(c);var p=new WS(r.read());switch(e.type){case 2:var y=p.parseComponentValue();return e.parse(u,Ss(y)?y.value:e.initialValue);case 0:return e.parse(u,p.parseComponentValue());case 1:return e.parse(u,p.parseComponentValues());case 4:return p.parseComponentValue();case 3:switch(e.format){case"angle":return Mv.parse(u,p.parseComponentValue());case"color":return Yd.parse(u,p.parseComponentValue());case"image":return E2.parse(u,p.parseComponentValue());case"length":var i=p.parseComponentValue();return np(i)?i:ka;case"length-percentage":var C=p.parseComponentValue();return zo(C)?C:ka;case"time":return cM.parse(u,p.parseComponentValue())}break}},xU="data-html2canvas-debug",vU=function(u){var e=u.getAttribute(xU);switch(e){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},bb=function(u,e){var t=vU(u);return t===1||e===t},Zu=function(){function u(e,t){if(this.context=e,this.textNodes=[],this.elements=[],this.flags=0,bb(t,3))debugger;this.styles=new _U(e,window.getComputedStyle(t,null)),Eb(t)&&(this.styles.animationDuration.some(function(r){return r>0})&&(t.style.animationDuration="0s"),this.styles.transform!==null&&(t.style.transform="none")),this.bounds=Tv(this.context,t),bb(t,4)&&(this.flags|=16)}return u}(),wU="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",cE="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",__=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var G0=0;G0>4,R[c++]=(y&15)<<4|i>>2,R[c++]=(i&3)<<6|C&63;return D},BU=function(u){for(var e=u.length,t=[],r=0;r>cf,TU=1<>cf,MU=hM+SU,IU=MU,FU=32,LU=IU+FU,DU=65536>>T2,PU=1<=0){if(e<55296||e>56319&&e<=65535)return t=this.index[e>>cf],t=(t<>cf)],t=(t<>T2),t=this.index[t],t+=e>>cf&UU,t=this.index[t],t=(t<"u"?[]:new Uint8Array(256);for(var W0=0;W0=55296&&c<=56319&&t>10)+55296,y%1024+56320)),(c+1===t||r.length>16384)&&(p+=String.fromCharCode.apply(String,r),r.length=0)}return p},GU=zU(wU),yh="\xD7",dw="\xF7",WU=function(u){return GU.get(u)},jU=function(u,e,t){var r=t-2,c=e[r],p=e[t-1],y=e[t];if(p===lw&&y===cw)return yh;if(p===lw||p===cw||p===AE||y===lw||y===cw||y===AE)return dw;if(p===pE&&[pE,hw,fE,mE].indexOf(y)!==-1||(p===fE||p===hw)&&(y===hw||y===uw)||(p===mE||p===uw)&&y===uw||y===gE||y===dE||y===QU||p===NU)return yh;if(p===gE&&y===_E){for(;c===dE;)c=e[--r];if(c===_E)return yh}if(p===Aw&&y===Aw){for(var i=0;c===Aw;)i++,c=e[--r];if(i%2===0)return yh}return dw},KU=function(u){var e=VU(u),t=e.length,r=0,c=0,p=e.map(WU);return{next:function(){if(r>=t)return{done:!0,value:null};for(var y=yh;ry.x||R.y>y.y;return y=R,D===0?!0:Q});return u.body.removeChild(e),i},qU=function(){return typeof new Image().crossOrigin<"u"},YU=function(){return typeof new XMLHttpRequest().responseType=="string"},JU=function(u){var e=new Image,t=u.createElement("canvas"),r=t.getContext("2d");if(!r)return!1;e.src="data:image/svg+xml,";try{r.drawImage(e,0,0),t.toDataURL()}catch{return!1}return!0},yE=function(u){return u[0]===0&&u[1]===255&&u[2]===0&&u[3]===255},e4=function(u){var e=u.createElement("canvas"),t=100;e.width=t,e.height=t;var r=e.getContext("2d");if(!r)return Promise.reject(!1);r.fillStyle="rgb(0, 255, 0)",r.fillRect(0,0,t,t);var c=new Image,p=e.toDataURL();c.src=p;var y=Bb(t,t,0,0,c);return r.fillStyle="red",r.fillRect(0,0,t,t),xE(y).then(function(i){r.drawImage(i,0,0);var C=r.getImageData(0,0,t,t).data;r.fillStyle="red",r.fillRect(0,0,t,t);var D=u.createElement("div");return D.style.backgroundImage="url("+p+")",D.style.height=t+"px",yE(C)?xE(Bb(t,t,0,0,D)):Promise.reject(!1)}).then(function(i){return r.drawImage(i,0,0),yE(r.getImageData(0,0,t,t).data)}).catch(function(){return!1})},Bb=function(u,e,t,r,c){var p="http://www.w3.org/2000/svg",y=document.createElementNS(p,"svg"),i=document.createElementNS(p,"foreignObject");return y.setAttributeNS(null,"width",u.toString()),y.setAttributeNS(null,"height",e.toString()),i.setAttributeNS(null,"width","100%"),i.setAttributeNS(null,"height","100%"),i.setAttributeNS(null,"x",t.toString()),i.setAttributeNS(null,"y",r.toString()),i.setAttributeNS(null,"externalResourcesRequired","true"),y.appendChild(i),i.appendChild(c),y},xE=function(u){return new Promise(function(e,t){var r=new Image;r.onload=function(){return e(r)},r.onerror=t,r.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(new XMLSerializer().serializeToString(u))})},Ra={get SUPPORT_RANGE_BOUNDS(){var u=ZU(document);return Object.defineProperty(Ra,"SUPPORT_RANGE_BOUNDS",{value:u}),u},get SUPPORT_WORD_BREAKING(){var u=Ra.SUPPORT_RANGE_BOUNDS&&XU(document);return Object.defineProperty(Ra,"SUPPORT_WORD_BREAKING",{value:u}),u},get SUPPORT_SVG_DRAWING(){var u=JU(document);return Object.defineProperty(Ra,"SUPPORT_SVG_DRAWING",{value:u}),u},get SUPPORT_FOREIGNOBJECT_DRAWING(){var u=typeof Array.from=="function"&&typeof window.fetch=="function"?e4(document):Promise.resolve(!1);return Object.defineProperty(Ra,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:u}),u},get SUPPORT_CORS_IMAGES(){var u=qU();return Object.defineProperty(Ra,"SUPPORT_CORS_IMAGES",{value:u}),u},get SUPPORT_RESPONSE_TYPE(){var u=YU();return Object.defineProperty(Ra,"SUPPORT_RESPONSE_TYPE",{value:u}),u},get SUPPORT_CORS_XHR(){var u="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Ra,"SUPPORT_CORS_XHR",{value:u}),u},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var u=!!(typeof Intl<"u"&&Intl.Segmenter);return Object.defineProperty(Ra,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:u}),u}},C_=function(){function u(e,t){this.text=e,this.bounds=t}return u}(),t4=function(u,e,t,r){var c=r4(e,t),p=[],y=0;return c.forEach(function(i){if(t.textDecorationLine.length||i.trim().length>0)if(Ra.SUPPORT_RANGE_BOUNDS){var C=vE(r,y,i.length).getClientRects();if(C.length>1){var D=S2(i),R=0;D.forEach(function(z){p.push(new C_(z,$A.fromDOMRectList(u,vE(r,R+y,z.length).getClientRects()))),R+=z.length})}else p.push(new C_(i,$A.fromDOMRectList(u,C)))}else{var Q=r.splitText(i.length);p.push(new C_(i,i4(u,r))),r=Q}else Ra.SUPPORT_RANGE_BOUNDS||(r=r.splitText(i.length));y+=i.length}),p},i4=function(u,e){var t=e.ownerDocument;if(t){var r=t.createElement("html2canvaswrapper");r.appendChild(e.cloneNode(!0));var c=e.parentNode;if(c){c.replaceChild(r,e);var p=Tv(u,r);return r.firstChild&&c.replaceChild(r.firstChild,r),p}}return $A.EMPTY},vE=function(u,e,t){var r=u.ownerDocument;if(!r)throw new Error("Node has no owner document");var c=r.createRange();return c.setStart(u,e),c.setEnd(u,e+t),c},S2=function(u){if(Ra.SUPPORT_NATIVE_TEXT_SEGMENTATION){var e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(u)).map(function(t){return t.segment})}return $U(u)},n4=function(u,e){if(Ra.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(t.segment(u)).map(function(r){return r.segment})}return o4(u,e)},r4=function(u,e){return e.letterSpacing!==0?S2(u):n4(u,e)},s4=[32,160,4961,65792,65793,4153,4241],o4=function(u,e){for(var t=DL(u,{lineBreak:e.lineBreak,wordBreak:e.overflowWrap==="break-word"?"break-word":e.wordBreak}),r=[],c,p=function(){if(c.value){var y=c.value.slice(),i=Sv(y),C="";i.forEach(function(D){s4.indexOf(D)===-1?C+=Bo(D):(C.length&&r.push(C),r.push(Bo(D)),C="")}),C.length&&r.push(C)}};!(c=t.next()).done;)p();return r},a4=function(){function u(e,t,r){this.text=l4(t.data,r.textTransform),this.textBounds=t4(e,this.text,r,t)}return u}(),l4=function(u,e){switch(e){case 1:return u.toLowerCase();case 3:return u.replace(c4,h4);case 2:return u.toUpperCase();default:return u}},c4=/(^|\s|:|-|\(|\))([a-z])/g,h4=function(u,e,t){return u.length>0?e+t.toUpperCase():u},uM=function(u){Au(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c.src=r.currentSrc||r.src,c.intrinsicWidth=r.naturalWidth,c.intrinsicHeight=r.naturalHeight,c.context.cache.addImage(c.src),c}return e}(Zu),AM=function(u){Au(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c.canvas=r,c.intrinsicWidth=r.width,c.intrinsicHeight=r.height,c}return e}(Zu),dM=function(u){Au(e,u);function e(t,r){var c=u.call(this,t,r)||this,p=new XMLSerializer,y=Tv(t,r);return r.setAttribute("width",y.width+"px"),r.setAttribute("height",y.height+"px"),c.svg="data:image/svg+xml,"+encodeURIComponent(p.serializeToString(r)),c.intrinsicWidth=r.width.baseVal.value,c.intrinsicHeight=r.height.baseVal.value,c.context.cache.addImage(c.svg),c}return e}(Zu),pM=function(u){Au(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c.value=r.value,c}return e}(Zu),Cb=function(u){Au(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c.start=r.start,c.reversed=typeof r.reversed=="boolean"&&r.reversed===!0,c}return e}(Zu),u4=[{type:15,flags:0,unit:"px",number:3}],A4=[{type:16,flags:0,number:50}],d4=function(u){return u.width>u.height?new $A(u.left+(u.width-u.height)/2,u.top,u.height,u.height):u.width0)t.textNodes.push(new a4(u,c,t.styles));else if(Fm(c))if(BM(c)&&c.assignedNodes)c.assignedNodes().forEach(function(i){return Vx(u,i,t,r)});else{var y=_M(u,c);y.styles.isVisible()&&(g4(c,y,r)?y.flags|=4:_4(y.styles)&&(y.flags|=2),m4.indexOf(c.tagName)!==-1&&(y.flags|=8),t.elements.push(y),c.slot,c.shadowRoot?Vx(u,c.shadowRoot,y,r):!sv(c)&&!vM(c)&&!ov(c)&&Vx(u,c,y,r))}},_M=function(u,e){return Tb(e)?new uM(u,e):wM(e)?new AM(u,e):vM(e)?new dM(u,e):y4(e)?new pM(u,e):x4(e)?new Cb(u,e):v4(e)?new M2(u,e):ov(e)?new fM(u,e):sv(e)?new mM(u,e):bM(e)?new gM(u,e):new Zu(u,e)},yM=function(u,e){var t=_M(u,e);return t.flags|=4,Vx(u,e,t,t),t},g4=function(u,e,t){return e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||I2(u)&&t.styles.isTransparent()},_4=function(u){return u.isPositioned()||u.isFloating()},xM=function(u){return u.nodeType===Node.TEXT_NODE},Fm=function(u){return u.nodeType===Node.ELEMENT_NODE},Eb=function(u){return Fm(u)&&typeof u.style<"u"&&!Hx(u)},Hx=function(u){return typeof u.className=="object"},y4=function(u){return u.tagName==="LI"},x4=function(u){return u.tagName==="OL"},v4=function(u){return u.tagName==="INPUT"},w4=function(u){return u.tagName==="HTML"},vM=function(u){return u.tagName==="svg"},I2=function(u){return u.tagName==="BODY"},wM=function(u){return u.tagName==="CANVAS"},bE=function(u){return u.tagName==="VIDEO"},Tb=function(u){return u.tagName==="IMG"},bM=function(u){return u.tagName==="IFRAME"},BE=function(u){return u.tagName==="STYLE"},b4=function(u){return u.tagName==="SCRIPT"},sv=function(u){return u.tagName==="TEXTAREA"},ov=function(u){return u.tagName==="SELECT"},BM=function(u){return u.tagName==="SLOT"},CE=function(u){return u.tagName.indexOf("-")>0},B4=function(){function u(){this.counters={}}return u.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},u.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},u.prototype.pop=function(e){var t=this;e.forEach(function(r){return t.counters[r].pop()})},u.prototype.parse=function(e){var t=this,r=e.counterIncrement,c=e.counterReset,p=!0;r!==null&&r.forEach(function(i){var C=t.counters[i.counter];C&&i.increment!==0&&(p=!1,C.length||C.push(1),C[Math.max(0,C.length-1)]+=i.increment)});var y=[];return p&&c.forEach(function(i){var C=t.counters[i.counter];y.push(i.counter),C||(C=t.counters[i.counter]=[]),C.push(i.reset)}),y},u}(),EE={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},TE={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u0554","\u0553","\u0552","\u0551","\u0550","\u054F","\u054E","\u054D","\u054C","\u054B","\u054A","\u0549","\u0548","\u0547","\u0546","\u0545","\u0544","\u0543","\u0542","\u0541","\u0540","\u053F","\u053E","\u053D","\u053C","\u053B","\u053A","\u0539","\u0538","\u0537","\u0536","\u0535","\u0534","\u0533","\u0532","\u0531"]},C4={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["\u05D9\u05F3","\u05D8\u05F3","\u05D7\u05F3","\u05D6\u05F3","\u05D5\u05F3","\u05D4\u05F3","\u05D3\u05F3","\u05D2\u05F3","\u05D1\u05F3","\u05D0\u05F3","\u05EA","\u05E9","\u05E8","\u05E7","\u05E6","\u05E4","\u05E2","\u05E1","\u05E0","\u05DE","\u05DC","\u05DB","\u05D9\u05D8","\u05D9\u05D7","\u05D9\u05D6","\u05D8\u05D6","\u05D8\u05D5","\u05D9","\u05D8","\u05D7","\u05D6","\u05D5","\u05D4","\u05D3","\u05D2","\u05D1","\u05D0"]},E4={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["\u10F5","\u10F0","\u10EF","\u10F4","\u10EE","\u10ED","\u10EC","\u10EB","\u10EA","\u10E9","\u10E8","\u10E7","\u10E6","\u10E5","\u10E4","\u10F3","\u10E2","\u10E1","\u10E0","\u10DF","\u10DE","\u10DD","\u10F2","\u10DC","\u10DB","\u10DA","\u10D9","\u10D8","\u10D7","\u10F1","\u10D6","\u10D5","\u10D4","\u10D3","\u10D2","\u10D1","\u10D0"]},sm=function(u,e,t,r,c,p){return ut?z_(u,c,p.length>0):r.integers.reduce(function(y,i,C){for(;u>=i;)u-=i,y+=r.values[C];return y},"")+p},CM=function(u,e,t,r){var c="";do t||u--,c=r(u)+c,u/=e;while(u*e>=e);return c},wo=function(u,e,t,r,c){var p=t-e+1;return(u<0?"-":"")+(CM(Math.abs(u),p,r,function(y){return Bo(Math.floor(y%p)+e)})+c)},zp=function(u,e,t){t===void 0&&(t=". ");var r=e.length;return CM(Math.abs(u),r,!1,function(c){return e[Math.floor(c%r)]})+t},Sm=1<<0,Hd=1<<1,Gd=1<<2,y_=1<<3,UA=function(u,e,t,r,c,p){if(u<-9999||u>9999)return z_(u,4,c.length>0);var y=Math.abs(u),i=c;if(y===0)return e[0]+i;for(var C=0;y>0&&C<=4;C++){var D=y%10;D===0&&na(p,Sm)&&i!==""?i=e[D]+i:D>1||D===1&&C===0||D===1&&C===1&&na(p,Hd)||D===1&&C===1&&na(p,Gd)&&u>100||D===1&&C>1&&na(p,y_)?i=e[D]+(C>0?t[C-1]:"")+i:D===1&&C>0&&(i=t[C-1]+i),y=Math.floor(y/10)}return(u<0?r:"")+i},SE="\u5341\u767E\u5343\u842C",ME="\u62FE\u4F70\u4EDF\u842C",IE="\u30DE\u30A4\u30CA\u30B9",pw="\uB9C8\uC774\uB108\uC2A4",z_=function(u,e,t){var r=t?". ":"",c=t?"\u3001":"",p=t?", ":"",y=t?" ":"";switch(e){case 0:return"\u2022"+y;case 1:return"\u25E6"+y;case 2:return"\u25FE"+y;case 5:var i=wo(u,48,57,!0,r);return i.length<4?"0"+i:i;case 4:return zp(u,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",c);case 6:return sm(u,1,3999,EE,3,r).toLowerCase();case 7:return sm(u,1,3999,EE,3,r);case 8:return wo(u,945,969,!1,r);case 9:return wo(u,97,122,!1,r);case 10:return wo(u,65,90,!1,r);case 11:return wo(u,1632,1641,!0,r);case 12:case 49:return sm(u,1,9999,TE,3,r);case 35:return sm(u,1,9999,TE,3,r).toLowerCase();case 13:return wo(u,2534,2543,!0,r);case 14:case 30:return wo(u,6112,6121,!0,r);case 15:return zp(u,"\u5B50\u4E11\u5BC5\u536F\u8FB0\u5DF3\u5348\u672A\u7533\u9149\u620C\u4EA5",c);case 16:return zp(u,"\u7532\u4E59\u4E19\u4E01\u620A\u5DF1\u5E9A\u8F9B\u58EC\u7678",c);case 17:case 48:return UA(u,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",SE,"\u8CA0",c,Hd|Gd|y_);case 47:return UA(u,"\u96F6\u58F9\u8CB3\u53C3\u8086\u4F0D\u9678\u67D2\u634C\u7396",ME,"\u8CA0",c,Sm|Hd|Gd|y_);case 42:return UA(u,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",SE,"\u8D1F",c,Hd|Gd|y_);case 41:return UA(u,"\u96F6\u58F9\u8D30\u53C1\u8086\u4F0D\u9646\u67D2\u634C\u7396",ME,"\u8D1F",c,Sm|Hd|Gd|y_);case 26:return UA(u,"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u4E07",IE,c,0);case 25:return UA(u,"\u96F6\u58F1\u5F10\u53C2\u56DB\u4F0D\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343\u4E07",IE,c,Sm|Hd|Gd);case 31:return UA(u,"\uC601\uC77C\uC774\uC0BC\uC0AC\uC624\uC721\uCE60\uD314\uAD6C","\uC2ED\uBC31\uCC9C\uB9CC",pw,p,Sm|Hd|Gd);case 33:return UA(u,"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u5341\u767E\u5343\u842C",pw,p,0);case 32:return UA(u,"\u96F6\u58F9\u8CB3\u53C3\u56DB\u4E94\u516D\u4E03\u516B\u4E5D","\u62FE\u767E\u5343",pw,p,Sm|Hd|Gd);case 18:return wo(u,2406,2415,!0,r);case 20:return sm(u,1,19999,E4,3,r);case 21:return wo(u,2790,2799,!0,r);case 22:return wo(u,2662,2671,!0,r);case 22:return sm(u,1,10999,C4,3,r);case 23:return zp(u,"\u3042\u3044\u3046\u3048\u304A\u304B\u304D\u304F\u3051\u3053\u3055\u3057\u3059\u305B\u305D\u305F\u3061\u3064\u3066\u3068\u306A\u306B\u306C\u306D\u306E\u306F\u3072\u3075\u3078\u307B\u307E\u307F\u3080\u3081\u3082\u3084\u3086\u3088\u3089\u308A\u308B\u308C\u308D\u308F\u3090\u3091\u3092\u3093");case 24:return zp(u,"\u3044\u308D\u306F\u306B\u307B\u3078\u3068\u3061\u308A\u306C\u308B\u3092\u308F\u304B\u3088\u305F\u308C\u305D\u3064\u306D\u306A\u3089\u3080\u3046\u3090\u306E\u304A\u304F\u3084\u307E\u3051\u3075\u3053\u3048\u3066\u3042\u3055\u304D\u3086\u3081\u307F\u3057\u3091\u3072\u3082\u305B\u3059");case 27:return wo(u,3302,3311,!0,r);case 28:return zp(u,"\u30A2\u30A4\u30A6\u30A8\u30AA\u30AB\u30AD\u30AF\u30B1\u30B3\u30B5\u30B7\u30B9\u30BB\u30BD\u30BF\u30C1\u30C4\u30C6\u30C8\u30CA\u30CB\u30CC\u30CD\u30CE\u30CF\u30D2\u30D5\u30D8\u30DB\u30DE\u30DF\u30E0\u30E1\u30E2\u30E4\u30E6\u30E8\u30E9\u30EA\u30EB\u30EC\u30ED\u30EF\u30F0\u30F1\u30F2\u30F3",c);case 29:return zp(u,"\u30A4\u30ED\u30CF\u30CB\u30DB\u30D8\u30C8\u30C1\u30EA\u30CC\u30EB\u30F2\u30EF\u30AB\u30E8\u30BF\u30EC\u30BD\u30C4\u30CD\u30CA\u30E9\u30E0\u30A6\u30F0\u30CE\u30AA\u30AF\u30E4\u30DE\u30B1\u30D5\u30B3\u30A8\u30C6\u30A2\u30B5\u30AD\u30E6\u30E1\u30DF\u30B7\u30F1\u30D2\u30E2\u30BB\u30B9",c);case 34:return wo(u,3792,3801,!0,r);case 37:return wo(u,6160,6169,!0,r);case 38:return wo(u,4160,4169,!0,r);case 39:return wo(u,2918,2927,!0,r);case 40:return wo(u,1776,1785,!0,r);case 43:return wo(u,3046,3055,!0,r);case 44:return wo(u,3174,3183,!0,r);case 45:return wo(u,3664,3673,!0,r);case 46:return wo(u,3872,3881,!0,r);case 3:default:return wo(u,48,57,!0,r)}},EM="data-html2canvas-ignore",FE=function(){function u(e,t,r){if(this.context=e,this.options=r,this.scrolledElements=[],this.referenceElement=t,this.counters=new B4,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return u.prototype.toIFrame=function(e,t){var r=this,c=T4(e,t);if(!c.contentWindow)return Promise.reject("Unable to find iframe window");var p=e.defaultView.pageXOffset,y=e.defaultView.pageYOffset,i=c.contentWindow,C=i.document,D=I4(c).then(function(){return Il(r,void 0,void 0,function(){var R,Q;return tl(this,function(z){switch(z.label){case 0:return this.scrolledElements.forEach(P4),i&&(i.scrollTo(t.left,t.top),/(iPad|iPhone|iPod)/g.test(navigator.userAgent)&&(i.scrollY!==t.top||i.scrollX!==t.left)&&(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(i.scrollX-t.left,i.scrollY-t.top,0,0))),R=this.options.onclone,Q=this.clonedReferenceElement,typeof Q>"u"?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:C.fonts&&C.fonts.ready?[4,C.fonts.ready]:[3,2];case 1:z.sent(),z.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,M4(C)]:[3,4];case 3:z.sent(),z.label=4;case 4:return typeof R=="function"?[2,Promise.resolve().then(function(){return R(C,Q)}).then(function(){return c})]:[2,c]}})})});return C.open(),C.write(L4(document.doctype)+""),D4(this.referenceElement.ownerDocument,p,y),C.replaceChild(C.adoptNode(this.documentElement),C.documentElement),C.close(),D},u.prototype.createElementClone=function(e){if(bb(e,2))debugger;if(wM(e))return this.createCanvasClone(e);if(bE(e))return this.createVideoClone(e);if(BE(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return Tb(t)&&(Tb(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager")),CE(t)?this.createCustomElementClone(t):t},u.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return fw(e.style,t),t},u.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var r=[].slice.call(t.cssRules,0).reduce(function(p,y){return y&&typeof y.cssText=="string"?p+y.cssText:p},""),c=e.cloneNode(!1);return c.textContent=r,c}}catch(p){if(this.context.logger.error("Unable to access cssRules property",p),p.name!=="SecurityError")throw p}return e.cloneNode(!1)},u.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var r=e.ownerDocument.createElement("img");try{return r.src=e.toDataURL(),r}catch{this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var c=e.cloneNode(!1);try{c.width=e.width,c.height=e.height;var p=e.getContext("2d"),y=c.getContext("2d");if(y)if(!this.options.allowTaint&&p)y.putImageData(p.getImageData(0,0,e.width,e.height),0,0);else{var i=(t=e.getContext("webgl2"))!==null&&t!==void 0?t:e.getContext("webgl");if(i){var C=i.getContextAttributes();(C==null?void 0:C.preserveDrawingBuffer)===!1&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}y.drawImage(e,0,0)}return c}catch{this.context.logger.info("Unable to clone canvas as it is tainted",e)}return c},u.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var r=t.getContext("2d");try{return r&&(r.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||r.getImageData(0,0,t.width,t.height)),t}catch{this.context.logger.info("Unable to clone video as it is tainted",e)}var c=e.ownerDocument.createElement("canvas");return c.width=e.offsetWidth,c.height=e.offsetHeight,c},u.prototype.appendChildNode=function(e,t,r){(!Fm(t)||!b4(t)&&!t.hasAttribute(EM)&&(typeof this.options.ignoreElements!="function"||!this.options.ignoreElements(t)))&&(!this.options.copyStyles||!Fm(t)||!BE(t))&&e.appendChild(this.cloneNode(t,r))},u.prototype.cloneChildNodes=function(e,t,r){for(var c=this,p=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;p;p=p.nextSibling)if(Fm(p)&&BM(p)&&typeof p.assignedNodes=="function"){var y=p.assignedNodes();y.length&&y.forEach(function(i){return c.appendChildNode(t,i,r)})}else this.appendChildNode(t,p,r)},u.prototype.cloneNode=function(e,t){if(xM(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var r=e.ownerDocument.defaultView;if(r&&Fm(e)&&(Eb(e)||Hx(e))){var c=this.createElementClone(e);c.style.transitionProperty="none";var p=r.getComputedStyle(e),y=r.getComputedStyle(e,":before"),i=r.getComputedStyle(e,":after");this.referenceElement===e&&Eb(c)&&(this.clonedReferenceElement=c),I2(c)&&z4(c);var C=this.counters.parse(new lE(this.context,p)),D=this.resolvePseudoContent(e,c,y,E_.BEFORE);CE(e)&&(t=!0),bE(e)||this.cloneChildNodes(e,c,t),D&&c.insertBefore(D,c.firstChild);var R=this.resolvePseudoContent(e,c,i,E_.AFTER);return R&&c.appendChild(R),this.counters.pop(C),(p&&(this.options.copyStyles||Hx(e))&&!bM(e)||t)&&fw(p,c),(e.scrollTop!==0||e.scrollLeft!==0)&&this.scrolledElements.push([c,e.scrollLeft,e.scrollTop]),(sv(e)||ov(e))&&(sv(c)||ov(c))&&(c.value=e.value),c}return e.cloneNode(!1)},u.prototype.resolvePseudoContent=function(e,t,r,c){var p=this;if(!!r){var y=r.content,i=t.ownerDocument;if(!(!i||!y||y==="none"||y==="-moz-alt-content"||r.display==="none")){this.counters.parse(new lE(this.context,r));var C=new yU(this.context,r),D=i.createElement("html2canvaspseudoelement");fw(r,D),C.content.forEach(function(Q){if(Q.type===0)D.appendChild(i.createTextNode(Q.value));else if(Q.type===22){var z=i.createElement("img");z.src=Q.value,z.style.opacity="1",D.appendChild(z)}else if(Q.type===18){if(Q.name==="attr"){var G=Q.values.filter(Ss);G.length&&D.appendChild(i.createTextNode(e.getAttribute(G[0].value)||""))}else if(Q.name==="counter"){var J=Q.values.filter(Hm),Y=J[0],B=J[1];if(Y&&Ss(Y)){var ae=p.counters.getCounterValue(Y.value),ce=B&&Ss(B)?wb.parse(p.context,B.value):3;D.appendChild(i.createTextNode(z_(ae,ce,!1)))}}else if(Q.name==="counters"){var Ae=Q.values.filter(Hm),Y=Ae[0],we=Ae[1],B=Ae[2];if(Y&&Ss(Y)){var me=p.counters.getCounterValues(Y.value),De=B&&Ss(B)?wb.parse(p.context,B.value):3,Je=we&&we.type===0?we.value:"",Fe=me.map(function(li){return z_(li,De,!1)}).join(Je);D.appendChild(i.createTextNode(Fe))}}}else if(Q.type===20)switch(Q.value){case"open-quote":D.appendChild(i.createTextNode(aE(C.quotes,p.quoteDepth++,!0)));break;case"close-quote":D.appendChild(i.createTextNode(aE(C.quotes,--p.quoteDepth,!1)));break;default:D.appendChild(i.createTextNode(Q.value))}}),D.className=Sb+" "+Mb;var R=c===E_.BEFORE?" "+Sb:" "+Mb;return Hx(t)?t.className.baseValue+=R:t.className+=R,D}}},u.destroy=function(e){return e.parentNode?(e.parentNode.removeChild(e),!0):!1},u}(),E_;(function(u){u[u.BEFORE=0]="BEFORE",u[u.AFTER=1]="AFTER"})(E_||(E_={}));var T4=function(u,e){var t=u.createElement("iframe");return t.className="html2canvas-container",t.style.visibility="hidden",t.style.position="fixed",t.style.left="-10000px",t.style.top="0px",t.style.border="0",t.width=e.width.toString(),t.height=e.height.toString(),t.scrolling="no",t.setAttribute(EM,"true"),u.body.appendChild(t),t},S4=function(u){return new Promise(function(e){if(u.complete){e();return}if(!u.src){e();return}u.onload=e,u.onerror=e})},M4=function(u){return Promise.all([].slice.call(u.images,0).map(S4))},I4=function(u){return new Promise(function(e,t){var r=u.contentWindow;if(!r)return t("No window assigned for iframe");var c=r.document;r.onload=u.onload=function(){r.onload=u.onload=null;var p=setInterval(function(){c.body.childNodes.length>0&&c.readyState==="complete"&&(clearInterval(p),e(u))},50)}})},F4=["all","d","content"],fw=function(u,e){for(var t=u.length-1;t>=0;t--){var r=u.item(t);F4.indexOf(r)===-1&&e.style.setProperty(r,u.getPropertyValue(r))}return e},L4=function(u){var e="";return u&&(e+=""),e},D4=function(u,e,t){u&&u.defaultView&&(e!==u.defaultView.pageXOffset||t!==u.defaultView.pageYOffset)&&u.defaultView.scrollTo(e,t)},P4=function(u){var e=u[0],t=u[1],r=u[2];e.scrollLeft=t,e.scrollTop=r},U4=":before",R4=":after",Sb="___html2canvas___pseudoelement_before",Mb="___html2canvas___pseudoelement_after",LE=`{ content: "" !important; display: none !important; }`,z4=function(u){k4(u,"."+Sb+U4+LE+` .`+Mb+R4+LE)},k4=function(u,e){var t=u.ownerDocument;if(t){var r=t.createElement("style");r.textContent=e,u.appendChild(r)}},TM=function(){function u(){}return u.getOrigin=function(e){var t=u._link;return t?(t.href=e,t.href=t.href,t.protocol+t.hostname+t.port):"about:blank"},u.isSameOrigin=function(e){return u.getOrigin(e)===u._origin},u.setContext=function(e){u._link=e.document.createElement("a"),u._origin=u.getOrigin(e.location.href)},u._origin="about:blank",u}(),O4=function(){function u(e,t){this.context=e,this._options=t,this._cache={}}return u.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)||(gw(e)||H4(e))&&(this._cache[e]=this.loadImage(e)).catch(function(){}),t},u.prototype.match=function(e){return this._cache[e]},u.prototype.loadImage=function(e){return Il(this,void 0,void 0,function(){var t,r,c,p,y=this;return tl(this,function(i){switch(i.label){case 0:return t=TM.isSameOrigin(e),r=!mw(e)&&this._options.useCORS===!0&&Ra.SUPPORT_CORS_IMAGES&&!t,c=!mw(e)&&!t&&!gw(e)&&typeof this._options.proxy=="string"&&Ra.SUPPORT_CORS_XHR&&!r,!t&&this._options.allowTaint===!1&&!mw(e)&&!gw(e)&&!c&&!r?[2]:(p=e,c?[4,this.proxy(p)]:[3,2]);case 1:p=i.sent(),i.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise(function(C,D){var R=new Image;R.onload=function(){return C(R)},R.onerror=D,(G4(p)||r)&&(R.crossOrigin="anonymous"),R.src=p,R.complete===!0&&setTimeout(function(){return C(R)},500),y._options.imageTimeout>0&&setTimeout(function(){return D("Timed out ("+y._options.imageTimeout+"ms) loading image")},y._options.imageTimeout)})];case 3:return[2,i.sent()]}})})},u.prototype.has=function(e){return typeof this._cache[e]<"u"},u.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},u.prototype.proxy=function(e){var t=this,r=this._options.proxy;if(!r)throw new Error("No proxy defined");var c=e.substring(0,256);return new Promise(function(p,y){var i=Ra.SUPPORT_RESPONSE_TYPE?"blob":"text",C=new XMLHttpRequest;C.onload=function(){if(C.status===200)if(i==="text")p(C.response);else{var Q=new FileReader;Q.addEventListener("load",function(){return p(Q.result)},!1),Q.addEventListener("error",function(z){return y(z)},!1),Q.readAsDataURL(C.response)}else y("Failed to proxy resource "+c+" with status code "+C.status)},C.onerror=y;var D=r.indexOf("?")>-1?"&":"?";if(C.open("GET",""+r+D+"url="+encodeURIComponent(e)+"&responseType="+i),i!=="text"&&C instanceof XMLHttpRequest&&(C.responseType=i),t._options.imageTimeout){var R=t._options.imageTimeout;C.timeout=R,C.ontimeout=function(){return y("Timed out ("+R+"ms) proxying "+c)}}C.send()})},u}(),N4=/^data:image\/svg\+xml/i,Q4=/^data:image\/.*;base64,/i,V4=/^data:image\/.*/i,H4=function(u){return Ra.SUPPORT_SVG_DRAWING||!W4(u)},mw=function(u){return V4.test(u)},G4=function(u){return Q4.test(u)},gw=function(u){return u.substr(0,4)==="blob"},W4=function(u){return u.substr(-3).toLowerCase()==="svg"||N4.test(u)},Rn=function(){function u(e,t){this.type=0,this.x=e,this.y=t}return u.prototype.add=function(e,t){return new u(this.x+e,this.y+t)},u}(),om=function(u,e,t){return new Rn(u.x+(e.x-u.x)*t,u.y+(e.y-u.y)*t)},j0=function(){function u(e,t,r,c){this.type=1,this.start=e,this.startControl=t,this.endControl=r,this.end=c}return u.prototype.subdivide=function(e,t){var r=om(this.start,this.startControl,e),c=om(this.startControl,this.endControl,e),p=om(this.endControl,this.end,e),y=om(r,c,e),i=om(c,p,e),C=om(y,i,e);return t?new u(this.start,r,y,C):new u(C,i,p,this.end)},u.prototype.add=function(e,t){return new u(this.start.add(e,t),this.startControl.add(e,t),this.endControl.add(e,t),this.end.add(e,t))},u.prototype.reverse=function(){return new u(this.end,this.endControl,this.startControl,this.start)},u}(),vh=function(u){return u.type===1},j4=function(){function u(e){var t=e.styles,r=e.bounds,c=g_(t.borderTopLeftRadius,r.width,r.height),p=c[0],y=c[1],i=g_(t.borderTopRightRadius,r.width,r.height),C=i[0],D=i[1],R=g_(t.borderBottomRightRadius,r.width,r.height),Q=R[0],z=R[1],G=g_(t.borderBottomLeftRadius,r.width,r.height),J=G[0],Y=G[1],B=[];B.push((p+C)/r.width),B.push((J+Q)/r.width),B.push((y+Y)/r.height),B.push((D+z)/r.height);var ae=Math.max.apply(Math,B);ae>1&&(p/=ae,y/=ae,C/=ae,D/=ae,Q/=ae,z/=ae,J/=ae,Y/=ae);var ce=r.width-C,Ae=r.height-z,we=r.width-Q,me=r.height-Y,De=t.borderTopWidth,Je=t.borderRightWidth,Fe=t.borderBottomWidth,Ge=t.borderLeftWidth,Et=Gs(t.paddingTop,e.bounds.width),li=Gs(t.paddingRight,e.bounds.width),xi=Gs(t.paddingBottom,e.bounds.width),te=Gs(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=p>0||y>0?ro(r.left+Ge/3,r.top+De/3,p-Ge/3,y-De/3,ys.TOP_LEFT):new Rn(r.left+Ge/3,r.top+De/3),this.topRightBorderDoubleOuterBox=p>0||y>0?ro(r.left+ce,r.top+De/3,C-Je/3,D-De/3,ys.TOP_RIGHT):new Rn(r.left+r.width-Je/3,r.top+De/3),this.bottomRightBorderDoubleOuterBox=Q>0||z>0?ro(r.left+we,r.top+Ae,Q-Je/3,z-Fe/3,ys.BOTTOM_RIGHT):new Rn(r.left+r.width-Je/3,r.top+r.height-Fe/3),this.bottomLeftBorderDoubleOuterBox=J>0||Y>0?ro(r.left+Ge/3,r.top+me,J-Ge/3,Y-Fe/3,ys.BOTTOM_LEFT):new Rn(r.left+Ge/3,r.top+r.height-Fe/3),this.topLeftBorderDoubleInnerBox=p>0||y>0?ro(r.left+Ge*2/3,r.top+De*2/3,p-Ge*2/3,y-De*2/3,ys.TOP_LEFT):new Rn(r.left+Ge*2/3,r.top+De*2/3),this.topRightBorderDoubleInnerBox=p>0||y>0?ro(r.left+ce,r.top+De*2/3,C-Je*2/3,D-De*2/3,ys.TOP_RIGHT):new Rn(r.left+r.width-Je*2/3,r.top+De*2/3),this.bottomRightBorderDoubleInnerBox=Q>0||z>0?ro(r.left+we,r.top+Ae,Q-Je*2/3,z-Fe*2/3,ys.BOTTOM_RIGHT):new Rn(r.left+r.width-Je*2/3,r.top+r.height-Fe*2/3),this.bottomLeftBorderDoubleInnerBox=J>0||Y>0?ro(r.left+Ge*2/3,r.top+me,J-Ge*2/3,Y-Fe*2/3,ys.BOTTOM_LEFT):new Rn(r.left+Ge*2/3,r.top+r.height-Fe*2/3),this.topLeftBorderStroke=p>0||y>0?ro(r.left+Ge/2,r.top+De/2,p-Ge/2,y-De/2,ys.TOP_LEFT):new Rn(r.left+Ge/2,r.top+De/2),this.topRightBorderStroke=p>0||y>0?ro(r.left+ce,r.top+De/2,C-Je/2,D-De/2,ys.TOP_RIGHT):new Rn(r.left+r.width-Je/2,r.top+De/2),this.bottomRightBorderStroke=Q>0||z>0?ro(r.left+we,r.top+Ae,Q-Je/2,z-Fe/2,ys.BOTTOM_RIGHT):new Rn(r.left+r.width-Je/2,r.top+r.height-Fe/2),this.bottomLeftBorderStroke=J>0||Y>0?ro(r.left+Ge/2,r.top+me,J-Ge/2,Y-Fe/2,ys.BOTTOM_LEFT):new Rn(r.left+Ge/2,r.top+r.height-Fe/2),this.topLeftBorderBox=p>0||y>0?ro(r.left,r.top,p,y,ys.TOP_LEFT):new Rn(r.left,r.top),this.topRightBorderBox=C>0||D>0?ro(r.left+ce,r.top,C,D,ys.TOP_RIGHT):new Rn(r.left+r.width,r.top),this.bottomRightBorderBox=Q>0||z>0?ro(r.left+we,r.top+Ae,Q,z,ys.BOTTOM_RIGHT):new Rn(r.left+r.width,r.top+r.height),this.bottomLeftBorderBox=J>0||Y>0?ro(r.left,r.top+me,J,Y,ys.BOTTOM_LEFT):new Rn(r.left,r.top+r.height),this.topLeftPaddingBox=p>0||y>0?ro(r.left+Ge,r.top+De,Math.max(0,p-Ge),Math.max(0,y-De),ys.TOP_LEFT):new Rn(r.left+Ge,r.top+De),this.topRightPaddingBox=C>0||D>0?ro(r.left+Math.min(ce,r.width-Je),r.top+De,ce>r.width+Je?0:Math.max(0,C-Je),Math.max(0,D-De),ys.TOP_RIGHT):new Rn(r.left+r.width-Je,r.top+De),this.bottomRightPaddingBox=Q>0||z>0?ro(r.left+Math.min(we,r.width-Ge),r.top+Math.min(Ae,r.height-Fe),Math.max(0,Q-Je),Math.max(0,z-Fe),ys.BOTTOM_RIGHT):new Rn(r.left+r.width-Je,r.top+r.height-Fe),this.bottomLeftPaddingBox=J>0||Y>0?ro(r.left+Ge,r.top+Math.min(me,r.height-Fe),Math.max(0,J-Ge),Math.max(0,Y-Fe),ys.BOTTOM_LEFT):new Rn(r.left+Ge,r.top+r.height-Fe),this.topLeftContentBox=p>0||y>0?ro(r.left+Ge+te,r.top+De+Et,Math.max(0,p-(Ge+te)),Math.max(0,y-(De+Et)),ys.TOP_LEFT):new Rn(r.left+Ge+te,r.top+De+Et),this.topRightContentBox=C>0||D>0?ro(r.left+Math.min(ce,r.width+Ge+te),r.top+De+Et,ce>r.width+Ge+te?0:C-Ge+te,D-(De+Et),ys.TOP_RIGHT):new Rn(r.left+r.width-(Je+li),r.top+De+Et),this.bottomRightContentBox=Q>0||z>0?ro(r.left+Math.min(we,r.width-(Ge+te)),r.top+Math.min(Ae,r.height+De+Et),Math.max(0,Q-(Je+li)),z-(Fe+xi),ys.BOTTOM_RIGHT):new Rn(r.left+r.width-(Je+li),r.top+r.height-(Fe+xi)),this.bottomLeftContentBox=J>0||Y>0?ro(r.left+Ge+te,r.top+me,Math.max(0,J-(Ge+te)),Y-(Fe+xi),ys.BOTTOM_LEFT):new Rn(r.left+Ge+te,r.top+r.height-(Fe+xi))}return u}(),ys;(function(u){u[u.TOP_LEFT=0]="TOP_LEFT",u[u.TOP_RIGHT=1]="TOP_RIGHT",u[u.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",u[u.BOTTOM_LEFT=3]="BOTTOM_LEFT"})(ys||(ys={}));var ro=function(u,e,t,r,c){var p=4*((Math.sqrt(2)-1)/3),y=t*p,i=r*p,C=u+t,D=e+r;switch(c){case ys.TOP_LEFT:return new j0(new Rn(u,D),new Rn(u,D-i),new Rn(C-y,e),new Rn(C,e));case ys.TOP_RIGHT:return new j0(new Rn(u,e),new Rn(u+y,e),new Rn(C,D-i),new Rn(C,D));case ys.BOTTOM_RIGHT:return new j0(new Rn(C,e),new Rn(C,e+i),new Rn(u+y,D),new Rn(u,D));case ys.BOTTOM_LEFT:default:return new j0(new Rn(C,D),new Rn(C-y,D),new Rn(u,e+i),new Rn(u,e))}},av=function(u){return[u.topLeftBorderBox,u.topRightBorderBox,u.bottomRightBorderBox,u.bottomLeftBorderBox]},K4=function(u){return[u.topLeftContentBox,u.topRightContentBox,u.bottomRightContentBox,u.bottomLeftContentBox]},lv=function(u){return[u.topLeftPaddingBox,u.topRightPaddingBox,u.bottomRightPaddingBox,u.bottomLeftPaddingBox]},$4=function(){function u(e,t,r){this.offsetX=e,this.offsetY=t,this.matrix=r,this.type=0,this.target=6}return u}(),K0=function(){function u(e,t){this.path=e,this.target=t,this.type=1}return u}(),Z4=function(){function u(e){this.opacity=e,this.type=2,this.target=6}return u}(),X4=function(u){return u.type===0},SM=function(u){return u.type===1},q4=function(u){return u.type===2},DE=function(u,e){return u.length===e.length?u.some(function(t,r){return t===e[r]}):!1},Y4=function(u,e,t,r,c){return u.map(function(p,y){switch(y){case 0:return p.add(e,t);case 1:return p.add(e+r,t);case 2:return p.add(e+r,t+c);case 3:return p.add(e,t+c)}return p})},MM=function(){function u(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return u}(),IM=function(){function u(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new j4(this.container),this.container.styles.opacity<1&&this.effects.push(new Z4(this.container.styles.opacity)),this.container.styles.transform!==null){var r=this.container.bounds.left+this.container.styles.transformOrigin[0].number,c=this.container.bounds.top+this.container.styles.transformOrigin[1].number,p=this.container.styles.transform;this.effects.push(new $4(r,c,p))}if(this.container.styles.overflowX!==0){var y=av(this.curves),i=lv(this.curves);DE(y,i)?this.effects.push(new K0(y,6)):(this.effects.push(new K0(y,2)),this.effects.push(new K0(i,4)))}}return u.prototype.getEffects=function(e){for(var t=[2,3].indexOf(this.container.styles.position)===-1,r=this.parent,c=this.effects.slice(0);r;){var p=r.effects.filter(function(C){return!SM(C)});if(t||r.container.styles.position!==0||!r.parent){if(c.unshift.apply(c,p),t=[2,3].indexOf(r.container.styles.position)===-1,r.container.styles.overflowX!==0){var y=av(r.curves),i=lv(r.curves);DE(y,i)||c.unshift(new K0(i,6))}}else c.unshift.apply(c,p);r=r.parent}return c.filter(function(C){return na(C.target,e)})},u}(),Ib=function(u,e,t,r){u.container.elements.forEach(function(c){var p=na(c.flags,4),y=na(c.flags,2),i=new IM(c,u);na(c.styles.display,2048)&&r.push(i);var C=na(c.flags,8)?[]:r;if(p||y){var D=p||c.styles.isPositioned()?t:e,R=new MM(i);if(c.styles.isPositioned()||c.styles.opacity<1||c.styles.isTransformed()){var Q=c.styles.zIndex.order;if(Q<0){var z=0;D.negativeZIndex.some(function(J,Y){return Q>J.element.container.styles.zIndex.order?(z=Y,!1):z>0}),D.negativeZIndex.splice(z,0,R)}else if(Q>0){var G=0;D.positiveZIndex.some(function(J,Y){return Q>=J.element.container.styles.zIndex.order?(G=Y+1,!1):G>0}),D.positiveZIndex.splice(G,0,R)}else D.zeroOrAutoZIndexOrTransformedOrOpacity.push(R)}else c.styles.isFloating()?D.nonPositionedFloats.push(R):D.nonPositionedInlineLevel.push(R);Ib(i,R,p?R:t,C)}else c.styles.isInlineLevel()?e.inlineLevel.push(i):e.nonInlineLevel.push(i),Ib(i,e,t,C);na(c.flags,8)&&FM(c,C)})},FM=function(u,e){for(var t=u instanceof Cb?u.start:1,r=u instanceof Cb?u.reversed:!1,c=0;c"u"?u[0]:t},oR=function(u,e,t,r,c){var p=e[0],y=e[1],i=t[0],C=t[1];switch(u){case 2:return[new Rn(Math.round(r.left),Math.round(r.top+y)),new Rn(Math.round(r.left+r.width),Math.round(r.top+y)),new Rn(Math.round(r.left+r.width),Math.round(C+r.top+y)),new Rn(Math.round(r.left),Math.round(C+r.top+y))];case 3:return[new Rn(Math.round(r.left+p),Math.round(r.top)),new Rn(Math.round(r.left+p+i),Math.round(r.top)),new Rn(Math.round(r.left+p+i),Math.round(r.height+r.top)),new Rn(Math.round(r.left+p),Math.round(r.height+r.top))];case 1:return[new Rn(Math.round(r.left+p),Math.round(r.top+y)),new Rn(Math.round(r.left+p+i),Math.round(r.top+y)),new Rn(Math.round(r.left+p+i),Math.round(r.top+y+C)),new Rn(Math.round(r.left+p),Math.round(r.top+y+C))];default:return[new Rn(Math.round(c.left),Math.round(c.top)),new Rn(Math.round(c.left+c.width),Math.round(c.top)),new Rn(Math.round(c.left+c.width),Math.round(c.height+c.top)),new Rn(Math.round(c.left),Math.round(c.height+c.top))]}},aR="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",UE="Hidden Text",lR=function(){function u(e){this._data={},this._document=e}return u.prototype.parseMetrics=function(e,t){var r=this._document.createElement("div"),c=this._document.createElement("img"),p=this._document.createElement("span"),y=this._document.body;r.style.visibility="hidden",r.style.fontFamily=e,r.style.fontSize=t,r.style.margin="0",r.style.padding="0",r.style.whiteSpace="nowrap",y.appendChild(r),c.src=aR,c.width=1,c.height=1,c.style.margin="0",c.style.padding="0",c.style.verticalAlign="baseline",p.style.fontFamily=e,p.style.fontSize=t,p.style.margin="0",p.style.padding="0",p.appendChild(this._document.createTextNode(UE)),r.appendChild(p),r.appendChild(c);var i=c.offsetTop-p.offsetTop+2;r.removeChild(p),r.appendChild(this._document.createTextNode(UE)),r.style.lineHeight="normal",c.style.verticalAlign="super";var C=c.offsetTop-r.offsetTop+2;return y.removeChild(r),{baseline:i,middle:C}},u.prototype.getMetrics=function(e,t){var r=e+" "+t;return typeof this._data[r]>"u"&&(this._data[r]=this.parseMetrics(e,t)),this._data[r]},u}(),DM=function(){function u(e,t){this.context=e,this.options=t}return u}(),cR=1e4,hR=function(u){Au(e,u);function e(t,r){var c=u.call(this,t,r)||this;return c._activeEffects=[],c.canvas=r.canvas?r.canvas:document.createElement("canvas"),c.ctx=c.canvas.getContext("2d"),r.canvas||(c.canvas.width=Math.floor(r.width*r.scale),c.canvas.height=Math.floor(r.height*r.scale),c.canvas.style.width=r.width+"px",c.canvas.style.height=r.height+"px"),c.fontMetrics=new lR(document),c.ctx.scale(c.options.scale,c.options.scale),c.ctx.translate(-r.x,-r.y),c.ctx.textBaseline="bottom",c._activeEffects=[],c.context.logger.debug("Canvas renderer initialized ("+r.width+"x"+r.height+") with scale "+r.scale),c}return e.prototype.applyEffects=function(t){for(var r=this;this._activeEffects.length;)this.popEffect();t.forEach(function(c){return r.applyEffect(c)})},e.prototype.applyEffect=function(t){this.ctx.save(),q4(t)&&(this.ctx.globalAlpha=t.opacity),X4(t)&&(this.ctx.translate(t.offsetX,t.offsetY),this.ctx.transform(t.matrix[0],t.matrix[1],t.matrix[2],t.matrix[3],t.matrix[4],t.matrix[5]),this.ctx.translate(-t.offsetX,-t.offsetY)),SM(t)&&(this.path(t.path),this.ctx.clip()),this._activeEffects.push(t)},e.prototype.popEffect=function(){this._activeEffects.pop(),this.ctx.restore()},e.prototype.renderStack=function(t){return Il(this,void 0,void 0,function(){var r;return tl(this,function(c){switch(c.label){case 0:return r=t.element.container.styles,r.isVisible()?[4,this.renderStackContent(t)]:[3,2];case 1:c.sent(),c.label=2;case 2:return[2]}})})},e.prototype.renderNode=function(t){return Il(this,void 0,void 0,function(){return tl(this,function(r){switch(r.label){case 0:if(na(t.container.flags,16))debugger;return t.container.styles.isVisible()?[4,this.renderNodeBackgroundAndBorders(t)]:[3,3];case 1:return r.sent(),[4,this.renderNodeContent(t)];case 2:r.sent(),r.label=3;case 3:return[2]}})})},e.prototype.renderTextWithLetterSpacing=function(t,r,c){var p=this;if(r===0)this.ctx.fillText(t.text,t.bounds.left,t.bounds.top+c);else{var y=S2(t.text);y.reduce(function(i,C){return p.ctx.fillText(C,i,t.bounds.top+c),i+p.ctx.measureText(C).width},t.bounds.left)}},e.prototype.createFontStyle=function(t){var r=t.fontVariant.filter(function(y){return y==="normal"||y==="small-caps"}).join(""),c=fR(t.fontFamily).join(", "),p=ay(t.fontSize)?""+t.fontSize.number+t.fontSize.unit:t.fontSize.number+"px";return[[t.fontStyle,r,t.fontWeight,p,c].join(" "),c,p]},e.prototype.renderTextNode=function(t,r){return Il(this,void 0,void 0,function(){var c,p,y,i,C,D,R,Q,z=this;return tl(this,function(G){return c=this.createFontStyle(r),p=c[0],y=c[1],i=c[2],this.ctx.font=p,this.ctx.direction=r.direction===1?"rtl":"ltr",this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic",C=this.fontMetrics.getMetrics(y,i),D=C.baseline,R=C.middle,Q=r.paintOrder,t.textBounds.forEach(function(J){Q.forEach(function(Y){switch(Y){case 0:z.ctx.fillStyle=ma(r.color),z.renderTextWithLetterSpacing(J,r.letterSpacing,D);var B=r.textShadow;B.length&&J.text.trim().length&&(B.slice(0).reverse().forEach(function(ae){z.ctx.shadowColor=ma(ae.color),z.ctx.shadowOffsetX=ae.offsetX.number*z.options.scale,z.ctx.shadowOffsetY=ae.offsetY.number*z.options.scale,z.ctx.shadowBlur=ae.blur.number,z.renderTextWithLetterSpacing(J,r.letterSpacing,D)}),z.ctx.shadowColor="",z.ctx.shadowOffsetX=0,z.ctx.shadowOffsetY=0,z.ctx.shadowBlur=0),r.textDecorationLine.length&&(z.ctx.fillStyle=ma(r.textDecorationColor||r.color),r.textDecorationLine.forEach(function(ae){switch(ae){case 1:z.ctx.fillRect(J.bounds.left,Math.round(J.bounds.top+D),J.bounds.width,1);break;case 2:z.ctx.fillRect(J.bounds.left,Math.round(J.bounds.top),J.bounds.width,1);break;case 3:z.ctx.fillRect(J.bounds.left,Math.ceil(J.bounds.top+R),J.bounds.width,1);break}}));break;case 1:r.webkitTextStrokeWidth&&J.text.trim().length&&(z.ctx.strokeStyle=ma(r.webkitTextStrokeColor),z.ctx.lineWidth=r.webkitTextStrokeWidth,z.ctx.lineJoin=window.chrome?"miter":"round",z.ctx.strokeText(J.text,J.bounds.left,J.bounds.top+D)),z.ctx.strokeStyle="",z.ctx.lineWidth=0,z.ctx.lineJoin="miter";break}})}),[2]})})},e.prototype.renderReplacedElement=function(t,r,c){if(c&&t.intrinsicWidth>0&&t.intrinsicHeight>0){var p=cv(t),y=lv(r);this.path(y),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(c,0,0,t.intrinsicWidth,t.intrinsicHeight,p.left,p.top,p.width,p.height),this.ctx.restore()}},e.prototype.renderNodeContent=function(t){return Il(this,void 0,void 0,function(){var r,c,p,y,i,C,ce,ce,D,R,Q,z,we,G,J,me,Y,B,ae,ce,Ae,we,me;return tl(this,function(De){switch(De.label){case 0:this.applyEffects(t.getEffects(4)),r=t.container,c=t.curves,p=r.styles,y=0,i=r.textNodes,De.label=1;case 1:return y0&&le>0&&(Fe=p.ctx.createPattern(me,"repeat"),p.renderRepeat(Et,Fe,xe,Re))):qD(R)&&(Ge=_w(t,r,[null,null,null]),Et=Ge[0],li=Ge[1],xi=Ge[2],te=Ge[3],le=Ge[4],ye=R.position.length===0?[C2]:R.position,xe=Gs(ye[0],te),Re=Gs(ye[ye.length-1],le),Oe=jD(R,xe,Re,te,le),We=Oe[0],Ve=Oe[1],We>0&&Ve>0&&(Qe=p.ctx.createRadialGradient(li+xe,xi+Re,0,li+xe,xi+Re,We),nE(R.stops,We*2).forEach(function(At){return Qe.addColorStop(At.stop,ma(At.color))}),p.path(Et),p.ctx.fillStyle=Qe,We!==Ve?(Se=t.bounds.left+.5*t.bounds.width,Ke=t.bounds.top+.5*t.bounds.height,nt=Ve/We,vt=1/nt,p.ctx.save(),p.ctx.translate(Se,Ke),p.ctx.transform(1,0,0,nt,0,0),p.ctx.translate(-Se,-Ke),p.ctx.fillRect(li,vt*(xi-Ke)+Ke,te,le*vt),p.ctx.restore()):p.ctx.fill())),be.label=6;case 6:return r--,[2]}})},p=this,y=0,i=t.styles.backgroundImage.slice(0).reverse(),D.label=1;case 1:return y0?R.style!==2?[3,5]:[4,this.renderDashedDottedBorder(R.color,R.width,i,t.curves,2)]:[3,11]):[3,13];case 4:return z.sent(),[3,11];case 5:return R.style!==3?[3,7]:[4,this.renderDashedDottedBorder(R.color,R.width,i,t.curves,3)];case 6:return z.sent(),[3,11];case 7:return R.style!==4?[3,9]:[4,this.renderDoubleBorder(R.color,R.width,i,t.curves)];case 8:return z.sent(),[3,11];case 9:return[4,this.renderSolidBorder(R.color,i,t.curves)];case 10:z.sent(),z.label=11;case 11:i++,z.label=12;case 12:return C++,[3,3];case 13:return[2]}})})},e.prototype.renderDashedDottedBorder=function(t,r,c,p,y){return Il(this,void 0,void 0,function(){var i,C,D,R,Q,z,G,J,Y,B,ae,ce,Ae,we,me,De,me,De;return tl(this,function(Je){return this.ctx.save(),i=iR(p,c),C=PE(p,c),y===2&&(this.path(C),this.ctx.clip()),vh(C[0])?(D=C[0].start.x,R=C[0].start.y):(D=C[0].x,R=C[0].y),vh(C[1])?(Q=C[1].end.x,z=C[1].end.y):(Q=C[1].x,z=C[1].y),c===0||c===2?G=Math.abs(D-Q):G=Math.abs(R-z),this.ctx.beginPath(),y===3?this.formatPath(i):this.formatPath(C.slice(0,2)),J=r<3?r*3:r*2,Y=r<3?r*2:r,y===3&&(J=r,Y=r),B=!0,G<=J*2?B=!1:G<=J*2+Y?(ae=G/(2*J+Y),J*=ae,Y*=ae):(ce=Math.floor((G+Y)/(J+Y)),Ae=(G-ce*J)/(ce-1),we=(G-(ce+1)*J)/ce,Y=we<=0||Math.abs(Y-Ae){let e=P_.parse(window.location.search),t=P_.parse(window.location.hash);return this.params=Object.assign(this.params,e,t),ef._instance});Qi(this,"Init",()=>{console.dir(this.nativeFns)});Qi(this,"IsPC",()=>{let e=navigator.userAgent,t=["Android","iPhone","SymbianOS","Windows Phone","iPad","iPod"],r=!0;for(let c=0;c0){r=!1;break}return r});Qi(this,"_OutScreenshot",async function(e=""){$(`#${this.domId} > div`).css("width","100%"),$(`#${this.domId} > div`).css("height","100%"),$(`#${this.domId} > div`).css("overflow","hidden"),$("#bim-cache").css("display","none");let t;if(e!==""&&document.getElementById(e)){let c=document.getElementById(e);t=await RE(c)}t=await RE(document.body);let r=t.toDataURL();return await this._scaleImage(600,r),r});Qi(this,"_scaleImage",async function(e=720,t=""){return new Promise((r,c)=>{let p="";if(!t||t==="")r(p);else{let y=document.body.offsetHeight,i=document.body.offsetWidth,C=e,D=e/(i/y),R=document.createElement("canvas");R.width=C,R.height=D;let Q=R.getContext("2d"),z=document.createElement("img");z.id="testimg",z.src=t,z.style.width="200px",z.style.position="absolute",z.style.top="0px",z.style.zIndex="9999",z.onload=G=>{console.dir(z),Q.drawImage(z,0,0,C,D),R.style.position="absolute",R.style.display="block",R.style.top="0px",R.style.right="0px",R.style.zIndex="10000",R.style.backgroundColor="red",p=R.toDataURL(),r(p)}}})})}static getInstance(){return ef._instance==null&&(ef._instance=new ef),ef._instance}BindFn(e){return this.nativeFns=e,this}};let Nm=ef;Qi(Nm,"_instance");const zm=class{constructor(){Qi(this,"targetComponentID","")}static getInstance(){return zm._instance==null&&(zm._instance=new zm),zm._instance}BindCbFn(e){return Jp.getInstance().Fn,this}};let T_=zm;Qi(T_,"_instance");var Ml={exports:{}};(function(u,e){(function({},t){u.exports=t()})(MS,function(){var t,r,c;function p(i,C){if(!t)t=C;else if(!r)r=C;else{var D="var sharedChunk = {}; ("+t+")(sharedChunk); ("+r+")(sharedChunk);",R={};t(R),c=C(R),typeof window<"u"&&(c.workerUrl=window.URL.createObjectURL(new Blob([D],{type:"text/javascript"})))}}p(["exports"],function(i){var C=D;function D(A,l,f,w){this.cx=3*A,this.bx=3*(f-A)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*l,this.by=3*(w-l)-this.cy,this.ay=1-this.cy-this.by,this.p1x=A,this.p1y=l,this.p2x=f,this.p2y=w}function R(A,l,f,w){const I=new C(A,l,f,w);return function(U){return I.solve(U)}}D.prototype={sampleCurveX:function(A){return((this.ax*A+this.bx)*A+this.cx)*A},sampleCurveY:function(A){return((this.ay*A+this.by)*A+this.cy)*A},sampleCurveDerivativeX:function(A){return(3*this.ax*A+2*this.bx)*A+this.cx},solveCurveX:function(A,l){if(l===void 0&&(l=1e-6),A<0)return 0;if(A>1)return 1;for(var f=A,w=0;w<8;w++){var I=this.sampleCurveX(f)-A;if(Math.abs(I)I?N=f:Z=f,f=.5*(Z-N)+N;return f},solve:function(A,l){return this.sampleCurveY(this.solveCurveX(A,l))}};const Q=R(.25,.1,.25,1);function z(A,l,f){return Math.min(f,Math.max(l,A))}function G(A,l,f){const w=f-l,I=((A-l)%w+w)%w+l;return I===l?f:I}function J(A,...l){for(const f of l)for(const w in f)A[w]=f[w];return A}let Y=1;function B(A,l){A.forEach(f=>{l[f]&&(l[f]=l[f].bind(l))})}function ae(A,l,f){const w={};for(const I in A)w[I]=l.call(f||this,A[I],I,A);return w}function ce(A,l,f){const w={};for(const I in A)l.call(f||this,A[I],I,A)&&(w[I]=A[I]);return w}function Ae(A){return Array.isArray(A)?A.map(Ae):typeof A=="object"&&A?ae(A,Ae):A}const we={};function me(A){we[A]||(typeof console<"u"&&console.warn(A),we[A]=!0)}function De(A,l,f){return(f.y-A.y)*(l.x-A.x)>(l.y-A.y)*(f.x-A.x)}function Je(A){let l=0;for(let f,w,I=0,U=A.length,N=U-1;I@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,w,I,U)=>{const N=I||U;return l[w]=!N||N.toLowerCase(),""}),l["max-age"]){const f=parseInt(l["max-age"],10);isNaN(f)?delete l["max-age"]:l["max-age"]=f}return l}let Et,li,xi=null;function te(A){if(xi==null){const l=A.navigator?A.navigator.userAgent:null;xi=!!A.safari||!(!l||!(/\b(iPad|iPhone|iPod)\b/.test(l)||l.match("Safari")&&!l.match("Chrome")))}return xi}function le(A){return typeof ImageBitmap<"u"&&A instanceof ImageBitmap}const ye={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(A){const l=requestAnimationFrame(A);return{cancel:()=>cancelAnimationFrame(l)}},getImageData(A,l=0){const f=window.document.createElement("canvas"),w=f.getContext("2d");if(!w)throw new Error("failed to create canvas 2d context");return f.width=A.width,f.height=A.height,w.drawImage(A,0,0,A.width,A.height),w.getImageData(-l,-l,A.width+2*l,A.height+2*l)},resolveURL:A=>(Et||(Et=document.createElement("a")),Et.href=A,Et.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(li==null&&(li=matchMedia("(prefers-reduced-motion: reduce)")),li.matches)}};var xe=Re;function Re(A,l){this.x=A,this.y=l}Re.prototype={clone:function(){return new Re(this.x,this.y)},add:function(A){return this.clone()._add(A)},sub:function(A){return this.clone()._sub(A)},multByPoint:function(A){return this.clone()._multByPoint(A)},divByPoint:function(A){return this.clone()._divByPoint(A)},mult:function(A){return this.clone()._mult(A)},div:function(A){return this.clone()._div(A)},rotate:function(A){return this.clone()._rotate(A)},rotateAround:function(A,l){return this.clone()._rotateAround(A,l)},matMult:function(A){return this.clone()._matMult(A)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(A){return this.x===A.x&&this.y===A.y},dist:function(A){return Math.sqrt(this.distSqr(A))},distSqr:function(A){var l=A.x-this.x,f=A.y-this.y;return l*l+f*f},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(A){return Math.atan2(this.y-A.y,this.x-A.x)},angleWith:function(A){return this.angleWithSep(A.x,A.y)},angleWithSep:function(A,l){return Math.atan2(this.x*l-this.y*A,this.x*A+this.y*l)},_matMult:function(A){var l=A[2]*this.x+A[3]*this.y;return this.x=A[0]*this.x+A[1]*this.y,this.y=l,this},_add:function(A){return this.x+=A.x,this.y+=A.y,this},_sub:function(A){return this.x-=A.x,this.y-=A.y,this},_mult:function(A){return this.x*=A,this.y*=A,this},_div:function(A){return this.x/=A,this.y/=A,this},_multByPoint:function(A){return this.x*=A.x,this.y*=A.y,this},_divByPoint:function(A){return this.x/=A.x,this.y/=A.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var A=this.y;return this.y=this.x,this.x=-A,this},_rotate:function(A){var l=Math.cos(A),f=Math.sin(A),w=f*this.x+l*this.y;return this.x=l*this.x-f*this.y,this.y=w,this},_rotateAround:function(A,l){var f=Math.cos(A),w=Math.sin(A),I=l.y+w*(this.x-l.x)+f*(this.y-l.y);return this.x=l.x+f*(this.x-l.x)-w*(this.y-l.y),this.y=I,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Re.convert=function(A){return A instanceof Re?A:Array.isArray(A)?new Re(A[0],A[1]):A};const Oe={MAX_PARALLEL_IMAGE_REQUESTS:16,REGISTERED_PROTOCOLS:{}},We="mapbox-tiles";let Ve,Qe,Se=500,Ke=50;function nt(){typeof caches>"u"||Ve||(Ve=caches.open(We))}let vt=1/0;const be={supported:!1,testSupport:function(A){!Nt&&ut&&(Gt?Qt(A):At=A)}};let At,ut,Nt=!1,Gt=!1;function Qt(A){const l=A.createTexture();A.bindTexture(A.TEXTURE_2D,l);try{if(A.texImage2D(A.TEXTURE_2D,0,A.RGBA,A.RGBA,A.UNSIGNED_BYTE,ut),A.isContextLost())return;be.supported=!0}catch{}A.deleteTexture(l),Nt=!0}typeof document<"u"&&(ut=document.createElement("img"),ut.onload=function(){At&&Qt(At),At=null,Gt=!0},ut.onerror=function(){Nt=!0,At=null},ut.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Ct={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(Ct);class Ft extends Error{constructor(l,f,w,I){super(`AJAXError: ${f} (${l}): ${w}`),this.status=l,this.statusText=f,this.url=w,this.body=I}}const Xt=Fe()?()=>self.worker&&self.worker.referrer:()=>(window.location.protocol==="blob:"?window.parent:window).location.href;function _i(A,l){const f=new AbortController,w=new Request(A.url,{method:A.method||"GET",body:A.body,credentials:A.credentials,headers:A.headers,referrer:Xt(),signal:f.signal});let I=!1,U=!1;return A.type==="json"&&w.headers.set("Accept","application/json"),((N,Z,re)=>{if(U)return;const ge=Date.now();fetch(w).then(Ce=>Ce.ok?((Ie,ke,$e)=>{(A.type==="arrayBuffer"?Ie.arrayBuffer():A.type==="json"?Ie.json():Ie.text()).then(Ze=>{U||(ke&&$e&&function(Rt,Mt,ri){if(nt(),!Ve)return;const mi={status:Mt.status,statusText:Mt.statusText,headers:new Headers};Mt.headers.forEach((ui,Pi)=>mi.headers.set(Pi,ui));const ei=Ge(Mt.headers.get("Cache-Control")||"");ei["no-store"]||(ei["max-age"]&&mi.headers.set("Expires",new Date(ri+1e3*ei["max-age"]).toUTCString()),new Date(mi.headers.get("Expires")).getTime()-ri<42e4||function(ui,Pi){if(Qe===void 0)try{new Response(new ReadableStream),Qe=!0}catch{Qe=!1}Qe?Pi(ui.body):ui.blob().then(Pi)}(Mt,ui=>{const Pi=new Response(ui,mi);nt(),Ve&&Ve.then(Fi=>Fi.put(function(Sn){const fn=Sn.indexOf("?");return fn<0?Sn:Sn.slice(0,fn)}(Rt.url),Pi)).catch(Fi=>me(Fi.message))}))}(w,ke,$e),I=!0,l(null,Ze,Ie.headers.get("Cache-Control"),Ie.headers.get("Expires")))}).catch(Ze=>{U||l(new Error(Ze.message))})})(Ce,null,ge):Ce.blob().then(Ie=>l(new Ft(Ce.status,Ce.statusText,A.url,Ie)))).catch(Ce=>{Ce.code!==20&&l(new Error(Ce.message))})})(),{cancel:()=>{U=!0,I||f.abort()}}}const fi=function(A,l){if(/:\/\//.test(A.url)&&!/^https?:|^file:/.test(A.url)){if(Fe()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",A,l);if(!Fe()){const w=A.url.substring(0,A.url.indexOf("://"));return(Oe.REGISTERED_PROTOCOLS[w]||_i)(A,l)}}if(!(/^file:/.test(f=A.url)||/^file:/.test(Xt())&&!/^\w+:/.test(f))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return _i(A,l);if(Fe()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",A,l,void 0,!0)}var f;return function(w,I){const U=new XMLHttpRequest;U.open(w.method||"GET",w.url,!0),w.type==="arrayBuffer"&&(U.responseType="arraybuffer");for(const N in w.headers)U.setRequestHeader(N,w.headers[N]);return w.type==="json"&&(U.responseType="text",U.setRequestHeader("Accept","application/json")),U.withCredentials=w.credentials==="include",U.onerror=()=>{I(new Error(U.statusText))},U.onload=()=>{if((U.status>=200&&U.status<300||U.status===0)&&U.response!==null){let N=U.response;if(w.type==="json")try{N=JSON.parse(U.response)}catch(Z){return I(Z)}I(null,N,U.getResponseHeader("Cache-Control"),U.getResponseHeader("Expires"))}else{const N=new Blob([U.response],{type:U.getResponseHeader("Content-Type")});I(new Ft(U.status,U.statusText,w.url,N))}},U.send(w.body),{cancel:()=>U.abort()}}(A,l)},Gi=function(A,l){return fi(J(A,{type:"arrayBuffer"}),l)};function wn(A){const l=window.document.createElement("a");return l.href=A,l.protocol===window.document.location.protocol&&l.host===window.document.location.host}const zi="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Gn,kn;Gn=[],kn=0;const yt=function(A,l){if(be.supported&&(A.headers||(A.headers={}),A.headers.accept="image/webp,*/*"),kn>=Oe.MAX_PARALLEL_IMAGE_REQUESTS){const U={requestParameters:A,callback:l,cancelled:!1,cancel(){this.cancelled=!0}};return Gn.push(U),U}kn++;let f=!1;const w=()=>{if(!f)for(f=!0,kn--;Gn.length&&kn{w(),U?l(U):N&&function(ge,Ce){typeof createImageBitmap=="function"?function(Ie,ke){const $e=new Blob([new Uint8Array(Ie)],{type:"image/png"});createImageBitmap($e).then(Ze=>{ke(null,Ze)}).catch(Ze=>{ke(new Error(`Could not load image because of ${Ze.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(ge,Ce):function(Ie,ke){const $e=new Image;$e.onload=()=>{ke(null,$e),URL.revokeObjectURL($e.src),$e.onload=null,window.requestAnimationFrame(()=>{$e.src=zi})},$e.onerror=()=>ke(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 Ze=new Blob([new Uint8Array(Ie)],{type:"image/png"});$e.src=Ie.byteLength?URL.createObjectURL(Ze):zi}(ge,Ce)}(N,(ge,Ce)=>{ge!=null?l(ge):Ce!=null&&l(null,Ce,{cacheControl:Z,expires:re})})});return{cancel:()=>{I.cancel(),w()}}};function rt(A,l,f){f[A]&&f[A].indexOf(l)!==-1||(f[A]=f[A]||[],f[A].push(l))}function ti(A,l,f){if(f&&f[A]){const w=f[A].indexOf(l);w!==-1&&f[A].splice(w,1)}}class Ni{constructor(l,f={}){J(this,f),this.type=l}}class qi extends Ni{constructor(l,f={}){super("error",J({error:l},f))}}class en{on(l,f){return this._listeners=this._listeners||{},rt(l,f,this._listeners),this}off(l,f){return ti(l,f,this._listeners),ti(l,f,this._oneTimeListeners),this}once(l,f){return this._oneTimeListeners=this._oneTimeListeners||{},rt(l,f,this._oneTimeListeners),this}fire(l,f){typeof l=="string"&&(l=new Ni(l,f||{}));const w=l.type;if(this.listens(w)){l.target=this;const I=this._listeners&&this._listeners[w]?this._listeners[w].slice():[];for(const Z of I)Z.call(this,l);const U=this._oneTimeListeners&&this._oneTimeListeners[w]?this._oneTimeListeners[w].slice():[];for(const Z of U)ti(w,Z,this._oneTimeListeners),Z.call(this,l);const N=this._eventedParent;N&&(J(l,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),N.fire(l))}else l instanceof qi&&console.error(l.error);return this}listens(l){return this._listeners&&this._listeners[l]&&this._listeners[l].length>0||this._oneTimeListeners&&this._oneTimeListeners[l]&&this._oneTimeListeners[l].length>0||this._eventedParent&&this._eventedParent.listens(l)}setEventedParent(l,f){return this._eventedParent=l,this._eventedParentData=f,this}}var $t={$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:"string"},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:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.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-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},elevationOffset:{type:"number",default:450}},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"}}};class at{constructor(l,f,w,I){this.message=(l?`${l}: `:"")+w,I&&(this.identifier=I),f!=null&&f.__line__&&(this.line=f.__line__)}}function ii(A){const l=A.value;return l?[new at(A.key,l,"constants have been deprecated as of v8")]:[]}function hn(A,...l){for(const f of l)for(const w in f)A[w]=f[w];return A}function Xi(A){return A instanceof Number||A instanceof String||A instanceof Boolean?A.valueOf():A}function on(A){if(Array.isArray(A))return A.map(on);if(A instanceof Object&&!(A instanceof Number||A instanceof String||A instanceof Boolean)){const l={};for(const f in A)l[f]=on(A[f]);return l}return Xi(A)}class Cn extends Error{constructor(l,f){super(f),this.message=f,this.key=l}}class Tn{constructor(l,f=[]){this.parent=l,this.bindings={};for(const[w,I]of f)this.bindings[w]=I}concat(l){return new Tn(this,l)}get(l){if(this.bindings[l])return this.bindings[l];if(this.parent)return this.parent.get(l);throw new Error(`${l} not found in scope.`)}has(l){return!!this.bindings[l]||!!this.parent&&this.parent.has(l)}}const nr={kind:"null"},Ii={kind:"number"},bn={kind:"string"},Ot={kind:"boolean"},wi={kind:"color"},Wi={kind:"object"},Ui={kind:"value"},Pn={kind:"collator"},qn={kind:"formatted"},Hr={kind:"padding"},fr={kind:"resolvedImage"};function kr(A,l){return{kind:"array",itemType:A,N:l}}function Qn(A){if(A.kind==="array"){const l=Qn(A.itemType);return typeof A.N=="number"?`array<${l}, ${A.N}>`:A.itemType.kind==="value"?"array":`array<${l}>`}return A.kind}const Rs=[nr,Ii,bn,Ot,wi,qn,Wi,kr(Ui),Hr,fr];function ot(A,l){if(l.kind==="error")return null;if(A.kind==="array"){if(l.kind==="array"&&(l.N===0&&l.itemType.kind==="value"||!ot(A.itemType,l.itemType))&&(typeof A.N!="number"||A.N===l.N))return null}else{if(A.kind===l.kind)return null;if(A.kind==="value"){for(const f of Rs)if(!ot(f,l))return null}}return`Expected ${Qn(A)} but found ${Qn(l)} instead.`}function Ee(A,l){return l.some(f=>f.kind===A.kind)}function Pe(A,l){return l.some(f=>f==="null"?A===null:f==="array"?Array.isArray(A):f==="object"?A&&!Array.isArray(A)&&typeof A=="object":f===typeof A)}var ct,wt={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function X(A){return(A=Math.round(A))<0?0:A>255?255:A}function j(A){return X(A[A.length-1]==="%"?parseFloat(A)/100*255:parseInt(A))}function ie(A){return(l=A[A.length-1]==="%"?parseFloat(A)/100:parseFloat(A))<0?0:l>1?1:l;var l}function ne(A,l,f){return f<0?f+=1:f>1&&(f-=1),6*f<1?A+(l-A)*f*6:2*f<1?l:3*f<2?A+(l-A)*(2/3-f)*6:A}try{ct={}.parseCSSColor=function(A){var l,f=A.replace(/ /g,"").toLowerCase();if(f in wt)return wt[f].slice();if(f[0]==="#")return f.length===4?(l=parseInt(f.substr(1),16))>=0&&l<=4095?[(3840&l)>>4|(3840&l)>>8,240&l|(240&l)>>4,15&l|(15&l)<<4,1]:null:f.length===7&&(l=parseInt(f.substr(1),16))>=0&&l<=16777215?[(16711680&l)>>16,(65280&l)>>8,255&l,1]:null;var w=f.indexOf("("),I=f.indexOf(")");if(w!==-1&&I+1===f.length){var U=f.substr(0,w),N=f.substr(w+1,I-(w+1)).split(","),Z=1;switch(U){case"rgba":if(N.length!==4)return null;Z=ie(N.pop());case"rgb":return N.length!==3?null:[j(N[0]),j(N[1]),j(N[2]),Z];case"hsla":if(N.length!==4)return null;Z=ie(N.pop());case"hsl":if(N.length!==3)return null;var re=(parseFloat(N[0])%360+360)%360/360,ge=ie(N[1]),Ce=ie(N[2]),Ie=Ce<=.5?Ce*(ge+1):Ce+ge-Ce*ge,ke=2*Ce-Ie;return[X(255*ne(ke,Ie,re+1/3)),X(255*ne(ke,Ie,re)),X(255*ne(ke,Ie,re-1/3)),Z];default:return null}}return null}}catch{}class de{constructor(l,f,w,I=1){this.r=l,this.g=f,this.b=w,this.a=I}static parse(l){if(!l)return;if(l instanceof de)return l;if(typeof l!="string")return;const f=ct(l);return f?new de(f[0]/255*f[3],f[1]/255*f[3],f[2]/255*f[3],f[3]):void 0}toString(){const[l,f,w,I]=this.toArray();return`rgba(${Math.round(l)},${Math.round(f)},${Math.round(w)},${I})`}toArray(){const{r:l,g:f,b:w,a:I}=this;return I===0?[0,0,0,0]:[255*l/I,255*f/I,255*w/I,I]}}de.black=new de(0,0,0,1),de.white=new de(1,1,1,1),de.transparent=new de(0,0,0,0),de.red=new de(1,0,0,1);class Ue{constructor(l,f,w){this.sensitivity=l?f?"variant":"case":f?"accent":"base",this.locale=w,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(l,f){return this.collator.compare(l,f)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class tt{constructor(l,f,w,I,U){this.text=l,this.image=f,this.scale=w,this.fontStack=I,this.textColor=U}}class He{constructor(l){this.sections=l}static fromString(l){return new He([new tt(l,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(l=>l.text.length!==0||l.image&&l.image.name.length!==0)}static factory(l){return l instanceof He?l:He.fromString(l)}toString(){return this.sections.length===0?"":this.sections.map(l=>l.text).join("")}}class et{constructor(l){this.values=l.slice()}static parse(l){if(l instanceof et)return l;if(typeof l=="number")return new et([l,l,l,l]);if(Array.isArray(l)&&!(l.length<1||l.length>4)){for(const f of l)if(typeof f!="number")return;switch(l.length){case 1:l=[l[0],l[0],l[0],l[0]];break;case 2:l=[l[0],l[1],l[0],l[1]];break;case 3:l=[l[0],l[1],l[2],l[1]]}return new et(l)}}toString(){return JSON.stringify(this.values)}}class pt{constructor(l){this.name=l.name,this.available=l.available}toString(){return this.name}static fromString(l){return l?new pt({name:l,available:!1}):null}}function Lt(A,l,f,w){return typeof A=="number"&&A>=0&&A<=255&&typeof l=="number"&&l>=0&&l<=255&&typeof f=="number"&&f>=0&&f<=255?w===void 0||typeof w=="number"&&w>=0&&w<=1?null:`Invalid rgba value [${[A,l,f,w].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof w=="number"?[A,l,f,w]:[A,l,f]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function jt(A){if(A===null||typeof A=="string"||typeof A=="boolean"||typeof A=="number"||A instanceof de||A instanceof Ue||A instanceof He||A instanceof et||A instanceof pt)return!0;if(Array.isArray(A)){for(const l of A)if(!jt(l))return!1;return!0}if(typeof A=="object"){for(const l in A)if(!jt(A[l]))return!1;return!0}return!1}function Wt(A){if(A===null)return nr;if(typeof A=="string")return bn;if(typeof A=="boolean")return Ot;if(typeof A=="number")return Ii;if(A instanceof de)return wi;if(A instanceof Ue)return Pn;if(A instanceof He)return qn;if(A instanceof et)return Hr;if(A instanceof pt)return fr;if(Array.isArray(A)){const l=A.length;let f;for(const w of A){const I=Wt(w);if(f){if(f===I)continue;f=Ui;break}f=I}return kr(f||Ui,l)}return Wi}function ki(A){const l=typeof A;return A===null?"":l==="string"||l==="number"||l==="boolean"?String(A):A instanceof de||A instanceof He||A instanceof et||A instanceof pt?A.toString():JSON.stringify(A)}class bi{constructor(l,f){this.type=l,this.value=f}static parse(l,f){if(l.length!==2)return f.error(`'literal' expression requires exactly one argument, but found ${l.length-1} instead.`);if(!jt(l[1]))return f.error("invalid value");const w=l[1];let I=Wt(w);const U=f.expectedType;return I.kind!=="array"||I.N!==0||!U||U.kind!=="array"||typeof U.N=="number"&&U.N!==0||(I=U),new bi(I,w)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class Oi{constructor(l){this.name="ExpressionEvaluationError",this.message=l}toJSON(){return this.message}}const Yi={string:bn,number:Ii,boolean:Ot,object:Wi};class tn{constructor(l,f){this.type=l,this.args=f}static parse(l,f){if(l.length<2)return f.error("Expected at least one argument.");let w,I=1;const U=l[0];if(U==="array"){let Z,re;if(l.length>2){const ge=l[1];if(typeof ge!="string"||!(ge in Yi)||ge==="object")return f.error('The item type argument of "array" must be one of string, number, boolean',1);Z=Yi[ge],I++}else Z=Ui;if(l.length>3){if(l[2]!==null&&(typeof l[2]!="number"||l[2]<0||l[2]!==Math.floor(l[2])))return f.error('The length argument to "array" must be a positive integer literal',2);re=l[2],I++}w=kr(Z,re)}else{if(!Yi[U])throw new Error(`Types doesn't contain name = ${U}`);w=Yi[U]}const N=[];for(;Il.outputDefined())}}const rr={"to-boolean":Ot,"to-color":wi,"to-number":Ii,"to-string":bn};class yn{constructor(l,f){this.type=l,this.args=f}static parse(l,f){if(l.length<2)return f.error("Expected at least one argument.");const w=l[0];if(!rr[w])throw new Error(`Can't parse ${w} as it is not part of the known types`);if((w==="to-boolean"||w==="to-string")&&l.length!==2)return f.error("Expected one argument.");const I=rr[w],U=[];for(let N=1;N4?`Invalid rbga value ${JSON.stringify(f)}: expected an array containing either three or four numeric values.`:Lt(f[0],f[1],f[2],f[3]),!w))return new de(f[0]/255,f[1]/255,f[2]/255,f[3])}throw new Oi(w||`Could not parse color from value '${typeof f=="string"?f:JSON.stringify(f)}'`)}if(this.type.kind==="padding"){let f;for(const w of this.args){f=w.evaluate(l);const I=et.parse(f);if(I)return I}throw new Oi(`Could not parse padding from value '${typeof f=="string"?f:JSON.stringify(f)}'`)}if(this.type.kind==="number"){let f=null;for(const w of this.args){if(f=w.evaluate(l),f===null)return 0;const I=Number(f);if(!isNaN(I))return I}throw new Oi(`Could not convert ${JSON.stringify(f)} to number.`)}return this.type.kind==="formatted"?He.fromString(ki(this.args[0].evaluate(l))):this.type.kind==="resolvedImage"?pt.fromString(ki(this.args[0].evaluate(l))):ki(this.args[0].evaluate(l))}eachChild(l){this.args.forEach(l)}outputDefined(){return this.args.every(l=>l.outputDefined())}}const Yt=["Unknown","Point","LineString","Polygon"];class sr{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Yt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(l){let f=this._parseColorCache[l];return f||(f=this._parseColorCache[l]=de.parse(l)),f}}class Yn{constructor(l,f,w,I){this.name=l,this.type=f,this._evaluate=w,this.args=I}evaluate(l){return this._evaluate(l,this.args)}eachChild(l){this.args.forEach(l)}outputDefined(){return!1}static parse(l,f){const w=l[0],I=Yn.definitions[w];if(!I)return f.error(`Unknown expression "${w}". If you wanted a literal array, use ["literal", [...]].`,0);const U=Array.isArray(I)?I[0]:I.type,N=Array.isArray(I)?[[I[1],I[2]]]:I.overloads,Z=N.filter(([ge])=>!Array.isArray(ge)||ge.length===l.length-1);let re=null;for(const[ge,Ce]of Z){re=new Ol(f.registry,f.path,null,f.scope);const Ie=[];let ke=!1;for(let $e=1;$e{return ke=Ie,Array.isArray(ke)?`(${ke.map(Qn).join(", ")})`:`(${Qn(ke.type)}...)`;var ke}).join(" | "),Ce=[];for(let Ie=1;Ie=l[2]||A[1]<=l[1]||A[3]>=l[3])}function zs(A,l){const f=(180+A[0])/360,w=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+A[1]*Math.PI/360)))/360,I=Math.pow(2,l.z);return[Math.round(f*I*mr),Math.round(w*I*mr)]}function or(A,l,f){const w=A[0]-l[0],I=A[1]-l[1],U=A[0]-f[0],N=A[1]-f[1];return w*N-U*I==0&&w*U<=0&&I*N<=0}function rn(A,l){let f=!1;for(let N=0,Z=l.length;N(w=A)[1]!=(U=re[ge+1])[1]>w[1]&&w[0]<(U[0]-I[0])*(w[1]-I[1])/(U[1]-I[1])+I[0]&&(f=!f)}}var w,I,U;return f}function cr(A,l){for(let f=0;f0&&Z<0||N<0&&Z>0}function aa(A,l,f){for(const ge of f)for(let Ce=0;Cef[2]){const I=.5*w;let U=A[0]-f[0]>I?-w:f[0]-A[0]>I?w:0;U===0&&(U=A[0]-f[2]>I?-w:f[2]-A[0]>I?w:0),A[0]+=U}Mr(l,A)}function qs(A,l,f,w){const I=Math.pow(2,w.z)*mr,U=[w.x*mr,w.y*mr],N=[];for(const Z of A)for(const re of Z){const ge=[re.x+U[0],re.y+U[1]];ll(ge,l,f,I),N.push(ge)}return N}function cs(A,l,f,w){const I=Math.pow(2,w.z)*mr,U=[w.x*mr,w.y*mr],N=[];for(const re of A){const ge=[];for(const Ce of re){const Ie=[Ce.x+U[0],Ce.y+U[1]];Mr(l,Ie),ge.push(Ie)}N.push(ge)}if(l[2]-l[0]<=I/2){(Z=l)[0]=Z[1]=1/0,Z[2]=Z[3]=-1/0;for(const re of N)for(const ge of re)ll(ge,l,f,I)}var Z;return N}class ho{constructor(l,f){this.type=Ot,this.geojson=l,this.geometries=f}static parse(l,f){if(l.length!==2)return f.error(`'within' expression requires exactly one argument, but found ${l.length-1} instead.`);if(jt(l[1])){const w=l[1];if(w.type==="FeatureCollection")for(let I=0;I{l&&!cl(f)&&(l=!1)}),l}function Oa(A){if(A instanceof Yn&&A.name==="feature-state")return!1;let l=!0;return A.eachChild(f=>{l&&!Oa(f)&&(l=!1)}),l}function zl(A,l){if(A instanceof Yn&&l.indexOf(A.name)>=0)return!1;let f=!0;return A.eachChild(w=>{f&&!zl(w,l)&&(f=!1)}),f}class kl{constructor(l,f){this.type=f.type,this.name=l,this.boundExpression=f}static parse(l,f){if(l.length!==2||typeof l[1]!="string")return f.error("'var' expression requires exactly one string literal argument.");const w=l[1];return f.scope.has(w)?new kl(w,f.scope.get(w)):f.error(`Unknown variable "${w}". Make sure "${w}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(l){return this.boundExpression.evaluate(l)}eachChild(){}outputDefined(){return!1}}class Ol{constructor(l,f=[],w,I=new Tn,U=[]){this.registry=l,this.path=f,this.key=f.map(N=>`[${N}]`).join(""),this.scope=I,this.errors=U,this.expectedType=w}parse(l,f,w,I,U={}){return f?this.concat(f,w,I)._parse(l,U):this._parse(l,U)}_parse(l,f){function w(I,U,N){return N==="assert"?new tn(U,[I]):N==="coerce"?new yn(U,[I]):I}if(l!==null&&typeof l!="string"&&typeof l!="boolean"&&typeof l!="number"||(l=["literal",l]),Array.isArray(l)){if(l.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const I=l[0];if(typeof I!="string")return this.error(`Expression name must be a string, but found ${typeof I} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const U=this.registry[I];if(U){let N=U.parse(l,this);if(!N)return null;if(this.expectedType){const Z=this.expectedType,re=N.type;if(Z.kind!=="string"&&Z.kind!=="number"&&Z.kind!=="boolean"&&Z.kind!=="object"&&Z.kind!=="array"||re.kind!=="value")if(Z.kind!=="color"&&Z.kind!=="formatted"&&Z.kind!=="resolvedImage"||re.kind!=="value"&&re.kind!=="string")if(Z.kind!=="padding"||re.kind!=="value"&&re.kind!=="number"&&re.kind!=="array"){if(this.checkSubtype(Z,re))return null}else N=w(N,Z,f.typeAnnotation||"coerce");else N=w(N,Z,f.typeAnnotation||"coerce");else N=w(N,Z,f.typeAnnotation||"assert")}if(!(N instanceof bi)&&N.type.kind!=="resolvedImage"&&Na(N)){const Z=new sr;try{N=new bi(N.type,N.evaluate(Z))}catch(re){return this.error(re.message),null}}return N}return this.error(`Unknown expression "${I}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(l===void 0?"'undefined' value invalid. Use null instead.":typeof l=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof l} instead.`)}concat(l,f,w){const I=typeof l=="number"?this.path.concat(l):this.path,U=w?this.scope.concat(w):this.scope;return new Ol(this.registry,I,f||null,U,this.errors)}error(l,...f){const w=`${this.key}${f.map(I=>`[${I}]`).join("")}`;this.errors.push(new Cn(w,l))}checkSubtype(l,f){const w=ot(l,f);return w&&this.error(w),w}}function Na(A){if(A instanceof kl)return Na(A.boundExpression);if(A instanceof Yn&&A.name==="error"||A instanceof Wr||A instanceof ho)return!1;const l=A instanceof yn||A instanceof tn;let f=!0;return A.eachChild(w=>{f=l?f&&Na(w):f&&w instanceof bi}),!!f&&cl(A)&&zl(A,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Nl(A,l){const f=A.length-1;let w,I,U=0,N=f,Z=0;for(;U<=N;)if(Z=Math.floor((U+N)/2),w=A[Z],I=A[Z+1],w<=l){if(Z===f||ll))throw new Oi("Input is not a number.");N=Z-1}return 0}class Ql{constructor(l,f,w){this.type=l,this.input=f,this.labels=[],this.outputs=[];for(const[I,U]of w)this.labels.push(I),this.outputs.push(U)}static parse(l,f){if(l.length-1<4)return f.error(`Expected at least 4 arguments, but found only ${l.length-1}.`);if((l.length-1)%2!=0)return f.error("Expected an even number of arguments.");const w=f.parse(l[1],1,Ii);if(!w)return null;const I=[];let U=null;f.expectedType&&f.expectedType.kind!=="value"&&(U=f.expectedType);for(let N=1;N=Z)return f.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',ge);const Ie=f.parse(re,Ce,U);if(!Ie)return null;U=U||Ie.type,I.push([Z,Ie])}return new Ql(U,w,I)}evaluate(l){const f=this.labels,w=this.outputs;if(f.length===1)return w[0].evaluate(l);const I=this.input.evaluate(l);if(I<=f[0])return w[0].evaluate(l);const U=f.length;return I>=f[U-1]?w[U-1].evaluate(l):w[Nl(f,I)].evaluate(l)}eachChild(l){l(this.input);for(const f of this.outputs)l(f)}outputDefined(){return this.outputs.every(l=>l.outputDefined())}}function is(A,l,f){return A*(1-f)+l*f}var Ys=Object.freeze({__proto__:null,number:is,color:function(A,l,f){return new de(is(A.r,l.r,f),is(A.g,l.g,f),is(A.b,l.b,f),is(A.a,l.a,f))},array:function(A,l,f){return A.map((w,I)=>is(w,l[I],f))},padding:function(A,l,f){const w=A.values,I=l.values;return new et([is(w[0],I[0],f),is(w[1],I[1],f),is(w[2],I[2],f),is(w[3],I[3],f)])}});const ps=.95047,Rc=1.08883,Eh=4/29,ks=6/29,No=3*ks*ks,JA=Math.PI/180,fu=180/Math.PI;function Bs(A){return A>.008856451679035631?Math.pow(A,1/3):A/No+Eh}function sc(A){return A>ks?A*A*A:No*(A-Eh)}function Th(A){return 255*(A<=.0031308?12.92*A:1.055*Math.pow(A,1/2.4)-.055)}function oc(A){return(A/=255)<=.04045?A/12.92:Math.pow((A+.055)/1.055,2.4)}function er(A){const l=oc(A.r),f=oc(A.g),w=oc(A.b),I=Bs((.4124564*l+.3575761*f+.1804375*w)/ps),U=Bs((.2126729*l+.7151522*f+.072175*w)/1);return{l:116*U-16,a:500*(I-U),b:200*(U-Bs((.0193339*l+.119192*f+.9503041*w)/Rc)),alpha:A.a}}function ac(A){let l=(A.l+16)/116,f=isNaN(A.a)?l:l+A.a/500,w=isNaN(A.b)?l:l-A.b/200;return l=1*sc(l),f=ps*sc(f),w=Rc*sc(w),new de(Th(3.2404542*f-1.5371385*l-.4985314*w),Th(-.969266*f+1.8760108*l+.041556*w),Th(.0556434*f-.2040259*l+1.0572252*w),A.alpha)}function Ju(A,l,f){const w=l-A;return A+f*(w>180||w<-180?w-360*Math.round(w/360):w)}const Qo={forward:er,reverse:ac,interpolate:function(A,l,f){return{l:is(A.l,l.l,f),a:is(A.a,l.a,f),b:is(A.b,l.b,f),alpha:is(A.alpha,l.alpha,f)}}},hl={forward:function(A){const{l,a:f,b:w}=er(A),I=Math.atan2(w,f)*fu;return{h:I<0?I+360:I,c:Math.sqrt(f*f+w*w),l,alpha:A.a}},reverse:function(A){const l=A.h*JA,f=A.c;return ac({l:A.l,a:Math.cos(l)*f,b:Math.sin(l)*f,alpha:A.alpha})},interpolate:function(A,l,f){return{h:Ju(A.h,l.h,f),c:is(A.c,l.c,f),l:is(A.l,l.l,f),alpha:is(A.alpha,l.alpha,f)}}};var Sh=Object.freeze({__proto__:null,lab:Qo,hcl:hl});class Vo{constructor(l,f,w,I,U){this.type=l,this.operator=f,this.interpolation=w,this.input=I,this.labels=[],this.outputs=[];for(const[N,Z]of U)this.labels.push(N),this.outputs.push(Z)}static interpolationFactor(l,f,w,I){let U=0;if(l.name==="exponential")U=Mh(f,l.base,w,I);else if(l.name==="linear")U=Mh(f,1,w,I);else if(l.name==="cubic-bezier"){const N=l.controlPoints;U=new C(N[0],N[1],N[2],N[3]).solve(Mh(f,1,w,I))}return U}static parse(l,f){let[w,I,U,...N]=l;if(!Array.isArray(I)||I.length===0)return f.error("Expected an interpolation type expression.",1);if(I[0]==="linear")I={name:"linear"};else if(I[0]==="exponential"){const ge=I[1];if(typeof ge!="number")return f.error("Exponential interpolation requires a numeric base.",1,1);I={name:"exponential",base:ge}}else{if(I[0]!=="cubic-bezier")return f.error(`Unknown interpolation type ${String(I[0])}`,1,0);{const ge=I.slice(1);if(ge.length!==4||ge.some(Ce=>typeof Ce!="number"||Ce<0||Ce>1))return f.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);I={name:"cubic-bezier",controlPoints:ge}}}if(l.length-1<4)return f.error(`Expected at least 4 arguments, but found only ${l.length-1}.`);if((l.length-1)%2!=0)return f.error("Expected an even number of arguments.");if(U=f.parse(U,2,Ii),!U)return null;const Z=[];let re=null;w==="interpolate-hcl"||w==="interpolate-lab"?re=wi:f.expectedType&&f.expectedType.kind!=="value"&&(re=f.expectedType);for(let ge=0;ge=Ce)return f.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ke);const Ze=f.parse(Ie,$e,re);if(!Ze)return null;re=re||Ze.type,Z.push([Ce,Ze])}return re.kind==="number"||re.kind==="color"||re.kind==="padding"||re.kind==="array"&&re.itemType.kind==="number"&&typeof re.N=="number"?new Vo(re,w,I,U,Z):f.error(`Type ${Qn(re)} is not interpolatable.`)}evaluate(l){const f=this.labels,w=this.outputs;if(f.length===1)return w[0].evaluate(l);const I=this.input.evaluate(l);if(I<=f[0])return w[0].evaluate(l);const U=f.length;if(I>=f[U-1])return w[U-1].evaluate(l);const N=Nl(f,I),Z=Vo.interpolationFactor(this.interpolation,I,f[N],f[N+1]),re=w[N].evaluate(l),ge=w[N+1].evaluate(l);return this.operator==="interpolate"?Ys[this.type.kind.toLowerCase()](re,ge,Z):this.operator==="interpolate-hcl"?hl.reverse(hl.interpolate(hl.forward(re),hl.forward(ge),Z)):Qo.reverse(Qo.interpolate(Qo.forward(re),Qo.forward(ge),Z))}eachChild(l){l(this.input);for(const f of this.outputs)l(f)}outputDefined(){return this.outputs.every(l=>l.outputDefined())}}function Mh(A,l,f,w){const I=w-f,U=A-f;return I===0?0:l===1?U/I:(Math.pow(l,U)-1)/(Math.pow(l,I)-1)}class Qa{constructor(l,f){this.type=l,this.args=f}static parse(l,f){if(l.length<2)return f.error("Expectected at least one argument.");let w=null;const I=f.expectedType;I&&I.kind!=="value"&&(w=I);const U=[];for(const Z of l.slice(1)){const re=f.parse(Z,1+U.length,w,void 0,{typeAnnotation:"omit"});if(!re)return null;w=w||re.type,U.push(re)}if(!w)throw new Error("No output type");const N=I&&U.some(Z=>ot(I,Z.type));return new Qa(N?Ui:w,U)}evaluate(l){let f,w=null,I=0;for(const U of this.args)if(I++,w=U.evaluate(l),w&&w instanceof pt&&!w.available&&(f||(f=w.name),w=null,I===this.args.length&&(w=f)),w!==null)break;return w}eachChild(l){this.args.forEach(l)}outputDefined(){return this.args.every(l=>l.outputDefined())}}class lc{constructor(l,f){this.type=f.type,this.bindings=[].concat(l),this.result=f}evaluate(l){return this.result.evaluate(l)}eachChild(l){for(const f of this.bindings)l(f[1]);l(this.result)}static parse(l,f){if(l.length<4)return f.error(`Expected at least 3 arguments, but found ${l.length-1} instead.`);const w=[];for(let U=1;U=w.length)throw new Oi(`Array index out of bounds: ${f} > ${w.length-1}.`);if(f!==Math.floor(f))throw new Oi(`Array index must be an integer, but found ${f} instead.`);return w[f]}eachChild(l){l(this.index),l(this.input)}outputDefined(){return!1}}class Vl{constructor(l,f){this.type=Ot,this.needle=l,this.haystack=f}static parse(l,f){if(l.length!==3)return f.error(`Expected 2 arguments, but found ${l.length-1} instead.`);const w=f.parse(l[1],1,Ui),I=f.parse(l[2],2,Ui);return w&&I?Ee(w.type,[Ot,bn,Ii,nr,Ui])?new Vl(w,I):f.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qn(w.type)} instead`):null}evaluate(l){const f=this.needle.evaluate(l),w=this.haystack.evaluate(l);if(!w)return!1;if(!Pe(f,["boolean","string","number","null"]))throw new Oi(`Expected first argument to be of type boolean, string, number or null, but found ${Qn(Wt(f))} instead.`);if(!Pe(w,["string","array"]))throw new Oi(`Expected second argument to be of type array or string, but found ${Qn(Wt(w))} instead.`);return w.indexOf(f)>=0}eachChild(l){l(this.needle),l(this.haystack)}outputDefined(){return!0}}class ya{constructor(l,f,w){this.type=Ii,this.needle=l,this.haystack=f,this.fromIndex=w}static parse(l,f){if(l.length<=2||l.length>=5)return f.error(`Expected 3 or 4 arguments, but found ${l.length-1} instead.`);const w=f.parse(l[1],1,Ui),I=f.parse(l[2],2,Ui);if(!w||!I)return null;if(!Ee(w.type,[Ot,bn,Ii,nr,Ui]))return f.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qn(w.type)} instead`);if(l.length===4){const U=f.parse(l[3],3,Ii);return U?new ya(w,I,U):null}return new ya(w,I)}evaluate(l){const f=this.needle.evaluate(l),w=this.haystack.evaluate(l);if(!Pe(f,["boolean","string","number","null"]))throw new Oi(`Expected first argument to be of type boolean, string, number or null, but found ${Qn(Wt(f))} instead.`);if(!Pe(w,["string","array"]))throw new Oi(`Expected second argument to be of type array or string, but found ${Qn(Wt(w))} instead.`);if(this.fromIndex){const I=this.fromIndex.evaluate(l);return w.indexOf(f,I)}return w.indexOf(f)}eachChild(l){l(this.needle),l(this.haystack),this.fromIndex&&l(this.fromIndex)}outputDefined(){return!1}}class zc{constructor(l,f,w,I,U,N){this.inputType=l,this.type=f,this.input=w,this.cases=I,this.outputs=U,this.otherwise=N}static parse(l,f){if(l.length<5)return f.error(`Expected at least 4 arguments, but found only ${l.length-1}.`);if(l.length%2!=1)return f.error("Expected an even number of arguments.");let w,I;f.expectedType&&f.expectedType.kind!=="value"&&(I=f.expectedType);const U={},N=[];for(let ge=2;geNumber.MAX_SAFE_INTEGER)return ke.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof Ze=="number"&&Math.floor(Ze)!==Ze)return ke.error("Numeric branch labels must be integer values.");if(w){if(ke.checkSubtype(w,Wt(Ze)))return null}else w=Wt(Ze);if(U[String(Ze)]!==void 0)return ke.error("Branch labels must be unique.");U[String(Ze)]=N.length}const $e=f.parse(Ie,ge,I);if(!$e)return null;I=I||$e.type,N.push($e)}const Z=f.parse(l[1],1,Ui);if(!Z)return null;const re=f.parse(l[l.length-1],l.length-1,I);return re?Z.type.kind!=="value"&&f.concat(1).checkSubtype(w,Z.type)?null:new zc(w,I,Z,U,N,re):null}evaluate(l){const f=this.input.evaluate(l);return(Wt(f)===this.inputType&&this.outputs[this.cases[f]]||this.otherwise).evaluate(l)}eachChild(l){l(this.input),this.outputs.forEach(l),l(this.otherwise)}outputDefined(){return this.outputs.every(l=>l.outputDefined())&&this.otherwise.outputDefined()}}class Ws{constructor(l,f,w){this.type=l,this.branches=f,this.otherwise=w}static parse(l,f){if(l.length<4)return f.error(`Expected at least 3 arguments, but found only ${l.length-1}.`);if(l.length%2!=0)return f.error("Expected an odd number of arguments.");let w;f.expectedType&&f.expectedType.kind!=="value"&&(w=f.expectedType);const I=[];for(let N=1;Nf.outputDefined())&&this.otherwise.outputDefined()}}class cc{constructor(l,f,w,I){this.type=l,this.input=f,this.beginIndex=w,this.endIndex=I}static parse(l,f){if(l.length<=2||l.length>=5)return f.error(`Expected 3 or 4 arguments, but found ${l.length-1} instead.`);const w=f.parse(l[1],1,Ui),I=f.parse(l[2],2,Ii);if(!w||!I)return null;if(!Ee(w.type,[kr(Ui),bn,Ui]))return f.error(`Expected first argument to be of type array or string, but found ${Qn(w.type)} instead`);if(l.length===4){const U=f.parse(l[3],3,Ii);return U?new cc(w.type,w,I,U):null}return new cc(w.type,w,I)}evaluate(l){const f=this.input.evaluate(l),w=this.beginIndex.evaluate(l);if(!Pe(f,["string","array"]))throw new Oi(`Expected first argument to be of type array or string, but found ${Qn(Wt(f))} instead.`);if(this.endIndex){const I=this.endIndex.evaluate(l);return f.slice(w,I)}return f.slice(w)}eachChild(l){l(this.input),l(this.beginIndex),this.endIndex&&l(this.endIndex)}outputDefined(){return!1}}function kc(A,l){return A==="=="||A==="!="?l.kind==="boolean"||l.kind==="string"||l.kind==="number"||l.kind==="null"||l.kind==="value":l.kind==="string"||l.kind==="number"||l.kind==="value"}function eA(A,l,f,w){return w.compare(l,f)===0}function hc(A,l,f){const w=A!=="=="&&A!=="!=";return class PM{constructor(U,N,Z){this.type=Ot,this.lhs=U,this.rhs=N,this.collator=Z,this.hasUntypedArgument=U.type.kind==="value"||N.type.kind==="value"}static parse(U,N){if(U.length!==3&&U.length!==4)return N.error("Expected two or three arguments.");const Z=U[0];let re=N.parse(U[1],1,Ui);if(!re)return null;if(!kc(Z,re.type))return N.concat(1).error(`"${Z}" comparisons are not supported for type '${Qn(re.type)}'.`);let ge=N.parse(U[2],2,Ui);if(!ge)return null;if(!kc(Z,ge.type))return N.concat(2).error(`"${Z}" comparisons are not supported for type '${Qn(ge.type)}'.`);if(re.type.kind!==ge.type.kind&&re.type.kind!=="value"&&ge.type.kind!=="value")return N.error(`Cannot compare types '${Qn(re.type)}' and '${Qn(ge.type)}'.`);w&&(re.type.kind==="value"&&ge.type.kind!=="value"?re=new tn(ge.type,[re]):re.type.kind!=="value"&&ge.type.kind==="value"&&(ge=new tn(re.type,[ge])));let Ce=null;if(U.length===4){if(re.type.kind!=="string"&&ge.type.kind!=="string"&&re.type.kind!=="value"&&ge.type.kind!=="value")return N.error("Cannot use collator to compare non-string types.");if(Ce=N.parse(U[3],3,Pn),!Ce)return null}return new PM(re,ge,Ce)}evaluate(U){const N=this.lhs.evaluate(U),Z=this.rhs.evaluate(U);if(w&&this.hasUntypedArgument){const re=Wt(N),ge=Wt(Z);if(re.kind!==ge.kind||re.kind!=="string"&&re.kind!=="number")throw new Oi(`Expected arguments for "${A}" to be (string, string) or (number, number), but found (${re.kind}, ${ge.kind}) instead.`)}if(this.collator&&!w&&this.hasUntypedArgument){const re=Wt(N),ge=Wt(Z);if(re.kind!=="string"||ge.kind!=="string")return l(U,N,Z)}return this.collator?f(U,N,Z,this.collator.evaluate(U)):l(U,N,Z)}eachChild(U){U(this.lhs),U(this.rhs),this.collator&&U(this.collator)}outputDefined(){return!0}}}const gu=hc("==",function(A,l,f){return l===f},eA),ed=hc("!=",function(A,l,f){return l!==f},function(A,l,f,w){return!eA(0,l,f,w)}),_u=hc("<",function(A,l,f){return l",function(A,l,f){return l>f},function(A,l,f,w){return w.compare(l,f)>0}),tA=hc("<=",function(A,l,f){return l<=f},function(A,l,f,w){return w.compare(l,f)<=0}),td=hc(">=",function(A,l,f){return l>=f},function(A,l,f,w){return w.compare(l,f)>=0});class uc{constructor(l,f,w,I,U){this.type=bn,this.number=l,this.locale=f,this.currency=w,this.minFractionDigits=I,this.maxFractionDigits=U}static parse(l,f){if(l.length!==3)return f.error("Expected two arguments.");const w=f.parse(l[1],1,Ii);if(!w)return null;const I=l[2];if(typeof I!="object"||Array.isArray(I))return f.error("NumberFormat options argument must be an object.");let U=null;if(I.locale&&(U=f.parse(I.locale,1,bn),!U))return null;let N=null;if(I.currency&&(N=f.parse(I.currency,1,bn),!N))return null;let Z=null;if(I["min-fraction-digits"]&&(Z=f.parse(I["min-fraction-digits"],1,Ii),!Z))return null;let re=null;return I["max-fraction-digits"]&&(re=f.parse(I["max-fraction-digits"],1,Ii),!re)?null:new uc(w,U,N,Z,re)}evaluate(l){return new Intl.NumberFormat(this.locale?this.locale.evaluate(l):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(l):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(l):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(l):void 0}).format(this.number.evaluate(l))}eachChild(l){l(this.number),this.locale&&l(this.locale),this.currency&&l(this.currency),this.minFractionDigits&&l(this.minFractionDigits),this.maxFractionDigits&&l(this.maxFractionDigits)}outputDefined(){return!1}}class Oc{constructor(l){this.type=qn,this.sections=l}static parse(l,f){if(l.length<2)return f.error("Expected at least one argument.");const w=l[1];if(!Array.isArray(w)&&typeof w=="object")return f.error("First argument must be an image or text section.");const I=[];let U=!1;for(let N=1;N<=l.length-1;++N){const Z=l[N];if(U&&typeof Z=="object"&&!Array.isArray(Z)){U=!1;let re=null;if(Z["font-scale"]&&(re=f.parse(Z["font-scale"],1,Ii),!re))return null;let ge=null;if(Z["text-font"]&&(ge=f.parse(Z["text-font"],1,kr(bn)),!ge))return null;let Ce=null;if(Z["text-color"]&&(Ce=f.parse(Z["text-color"],1,wi),!Ce))return null;const Ie=I[I.length-1];Ie.scale=re,Ie.font=ge,Ie.textColor=Ce}else{const re=f.parse(l[N],1,Ui);if(!re)return null;const ge=re.type.kind;if(ge!=="string"&&ge!=="value"&&ge!=="null"&&ge!=="resolvedImage")return f.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");U=!0,I.push({content:re,scale:null,font:null,textColor:null})}}return new Oc(I)}evaluate(l){return new He(this.sections.map(f=>{const w=f.content.evaluate(l);return Wt(w)===fr?new tt("",w,null,null,null):new tt(ki(w),null,f.scale?f.scale.evaluate(l):null,f.font?f.font.evaluate(l).join(","):null,f.textColor?f.textColor.evaluate(l):null)}))}eachChild(l){for(const f of this.sections)l(f.content),f.scale&&l(f.scale),f.font&&l(f.font),f.textColor&&l(f.textColor)}outputDefined(){return!1}}class ul{constructor(l){this.type=fr,this.input=l}static parse(l,f){if(l.length!==2)return f.error("Expected two arguments.");const w=f.parse(l[1],1,bn);return w?new ul(w):f.error("No image name provided.")}evaluate(l){const f=this.input.evaluate(l),w=pt.fromString(f);return w&&l.availableImages&&(w.available=l.availableImages.indexOf(f)>-1),w}eachChild(l){l(this.input)}outputDefined(){return!1}}class Ir{constructor(l){this.type=Ii,this.input=l}static parse(l,f){if(l.length!==2)return f.error(`Expected 1 argument, but found ${l.length-1} instead.`);const w=f.parse(l[1],1);return w?w.type.kind!=="array"&&w.type.kind!=="string"&&w.type.kind!=="value"?f.error(`Expected argument of type string or array, but found ${Qn(w.type)} instead.`):new Ir(w):null}evaluate(l){const f=this.input.evaluate(l);if(typeof f=="string"||Array.isArray(f))return f.length;throw new Oi(`Expected value to be of type string or array, but found ${Qn(Wt(f))} instead.`)}eachChild(l){l(this.input)}outputDefined(){return!1}}const Ac={"==":gu,"!=":ed,">":Ih,"<":_u,">=":td,"<=":tA,array:tn,at:mu,boolean:tn,case:Ws,coalesce:Qa,collator:Wr,format:Oc,image:ul,in:Vl,"index-of":ya,interpolate:Vo,"interpolate-hcl":Vo,"interpolate-lab":Vo,length:Ir,let:lc,literal:bi,match:zc,number:tn,"number-format":uc,object:tn,slice:cc,step:Ql,string:tn,"to-boolean":yn,"to-color":yn,"to-number":yn,"to-string":yn,var:kl,within:ho};function Nc(A,[l,f,w,I]){l=l.evaluate(A),f=f.evaluate(A),w=w.evaluate(A);const U=I?I.evaluate(A):1,N=Lt(l,f,w,U);if(N)throw new Oi(N);return new de(l/255*U,f/255*U,w/255*U,U)}function yu(A,l){return A in l}function Al(A,l){const f=l[A];return f===void 0?null:f}function Va(A){return{type:A}}function Qc(A){return{result:"success",value:A}}function dl(A){return{result:"error",value:A}}function qr(A){return A["property-type"]==="data-driven"||A["property-type"]==="cross-faded-data-driven"}function Fh(A){return!!A.expression&&A.expression.parameters.indexOf("zoom")>-1}function hr(A){return!!A.expression&&A.expression.interpolated}function Br(A){return A instanceof Number?"number":A instanceof String?"string":A instanceof Boolean?"boolean":Array.isArray(A)?"array":A===null?"null":typeof A}function jr(A){return typeof A=="object"&&A!==null&&!Array.isArray(A)}function $r(A){return A}function Hl(A,l){const f=l.type==="color",w=A.stops&&typeof A.stops[0][0]=="object",I=w||!(w||A.property!==void 0),U=A.type||(hr(l)?"exponential":"interval");if(f||l.type==="padding"){const ge=f?de.parse:et.parse;(A=hn({},A)).stops&&(A.stops=A.stops.map(Ce=>[Ce[0],ge(Ce[1])])),A.default=ge(A.default?A.default:l.default)}if(A.colorSpace&&A.colorSpace!=="rgb"&&!Sh[A.colorSpace])throw new Error(`Unknown color space: ${A.colorSpace}`);let N,Z,re;if(U==="exponential")N=nA;else if(U==="interval")N=iA;else if(U==="categorical"){N=xu,Z=Object.create(null);for(const ge of A.stops)Z[ge[0]]=ge[1];re=typeof A.stops[0][0]}else{if(U!=="identity")throw new Error(`Unknown function type "${U}"`);N=rA}if(w){const ge={},Ce=[];for(let $e=0;$e$e[0]),evaluate:({zoom:$e},Ze)=>nA({stops:Ie,base:A.base},l,$e).evaluate($e,Ze)}}if(I){const ge=U==="exponential"?{name:"exponential",base:A.base!==void 0?A.base:1}:null;return{kind:"camera",interpolationType:ge,interpolationFactor:Vo.interpolationFactor.bind(void 0,ge),zoomStops:A.stops.map(Ce=>Ce[0]),evaluate:({zoom:Ce})=>N(A,l,Ce,Z,re)}}return{kind:"source",evaluate(ge,Ce){const Ie=Ce&&Ce.properties?Ce.properties[A.property]:void 0;return Ie===void 0?gr(A.default,l.default):N(A,l,Ie,Z,re)}}}function gr(A,l,f){return A!==void 0?A:l!==void 0?l:f!==void 0?f:void 0}function xu(A,l,f,w,I){return gr(typeof f===I?w[f]:void 0,A.default,l.default)}function iA(A,l,f){if(Br(f)!=="number")return gr(A.default,l.default);const w=A.stops.length;if(w===1||f<=A.stops[0][0])return A.stops[0][1];if(f>=A.stops[w-1][0])return A.stops[w-1][1];const I=Nl(A.stops.map(U=>U[0]),f);return A.stops[I][1]}function nA(A,l,f){const w=A.base!==void 0?A.base:1;if(Br(f)!=="number")return gr(A.default,l.default);const I=A.stops.length;if(I===1||f<=A.stops[0][0])return A.stops[0][1];if(f>=A.stops[I-1][0])return A.stops[I-1][1];const U=Nl(A.stops.map(Ce=>Ce[0]),f),N=function(Ce,Ie,ke,$e){const Ze=$e-ke,Rt=Ce-ke;return Ze===0?0:Ie===1?Rt/Ze:(Math.pow(Ie,Rt)-1)/(Math.pow(Ie,Ze)-1)}(f,w,A.stops[U][0],A.stops[U+1][0]),Z=A.stops[U][1],re=A.stops[U+1][1];let ge=Ys[l.type]||$r;if(A.colorSpace&&A.colorSpace!=="rgb"){const Ce=Sh[A.colorSpace];ge=(Ie,ke)=>Ce.reverse(Ce.interpolate(Ce.forward(Ie),Ce.forward(ke),N))}return typeof Z.evaluate=="function"?{evaluate(...Ce){const Ie=Z.evaluate.apply(void 0,Ce),ke=re.evaluate.apply(void 0,Ce);if(Ie!==void 0&&ke!==void 0)return ge(Ie,ke,N)}}:ge(Z,re,N)}function rA(A,l,f){switch(l.type){case"color":f=de.parse(f);break;case"formatted":f=He.fromString(f.toString());break;case"resolvedImage":f=pt.fromString(f.toString());break;case"padding":f=et.parse(f);break;default:Br(f)===l.type||l.type==="enum"&&l.values[f]||(f=void 0)}return gr(f,A.default,l.default)}Yn.register(Ac,{error:[{kind:"error"},[bn],(A,[l])=>{throw new Oi(l.evaluate(A))}],typeof:[bn,[Ui],(A,[l])=>Qn(Wt(l.evaluate(A)))],"to-rgba":[kr(Ii,4),[wi],(A,[l])=>l.evaluate(A).toArray()],rgb:[wi,[Ii,Ii,Ii],Nc],rgba:[wi,[Ii,Ii,Ii,Ii],Nc],has:{type:Ot,overloads:[[[bn],(A,[l])=>yu(l.evaluate(A),A.properties())],[[bn,Wi],(A,[l,f])=>yu(l.evaluate(A),f.evaluate(A))]]},get:{type:Ui,overloads:[[[bn],(A,[l])=>Al(l.evaluate(A),A.properties())],[[bn,Wi],(A,[l,f])=>Al(l.evaluate(A),f.evaluate(A))]]},"feature-state":[Ui,[bn],(A,[l])=>Al(l.evaluate(A),A.featureState||{})],properties:[Wi,[],A=>A.properties()],"geometry-type":[bn,[],A=>A.geometryType()],id:[Ui,[],A=>A.id()],zoom:[Ii,[],A=>A.globals.zoom],"heatmap-density":[Ii,[],A=>A.globals.heatmapDensity||0],"line-progress":[Ii,[],A=>A.globals.lineProgress||0],accumulated:[Ui,[],A=>A.globals.accumulated===void 0?null:A.globals.accumulated],"+":[Ii,Va(Ii),(A,l)=>{let f=0;for(const w of l)f+=w.evaluate(A);return f}],"*":[Ii,Va(Ii),(A,l)=>{let f=1;for(const w of l)f*=w.evaluate(A);return f}],"-":{type:Ii,overloads:[[[Ii,Ii],(A,[l,f])=>l.evaluate(A)-f.evaluate(A)],[[Ii],(A,[l])=>-l.evaluate(A)]]},"/":[Ii,[Ii,Ii],(A,[l,f])=>l.evaluate(A)/f.evaluate(A)],"%":[Ii,[Ii,Ii],(A,[l,f])=>l.evaluate(A)%f.evaluate(A)],ln2:[Ii,[],()=>Math.LN2],pi:[Ii,[],()=>Math.PI],e:[Ii,[],()=>Math.E],"^":[Ii,[Ii,Ii],(A,[l,f])=>Math.pow(l.evaluate(A),f.evaluate(A))],sqrt:[Ii,[Ii],(A,[l])=>Math.sqrt(l.evaluate(A))],log10:[Ii,[Ii],(A,[l])=>Math.log(l.evaluate(A))/Math.LN10],ln:[Ii,[Ii],(A,[l])=>Math.log(l.evaluate(A))],log2:[Ii,[Ii],(A,[l])=>Math.log(l.evaluate(A))/Math.LN2],sin:[Ii,[Ii],(A,[l])=>Math.sin(l.evaluate(A))],cos:[Ii,[Ii],(A,[l])=>Math.cos(l.evaluate(A))],tan:[Ii,[Ii],(A,[l])=>Math.tan(l.evaluate(A))],asin:[Ii,[Ii],(A,[l])=>Math.asin(l.evaluate(A))],acos:[Ii,[Ii],(A,[l])=>Math.acos(l.evaluate(A))],atan:[Ii,[Ii],(A,[l])=>Math.atan(l.evaluate(A))],min:[Ii,Va(Ii),(A,l)=>Math.min(...l.map(f=>f.evaluate(A)))],max:[Ii,Va(Ii),(A,l)=>Math.max(...l.map(f=>f.evaluate(A)))],abs:[Ii,[Ii],(A,[l])=>Math.abs(l.evaluate(A))],round:[Ii,[Ii],(A,[l])=>{const f=l.evaluate(A);return f<0?-Math.round(-f):Math.round(f)}],floor:[Ii,[Ii],(A,[l])=>Math.floor(l.evaluate(A))],ceil:[Ii,[Ii],(A,[l])=>Math.ceil(l.evaluate(A))],"filter-==":[Ot,[bn,Ui],(A,[l,f])=>A.properties()[l.value]===f.value],"filter-id-==":[Ot,[Ui],(A,[l])=>A.id()===l.value],"filter-type-==":[Ot,[bn],(A,[l])=>A.geometryType()===l.value],"filter-<":[Ot,[bn,Ui],(A,[l,f])=>{const w=A.properties()[l.value],I=f.value;return typeof w==typeof I&&w{const f=A.id(),w=l.value;return typeof f==typeof w&&f":[Ot,[bn,Ui],(A,[l,f])=>{const w=A.properties()[l.value],I=f.value;return typeof w==typeof I&&w>I}],"filter-id->":[Ot,[Ui],(A,[l])=>{const f=A.id(),w=l.value;return typeof f==typeof w&&f>w}],"filter-<=":[Ot,[bn,Ui],(A,[l,f])=>{const w=A.properties()[l.value],I=f.value;return typeof w==typeof I&&w<=I}],"filter-id-<=":[Ot,[Ui],(A,[l])=>{const f=A.id(),w=l.value;return typeof f==typeof w&&f<=w}],"filter->=":[Ot,[bn,Ui],(A,[l,f])=>{const w=A.properties()[l.value],I=f.value;return typeof w==typeof I&&w>=I}],"filter-id->=":[Ot,[Ui],(A,[l])=>{const f=A.id(),w=l.value;return typeof f==typeof w&&f>=w}],"filter-has":[Ot,[Ui],(A,[l])=>l.value in A.properties()],"filter-has-id":[Ot,[],A=>A.id()!==null&&A.id()!==void 0],"filter-type-in":[Ot,[kr(bn)],(A,[l])=>l.value.indexOf(A.geometryType())>=0],"filter-id-in":[Ot,[kr(Ui)],(A,[l])=>l.value.indexOf(A.id())>=0],"filter-in-small":[Ot,[bn,kr(Ui)],(A,[l,f])=>f.value.indexOf(A.properties()[l.value])>=0],"filter-in-large":[Ot,[bn,kr(Ui)],(A,[l,f])=>function(w,I,U,N){for(;U<=N;){const Z=U+N>>1;if(I[Z]===w)return!0;I[Z]>w?N=Z-1:U=Z+1}return!1}(A.properties()[l.value],f.value,0,f.value.length-1)],all:{type:Ot,overloads:[[[Ot,Ot],(A,[l,f])=>l.evaluate(A)&&f.evaluate(A)],[Va(Ot),(A,l)=>{for(const f of l)if(!f.evaluate(A))return!1;return!0}]]},any:{type:Ot,overloads:[[[Ot,Ot],(A,[l,f])=>l.evaluate(A)||f.evaluate(A)],[Va(Ot),(A,l)=>{for(const f of l)if(f.evaluate(A))return!0;return!1}]]},"!":[Ot,[Ot],(A,[l])=>!l.evaluate(A)],"is-supported-script":[Ot,[bn],(A,[l])=>{const f=A.globals&&A.globals.isSupportedScript;return!f||f(l.evaluate(A))}],upcase:[bn,[bn],(A,[l])=>l.evaluate(A).toUpperCase()],downcase:[bn,[bn],(A,[l])=>l.evaluate(A).toLowerCase()],concat:[bn,Va(Ui),(A,l)=>l.map(f=>ki(f.evaluate(A))).join("")],"resolved-locale":[bn,[Pn],(A,[l])=>l.evaluate(A).resolvedLocale()]});class dc{constructor(l,f){this.expression=l,this._warningHistory={},this._evaluator=new sr,this._defaultValue=f?function(w){return w.type==="color"&&jr(w.default)?new de(0,0,0,0):w.type==="color"?de.parse(w.default)||null:w.type==="padding"?et.parse(w.default)||null:w.default===void 0?null:w.default}(f):null,this._enumValues=f&&f.type==="enum"?f.values:null}evaluateWithoutErrorHandling(l,f,w,I,U,N){return this._evaluator.globals=l,this._evaluator.feature=f,this._evaluator.featureState=w,this._evaluator.canonical=I,this._evaluator.availableImages=U||null,this._evaluator.formattedSection=N,this.expression.evaluate(this._evaluator)}evaluate(l,f,w,I,U,N){this._evaluator.globals=l,this._evaluator.feature=f||null,this._evaluator.featureState=w||null,this._evaluator.canonical=I,this._evaluator.availableImages=U||null,this._evaluator.formattedSection=N||null;try{const Z=this.expression.evaluate(this._evaluator);if(Z==null||typeof Z=="number"&&Z!=Z)return this._defaultValue;if(this._enumValues&&!(Z in this._enumValues))throw new Oi(`Expected value to be one of ${Object.keys(this._enumValues).map(re=>JSON.stringify(re)).join(", ")}, but found ${JSON.stringify(Z)} instead.`);return Z}catch(Z){return this._warningHistory[Z.message]||(this._warningHistory[Z.message]=!0,typeof console<"u"&&console.warn(Z.message)),this._defaultValue}}}function Vc(A){return Array.isArray(A)&&A.length>0&&typeof A[0]=="string"&&A[0]in Ac}function Hc(A,l){const f=new Ol(Ac,[],l?function(I){const U={color:wi,string:bn,number:Ii,enum:bn,boolean:Ot,formatted:qn,padding:Hr,resolvedImage:fr};return I.type==="array"?kr(U[I.value]||Ui,I.length):U[I.type]}(l):void 0),w=f.parse(A,void 0,void 0,void 0,l&&l.type==="string"?{typeAnnotation:"coerce"}:void 0);return w?Qc(new dc(w,l)):dl(f.errors)}class Lh{constructor(l,f){this.kind=l,this._styleExpression=f,this.isStateDependent=l!=="constant"&&!Oa(f.expression)}evaluateWithoutErrorHandling(l,f,w,I,U,N){return this._styleExpression.evaluateWithoutErrorHandling(l,f,w,I,U,N)}evaluate(l,f,w,I,U,N){return this._styleExpression.evaluate(l,f,w,I,U,N)}}class Gc{constructor(l,f,w,I){this.kind=l,this.zoomStops=w,this._styleExpression=f,this.isStateDependent=l!=="camera"&&!Oa(f.expression),this.interpolationType=I}evaluateWithoutErrorHandling(l,f,w,I,U,N){return this._styleExpression.evaluateWithoutErrorHandling(l,f,w,I,U,N)}evaluate(l,f,w,I,U,N){return this._styleExpression.evaluate(l,f,w,I,U,N)}interpolationFactor(l,f,w){return this.interpolationType?Vo.interpolationFactor(this.interpolationType,l,f,w):0}}function Dh(A,l){const f=Hc(A,l);if(f.result==="error")return f;const w=f.value.expression,I=cl(w);if(!I&&!qr(l))return dl([new Cn("","data expressions not supported")]);const U=zl(w,["zoom"]);if(!U&&!Fh(l))return dl([new Cn("","zoom expressions not supported")]);const N=jc(w);return N||U?N instanceof Cn?dl([N]):N instanceof Vo&&!hr(l)?dl([new Cn("",'"interpolate" expressions cannot be used with this property')]):Qc(N?new Gc(I?"camera":"composite",f.value,N.labels,N instanceof Vo?N.interpolation:void 0):new Lh(I?"constant":"source",f.value)):dl([new Cn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Wc{constructor(l,f){this._parameters=l,this._specification=f,hn(this,Hl(this._parameters,this._specification))}static deserialize(l){return new Wc(l._parameters,l._specification)}static serialize(l){return{_parameters:l._parameters,_specification:l._specification}}}function jc(A){let l=null;if(A instanceof lc)l=jc(A.result);else if(A instanceof Qa){for(const f of A.args)if(l=jc(f),l)break}else(A instanceof Ql||A instanceof Vo)&&A.input instanceof Yn&&A.input.name==="zoom"&&(l=A);return l instanceof Cn||A.eachChild(f=>{const w=jc(f);w instanceof Cn?l=w:!l&&w?l=new Cn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):l&&w&&l!==w&&(l=new Cn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),l}function la(A){const l=A.key,f=A.value,w=A.valueSpec||{},I=A.objectElementValidators||{},U=A.style,N=A.styleSpec;let Z=[];const re=Br(f);if(re!=="object")return[new at(l,f,`object expected, ${re} found`)];for(const ge in f){const Ce=ge.split(".")[0],Ie=w[Ce]||w["*"];let ke;if(I[Ce])ke=I[Ce];else if(w[Ce])ke=Mo;else if(I["*"])ke=I["*"];else{if(!w["*"]){Z.push(new at(l,f[ge],`unknown property "${ge}"`));continue}ke=Mo}Z=Z.concat(ke({key:(l&&`${l}.`)+ge,value:f[ge],valueSpec:Ie,style:U,styleSpec:N,object:f,objectKey:ge},f))}for(const ge in w)I[ge]||w[ge].required&&w[ge].default===void 0&&f[ge]===void 0&&Z.push(new at(l,f,`missing required property "${ge}"`));return Z}function sA(A){const l=A.value,f=A.valueSpec,w=A.style,I=A.styleSpec,U=A.key,N=A.arrayElementValidator||Mo;if(Br(l)!=="array")return[new at(U,l,`array expected, ${Br(l)} found`)];if(f.length&&l.length!==f.length)return[new at(U,l,`array length ${f.length} expected, length ${l.length} found`)];if(f["min-length"]&&l.lengthw.maximum?[new at(l,f,`${f} is greater than the maximum value ${w.maximum}`)]:[]}function Kc(A){const l=A.valueSpec,f=Xi(A.value.type);let w,I,U,N={};const Z=f!=="categorical"&&A.value.property===void 0,re=!Z,ge=Br(A.value.stops)==="array"&&Br(A.value.stops[0])==="array"&&Br(A.value.stops[0][0])==="object",Ce=la({key:A.key,value:A.value,valueSpec:A.styleSpec.function,style:A.style,styleSpec:A.styleSpec,objectElementValidators:{stops:function($e){if(f==="identity")return[new at($e.key,$e.value,'identity function may not have a "stops" property')];let Ze=[];const Rt=$e.value;return Ze=Ze.concat(sA({key:$e.key,value:Rt,valueSpec:$e.valueSpec,style:$e.style,styleSpec:$e.styleSpec,arrayElementValidator:Ie})),Br(Rt)==="array"&&Rt.length===0&&Ze.push(new at($e.key,Rt,"array must have at least one stop")),Ze},default:function($e){return Mo({key:$e.key,value:$e.value,valueSpec:l,style:$e.style,styleSpec:$e.styleSpec})}}});return f==="identity"&&Z&&Ce.push(new at(A.key,A.value,'missing required property "property"')),f==="identity"||A.value.stops||Ce.push(new at(A.key,A.value,'missing required property "stops"')),f==="exponential"&&A.valueSpec.expression&&!hr(A.valueSpec)&&Ce.push(new at(A.key,A.value,"exponential functions not supported")),A.styleSpec.$version>=8&&(re&&!qr(A.valueSpec)?Ce.push(new at(A.key,A.value,"property functions not supported")):Z&&!Fh(A.valueSpec)&&Ce.push(new at(A.key,A.value,"zoom functions not supported"))),f!=="categorical"&&!ge||A.value.property!==void 0||Ce.push(new at(A.key,A.value,'"property" property is required')),Ce;function Ie($e){let Ze=[];const Rt=$e.value,Mt=$e.key;if(Br(Rt)!=="array")return[new at(Mt,Rt,`array expected, ${Br(Rt)} found`)];if(Rt.length!==2)return[new at(Mt,Rt,`array length 2 expected, length ${Rt.length} found`)];if(ge){if(Br(Rt[0])!=="object")return[new at(Mt,Rt,`object expected, ${Br(Rt[0])} found`)];if(Rt[0].zoom===void 0)return[new at(Mt,Rt,"object stop key must have zoom")];if(Rt[0].value===void 0)return[new at(Mt,Rt,"object stop key must have value")];if(U&&U>Xi(Rt[0].zoom))return[new at(Mt,Rt[0].zoom,"stop zoom values must appear in ascending order")];Xi(Rt[0].zoom)!==U&&(U=Xi(Rt[0].zoom),I=void 0,N={}),Ze=Ze.concat(la({key:`${Mt}[0]`,value:Rt[0],valueSpec:{zoom:{}},style:$e.style,styleSpec:$e.styleSpec,objectElementValidators:{zoom:oA,value:ke}}))}else Ze=Ze.concat(ke({key:`${Mt}[0]`,value:Rt[0],valueSpec:{},style:$e.style,styleSpec:$e.styleSpec},Rt));return Vc(on(Rt[1]))?Ze.concat([new at(`${Mt}[1]`,Rt[1],"expressions are not allowed in function stops.")]):Ze.concat(Mo({key:`${Mt}[1]`,value:Rt[1],valueSpec:l,style:$e.style,styleSpec:$e.styleSpec}))}function ke($e,Ze){const Rt=Br($e.value),Mt=Xi($e.value),ri=$e.value!==null?$e.value:Ze;if(w){if(Rt!==w)return[new at($e.key,ri,`${Rt} stop domain type must match previous stop domain type ${w}`)]}else w=Rt;if(Rt!=="number"&&Rt!=="string"&&Rt!=="boolean")return[new at($e.key,ri,"stop domain value must be a number, string, or boolean")];if(Rt!=="number"&&f!=="categorical"){let mi=`number expected, ${Rt} found`;return qr(l)&&f===void 0&&(mi+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new at($e.key,ri,mi)]}return f!=="categorical"||Rt!=="number"||isFinite(Mt)&&Math.floor(Mt)===Mt?f!=="categorical"&&Rt==="number"&&I!==void 0&&Mtnew at(`${A.key}${w.key}`,A.value,w.message));const f=l.value.expression||l.value._styleExpression.expression;if(A.expressionContext==="property"&&A.propertyKey==="text-font"&&!f.outputDefined())return[new at(A.key,A.value,`Invalid data expression for "${A.propertyKey}". Output values must be contained as literals within the expression.`)];if(A.expressionContext==="property"&&A.propertyType==="layout"&&!Oa(f))return[new at(A.key,A.value,'"feature-state" data expressions are not supported with layout properties.')];if(A.expressionContext==="filter"&&!Oa(f))return[new at(A.key,A.value,'"feature-state" data expressions are not supported with filters.')];if(A.expressionContext&&A.expressionContext.indexOf("cluster")===0){if(!zl(f,["zoom","feature-state"]))return[new at(A.key,A.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(A.expressionContext==="cluster-initial"&&!cl(f))return[new at(A.key,A.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function $c(A){const l=A.key,f=A.value,w=A.valueSpec,I=[];return Array.isArray(w.values)?w.values.indexOf(Xi(f))===-1&&I.push(new at(l,f,`expected one of [${w.values.join(", ")}], ${JSON.stringify(f)} found`)):Object.keys(w.values).indexOf(Xi(f))===-1&&I.push(new at(l,f,`expected one of [${Object.keys(w.values).join(", ")}], ${JSON.stringify(f)} found`)),I}function pl(A){if(A===!0||A===!1)return!0;if(!Array.isArray(A)||A.length===0)return!1;switch(A[0]){case"has":return A.length>=2&&A[1]!=="$id"&&A[1]!=="$type";case"in":return A.length>=3&&(typeof A[1]!="string"||Array.isArray(A[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return A.length!==3||Array.isArray(A[1])||Array.isArray(A[2]);case"any":case"all":for(const l of A.slice(1))if(!pl(l)&&typeof l!="boolean")return!1;return!0;default:return!0}}const aA={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Ho(A){if(A==null)return{filter:()=>!0,needGeometry:!1};pl(A)||(A=Gl(A));const l=Hc(A,aA);if(l.result==="error")throw new Error(l.value.map(f=>`${f.key}: ${f.message}`).join(", "));return{filter:(f,w,I)=>l.value.evaluate(f,w,{},I),needGeometry:vu(A)}}function Ph(A,l){return Al?1:0}function vu(A){if(!Array.isArray(A))return!1;if(A[0]==="within")return!0;for(let l=1;l"||l==="<="||l===">="?wu(A[1],A[2],l):l==="any"?(f=A.slice(1),["any"].concat(f.map(Gl))):l==="all"?["all"].concat(A.slice(1).map(Gl)):l==="none"?["all"].concat(A.slice(1).map(Gl).map(fl)):l==="in"?Zc(A[1],A.slice(2)):l==="!in"?fl(Zc(A[1],A.slice(2))):l==="has"?Xc(A[1]):l==="!has"?fl(Xc(A[1])):l!=="within"||A;var f}function wu(A,l,f){switch(A){case"$type":return[`filter-type-${f}`,l];case"$id":return[`filter-id-${f}`,l];default:return[`filter-${f}`,A,l]}}function Zc(A,l){if(l.length===0)return!1;switch(A){case"$type":return["filter-type-in",["literal",l]];case"$id":return["filter-id-in",["literal",l]];default:return l.length>200&&!l.some(f=>typeof f!=typeof l[0])?["filter-in-large",A,["literal",l.sort(Ph)]]:["filter-in-small",A,["literal",l]]}}function Xc(A){switch(A){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",A]}}function fl(A){return["!",A]}function qc(A){return pl(on(A.value))?ca(hn({},A,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Uh(A)}function Uh(A){const l=A.value,f=A.key;if(Br(l)!=="array")return[new at(f,l,`array expected, ${Br(l)} found`)];const w=A.styleSpec;let I,U=[];if(l.length<1)return[new at(f,l,"filter array must have at least 1 element")];switch(U=U.concat($c({key:`${f}[0]`,value:l[0],valueSpec:w.filter_operator,style:A.style,styleSpec:A.styleSpec})),Xi(l[0])){case"<":case"<=":case">":case">=":l.length>=2&&Xi(l[1])==="$type"&&U.push(new at(f,l,`"$type" cannot be use with operator "${l[0]}"`));case"==":case"!=":l.length!==3&&U.push(new at(f,l,`filter array for operator "${l[0]}" must have 3 elements`));case"in":case"!in":l.length>=2&&(I=Br(l[1]),I!=="string"&&U.push(new at(`${f}[1]`,l[1],`string expected, ${I} found`)));for(let N=2;N{ge in f&&l.push(new at(w,f[ge],`"${ge}" is prohibited for ref layers`))}),I.layers.forEach(ge=>{Xi(ge.id)===Z&&(re=ge)}),re?re.ref?l.push(new at(w,f.ref,"ref cannot reference another ref layer")):N=Xi(re.type):l.push(new at(w,f.ref,`ref layer "${Z}" not found`))}else if(N!=="background")if(f.source){const re=I.sources&&I.sources[f.source],ge=re&&Xi(re.type);re?ge==="vector"&&N==="raster"?l.push(new at(w,f.source,`layer "${f.id}" requires a raster source`)):ge==="raster"&&N!=="raster"?l.push(new at(w,f.source,`layer "${f.id}" requires a vector source`)):ge!=="vector"||f["source-layer"]?ge==="raster-dem"&&N!=="hillshade"?l.push(new at(w,f.source,"raster-dem source can only be used with layer type 'hillshade'.")):N!=="line"||!f.paint||!f.paint["line-gradient"]||ge==="geojson"&&re.lineMetrics||l.push(new at(w,f,`layer "${f.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):l.push(new at(w,f,`layer "${f.id}" must specify a "source-layer"`)):l.push(new at(w,f.source,`source "${f.source}" not found`))}else l.push(new at(w,f,'missing required property "source"'));return l=l.concat(la({key:w,value:f,valueSpec:U.layer,style:A.style,styleSpec:A.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Mo({key:`${w}.type`,value:f.type,valueSpec:U.layer.type,style:A.style,styleSpec:A.styleSpec,object:f,objectKey:"type"}),filter:qc,layout:re=>la({layer:f,key:re.key,value:re.value,style:re.style,styleSpec:re.styleSpec,objectElementValidators:{"*":ge=>id(hn({layerType:N},ge))}}),paint:re=>la({layer:f,key:re.key,value:re.value,style:re.style,styleSpec:re.styleSpec,objectElementValidators:{"*":ge=>bu(hn({layerType:N},ge))}})}})),l}function fc(A){const l=A.value,f=A.key,w=Br(l);return w!=="string"?[new at(f,l,`string expected, ${w} found`)]:[]}const Yc={promoteId:function({key:A,value:l}){if(Br(l)==="string")return fc({key:A,value:l});{const f=[];for(const w in l)f.push(...fc({key:`${A}.${w}`,value:l[w]}));return f}}};function zh(A){const l=A.value,f=A.key,w=A.styleSpec,I=A.style;if(!l.type)return[new at(f,l,'"type" is required')];const U=Xi(l.type);let N;switch(U){case"vector":case"raster":case"raster-dem":return N=la({key:f,value:l,valueSpec:w[`source_${U.replace("-","_")}`],style:A.style,styleSpec:w,objectElementValidators:Yc}),N;case"geojson":if(N=la({key:f,value:l,valueSpec:w.source_geojson,style:I,styleSpec:w,objectElementValidators:Yc}),l.cluster)for(const Z in l.clusterProperties){const[re,ge]=l.clusterProperties[Z],Ce=typeof re=="string"?[re,["accumulated"],["get",Z]]:re;N.push(...ca({key:`${f}.${Z}.map`,value:ge,expressionContext:"cluster-map"})),N.push(...ca({key:`${f}.${Z}.reduce`,value:Ce,expressionContext:"cluster-reduce"}))}return N;case"video":return la({key:f,value:l,valueSpec:w.source_video,style:I,styleSpec:w});case"image":return la({key:f,value:l,valueSpec:w.source_image,style:I,styleSpec:w});case"canvas":return[new at(f,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return $c({key:`${f}.type`,value:l.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:I,styleSpec:w})}}function Jc(A){const l=A.value,f=A.styleSpec,w=f.light,I=A.style;let U=[];const N=Br(l);if(l===void 0)return U;if(N!=="object")return U=U.concat([new at("light",l,`object expected, ${N} found`)]),U;for(const Z in l){const re=Z.match(/^(.*)-transition$/);U=U.concat(re&&w[re[1]]&&w[re[1]].transition?Mo({key:Z,value:l[Z],valueSpec:f.transition,style:I,styleSpec:f}):w[Z]?Mo({key:Z,value:l[Z],valueSpec:w[Z],style:I,styleSpec:f}):[new at(Z,l[Z],`unknown property "${Z}"`)])}return U}function So(A){const l=A.value,f=A.styleSpec,w=f.terrain,I=A.style;let U=[];const N=Br(l);if(l===void 0)return U;if(N!=="object")return U=U.concat([new at("terrain",l,`object expected, ${N} found`)]),U;for(const Z in l)U=U.concat(w[Z]?Mo({key:Z,value:l[Z],valueSpec:w[Z],style:I,styleSpec:f}):[new at(Z,l[Z],`unknown property "${Z}"`)]);return U}const xa={"*":()=>[],array:sA,boolean:function(A){const l=A.value,f=A.key,w=Br(l);return w!=="boolean"?[new at(f,l,`boolean expected, ${w} found`)]:[]},number:oA,color:function(A){const l=A.key,f=A.value,w=Br(f);return w!=="string"?[new at(l,f,`color expected, ${w} found`)]:ct(f)===null?[new at(l,f,`color expected, "${f}" found`)]:[]},constants:ii,enum:$c,filter:qc,function:Kc,layer:pc,object:la,source:zh,light:Jc,terrain:So,string:fc,formatted:function(A){return fc(A).length===0?[]:ca(A)},resolvedImage:function(A){return fc(A).length===0?[]:ca(A)},padding:function(A){const l=A.key,f=A.value;if(Br(f)==="array"){if(f.length<1||f.length>4)return[new at(l,f,`padding requires 1 to 4 values; ${f.length} values found`)];const w={type:"number"};let I=[];for(let U=0;U[]}})),A.constants&&(f=f.concat(ii({key:"constants",value:A.constants,style:A,styleSpec:l}))),rd(f)}function rd(A){return[].concat(A).sort((l,f)=>l.line-f.line)}function ml(A){return function(...l){return rd(A.apply(this,l))}}Ha.source=ml(zh),Ha.light=ml(Jc),Ha.terrain=ml(So),Ha.layer=ml(pc),Ha.filter=ml(qc),Ha.paintProperty=ml(bu),Ha.layoutProperty=ml(id);const kh=Ha,Oh=kh.light,lA=kh.paintProperty,sd=kh.layoutProperty;function Nh(A,l){let f=!1;if(l&&l.length)for(const w of l)A.fire(new qi(new Error(w.message))),f=!0;return f}class mc{constructor(l,f,w){const I=this.cells=[];if(l instanceof ArrayBuffer){this.arrayBuffer=l;const N=new Int32Array(this.arrayBuffer);l=N[0],this.d=(f=N[1])+2*(w=N[2]);for(let re=0;re=Ie[Ze+0]&&I>=Ie[Ze+1])?(Z[$e]=!0,N.push(Ce[$e])):Z[$e]=!1}}}}_forEachCell(l,f,w,I,U,N,Z,re){const ge=this._convertToCellCoord(l),Ce=this._convertToCellCoord(f),Ie=this._convertToCellCoord(w),ke=this._convertToCellCoord(I);for(let $e=ge;$e<=Ie;$e++)for(let Ze=Ce;Ze<=ke;Ze++){const Rt=this.d*Ze+$e;if((!re||re(this._convertFromCellCoord($e),this._convertFromCellCoord(Ze),this._convertFromCellCoord($e+1),this._convertFromCellCoord(Ze+1)))&&U.call(this,l,f,w,I,Rt,N,Z,re))return}}_convertFromCellCoord(l){return(l-this.padding)/this.scale}_convertToCellCoord(l){return Math.max(0,Math.min(this.d-1,Math.floor(l*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const l=this.cells,f=3+this.cells.length+1+1;let w=0;for(let N=0;N=0)continue;const N=A[U];I[U]=ha[w].shallow.indexOf(U)>=0?N:Wl(N,l)}A instanceof Error&&(I.message=A.message)}if(I.$name)throw new Error("$name property is reserved for worker serialization logic.");return w!=="Object"&&(I.$name=w),I}throw new Error("can't serialize object of type "+typeof A)}function Os(A){if(A==null||typeof A=="boolean"||typeof A=="number"||typeof A=="string"||A instanceof Boolean||A instanceof Number||A instanceof String||A instanceof Date||A instanceof RegExp||A instanceof Blob||eh(A)||le(A)||ArrayBuffer.isView(A)||A instanceof ImageData)return A;if(Array.isArray(A))return A.map(Os);if(typeof A=="object"){const l=A.$name||"Object";if(!ha[l])throw new Error(`can't deserialize unregistered class ${l}`);const{klass:f}=ha[l];if(!f)throw new Error(`can't deserialize unregistered class ${l}`);if(f.deserialize)return f.deserialize(A);const w=Object.create(f.prototype);for(const I of Object.keys(A)){if(I==="$name")continue;const U=A[I];w[I]=ha[l].shallow.indexOf(I)>=0?U:Os(U)}return w}throw new Error("can't deserialize object of type "+typeof A)}class gl{constructor(){this.first=!0}update(l,f){const w=Math.floor(l);return this.first?(this.first=!1,this.lastIntegerZoom=w,this.lastIntegerZoomTime=0,this.lastZoom=l,this.lastFloorZoom=w,!0):(this.lastFloorZoom>w?(this.lastIntegerZoom=w+1,this.lastIntegerZoomTime=f):this.lastFloorZoomA>=128&&A<=255,Arabic:A=>A>=1536&&A<=1791,"Arabic Supplement":A=>A>=1872&&A<=1919,"Arabic Extended-A":A=>A>=2208&&A<=2303,"Hangul Jamo":A=>A>=4352&&A<=4607,"Unified Canadian Aboriginal Syllabics":A=>A>=5120&&A<=5759,Khmer:A=>A>=6016&&A<=6143,"Unified Canadian Aboriginal Syllabics Extended":A=>A>=6320&&A<=6399,"General Punctuation":A=>A>=8192&&A<=8303,"Letterlike Symbols":A=>A>=8448&&A<=8527,"Number Forms":A=>A>=8528&&A<=8591,"Miscellaneous Technical":A=>A>=8960&&A<=9215,"Control Pictures":A=>A>=9216&&A<=9279,"Optical Character Recognition":A=>A>=9280&&A<=9311,"Enclosed Alphanumerics":A=>A>=9312&&A<=9471,"Geometric Shapes":A=>A>=9632&&A<=9727,"Miscellaneous Symbols":A=>A>=9728&&A<=9983,"Miscellaneous Symbols and Arrows":A=>A>=11008&&A<=11263,"CJK Radicals Supplement":A=>A>=11904&&A<=12031,"Kangxi Radicals":A=>A>=12032&&A<=12255,"Ideographic Description Characters":A=>A>=12272&&A<=12287,"CJK Symbols and Punctuation":A=>A>=12288&&A<=12351,Hiragana:A=>A>=12352&&A<=12447,Katakana:A=>A>=12448&&A<=12543,Bopomofo:A=>A>=12544&&A<=12591,"Hangul Compatibility Jamo":A=>A>=12592&&A<=12687,Kanbun:A=>A>=12688&&A<=12703,"Bopomofo Extended":A=>A>=12704&&A<=12735,"CJK Strokes":A=>A>=12736&&A<=12783,"Katakana Phonetic Extensions":A=>A>=12784&&A<=12799,"Enclosed CJK Letters and Months":A=>A>=12800&&A<=13055,"CJK Compatibility":A=>A>=13056&&A<=13311,"CJK Unified Ideographs Extension A":A=>A>=13312&&A<=19903,"Yijing Hexagram Symbols":A=>A>=19904&&A<=19967,"CJK Unified Ideographs":A=>A>=19968&&A<=40959,"Yi Syllables":A=>A>=40960&&A<=42127,"Yi Radicals":A=>A>=42128&&A<=42191,"Hangul Jamo Extended-A":A=>A>=43360&&A<=43391,"Hangul Syllables":A=>A>=44032&&A<=55215,"Hangul Jamo Extended-B":A=>A>=55216&&A<=55295,"Private Use Area":A=>A>=57344&&A<=63743,"CJK Compatibility Ideographs":A=>A>=63744&&A<=64255,"Arabic Presentation Forms-A":A=>A>=64336&&A<=65023,"Vertical Forms":A=>A>=65040&&A<=65055,"CJK Compatibility Forms":A=>A>=65072&&A<=65103,"Small Form Variants":A=>A>=65104&&A<=65135,"Arabic Presentation Forms-B":A=>A>=65136&&A<=65279,"Halfwidth and Fullwidth Forms":A=>A>=65280&&A<=65519};function th(A){for(const l of A)if(cA(l.charCodeAt(0)))return!0;return!1}function Ur(A){for(const l of A)if(!gc(l.charCodeAt(0)))return!1;return!0}function gc(A){return!(un.Arabic(A)||un["Arabic Supplement"](A)||un["Arabic Extended-A"](A)||un["Arabic Presentation Forms-A"](A)||un["Arabic Presentation Forms-B"](A))}function cA(A){return!(A!==746&&A!==747&&(A<4352||!(un["Bopomofo Extended"](A)||un.Bopomofo(A)||un["CJK Compatibility Forms"](A)&&!(A>=65097&&A<=65103)||un["CJK Compatibility Ideographs"](A)||un["CJK Compatibility"](A)||un["CJK Radicals Supplement"](A)||un["CJK Strokes"](A)||!(!un["CJK Symbols and Punctuation"](A)||A>=12296&&A<=12305||A>=12308&&A<=12319||A===12336)||un["CJK Unified Ideographs Extension A"](A)||un["CJK Unified Ideographs"](A)||un["Enclosed CJK Letters and Months"](A)||un["Hangul Compatibility Jamo"](A)||un["Hangul Jamo Extended-A"](A)||un["Hangul Jamo Extended-B"](A)||un["Hangul Jamo"](A)||un["Hangul Syllables"](A)||un.Hiragana(A)||un["Ideographic Description Characters"](A)||un.Kanbun(A)||un["Kangxi Radicals"](A)||un["Katakana Phonetic Extensions"](A)||un.Katakana(A)&&A!==12540||!(!un["Halfwidth and Fullwidth Forms"](A)||A===65288||A===65289||A===65293||A>=65306&&A<=65310||A===65339||A===65341||A===65343||A>=65371&&A<=65503||A===65507||A>=65512&&A<=65519)||!(!un["Small Form Variants"](A)||A>=65112&&A<=65118||A>=65123&&A<=65126)||un["Unified Canadian Aboriginal Syllabics"](A)||un["Unified Canadian Aboriginal Syllabics Extended"](A)||un["Vertical Forms"](A)||un["Yijing Hexagram Symbols"](A)||un["Yi Syllables"](A)||un["Yi Radicals"](A))))}function Qh(A){return!(cA(A)||function(l){return!!(un["Latin-1 Supplement"](l)&&(l===167||l===169||l===174||l===177||l===188||l===189||l===190||l===215||l===247)||un["General Punctuation"](l)&&(l===8214||l===8224||l===8225||l===8240||l===8241||l===8251||l===8252||l===8258||l===8263||l===8264||l===8265||l===8273)||un["Letterlike Symbols"](l)||un["Number Forms"](l)||un["Miscellaneous Technical"](l)&&(l>=8960&&l<=8967||l>=8972&&l<=8991||l>=8996&&l<=9e3||l===9003||l>=9085&&l<=9114||l>=9150&&l<=9165||l===9167||l>=9169&&l<=9179||l>=9186&&l<=9215)||un["Control Pictures"](l)&&l!==9251||un["Optical Character Recognition"](l)||un["Enclosed Alphanumerics"](l)||un["Geometric Shapes"](l)||un["Miscellaneous Symbols"](l)&&!(l>=9754&&l<=9759)||un["Miscellaneous Symbols and Arrows"](l)&&(l>=11026&&l<=11055||l>=11088&&l<=11097||l>=11192&&l<=11243)||un["CJK Symbols and Punctuation"](l)||un.Katakana(l)||un["Private Use Area"](l)||un["CJK Compatibility Forms"](l)||un["Small Form Variants"](l)||un["Halfwidth and Fullwidth Forms"](l)||l===8734||l===8756||l===8757||l>=9984&&l<=10087||l>=10102&&l<=10131||l===65532||l===65533)}(A))}function _c(A){return A>=1424&&A<=2303||un["Arabic Presentation Forms-A"](A)||un["Arabic Presentation Forms-B"](A)}function hA(A,l){return!(!l&&_c(A)||A>=2304&&A<=3583||A>=3840&&A<=4255||un.Khmer(A))}function uA(A){for(const l of A)if(_c(l.charCodeAt(0)))return!0;return!1}const Vh="deferred",Hh="loading",ih="loaded";let yc=null,Ms="unavailable",fo=null;const Gh=function(A){A&&typeof A=="string"&&A.indexOf("NetworkError")>-1&&(Ms="error"),yc&&yc(A)};function jl(){Kl.fire(new Ni("pluginStateChange",{pluginStatus:Ms,pluginURL:fo}))}const Kl=new en,_l=function(){return Ms},An=function(){if(Ms!==Vh||!fo)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ms=Hh,jl(),fo&&Gi({url:fo},A=>{A?Gh(A):(Ms=ih,jl())})},xs={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ms===ih||xs.applyArabicShaping!=null,isLoading:()=>Ms===Hh,setState(A){if(!Fe())throw new Error("Cannot set the state of the rtl-text-plugin when not in the web-worker context");Ms=A.pluginStatus,fo=A.pluginURL},isParsed(){if(!Fe())throw new Error("rtl-text-plugin is only parsed on the worker-threads");return xs.applyArabicShaping!=null&&xs.processBidirectionalText!=null&&xs.processStyledBidirectionalText!=null},getPluginURL(){if(!Fe())throw new Error("rtl-text-plugin url can only be queried from the worker threads");return fo}};class Zr{constructor(l,f){this.zoom=l,f?(this.now=f.now,this.fadeDuration=f.fadeDuration,this.zoomHistory=f.zoomHistory,this.transition=f.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new gl,this.transition={})}isSupportedScript(l){return function(f,w){for(const I of f)if(!hA(I.charCodeAt(0),w))return!1;return!0}(l,xs.isLoaded())}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const l=this.zoom,f=l-Math.floor(l),w=this.crossFadingFactor();return l>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:f+(1-f)*w}:{fromScale:.5,toScale:1,t:1-(1-w)*f}}}class nh{constructor(l,f){this.property=l,this.value=f,this.expression=function(w,I){if(jr(w))return new Wc(w,I);if(Vc(w)){const U=Dh(w,I);if(U.result==="error")throw new Error(U.value.map(N=>`${N.key}: ${N.message}`).join(", "));return U.value}{let U=w;return I.type==="color"&&typeof w=="string"?U=de.parse(w):I.type!=="padding"||typeof w!="number"&&!Array.isArray(w)||(U=et.parse(w)),{kind:"constant",evaluate:()=>U}}}(f===void 0?l.specification.default:f,l.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(l,f,w){return this.property.possiblyEvaluate(this,l,f,w)}}class Wh{constructor(l){this.property=l,this.value=new nh(l,void 0)}transitioned(l,f){return new AA(this.property,this.value,f,J({},l.transition,this.transition),l.now)}untransitioned(){return new AA(this.property,this.value,null,{},0)}}class xc{constructor(l){this._properties=l,this._values=Object.create(l.defaultTransitionablePropertyValues)}getValue(l){return Ae(this._values[l].value.value)}setValue(l,f){Object.prototype.hasOwnProperty.call(this._values,l)||(this._values[l]=new Wh(this._values[l].property)),this._values[l].value=new nh(this._values[l].property,f===null?void 0:Ae(f))}getTransition(l){return Ae(this._values[l].transition)}setTransition(l,f){Object.prototype.hasOwnProperty.call(this._values,l)||(this._values[l]=new Wh(this._values[l].property)),this._values[l].transition=Ae(f)||void 0}serialize(){const l={};for(const f of Object.keys(this._values)){const w=this.getValue(f);w!==void 0&&(l[f]=w);const I=this.getTransition(f);I!==void 0&&(l[`${f}-transition`]=I)}return l}transitioned(l,f){const w=new jh(this._properties);for(const I of Object.keys(this._values))w._values[I]=this._values[I].transitioned(l,f._values[I]);return w}untransitioned(){const l=new jh(this._properties);for(const f of Object.keys(this._values))l._values[f]=this._values[f].untransitioned();return l}}class AA{constructor(l,f,w,I,U){this.property=l,this.value=f,this.begin=U+I.delay||0,this.end=this.begin+I.duration||0,l.specification.transition&&(I.delay||I.duration)&&(this.prior=w)}possiblyEvaluate(l,f,w){const I=l.now||0,U=this.value.possiblyEvaluate(l,f,w),N=this.prior;if(N){if(I>this.end)return this.prior=null,U;if(this.value.isDataDriven())return this.prior=null,U;if(I=1)return 1;const ge=re*re,Ce=ge*re;return 4*(re<.5?Ce:3*(re-ge)+Ce-.75)}(Z))}}return U}}class jh{constructor(l){this._properties=l,this._values=Object.create(l.defaultTransitioningPropertyValues)}possiblyEvaluate(l,f,w){const I=new Js(this._properties);for(const U of Object.keys(this._values))I._values[U]=this._values[U].possiblyEvaluate(l,f,w);return I}hasTransition(){for(const l of Object.keys(this._values))if(this._values[l].prior)return!0;return!1}}class rh{constructor(l){this._properties=l,this._values=Object.create(l.defaultPropertyValues)}getValue(l){return Ae(this._values[l].value)}setValue(l,f){this._values[l]=new nh(this._values[l].property,f===null?void 0:Ae(f))}serialize(){const l={};for(const f of Object.keys(this._values)){const w=this.getValue(f);w!==void 0&&(l[f]=w)}return l}possiblyEvaluate(l,f,w){const I=new Js(this._properties);for(const U of Object.keys(this._values))I._values[U]=this._values[U].possiblyEvaluate(l,f,w);return I}}class uo{constructor(l,f,w){this.property=l,this.value=f,this.parameters=w}isConstant(){return this.value.kind==="constant"}constantOr(l){return this.value.kind==="constant"?this.value.value:l}evaluate(l,f,w,I){return this.property.evaluate(this.value,this.parameters,l,f,w,I)}}class Js{constructor(l){this._properties=l,this._values=Object.create(l.defaultPossiblyEvaluatedValues)}get(l){return this._values[l]}}class Fn{constructor(l){this.specification=l}possiblyEvaluate(l,f){if(l.isDataDriven())throw new Error("Value should not be data driven");return l.expression.evaluate(f)}interpolate(l,f,w){const I=Ys[this.specification.type];return I?I(l,f,w):l}}class Vn{constructor(l,f){this.specification=l,this.overrides=f}possiblyEvaluate(l,f,w,I){return new uo(this,l.expression.kind==="constant"||l.expression.kind==="camera"?{kind:"constant",value:l.expression.evaluate(f,null,{},w,I)}:l.expression,f)}interpolate(l,f,w){if(l.value.kind!=="constant"||f.value.kind!=="constant")return l;if(l.value.value===void 0||f.value.value===void 0)return new uo(this,{kind:"constant",value:void 0},l.parameters);const I=Ys[this.specification.type];return I?new uo(this,{kind:"constant",value:I(l.value.value,f.value.value,w)},l.parameters):l}evaluate(l,f,w,I,U,N){return l.kind==="constant"?l.value:l.evaluate(f,w,I,U,N)}}class sh extends Vn{possiblyEvaluate(l,f,w,I){if(l.value===void 0)return new uo(this,{kind:"constant",value:void 0},f);if(l.expression.kind==="constant"){const U=l.expression.evaluate(f,null,{},w,I),N=l.property.specification.type==="resolvedImage"&&typeof U!="string"?U.name:U,Z=this._calculate(N,N,N,f);return new uo(this,{kind:"constant",value:Z},f)}if(l.expression.kind==="camera"){const U=this._calculate(l.expression.evaluate({zoom:f.zoom-1}),l.expression.evaluate({zoom:f.zoom}),l.expression.evaluate({zoom:f.zoom+1}),f);return new uo(this,{kind:"constant",value:U},f)}return new uo(this,l.expression,f)}evaluate(l,f,w,I,U,N){if(l.kind==="source"){const Z=l.evaluate(f,w,I,U,N);return this._calculate(Z,Z,Z,f)}return l.kind==="composite"?this._calculate(l.evaluate({zoom:Math.floor(f.zoom)-1},w,I),l.evaluate({zoom:Math.floor(f.zoom)},w,I),l.evaluate({zoom:Math.floor(f.zoom)+1},w,I),f):l.value}_calculate(l,f,w,I){return I.zoom>I.zoomHistory.lastIntegerZoom?{from:l,to:f}:{from:w,to:f}}interpolate(l){return l}}class dA{constructor(l){this.specification=l}possiblyEvaluate(l,f,w,I){if(l.value!==void 0){if(l.expression.kind==="constant"){const U=l.expression.evaluate(f,null,{},w,I);return this._calculate(U,U,U,f)}return this._calculate(l.expression.evaluate(new Zr(Math.floor(f.zoom-1),f)),l.expression.evaluate(new Zr(Math.floor(f.zoom),f)),l.expression.evaluate(new Zr(Math.floor(f.zoom+1),f)),f)}}_calculate(l,f,w,I){return I.zoom>I.zoomHistory.lastIntegerZoom?{from:l,to:f}:{from:w,to:f}}interpolate(l){return l}}class yl{constructor(l){this.specification=l}possiblyEvaluate(l,f,w,I){return!!l.expression.evaluate(f,null,{},w,I)}interpolate(){return!1}}class Cs{constructor(l){this.properties=l,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const f in l){const w=l[f];w.specification.overridable&&this.overridableProperties.push(f);const I=this.defaultPropertyValues[f]=new nh(w,void 0),U=this.defaultTransitionablePropertyValues[f]=new Wh(w);this.defaultTransitioningPropertyValues[f]=U.untransitioned(),this.defaultPossiblyEvaluatedValues[f]=I.possiblyEvaluate({})}}}pn("DataDrivenProperty",Vn),pn("DataConstantProperty",Fn),pn("CrossFadedDataDrivenProperty",sh),pn("CrossFadedProperty",dA),pn("ColorRampProperty",yl);const Ga="-transition";class Go extends en{constructor(l,f){if(super(),this.id=l.id,this.type=l.type,this._featureFilter={filter:()=>!0,needGeometry:!1},l.type!=="custom"&&(this.metadata=l.metadata,this.minzoom=l.minzoom,this.maxzoom=l.maxzoom,l.type!=="background"&&(this.source=l.source,this.sourceLayer=l["source-layer"],this.filter=l.filter),f.layout&&(this._unevaluatedLayout=new rh(f.layout)),f.paint)){this._transitionablePaint=new xc(f.paint);for(const w in l.paint)this.setPaintProperty(w,l.paint[w],{validate:!1});for(const w in l.layout)this.setLayoutProperty(w,l.layout[w],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Js(f.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(l){return l==="visibility"?this.visibility:this._unevaluatedLayout.getValue(l)}setLayoutProperty(l,f,w={}){f!=null&&this._validate(sd,`layers.${this.id}.layout.${l}`,l,f,w)||(l!=="visibility"?this._unevaluatedLayout.setValue(l,f):this.visibility=f)}getPaintProperty(l){return l.endsWith(Ga)?this._transitionablePaint.getTransition(l.slice(0,-Ga.length)):this._transitionablePaint.getValue(l)}setPaintProperty(l,f,w={}){if(f!=null&&this._validate(lA,`layers.${this.id}.paint.${l}`,l,f,w))return!1;if(l.endsWith(Ga))return this._transitionablePaint.setTransition(l.slice(0,-Ga.length),f||void 0),!1;{const I=this._transitionablePaint._values[l],U=I.property.specification["property-type"]==="cross-faded-data-driven",N=I.value.isDataDriven(),Z=I.value;this._transitionablePaint.setValue(l,f),this._handleSpecialPaintPropertyUpdate(l);const re=this._transitionablePaint._values[l].value;return re.isDataDriven()||N||U||this._handleOverridablePaintPropertyUpdate(l,Z,re)}}_handleSpecialPaintPropertyUpdate(l){}_handleOverridablePaintPropertyUpdate(l,f,w){return!1}isHidden(l){return!!(this.minzoom&&l=this.maxzoom)||this.visibility==="none"}updateTransitions(l){this._transitioningPaint=this._transitionablePaint.transitioned(l,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(l,f){l.getCrossfadeParameters&&(this._crossfadeParameters=l.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(l,void 0,f)),this.paint=this._transitioningPaint.possiblyEvaluate(l,void 0,f)}serialize(){const l={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&&(l.layout=l.layout||{},l.layout.visibility=this.visibility),ce(l,(f,w)=>!(f===void 0||w==="layout"&&!Object.keys(f).length||w==="paint"&&!Object.keys(f).length))}_validate(l,f,w,I,U={}){return(!U||U.validate!==!1)&&Nh(this,l.call(kh,{key:f,layerType:this.type,objectKey:w,value:I,styleSpec:$t,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const l in this.paint._values){const f=this.paint.get(l);if(f instanceof uo&&qr(f.property.specification)&&(f.value.kind==="source"||f.value.kind==="composite")&&f.value.isStateDependent)return!0}return!1}}const pA={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class va{constructor(l,f){this._structArray=l,this._pos1=f*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class hs{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(l,f){return l._trim(),f&&(l.isTransferred=!0,f.push(l.arrayBuffer)),{length:l.length,arrayBuffer:l.arrayBuffer}}static deserialize(l){const f=Object.create(this.prototype);return f.arrayBuffer=l.arrayBuffer,f.length=l.length,f.capacity=l.arrayBuffer.byteLength/f.bytesPerElement,f._refreshViews(),f}_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(l){this.reserve(l),this.length=l}reserve(l){if(l>this.capacity){this.capacity=Math.max(l,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const f=this.uint8;this._refreshViews(),f&&this.uint8.set(f)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Is(A,l=1){let f=0,w=0;return{members:A.map(I=>{const U=pA[I.type].BYTES_PER_ELEMENT,N=f=Kh(f,Math.max(l,U)),Z=I.components||1;return w=Math.max(w,U),f+=U*Z,{name:I.name,type:I.type,components:Z,offset:N}}),size:Kh(f,Math.max(w,l)),alignment:l}}function Kh(A,l){return Math.ceil(A/l)*l}class xl extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f){const w=this.length;return this.resize(w+1),this.emplace(w,l,f)}emplace(l,f,w){const I=2*l;return this.int16[I+0]=f,this.int16[I+1]=w,l}}xl.prototype.bytesPerElement=4,pn("StructArrayLayout2i4",xl);class M extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I){const U=this.length;return this.resize(U+1),this.emplace(U,l,f,w,I)}emplace(l,f,w,I,U){const N=4*l;return this.int16[N+0]=f,this.int16[N+1]=w,this.int16[N+2]=I,this.int16[N+3]=U,l}}M.prototype.bytesPerElement=8,pn("StructArrayLayout4i8",M);class h extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,U,N){const Z=this.length;return this.resize(Z+1),this.emplace(Z,l,f,w,I,U,N)}emplace(l,f,w,I,U,N,Z){const re=6*l;return this.int16[re+0]=f,this.int16[re+1]=w,this.int16[re+2]=I,this.int16[re+3]=U,this.int16[re+4]=N,this.int16[re+5]=Z,l}}h.prototype.bytesPerElement=12,pn("StructArrayLayout2i4i12",h);class _ extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,U,N){const Z=this.length;return this.resize(Z+1),this.emplace(Z,l,f,w,I,U,N)}emplace(l,f,w,I,U,N,Z){const re=4*l,ge=8*l;return this.int16[re+0]=f,this.int16[re+1]=w,this.uint8[ge+4]=I,this.uint8[ge+5]=U,this.uint8[ge+6]=N,this.uint8[ge+7]=Z,l}}_.prototype.bytesPerElement=8,pn("StructArrayLayout2i4ub8",_);class T extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f){const w=this.length;return this.resize(w+1),this.emplace(w,l,f)}emplace(l,f,w){const I=2*l;return this.float32[I+0]=f,this.float32[I+1]=w,l}}T.prototype.bytesPerElement=8,pn("StructArrayLayout2f8",T);class F extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,U,N,Z,re,ge,Ce){const Ie=this.length;return this.resize(Ie+1),this.emplace(Ie,l,f,w,I,U,N,Z,re,ge,Ce)}emplace(l,f,w,I,U,N,Z,re,ge,Ce,Ie){const ke=10*l;return this.uint16[ke+0]=f,this.uint16[ke+1]=w,this.uint16[ke+2]=I,this.uint16[ke+3]=U,this.uint16[ke+4]=N,this.uint16[ke+5]=Z,this.uint16[ke+6]=re,this.uint16[ke+7]=ge,this.uint16[ke+8]=Ce,this.uint16[ke+9]=Ie,l}}F.prototype.bytesPerElement=20,pn("StructArrayLayout10ui20",F);class O extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke){const $e=this.length;return this.resize($e+1),this.emplace($e,l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke)}emplace(l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke,$e){const Ze=12*l;return this.int16[Ze+0]=f,this.int16[Ze+1]=w,this.int16[Ze+2]=I,this.int16[Ze+3]=U,this.uint16[Ze+4]=N,this.uint16[Ze+5]=Z,this.uint16[Ze+6]=re,this.uint16[Ze+7]=ge,this.int16[Ze+8]=Ce,this.int16[Ze+9]=Ie,this.int16[Ze+10]=ke,this.int16[Ze+11]=$e,l}}O.prototype.bytesPerElement=24,pn("StructArrayLayout4i4ui4i24",O);class K extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f,w){const I=this.length;return this.resize(I+1),this.emplace(I,l,f,w)}emplace(l,f,w,I){const U=3*l;return this.float32[U+0]=f,this.float32[U+1]=w,this.float32[U+2]=I,l}}K.prototype.bytesPerElement=12,pn("StructArrayLayout3f12",K);class oe extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(l){const f=this.length;return this.resize(f+1),this.emplace(f,l)}emplace(l,f){return this.uint32[1*l+0]=f,l}}oe.prototype.bytesPerElement=4,pn("StructArrayLayout1ul4",oe);class ue extends hs{_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(l,f,w,I,U,N,Z,re,ge){const Ce=this.length;return this.resize(Ce+1),this.emplace(Ce,l,f,w,I,U,N,Z,re,ge)}emplace(l,f,w,I,U,N,Z,re,ge,Ce){const Ie=10*l,ke=5*l;return this.int16[Ie+0]=f,this.int16[Ie+1]=w,this.int16[Ie+2]=I,this.int16[Ie+3]=U,this.int16[Ie+4]=N,this.int16[Ie+5]=Z,this.uint32[ke+3]=re,this.uint16[Ie+8]=ge,this.uint16[Ie+9]=Ce,l}}ue.prototype.bytesPerElement=20,pn("StructArrayLayout6i1ul2ui20",ue);class ve extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,U,N){const Z=this.length;return this.resize(Z+1),this.emplace(Z,l,f,w,I,U,N)}emplace(l,f,w,I,U,N,Z){const re=6*l;return this.int16[re+0]=f,this.int16[re+1]=w,this.int16[re+2]=I,this.int16[re+3]=U,this.int16[re+4]=N,this.int16[re+5]=Z,l}}ve.prototype.bytesPerElement=12,pn("StructArrayLayout2i2i2i12",ve);class Te extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w,I,U){const N=this.length;return this.resize(N+1),this.emplace(N,l,f,w,I,U)}emplace(l,f,w,I,U,N){const Z=4*l,re=8*l;return this.float32[Z+0]=f,this.float32[Z+1]=w,this.float32[Z+2]=I,this.int16[re+6]=U,this.int16[re+7]=N,l}}Te.prototype.bytesPerElement=16,pn("StructArrayLayout2f1f2i16",Te);class ze extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f,w,I){const U=this.length;return this.resize(U+1),this.emplace(U,l,f,w,I)}emplace(l,f,w,I,U){const N=12*l,Z=3*l;return this.uint8[N+0]=f,this.uint8[N+1]=w,this.float32[Z+1]=I,this.float32[Z+2]=U,l}}ze.prototype.bytesPerElement=12,pn("StructArrayLayout2ub2f12",ze);class je extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f,w){const I=this.length;return this.resize(I+1),this.emplace(I,l,f,w)}emplace(l,f,w,I){const U=3*l;return this.uint16[U+0]=f,this.uint16[U+1]=w,this.uint16[U+2]=I,l}}je.prototype.bytesPerElement=6,pn("StructArrayLayout3ui6",je);class bt extends hs{_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(l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke,$e,Ze,Rt,Mt,ri){const mi=this.length;return this.resize(mi+1),this.emplace(mi,l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke,$e,Ze,Rt,Mt,ri)}emplace(l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke,$e,Ze,Rt,Mt,ri,mi){const ei=24*l,ui=12*l,Pi=48*l;return this.int16[ei+0]=f,this.int16[ei+1]=w,this.uint16[ei+2]=I,this.uint16[ei+3]=U,this.uint32[ui+2]=N,this.uint32[ui+3]=Z,this.uint32[ui+4]=re,this.uint16[ei+10]=ge,this.uint16[ei+11]=Ce,this.uint16[ei+12]=Ie,this.float32[ui+7]=ke,this.float32[ui+8]=$e,this.uint8[Pi+36]=Ze,this.uint8[Pi+37]=Rt,this.uint8[Pi+38]=Mt,this.uint32[ui+10]=ri,this.int16[ei+22]=mi,l}}bt.prototype.bytesPerElement=48,pn("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",bt);class mt extends hs{_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(l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke,$e,Ze,Rt,Mt,ri,mi,ei,ui,Pi,Fi,Sn,fn,mn,an,nn,vn){const gn=this.length;return this.resize(gn+1),this.emplace(gn,l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke,$e,Ze,Rt,Mt,ri,mi,ei,ui,Pi,Fi,Sn,fn,mn,an,nn,vn)}emplace(l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke,$e,Ze,Rt,Mt,ri,mi,ei,ui,Pi,Fi,Sn,fn,mn,an,nn,vn,gn){const Ji=34*l,Wn=17*l;return this.int16[Ji+0]=f,this.int16[Ji+1]=w,this.int16[Ji+2]=I,this.int16[Ji+3]=U,this.int16[Ji+4]=N,this.int16[Ji+5]=Z,this.int16[Ji+6]=re,this.int16[Ji+7]=ge,this.uint16[Ji+8]=Ce,this.uint16[Ji+9]=Ie,this.uint16[Ji+10]=ke,this.uint16[Ji+11]=$e,this.uint16[Ji+12]=Ze,this.uint16[Ji+13]=Rt,this.uint16[Ji+14]=Mt,this.uint16[Ji+15]=ri,this.uint16[Ji+16]=mi,this.uint16[Ji+17]=ei,this.uint16[Ji+18]=ui,this.uint16[Ji+19]=Pi,this.uint16[Ji+20]=Fi,this.uint16[Ji+21]=Sn,this.uint16[Ji+22]=fn,this.uint32[Wn+12]=mn,this.float32[Wn+13]=an,this.float32[Wn+14]=nn,this.float32[Wn+15]=vn,this.float32[Wn+16]=gn,l}}mt.prototype.bytesPerElement=68,pn("StructArrayLayout8i15ui1ul4f68",mt);class gt extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l){const f=this.length;return this.resize(f+1),this.emplace(f,l)}emplace(l,f){return this.float32[1*l+0]=f,l}}gt.prototype.bytesPerElement=4,pn("StructArrayLayout1f4",gt);class Vt extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(l,f,w){const I=this.length;return this.resize(I+1),this.emplace(I,l,f,w)}emplace(l,f,w,I){const U=3*l;return this.int16[U+0]=f,this.int16[U+1]=w,this.int16[U+2]=I,l}}Vt.prototype.bytesPerElement=6,pn("StructArrayLayout3i6",Vt);class Zt extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f,w){const I=this.length;return this.resize(I+1),this.emplace(I,l,f,w)}emplace(l,f,w,I){const U=4*l;return this.uint32[2*l+0]=f,this.uint16[U+2]=w,this.uint16[U+3]=I,l}}Zt.prototype.bytesPerElement=8,pn("StructArrayLayout1ul2ui8",Zt);class ni extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l,f){const w=this.length;return this.resize(w+1),this.emplace(w,l,f)}emplace(l,f,w){const I=2*l;return this.uint16[I+0]=f,this.uint16[I+1]=w,l}}ni.prototype.bytesPerElement=4,pn("StructArrayLayout2ui4",ni);class St extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(l){const f=this.length;return this.resize(f+1),this.emplace(f,l)}emplace(l,f){return this.uint16[1*l+0]=f,l}}St.prototype.bytesPerElement=2,pn("StructArrayLayout1ui2",St);class zt extends hs{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(l,f,w,I){const U=this.length;return this.resize(U+1),this.emplace(U,l,f,w,I)}emplace(l,f,w,I,U){const N=4*l;return this.float32[N+0]=f,this.float32[N+1]=w,this.float32[N+2]=I,this.float32[N+3]=U,l}}zt.prototype.bytesPerElement=16,pn("StructArrayLayout4f16",zt);class ai extends va{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 xe(this.anchorPointX,this.anchorPointY)}}ai.prototype.size=20;class Ei extends ue{get(l){return new ai(this,l)}}pn("CollisionBoxArray",Ei);class Bi extends va{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(l){this._structArray.uint8[this._pos1+37]=l}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(l){this._structArray.uint8[this._pos1+38]=l}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(l){this._structArray.uint32[this._pos4+10]=l}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Bi.prototype.size=48;class Hi extends bt{get(l){return new Bi(this,l)}}pn("PlacedSymbolArray",Hi);class vi extends va{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(l){this._structArray.uint32[this._pos4+12]=l}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get textOffset0(){return this._structArray.float32[this._pos4+14]}get textOffset1(){return this._structArray.float32[this._pos4+15]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+16]}}vi.prototype.size=68;class xn extends mt{get(l){return new vi(this,l)}}pn("SymbolInstanceArray",xn);class cn extends gt{getoffsetX(l){return this.float32[1*l+0]}}pn("GlyphOffsetArray",cn);class Bn extends Vt{getx(l){return this.int16[3*l+0]}gety(l){return this.int16[3*l+1]}gettileUnitDistanceFromAnchor(l){return this.int16[3*l+2]}}pn("SymbolLineVertexArray",Bn);class tr extends va{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}tr.prototype.size=8;class ur extends Zt{get(l){return new tr(this,l)}}pn("FeatureIndexArray",ur);class Un extends xl{}class Lr extends xl{}class Rr extends xl{}class Cr extends h{}class Er extends _{}class Gr extends T{}class js extends F{}class wa extends O{}class ua extends K{}class ba extends oe{}class Wa extends ve{}class Wo extends ze{}class mo extends je{}class Ba extends ni{}const $l=Is([{name:"a_pos",components:2,type:"Int16"}],4),{members:x}=$l;class a{constructor(l=[]){this.segments=l}prepareSegment(l,f,w,I){let U=this.segments[this.segments.length-1];return l>a.MAX_VERTEX_ARRAY_LENGTH&&me(`Max vertices per segment is ${a.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${l}`),(!U||U.vertexLength+l>a.MAX_VERTEX_ARRAY_LENGTH||U.sortKey!==I)&&(U={vertexOffset:f.length,primitiveOffset:w.length,vertexLength:0,primitiveLength:0},I!==void 0&&(U.sortKey=I),this.segments.push(U)),U}get(){return this.segments}destroy(){for(const l of this.segments)for(const f in l.vaos)l.vaos[f].destroy()}static simpleSegment(l,f,w,I){return new a([{vertexOffset:l,primitiveOffset:f,vertexLength:w,primitiveLength:I,vaos:{},sortKey:0}])}}function m(A,l){return 256*(A=z(Math.floor(A),0,255))+z(Math.floor(l),0,255)}a.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,pn("SegmentVector",a);const b=Is([{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:{}},P={exports:{}};P.exports=function(A,l){var f,w,I,U,N,Z,re,ge;for(w=A.length-(f=3&A.length),I=l,N=3432918353,Z=461845907,ge=0;ge>>16)*N&65535)<<16)&4294967295)<<15|re>>>17))*Z+(((re>>>16)*Z&65535)<<16)&4294967295)<<13|I>>>19))+((5*(I>>>16)&65535)<<16)&4294967295))+((58964+(U>>>16)&65535)<<16);switch(re=0,f){case 3:re^=(255&A.charCodeAt(ge+2))<<16;case 2:re^=(255&A.charCodeAt(ge+1))<<8;case 1:I^=re=(65535&(re=(re=(65535&(re^=255&A.charCodeAt(ge)))*N+(((re>>>16)*N&65535)<<16)&4294967295)<<15|re>>>17))*Z+(((re>>>16)*Z&65535)<<16)&4294967295}return I^=A.length,I=2246822507*(65535&(I^=I>>>16))+((2246822507*(I>>>16)&65535)<<16)&4294967295,I=3266489909*(65535&(I^=I>>>13))+((3266489909*(I>>>16)&65535)<<16)&4294967295,(I^=I>>>16)>>>0};var H={exports:{}};H.exports=function(A,l){for(var f,w=A.length,I=l^w,U=0;w>=4;)f=1540483477*(65535&(f=255&A.charCodeAt(U)|(255&A.charCodeAt(++U))<<8|(255&A.charCodeAt(++U))<<16|(255&A.charCodeAt(++U))<<24))+((1540483477*(f>>>16)&65535)<<16),I=1540483477*(65535&I)+((1540483477*(I>>>16)&65535)<<16)^(f=1540483477*(65535&(f^=f>>>24))+((1540483477*(f>>>16)&65535)<<16)),w-=4,++U;switch(w){case 3:I^=(255&A.charCodeAt(U+2))<<16;case 2:I^=(255&A.charCodeAt(U+1))<<8;case 1:I=1540483477*(65535&(I^=255&A.charCodeAt(U)))+((1540483477*(I>>>16)&65535)<<16)}return I=1540483477*(65535&(I^=I>>>13))+((1540483477*(I>>>16)&65535)<<16),(I^=I>>>15)>>>0};var W=P.exports,ee=H.exports;S.exports=W,S.exports.murmur3=W,S.exports.murmur2=ee;class pe{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(l,f,w,I){this.ids.push(fe(l)),this.positions.push(f,w,I)}getPositions(l){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const f=fe(l);let w=0,I=this.ids.length-1;for(;w>1;this.ids[N]>=f?I=N:w=N+1}const U=[];for(;this.ids[w]===f;)U.push({index:this.positions[3*w],start:this.positions[3*w+1],end:this.positions[3*w+2]}),w++;return U}static serialize(l,f){const w=new Float64Array(l.ids),I=new Uint32Array(l.positions);return Me(w,I,0,w.length-1),f&&f.push(w.buffer,I.buffer),{ids:w,positions:I}}static deserialize(l){const f=new pe;return f.ids=l.ids,f.positions=l.positions,f.indexed=!0,f}}function fe(A){const l=+A;return!isNaN(l)&&l<=Number.MAX_SAFE_INTEGER?l:S.exports(String(A))}function Me(A,l,f,w){for(;f>1];let U=f-1,N=w+1;for(;;){do U++;while(A[U]I);if(U>=N)break;Ne(A,U,N),Ne(l,3*U,3*N),Ne(l,3*U+1,3*N+1),Ne(l,3*U+2,3*N+2)}N-f`u_${I}`),this.type=w}setUniform(l,f,w){l.set(w.constantOr(this.value))}getBinding(l,f,w){return this.type==="color"?new qe(l,f):new it(l,f)}}class Bt{constructor(l,f){this.uniformNames=f.map(w=>`u_${w}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(l,f){this.pixelRatioFrom=f.pixelRatio,this.pixelRatioTo=l.pixelRatio,this.patternFrom=f.tlbr,this.patternTo=l.tlbr}setUniform(l,f,w,I){const U=I==="u_pattern_to"?this.patternTo:I==="u_pattern_from"?this.patternFrom:I==="u_pixel_ratio_to"?this.pixelRatioTo:I==="u_pixel_ratio_from"?this.pixelRatioFrom:null;U&&l.set(U)}getBinding(l,f,w){return w.substr(0,9)==="u_pattern"?new lt(l,f):new it(l,f)}}class Pt{constructor(l,f,w,I){this.expression=l,this.type=w,this.maxValue=0,this.paintVertexAttributes=f.map(U=>({name:`a_${U}`,type:"Float32",components:w==="color"?2:1,offset:0})),this.paintVertexArray=new I}populatePaintArray(l,f,w,I,U){const N=this.paintVertexArray.length,Z=this.expression.evaluate(new Zr(0),f,{},I,[],U);this.paintVertexArray.resize(l),this._setPaintValue(N,l,Z)}updatePaintArray(l,f,w,I){const U=this.expression.evaluate({zoom:0},w,I);this._setPaintValue(l,f,U)}_setPaintValue(l,f,w){if(this.type==="color"){const I=dt(w);for(let U=l;U`u_${Z}_t`),this.type=w,this.useIntegerZoom=I,this.zoom=U,this.maxValue=0,this.paintVertexAttributes=f.map(Z=>({name:`a_${Z}`,type:"Float32",components:w==="color"?4:2,offset:0})),this.paintVertexArray=new N}populatePaintArray(l,f,w,I,U){const N=this.expression.evaluate(new Zr(this.zoom),f,{},I,[],U),Z=this.expression.evaluate(new Zr(this.zoom+1),f,{},I,[],U),re=this.paintVertexArray.length;this.paintVertexArray.resize(l),this._setPaintValue(re,l,N,Z)}updatePaintArray(l,f,w,I){const U=this.expression.evaluate({zoom:this.zoom},w,I),N=this.expression.evaluate({zoom:this.zoom+1},w,I);this._setPaintValue(l,f,U,N)}_setPaintValue(l,f,w,I){if(this.type==="color"){const U=dt(w),N=dt(I);for(let Z=l;Z`#define HAS_UNIFORM_${I}`))}return l}getBinderAttributes(){const l=[];for(const f in this.binders){const w=this.binders[f];if(w instanceof Pt||w instanceof It)for(let I=0;I!0){this.programConfigurations={};for(const I of l)this.programConfigurations[I.id]=new hi(I,f,w);this.needsUpload=!1,this._featureMap=new pe,this._bufferOffset=0}populatePaintArrays(l,f,w,I,U,N){for(const Z in this.programConfigurations)this.programConfigurations[Z].populatePaintArrays(l,f,I,U,N);f.id!==void 0&&this._featureMap.add(f.id,w,this._bufferOffset,l),this._bufferOffset=l,this.needsUpload=!0}updatePaintArrays(l,f,w,I){for(const U of w)this.needsUpload=this.programConfigurations[U.id].updatePaintArrays(l,this._featureMap,f,U,I)||this.needsUpload}get(l){return this.programConfigurations[l]}upload(l){if(this.needsUpload){for(const f in this.programConfigurations)this.programConfigurations[f].upload(l);this.needsUpload=!1}}destroy(){for(const l in this.programConfigurations)this.programConfigurations[l].destroy()}}function qt(A,l){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[A]||[A.replace(`${l}-`,"").replace(/-/g,"_")]}function ji(A,l,f){const w={color:{source:T,composite:zt},number:{source:gt,composite:T}},I=function(U){return{"line-pattern":{source:js,composite:js},"fill-pattern":{source:js,composite:js},"fill-extrusion-pattern":{source:js,composite:js}}[U]}(A);return I&&I[f]||w[l][f]}pn("ConstantBinder",ht),pn("CrossFadedConstantBinder",Bt),pn("SourceExpressionBinder",Pt),pn("CrossFadedCompositeBinder",Ht),pn("CompositeExpressionBinder",It),pn("ProgramConfiguration",hi,{omit:["_buffers"]}),pn("ProgramConfigurationSet",si);var Kt=8192;const Ci=Math.pow(2,14)-1,di=-Ci-1;function Ri(A){const l=Kt/A.extent,f=A.loadGeometry();for(let w=0;wN.x+1||reN.y+1)&&me("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return f}function Ai(A,l){return{type:A.type,id:A.id,properties:A.properties,geometry:l?Ri(A):[]}}function Mi(A,l,f,w,I){A.emplaceBack(2*l+(w+1)/2,2*f+(I+1)/2)}class $i{constructor(l){this.zoom=l.zoom,this.overscaling=l.overscaling,this.layers=l.layers,this.layerIds=this.layers.map(f=>f.id),this.index=l.index,this.hasPattern=!1,this.layoutVertexArray=new Lr,this.indexArray=new mo,this.segments=new a,this.programConfigurations=new si(l.layers,l.zoom),this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id)}populate(l,f,w){const I=this.layers[0],U=[];let N=null,Z=!1;I.type==="circle"&&(N=I.layout.get("circle-sort-key"),Z=!N.isConstant());for(const{feature:re,id:ge,index:Ce,sourceLayerIndex:Ie}of l){const ke=this.layers[0]._featureFilter.needGeometry,$e=Ai(re,ke);if(!this.layers[0]._featureFilter.filter(new Zr(this.zoom),$e,w))continue;const Ze=Z?N.evaluate($e,{},w):void 0,Rt={id:ge,properties:re.properties,type:re.type,sourceLayerIndex:Ie,index:Ce,geometry:ke?$e.geometry:Ri(re),patterns:{},sortKey:Ze};U.push(Rt)}Z&&U.sort((re,ge)=>re.sortKey-ge.sortKey);for(const re of U){const{geometry:ge,index:Ce,sourceLayerIndex:Ie}=re,ke=l[Ce].feature;this.addFeature(re,ge,Ce,w),f.featureIndex.insert(ke,ge,Ce,Ie,this.index)}}update(l,f,w){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(l,f,this.stateDependentLayers,w)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,x),this.indexBuffer=l.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(l,f,w,I){for(const U of f)for(const N of U){const Z=N.x,re=N.y;if(Z<0||Z>=Kt||re<0||re>=Kt)continue;const ge=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,l.sortKey),Ce=ge.vertexLength;Mi(this.layoutVertexArray,Z,re,-1,-1),Mi(this.layoutVertexArray,Z,re,1,-1),Mi(this.layoutVertexArray,Z,re,1,1),Mi(this.layoutVertexArray,Z,re,-1,1),this.indexArray.emplaceBack(Ce,Ce+1,Ce+2),this.indexArray.emplaceBack(Ce,Ce+3,Ce+2),ge.vertexLength+=4,ge.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,l,w,{},I)}}function Jt(A,l){for(let f=0;f1){if(Mn(A,l))return!0;for(let w=0;w1?f:f.sub(l)._mult(I)._add(l))}function _n(A,l){let f,w,I,U=!1;for(let N=0;Nl.y!=I.y>l.y&&l.x<(I.x-w.x)*(l.y-w.y)/(I.y-w.y)+w.x&&(U=!U)}return U}function Dr(A,l){let f=!1;for(let w=0,I=A.length-1;wl.y!=N.y>l.y&&l.x<(N.x-U.x)*(l.y-U.y)/(N.y-U.y)+U.x&&(f=!f)}return f}function Or(A,l,f){const w=f[0],I=f[2];if(A.xI.x&&l.x>I.x||A.yI.y&&l.y>I.y)return!1;const U=De(A,l,f[0]);return U!==De(A,l,f[1])||U!==De(A,l,f[2])||U!==De(A,l,f[3])}function Nr(A,l,f){const w=l.paint.get(A).value;return w.kind==="constant"?w.value:f.programConfigurations.get(l.id).getMaxValue(A)}function Qr(A){return Math.sqrt(A[0]*A[0]+A[1]*A[1])}function go(A,l,f,w,I){if(!l[0]&&!l[1])return A;const U=xe.convert(l)._mult(I);f==="viewport"&&U._rotate(-w);const N=[];for(let Z=0;ZA.width||I.height>A.height||f.x>A.width-I.width||f.y>A.height-I.height)throw new RangeError("out of range source coordinates for image copy");if(I.width>l.width||I.height>l.height||w.x>l.width-I.width||w.y>l.height-I.height)throw new RangeError("out of range destination coordinates for image copy");const N=A.data,Z=l.data;if(N===Z)throw new Error("srcData equals dstData, so image is already copied");for(let re=0;re{l[A.evaluationKey]=re;const ge=A.expression.evaluate(l);I.data[N+Z+0]=Math.floor(255*ge.r/ge.a),I.data[N+Z+1]=Math.floor(255*ge.g/ge.a),I.data[N+Z+2]=Math.floor(255*ge.b/ge.a),I.data[N+Z+3]=Math.floor(255*ge.a)};if(A.clips)for(let N=0,Z=0;N80*f){w=U=A[0],I=N=A[1];for(var Ze=f;ZeU&&(U=Z),re>N&&(N=re);ge=(ge=Math.max(U-w,N-I))!==0?32767/ge:0}return od(ke,$e,f,w,I,ge,0),$e}function og(A,l,f,w,I){var U,N;if(I===gA(A,l,f,w)>0)for(U=l;U=l;U-=w)N=Py(U,A[U],A[U+1],N);return N&&fA(N,N.next)&&(pp(N),N=N.next),N}function Cu(A,l){if(!A)return A;l||(l=A);var f,w=A;do if(f=!1,w.steiner||!fA(w,w.next)&&Ls(w.prev,w,w.next)!==0)w=w.next;else{if(pp(w),(w=l=w.prev)===w.next)break;f=!0}while(f||w!==l);return l}function od(A,l,f,w,I,U,N){if(A){!N&&U&&function(Ce,Ie,ke,$e){var Ze=Ce;do Ze.z===0&&(Ze.z=Bf(Ze.x,Ze.y,Ie,ke,$e)),Ze.prevZ=Ze.prev,Ze.nextZ=Ze.next,Ze=Ze.next;while(Ze!==Ce);Ze.prevZ.nextZ=null,Ze.prevZ=null,function(Rt){var Mt,ri,mi,ei,ui,Pi,Fi,Sn,fn=1;do{for(ri=Rt,Rt=null,ui=null,Pi=0;ri;){for(Pi++,mi=ri,Fi=0,Mt=0;Mt0||Sn>0&&mi;)Fi!==0&&(Sn===0||!mi||ri.z<=mi.z)?(ei=ri,ri=ri.nextZ,Fi--):(ei=mi,mi=mi.nextZ,Sn--),ui?ui.nextZ=ei:Rt=ei,ei.prevZ=ui,ui=ei;ri=mi}ui.nextZ=null,fn*=2}while(Pi>1)}(Ze)}(A,w,I,U);for(var Z,re,ge=A;A.prev!==A.next;)if(Z=A.prev,re=A.next,U?My(A,w,I,U):Sy(A))l.push(Z.i/f|0),l.push(A.i/f|0),l.push(re.i/f|0),pp(A),A=re.next,ge=re.next;else if((A=re)===ge){N?N===1?od(A=i1(Cu(A),l,f),l,f,w,I,U,2):N===2&&n1(A,l,f,w,I,U):od(Cu(A),l,f,w,I,U,1);break}}}function Sy(A){var l=A.prev,f=A,w=A.next;if(Ls(l,f,w)>=0)return!1;for(var I=l.x,U=f.x,N=w.x,Z=l.y,re=f.y,ge=w.y,Ce=IU?I>N?I:N:U>N?U:N,$e=Z>re?Z>ge?Z:ge:re>ge?re:ge,Ze=w.next;Ze!==l;){if(Ze.x>=Ce&&Ze.x<=ke&&Ze.y>=Ie&&Ze.y<=$e&&qh(I,Z,U,re,N,ge,Ze.x,Ze.y)&&Ls(Ze.prev,Ze,Ze.next)>=0)return!1;Ze=Ze.next}return!0}function My(A,l,f,w){var I=A.prev,U=A,N=A.next;if(Ls(I,U,N)>=0)return!1;for(var Z=I.x,re=U.x,ge=N.x,Ce=I.y,Ie=U.y,ke=N.y,$e=Zre?Z>ge?Z:ge:re>ge?re:ge,Mt=Ce>Ie?Ce>ke?Ce:ke:Ie>ke?Ie:ke,ri=Bf($e,Ze,l,f,w),mi=Bf(Rt,Mt,l,f,w),ei=A.prevZ,ui=A.nextZ;ei&&ei.z>=ri&&ui&&ui.z<=mi;){if(ei.x>=$e&&ei.x<=Rt&&ei.y>=Ze&&ei.y<=Mt&&ei!==I&&ei!==N&&qh(Z,Ce,re,Ie,ge,ke,ei.x,ei.y)&&Ls(ei.prev,ei,ei.next)>=0||(ei=ei.prevZ,ui.x>=$e&&ui.x<=Rt&&ui.y>=Ze&&ui.y<=Mt&&ui!==I&&ui!==N&&qh(Z,Ce,re,Ie,ge,ke,ui.x,ui.y)&&Ls(ui.prev,ui,ui.next)>=0))return!1;ui=ui.nextZ}for(;ei&&ei.z>=ri;){if(ei.x>=$e&&ei.x<=Rt&&ei.y>=Ze&&ei.y<=Mt&&ei!==I&&ei!==N&&qh(Z,Ce,re,Ie,ge,ke,ei.x,ei.y)&&Ls(ei.prev,ei,ei.next)>=0)return!1;ei=ei.prevZ}for(;ui&&ui.z<=mi;){if(ui.x>=$e&&ui.x<=Rt&&ui.y>=Ze&&ui.y<=Mt&&ui!==I&&ui!==N&&qh(Z,Ce,re,Ie,ge,ke,ui.x,ui.y)&&Ls(ui.prev,ui,ui.next)>=0)return!1;ui=ui.nextZ}return!0}function i1(A,l,f){var w=A;do{var I=w.prev,U=w.next.next;!fA(I,U)&&oh(I,w,w.next,U)&&ld(I,U)&&ld(U,I)&&(l.push(I.i/f|0),l.push(w.i/f|0),l.push(U.i/f|0),pp(w),pp(w.next),w=A=U),w=w.next}while(w!==A);return Cu(w)}function n1(A,l,f,w,I,U){var N=A;do{for(var Z=N.next.next;Z!==N.prev;){if(N.i!==Z.i&&Ly(N,Z)){var re=Dy(N,Z);return N=Cu(N,N.next),re=Cu(re,re.next),od(N,l,f,w,I,U,0),void od(re,l,f,w,I,U,0)}Z=Z.next}N=N.next}while(N!==A)}function ad(A,l){return A.x-l.x}function Iy(A,l){var f=function(I,U){var N,Z=U,re=I.x,ge=I.y,Ce=-1/0;do{if(ge<=Z.y&&ge>=Z.next.y&&Z.next.y!==Z.y){var Ie=Z.x+(ge-Z.y)*(Z.next.x-Z.x)/(Z.next.y-Z.y);if(Ie<=re&&Ie>Ce&&(Ce=Ie,N=Z.x=Z.x&&Z.x>=Ze&&re!==Z.x&&qh(geN.x||Z.x===N.x&&Fy(N,Z)))&&(N=Z,Mt=ke)),Z=Z.next;while(Z!==$e);return N}(A,l);if(!f)return l;var w=Dy(f,A);return Cu(w,w.next),Cu(f,f.next)}function Fy(A,l){return Ls(A.prev,A,l.prev)<0&&Ls(l.next,A,A.next)<0}function Bf(A,l,f,w,I){return(A=1431655765&((A=858993459&((A=252645135&((A=16711935&((A=(A-f)*I|0)|A<<8))|A<<4))|A<<2))|A<<1))|(l=1431655765&((l=858993459&((l=252645135&((l=16711935&((l=(l-w)*I|0)|l<<8))|l<<4))|l<<2))|l<<1))<<1}function r1(A){var l=A,f=A;do(l.x=(A-N)*(U-Z)&&(A-N)*(w-Z)>=(f-N)*(l-Z)&&(f-N)*(U-Z)>=(I-N)*(w-Z)}function Ly(A,l){return A.next.i!==l.i&&A.prev.i!==l.i&&!function(f,w){var I=f;do{if(I.i!==f.i&&I.next.i!==f.i&&I.i!==w.i&&I.next.i!==w.i&&oh(I,I.next,f,w))return!0;I=I.next}while(I!==f);return!1}(A,l)&&(ld(A,l)&&ld(l,A)&&function(f,w){var I=f,U=!1,N=(f.x+w.x)/2,Z=(f.y+w.y)/2;do I.y>Z!=I.next.y>Z&&I.next.y!==I.y&&N<(I.next.x-I.x)*(Z-I.y)/(I.next.y-I.y)+I.x&&(U=!U),I=I.next;while(I!==f);return U}(A,l)&&(Ls(A.prev,A,l.prev)||Ls(A,l.prev,l))||fA(A,l)&&Ls(A.prev,A,A.next)>0&&Ls(l.prev,l,l.next)>0)}function Ls(A,l,f){return(l.y-A.y)*(f.x-l.x)-(l.x-A.x)*(f.y-l.y)}function fA(A,l){return A.x===l.x&&A.y===l.y}function oh(A,l,f,w){var I=dp(Ls(A,l,f)),U=dp(Ls(A,l,w)),N=dp(Ls(f,w,A)),Z=dp(Ls(f,w,l));return I!==U&&N!==Z||!(I!==0||!mA(A,f,l))||!(U!==0||!mA(A,w,l))||!(N!==0||!mA(f,A,w))||!(Z!==0||!mA(f,l,w))}function mA(A,l,f){return l.x<=Math.max(A.x,f.x)&&l.x>=Math.min(A.x,f.x)&&l.y<=Math.max(A.y,f.y)&&l.y>=Math.min(A.y,f.y)}function dp(A){return A>0?1:A<0?-1:0}function ld(A,l){return Ls(A.prev,A,A.next)<0?Ls(A,l,A.next)>=0&&Ls(A,A.prev,l)>=0:Ls(A,l,A.prev)<0||Ls(A,A.next,l)<0}function Dy(A,l){var f=new fp(A.i,A.x,A.y),w=new fp(l.i,l.x,l.y),I=A.next,U=l.prev;return A.next=l,l.prev=A,f.next=I,I.prev=f,w.next=f,f.prev=w,U.next=w,w.prev=U,w}function Py(A,l,f,w){var I=new fp(A,l,f);return w?(I.next=w.next,I.prev=w,w.next.prev=I,w.next=I):(I.prev=I,I.next=I),I}function pp(A){A.next.prev=A.prev,A.prev.next=A.next,A.prevZ&&(A.prevZ.nextZ=A.nextZ),A.nextZ&&(A.nextZ.prevZ=A.prevZ)}function fp(A,l,f){this.i=A,this.x=l,this.y=f,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function gA(A,l,f,w){for(var I=0,U=l,N=f-w;Uf;){if(w-f>600){var U=w-f+1,N=l-f+1,Z=Math.log(U),re=.5*Math.exp(2*Z/3),ge=.5*Math.sqrt(Z*re*(U-re)/U)*(N-U/2<0?-1:1);ah(A,l,Math.max(f,Math.floor(l-N*re/U+ge)),Math.min(w,Math.floor(l+(U-N)*re/U+ge)),I)}var Ce=A[l],Ie=f,ke=w;for(Ta(A,f,l),I(A[w],Ce)>0&&Ta(A,f,w);Ie0;)ke--}I(A[f],Ce)===0?Ta(A,f,ke):Ta(A,++ke,w),ke<=l&&(f=ke+1),l<=ke&&(w=ke-1)}}function Ta(A,l,f){var w=A[l];A[l]=A[f],A[f]=w}function Eu(A,l){return Al?1:0}function lh(A,l){const f=A.length;if(f<=1)return[A];const w=[];let I,U;for(let N=0;N1)for(let N=0;N0&&f.holes.push(w+=A[I-1].length)}return f};class cg{constructor(l){this.zoom=l.zoom,this.overscaling=l.overscaling,this.layers=l.layers,this.layerIds=this.layers.map(f=>f.id),this.index=l.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Rr,this.indexArray=new mo,this.indexArray2=new Ba,this.programConfigurations=new si(l.layers,l.zoom),this.segments=new a,this.segments2=new a,this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id)}populate(l,f,w){this.hasPattern=ag("fill",this.layers,f);const I=this.layers[0].layout.get("fill-sort-key"),U=!I.isConstant(),N=[];for(const{feature:Z,id:re,index:ge,sourceLayerIndex:Ce}of l){const Ie=this.layers[0]._featureFilter.needGeometry,ke=Ai(Z,Ie);if(!this.layers[0]._featureFilter.filter(new Zr(this.zoom),ke,w))continue;const $e=U?I.evaluate(ke,{},w,f.availableImages):void 0,Ze={id:re,properties:Z.properties,type:Z.type,sourceLayerIndex:Ce,index:ge,geometry:Ie?ke.geometry:Ri(Z),patterns:{},sortKey:$e};N.push(Ze)}U&&N.sort((Z,re)=>Z.sortKey-re.sortKey);for(const Z of N){const{geometry:re,index:ge,sourceLayerIndex:Ce}=Z;if(this.hasPattern){const Ie=lg("fill",this.layers,Z,this.zoom,f);this.patternFeatures.push(Ie)}else this.addFeature(Z,re,ge,w,{});f.featureIndex.insert(l[ge].feature,re,ge,Ce,this.index)}}update(l,f,w){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(l,f,this.stateDependentLayers,w)}addFeatures(l,f,w){for(const I of this.patternFeatures)this.addFeature(I,I.geometry,I.index,f,w)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,Ty),this.indexBuffer=l.createIndexBuffer(this.indexArray),this.indexBuffer2=l.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(l),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(l,f,w,I,U){for(const N of lh(f,500)){let Z=0;for(const $e of N)Z+=$e.length;const re=this.segments.prepareSegment(Z,this.layoutVertexArray,this.indexArray),ge=re.vertexLength,Ce=[],Ie=[];for(const $e of N){if($e.length===0)continue;$e!==N[0]&&Ie.push(Ce.length/2);const Ze=this.segments2.prepareSegment($e.length,this.layoutVertexArray,this.indexArray2),Rt=Ze.vertexLength;this.layoutVertexArray.emplaceBack($e[0].x,$e[0].y),this.indexArray2.emplaceBack(Rt+$e.length-1,Rt),Ce.push($e[0].x),Ce.push($e[0].y);for(let Mt=1;Mt<$e.length;Mt++)this.layoutVertexArray.emplaceBack($e[Mt].x,$e[Mt].y),this.indexArray2.emplaceBack(Rt+Mt-1,Rt+Mt),Ce.push($e[Mt].x),Ce.push($e[Mt].y);Ze.vertexLength+=$e.length,Ze.primitiveLength+=$e.length}const ke=up.exports(Ce,Ie);for(let $e=0;$e>3}if(I--,w===1||w===2)U+=A.readSVarint(),N+=A.readSVarint(),w===1&&(l&&Z.push(l),l=[]),l.push(new to(U,N));else{if(w!==7)throw new Error("unknown command "+w);l&&l.push(l[0].clone())}}return l&&Z.push(l),Z},wl.prototype.bbox=function(){var A=this._pbf;A.pos=this._geometry;for(var l=A.readVarint()+A.pos,f=1,w=0,I=0,U=0,N=1/0,Z=-1/0,re=1/0,ge=-1/0;A.pos>3}if(w--,f===1||f===2)(I+=A.readSVarint())Z&&(Z=I),(U+=A.readSVarint())ge&&(ge=U);else if(f!==7)throw new Error("unknown command "+f)}return[N,re,Z,ge]},wl.prototype.toGeoJSON=function(A,l,f){var w,I,U=this.extent*Math.pow(2,f),N=this.extent*A,Z=this.extent*l,re=this.loadGeometry(),ge=wl.types[this.type];function Ce($e){for(var Ze=0;Ze<$e.length;Ze++){var Rt=$e[Ze];$e[Ze]=[360*(Rt.x+N)/U-180,360/Math.PI*Math.atan(Math.exp((180-360*(Rt.y+Z)/U)*Math.PI/180))-90]}}switch(this.type){case 1:var Ie=[];for(w=0;w>3;I=N===1?w.readString():N===2?w.readFloat():N===3?w.readDouble():N===4?w.readVarint64():N===5?w.readVarint():N===6?w.readSVarint():N===7?w.readBoolean():null}return I}(f))}wc.prototype.feature=function(A){if(A<0||A>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[A];var l=this._pbf.readVarint()+this._pbf.pos;return new Ry(this._pbf,l,this.extent,this._keys,this._values)};var Xl=Tf;function bl(A,l,f){if(A===3){var w=new Xl(f,f.readVarint()+f.pos);w.length&&(l[w.name]=w)}}Tu.VectorTile=function(A,l){this.layers=A.readFields(bl,{},l)},Tu.VectorTileFeature=Zn,Tu.VectorTileLayer=Tf;const Fo=Tu.VectorTileFeature.types,Sf=Math.pow(2,13);function $a(A,l,f,w,I,U,N,Z){A.emplaceBack(l,f,2*Math.floor(w*Sf)+N,I*Sf*2,U*Sf*2,Math.round(Z))}class Mf{constructor(l){this.zoom=l.zoom,this.overscaling=l.overscaling,this.layers=l.layers,this.layerIds=this.layers.map(f=>f.id),this.index=l.index,this.hasPattern=!1,this.layoutVertexArray=new Cr,this.centroidVertexArray=new Un,this.indexArray=new mo,this.programConfigurations=new si(l.layers,l.zoom),this.segments=new a,this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id)}populate(l,f,w){this.features=[],this.hasPattern=ag("fill-extrusion",this.layers,f);for(const{feature:I,id:U,index:N,sourceLayerIndex:Z}of l){const re=this.layers[0]._featureFilter.needGeometry,ge=Ai(I,re);if(!this.layers[0]._featureFilter.filter(new Zr(this.zoom),ge,w))continue;const Ce={id:U,sourceLayerIndex:Z,index:N,geometry:re?ge.geometry:Ri(I),properties:I.properties,type:I.type,patterns:{}};this.hasPattern?this.features.push(lg("fill-extrusion",this.layers,Ce,this.zoom,f)):this.addFeature(Ce,Ce.geometry,N,w,{}),f.featureIndex.insert(I,Ce.geometry,N,Z,this.index,!0)}}addFeatures(l,f,w){for(const I of this.features){const{geometry:U}=I;this.addFeature(I,U,I.index,f,w)}}update(l,f,w){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(l,f,this.stateDependentLayers,w)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,o1),this.centroidVertexBuffer=l.createVertexBuffer(this.centroidVertexArray,vc.members,!0),this.indexBuffer=l.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(l,f,w,I,U){const N={x:0,y:0,vertexCount:0};for(const Z of lh(f,500)){let re=0;for(const Ze of Z)re+=Ze.length;let ge=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const Ze of Z){if(Ze.length===0||hg(Ze))continue;let Rt=0;for(let Mt=0;Mt=1){const mi=Ze[Mt-1];if(!hd(ri,mi)){ge.vertexLength+4>a.MAX_VERTEX_ARRAY_LENGTH&&(ge=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const ei=ri.sub(mi)._perp()._unit(),ui=mi.dist(ri);Rt+ui>32768&&(Rt=0),$a(this.layoutVertexArray,ri.x,ri.y,ei.x,ei.y,0,0,Rt),$a(this.layoutVertexArray,ri.x,ri.y,ei.x,ei.y,0,1,Rt),N.x+=2*ri.x,N.y+=2*ri.y,N.vertexCount+=2,Rt+=ui,$a(this.layoutVertexArray,mi.x,mi.y,ei.x,ei.y,0,0,Rt),$a(this.layoutVertexArray,mi.x,mi.y,ei.x,ei.y,0,1,Rt),N.x+=2*mi.x,N.y+=2*mi.y,N.vertexCount+=2;const Pi=ge.vertexLength;this.indexArray.emplaceBack(Pi,Pi+2,Pi+1),this.indexArray.emplaceBack(Pi+1,Pi+2,Pi+3),ge.vertexLength+=4,ge.primitiveLength+=2}}}}if(ge.vertexLength+re>a.MAX_VERTEX_ARRAY_LENGTH&&(ge=this.segments.prepareSegment(re,this.layoutVertexArray,this.indexArray)),Fo[l.type]!=="Polygon")continue;const Ce=[],Ie=[],ke=ge.vertexLength;for(const Ze of Z)if(Ze.length!==0){Ze!==Z[0]&&Ie.push(Ce.length/2);for(let Rt=0;RtKt)||A.y===l.y&&(A.y<0||A.y>Kt)}function hg(A){return A.every(l=>l.x<0)||A.every(l=>l.x>Kt)||A.every(l=>l.y<0)||A.every(l=>l.y>Kt)}pn("FillExtrusionBucket",Mf,{omit:["layers","features"]});var zy={paint:new Cs({"fill-extrusion-opacity":new Fn($t["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Vn($t["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Fn($t["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Fn($t["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new sh($t["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Vn($t["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Vn($t["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Fn($t["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function yA(A,l){return A.x*l.x+A.y*l.y}function ky(A,l){if(A.length===1){let f=0;const w=l[f++];let I;for(;!I||w.equals(I);)if(I=l[f++],!I)return 1/0;for(;ff.id),this.index=l.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(f=>{this.gradients[f.id]={}}),this.layoutVertexArray=new Er,this.layoutVertexArray2=new Gr,this.indexArray=new mo,this.programConfigurations=new si(l.layers,l.zoom),this.segments=new a,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(f=>f.isStateDependent()).map(f=>f.id)}populate(l,f,w){this.hasPattern=ag("line",this.layers,f);const I=this.layers[0].layout.get("line-sort-key"),U=!I.isConstant(),N=[];for(const{feature:Z,id:re,index:ge,sourceLayerIndex:Ce}of l){const Ie=this.layers[0]._featureFilter.needGeometry,ke=Ai(Z,Ie);if(!this.layers[0]._featureFilter.filter(new Zr(this.zoom),ke,w))continue;const $e=U?I.evaluate(ke,{},w):void 0,Ze={id:re,properties:Z.properties,type:Z.type,sourceLayerIndex:Ce,index:ge,geometry:Ie?ke.geometry:Ri(Z),patterns:{},sortKey:$e};N.push(Ze)}U&&N.sort((Z,re)=>Z.sortKey-re.sortKey);for(const Z of N){const{geometry:re,index:ge,sourceLayerIndex:Ce}=Z;if(this.hasPattern){const Ie=lg("line",this.layers,Z,this.zoom,f);this.patternFeatures.push(Ie)}else this.addFeature(Z,re,ge,w,{});f.featureIndex.insert(l[ge].feature,re,ge,Ce,this.index)}}update(l,f,w){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(l,f,this.stateDependentLayers,w)}addFeatures(l,f,w){for(const I of this.patternFeatures)this.addFeature(I,I.geometry,I.index,f,w)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(l){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=l.createVertexBuffer(this.layoutVertexArray2,Yh)),this.layoutVertexBuffer=l.createVertexBuffer(this.layoutVertexArray,Oy),this.indexBuffer=l.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(l),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(l){if(l.properties&&Object.prototype.hasOwnProperty.call(l.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(l.properties,"mapbox_clip_end"))return{start:+l.properties.mapbox_clip_start,end:+l.properties.mapbox_clip_end}}addFeature(l,f,w,I,U){const N=this.layers[0].layout,Z=N.get("line-join").evaluate(l,{}),re=N.get("line-cap"),ge=N.get("line-miter-limit"),Ce=N.get("line-round-limit");this.lineClips=this.lineFeatureClips(l);for(const Ie of f)this.addLine(Ie,l,Z,re,ge,Ce);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,l,w,U,I)}addLine(l,f,w,I,U,N){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let ri=0;ri=2&&l[re-1].equals(l[re-2]);)re--;let ge=0;for(;ge0;if(Sn&&ri>ge){const nn=ke.dist($e);if(nn>2*Ce){const vn=ke.sub(ke.sub($e)._mult(Ce/nn)._round());this.updateDistance($e,vn),this.addCurrentVertex(vn,Rt,0,0,Ie),$e=vn}}const mn=$e&&Ze;let an=mn?w:Z?"butt":I;if(mn&&an==="round"&&(PiU&&(an="bevel"),an==="bevel"&&(Pi>2&&(an="flipbevel"),Pi100)mi=Mt.mult(-1);else{const nn=Pi*Rt.add(Mt).mag()/Rt.sub(Mt).mag();mi._perp()._mult(nn*(fn?-1:1))}this.addCurrentVertex(ke,mi,0,0,Ie),this.addCurrentVertex(ke,mi.mult(-1),0,0,Ie)}else if(an==="bevel"||an==="fakeround"){const nn=-Math.sqrt(Pi*Pi-1),vn=fn?nn:0,gn=fn?0:nn;if($e&&this.addCurrentVertex(ke,Rt,vn,gn,Ie),an==="fakeround"){const Ji=Math.round(180*Fi/Math.PI/20);for(let Wn=1;Wn2*Ce){const vn=ke.add(Ze.sub(ke)._mult(Ce/nn)._round());this.updateDistance(ke,vn),this.addCurrentVertex(vn,Mt,0,0,Ie),ke=vn}}}}addCurrentVertex(l,f,w,I,U,N=!1){const Z=f.y*I-f.x,re=-f.y-f.x*I;this.addHalfVertex(l,f.x+f.y*w,f.y-f.x*w,N,!1,w,U),this.addHalfVertex(l,Z,re,N,!0,-I,U),this.distance>mp/2&&this.totalDistance===0&&(this.distance=0,this.addCurrentVertex(l,f,w,I,U,N))}addHalfVertex({x:l,y:f},w,I,U,N,Z,re){const ge=.5*(this.lineClips?this.scaledDistance*(mp-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((l<<1)+(U?1:0),(f<<1)+(N?1:0),Math.round(63*w)+128,Math.round(63*I)+128,1+(Z===0?0:Z<0?-1:1)|(63&ge)<<2,ge>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const Ce=re.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,Ce),re.primitiveLength++),N?this.e2=Ce:this.e1=Ce}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(l,f){this.distance+=l.dist(f),this.updateScaledDistance()}}pn("LineBucket",gp,{omit:["layers","patternFeatures"]});const Ny=new Cs({"line-cap":new Fn($t.layout_line["line-cap"]),"line-join":new Vn($t.layout_line["line-join"]),"line-miter-limit":new Fn($t.layout_line["line-miter-limit"]),"line-round-limit":new Fn($t.layout_line["line-round-limit"]),"line-sort-key":new Vn($t.layout_line["line-sort-key"])});var Qy={paint:new Cs({"line-opacity":new Vn($t.paint_line["line-opacity"]),"line-color":new Vn($t.paint_line["line-color"]),"line-translate":new Fn($t.paint_line["line-translate"]),"line-translate-anchor":new Fn($t.paint_line["line-translate-anchor"]),"line-width":new Vn($t.paint_line["line-width"]),"line-gap-width":new Vn($t.paint_line["line-gap-width"]),"line-offset":new Vn($t.paint_line["line-offset"]),"line-blur":new Vn($t.paint_line["line-blur"]),"line-dasharray":new dA($t.paint_line["line-dasharray"]),"line-pattern":new sh($t.paint_line["line-pattern"]),"line-gradient":new yl($t.paint_line["line-gradient"])}),layout:Ny};const Ag=new class extends Vn{possiblyEvaluate(A,l){return l=new Zr(Math.floor(l.zoom),{now:l.now,fadeDuration:l.fadeDuration,zoomHistory:l.zoomHistory,transition:l.transition}),super.possiblyEvaluate(A,l)}evaluate(A,l,f,w){return l=J({},l,{zoom:Math.floor(l.zoom)}),super.evaluate(A,l,f,w)}}(Qy.paint.properties["line-width"].specification);function Vy(A,l){return l>0?l+2*A:A}Ag.useIntegerZoom=!0;const dg=Is([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),l1=Is([{name:"a_projected_pos",components:3,type:"Float32"}],4);Is([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const pg=Is([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Is([{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 fg=Is([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Hy=Is([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function vA(A,l,f){return A.sections.forEach(w=>{w.text=function(I,U,N){const Z=U.layout.get("text-transform").evaluate(N,{});return Z==="uppercase"?I=I.toLocaleUpperCase():Z==="lowercase"&&(I=I.toLocaleLowerCase()),xs.applyArabicShaping&&(I=xs.applyArabicShaping(I)),I}(w.text,l,f)}),A}Is([{name:"triangle",components:3,type:"Uint16"}]),Is([{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"}]),Is([{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Is([{type:"Float32",name:"offsetX"}]),Is([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const ud={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};var yo=24,Su=Yr,_p=function(A,l,f,w,I){var U,N,Z=8*I-w-1,re=(1<>1,Ce=-7,Ie=f?I-1:0,ke=f?-1:1,$e=A[l+Ie];for(Ie+=ke,U=$e&(1<<-Ce)-1,$e>>=-Ce,Ce+=Z;Ce>0;U=256*U+A[l+Ie],Ie+=ke,Ce-=8);for(N=U&(1<<-Ce)-1,U>>=-Ce,Ce+=w;Ce>0;N=256*N+A[l+Ie],Ie+=ke,Ce-=8);if(U===0)U=1-ge;else{if(U===re)return N?NaN:1/0*($e?-1:1);N+=Math.pow(2,w),U-=ge}return($e?-1:1)*N*Math.pow(2,U-w)},mg=function(A,l,f,w,I,U){var N,Z,re,ge=8*U-I-1,Ce=(1<>1,ke=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,$e=w?0:U-1,Ze=w?1:-1,Rt=l<0||l===0&&1/l<0?1:0;for(l=Math.abs(l),isNaN(l)||l===1/0?(Z=isNaN(l)?1:0,N=Ce):(N=Math.floor(Math.log(l)/Math.LN2),l*(re=Math.pow(2,-N))<1&&(N--,re*=2),(l+=N+Ie>=1?ke/re:ke*Math.pow(2,1-Ie))*re>=2&&(N++,re/=2),N+Ie>=Ce?(Z=0,N=Ce):N+Ie>=1?(Z=(l*re-1)*Math.pow(2,I),N+=Ie):(Z=l*Math.pow(2,Ie-1)*Math.pow(2,I),N=0));I>=8;A[f+$e]=255&Z,$e+=Ze,Z/=256,I-=8);for(N=N<0;A[f+$e]=255&N,$e+=Ze,N/=256,ge-=8);A[f+$e-Ze]|=128*Rt};function Yr(A){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(A)?A:new Uint8Array(A||0),this.pos=0,this.type=0,this.length=this.buf.length}Yr.Varint=0,Yr.Fixed64=1,Yr.Bytes=2,Yr.Fixed32=5;var Mu,gg=4294967296,yp=1/gg,Sa=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function hh(A){return A.type===Yr.Bytes?A.readVarint()+A.pos:A.pos+1}function wA(A,l,f){return f?4294967296*l+(A>>>0):4294967296*(l>>>0)+(A>>>0)}function ql(A,l,f){var w=l<=16383?1:l<=2097151?2:l<=268435455?3:Math.floor(Math.log(l)/(7*Math.LN2));f.realloc(w);for(var I=f.pos-1;I>=A;I--)f.buf[I+w]=f.buf[I]}function _g(A,l){for(var f=0;f>>8,A[f+2]=l>>>16,A[f+3]=l>>>24}function dd(A,l){return(A[l]|A[l+1]<<8|A[l+2]<<16)+(A[l+3]<<24)}function pd(A,l,f){A===1&&f.readMessage(Jh,l)}function Jh(A,l,f){if(A===3){const{id:w,bitmap:I,width:U,height:N,left:Z,top:re,advance:ge}=f.readMessage(xg,{});l.push({id:w,bitmap:new Xh({width:U+6,height:N+6},I),metrics:{width:U,height:N,left:Z,top:re,advance:ge}})}}function xg(A,l,f){A===1?l.id=f.readVarint():A===2?l.bitmap=f.readBytes():A===3?l.width=f.readVarint():A===4?l.height=f.readVarint():A===5?l.left=f.readSVarint():A===6?l.top=f.readSVarint():A===7&&(l.advance=f.readVarint())}function vg(A){let l=0,f=0;for(const N of A)l+=N.w*N.h,f=Math.max(f,N.w);A.sort((N,Z)=>Z.h-N.h);const w=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(l/.95)),f),h:1/0}];let I=0,U=0;for(const N of A)for(let Z=w.length-1;Z>=0;Z--){const re=w[Z];if(!(N.w>re.w||N.h>re.h)){if(N.x=re.x,N.y=re.y,U=Math.max(U,N.y+N.h),I=Math.max(I,N.x+N.w),N.w===re.w&&N.h===re.h){const ge=w.pop();Z>3,U=this.pos;this.type=7&w,A(I,l,this),this.pos===U&&this.skip(w)}return l},readMessage:function(A,l){return this.readFields(A,l,this.readVarint()+this.pos)},readFixed32:function(){var A=Ad(this.buf,this.pos);return this.pos+=4,A},readSFixed32:function(){var A=dd(this.buf,this.pos);return this.pos+=4,A},readFixed64:function(){var A=Ad(this.buf,this.pos)+Ad(this.buf,this.pos+4)*gg;return this.pos+=8,A},readSFixed64:function(){var A=Ad(this.buf,this.pos)+dd(this.buf,this.pos+4)*gg;return this.pos+=8,A},readFloat:function(){var A=_p(this.buf,this.pos,!0,23,4);return this.pos+=4,A},readDouble:function(){var A=_p(this.buf,this.pos,!0,52,8);return this.pos+=8,A},readVarint:function(A){var l,f,w=this.buf;return l=127&(f=w[this.pos++]),f<128?l:(l|=(127&(f=w[this.pos++]))<<7,f<128?l:(l|=(127&(f=w[this.pos++]))<<14,f<128?l:(l|=(127&(f=w[this.pos++]))<<21,f<128?l:function(I,U,N){var Z,re,ge=N.buf;if(Z=(112&(re=ge[N.pos++]))>>4,re<128||(Z|=(127&(re=ge[N.pos++]))<<3,re<128)||(Z|=(127&(re=ge[N.pos++]))<<10,re<128)||(Z|=(127&(re=ge[N.pos++]))<<17,re<128)||(Z|=(127&(re=ge[N.pos++]))<<24,re<128)||(Z|=(1&(re=ge[N.pos++]))<<31,re<128))return wA(I,Z,U);throw new Error("Expected varint not more than 10 bytes")}(l|=(15&(f=w[this.pos]))<<28,A,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var A=this.readVarint();return A%2==1?(A+1)/-2:A/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var A=this.readVarint()+this.pos,l=this.pos;return this.pos=A,A-l>=12&&Sa?function(f,w,I){return Sa.decode(f.subarray(w,I))}(this.buf,l,A):function(f,w,I){for(var U="",N=w;N239?4:Ce>223?3:Ce>191?2:1;if(N+ke>I)break;ke===1?Ce<128&&(Ie=Ce):ke===2?(192&(Z=f[N+1]))==128&&(Ie=(31&Ce)<<6|63&Z)<=127&&(Ie=null):ke===3?(re=f[N+2],(192&(Z=f[N+1]))==128&&(192&re)==128&&((Ie=(15&Ce)<<12|(63&Z)<<6|63&re)<=2047||Ie>=55296&&Ie<=57343)&&(Ie=null)):ke===4&&(re=f[N+2],ge=f[N+3],(192&(Z=f[N+1]))==128&&(192&re)==128&&(192&ge)==128&&((Ie=(15&Ce)<<18|(63&Z)<<12|(63&re)<<6|63&ge)<=65535||Ie>=1114112)&&(Ie=null)),Ie===null?(Ie=65533,ke=1):Ie>65535&&(Ie-=65536,U+=String.fromCharCode(Ie>>>10&1023|55296),Ie=56320|1023&Ie),U+=String.fromCharCode(Ie),N+=ke}return U}(this.buf,l,A)},readBytes:function(){var A=this.readVarint()+this.pos,l=this.buf.subarray(this.pos,A);return this.pos=A,l},readPackedVarint:function(A,l){if(this.type!==Yr.Bytes)return A.push(this.readVarint(l));var f=hh(this);for(A=A||[];this.pos127;);else if(l===Yr.Bytes)this.pos=this.readVarint()+this.pos;else if(l===Yr.Fixed32)this.pos+=4;else{if(l!==Yr.Fixed64)throw new Error("Unimplemented type: "+l);this.pos+=8}},writeTag:function(A,l){this.writeVarint(A<<3|l)},realloc:function(A){for(var l=this.length||16;l268435455||A<0?function(l,f){var w,I;if(l>=0?(w=l%4294967296|0,I=l/4294967296|0):(I=~(-l/4294967296),4294967295^(w=~(-l%4294967296))?w=w+1|0:(w=0,I=I+1|0)),l>=18446744073709552e3||l<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");f.realloc(10),function(U,N,Z){Z.buf[Z.pos++]=127&U|128,U>>>=7,Z.buf[Z.pos++]=127&U|128,U>>>=7,Z.buf[Z.pos++]=127&U|128,U>>>=7,Z.buf[Z.pos++]=127&U|128,Z.buf[Z.pos]=127&(U>>>=7)}(w,0,f),function(U,N){var Z=(7&U)<<4;N.buf[N.pos++]|=Z|((U>>>=3)?128:0),U&&(N.buf[N.pos++]=127&U|((U>>>=7)?128:0),U&&(N.buf[N.pos++]=127&U|((U>>>=7)?128:0),U&&(N.buf[N.pos++]=127&U|((U>>>=7)?128:0),U&&(N.buf[N.pos++]=127&U|((U>>>=7)?128:0),U&&(N.buf[N.pos++]=127&U)))))}(I,f)}(A,this):(this.realloc(4),this.buf[this.pos++]=127&A|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=127&(A>>>=7)|(A>127?128:0),A<=127||(this.buf[this.pos++]=A>>>7&127))))},writeSVarint:function(A){this.writeVarint(A<0?2*-A-1:2*A)},writeBoolean:function(A){this.writeVarint(Boolean(A))},writeString:function(A){A=String(A),this.realloc(4*A.length),this.pos++;var l=this.pos;this.pos=function(w,I,U){for(var N,Z,re=0;re55295&&N<57344){if(!Z){N>56319||re+1===I.length?(w[U++]=239,w[U++]=191,w[U++]=189):Z=N;continue}if(N<56320){w[U++]=239,w[U++]=191,w[U++]=189,Z=N;continue}N=Z-55296<<10|N-56320|65536,Z=null}else Z&&(w[U++]=239,w[U++]=191,w[U++]=189,Z=null);N<128?w[U++]=N:(N<2048?w[U++]=N>>6|192:(N<65536?w[U++]=N>>12|224:(w[U++]=N>>18|240,w[U++]=N>>12&63|128),w[U++]=N>>6&63|128),w[U++]=63&N|128)}return U}(this.buf,A,this.pos);var f=this.pos-l;f>=128&&ql(l,f,this),this.pos=l-1,this.writeVarint(f),this.pos+=f},writeFloat:function(A){this.realloc(4),mg(this.buf,A,this.pos,!0,23,4),this.pos+=4},writeDouble:function(A){this.realloc(8),mg(this.buf,A,this.pos,!0,52,8),this.pos+=8},writeBytes:function(A){var l=A.length;this.writeVarint(l),this.realloc(l);for(var f=0;f=128&&ql(f,w,this),this.pos=f-1,this.writeVarint(w),this.pos+=w},writeMessage:function(A,l,f){this.writeTag(A,Yr.Bytes),this.writeRawMessage(l,f)},writePackedVarint:function(A,l){l.length&&this.writeMessage(A,_g,l)},writePackedSVarint:function(A,l){l.length&&this.writeMessage(A,bA,l)},writePackedBoolean:function(A,l){l.length&&this.writeMessage(A,yg,l)},writePackedFloat:function(A,l){l.length&&this.writeMessage(A,xp,l)},writePackedDouble:function(A,l){l.length&&this.writeMessage(A,BA,l)},writePackedFixed32:function(A,l){l.length&&this.writeMessage(A,Ff,l)},writePackedSFixed32:function(A,l){l.length&&this.writeMessage(A,Gy,l)},writePackedFixed64:function(A,l){l.length&&this.writeMessage(A,Wy,l)},writePackedSFixed64:function(A,l){l.length&&this.writeMessage(A,c1,l)},writeBytesField:function(A,l){this.writeTag(A,Yr.Bytes),this.writeBytes(l)},writeFixed32Field:function(A,l){this.writeTag(A,Yr.Fixed32),this.writeFixed32(l)},writeSFixed32Field:function(A,l){this.writeTag(A,Yr.Fixed32),this.writeSFixed32(l)},writeFixed64Field:function(A,l){this.writeTag(A,Yr.Fixed64),this.writeFixed64(l)},writeSFixed64Field:function(A,l){this.writeTag(A,Yr.Fixed64),this.writeSFixed64(l)},writeVarintField:function(A,l){this.writeTag(A,Yr.Varint),this.writeVarint(l)},writeSVarintField:function(A,l){this.writeTag(A,Yr.Varint),this.writeSVarint(l)},writeStringField:function(A,l){this.writeTag(A,Yr.Bytes),this.writeString(l)},writeFloatField:function(A,l){this.writeTag(A,Yr.Fixed32),this.writeFloat(l)},writeDoubleField:function(A,l){this.writeTag(A,Yr.Fixed64),this.writeDouble(l)},writeBooleanField:function(A,l){this.writeVarintField(A,Boolean(l))}};class EA{constructor(l,{pixelRatio:f,version:w,stretchX:I,stretchY:U,content:N}){this.paddedRect=l,this.pixelRatio=f,this.stretchX=I,this.stretchY=U,this.content=N,this.version=w}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class fd{constructor(l,f){const w={},I={};this.haveRenderCallbacks=[];const U=[];this.addImages(l,w,U),this.addImages(f,I,U);const{w:N,h:Z}=vg(U),re=new Aa({width:N||1,height:Z||1});for(const ge in l){const Ce=l[ge],Ie=w[ge].paddedRect;Aa.copy(Ce.data,re,{x:0,y:0},{x:Ie.x+1,y:Ie.y+1},Ce.data)}for(const ge in f){const Ce=f[ge],Ie=I[ge].paddedRect,ke=Ie.x+1,$e=Ie.y+1,Ze=Ce.data.width,Rt=Ce.data.height;Aa.copy(Ce.data,re,{x:0,y:0},{x:ke,y:$e},Ce.data),Aa.copy(Ce.data,re,{x:0,y:Rt-1},{x:ke,y:$e-1},{width:Ze,height:1}),Aa.copy(Ce.data,re,{x:0,y:0},{x:ke,y:$e+Rt},{width:Ze,height:1}),Aa.copy(Ce.data,re,{x:Ze-1,y:0},{x:ke-1,y:$e},{width:1,height:Rt}),Aa.copy(Ce.data,re,{x:0,y:0},{x:ke+Ze,y:$e},{width:1,height:Rt})}this.image=re,this.iconPositions=w,this.patternPositions=I}addImages(l,f,w){for(const I in l){const U=l[I],N={x:0,y:0,w:U.data.width+2,h:U.data.height+2};w.push(N),f[I]=new EA(N,U),U.hasRenderCallback&&this.haveRenderCallbacks.push(I)}}patchUpdatedImages(l,f){l.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const w in l.updatedImages)this.patchUpdatedImage(this.iconPositions[w],l.getImage(w),f),this.patchUpdatedImage(this.patternPositions[w],l.getImage(w),f)}patchUpdatedImage(l,f,w){if(!l||!f||l.version===f.version)return;l.version=f.version;const[I,U]=l.tl;w.update(f.data,void 0,{x:I,y:U})}}pn("ImagePosition",EA),pn("ImageAtlas",fd),i.WritingMode=void 0,(Mu=i.WritingMode||(i.WritingMode={}))[Mu.none=0]="none",Mu[Mu.horizontal=1]="horizontal",Mu[Mu.vertical=2]="vertical",Mu[Mu.horizontalOnly=3]="horizontalOnly";const da=-17;class eu{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(l,f){const w=new eu;return w.scale=l||1,w.fontStack=f,w}static forImage(l){const f=new eu;return f.imageName=l,f}}class so{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(l,f){const w=new so;for(let I=0;I=0&&w>=l&&md[this.text.charCodeAt(w)];w--)f--;this.text=this.text.substring(l,f),this.sectionIndex=this.sectionIndex.slice(l,f)}substring(l,f){const w=new so;return w.text=this.text.substring(l,f),w.sectionIndex=this.sectionIndex.slice(l,f),w.sections=this.sections,w}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((l,f)=>Math.max(l,this.sections[f].scale),0)}addTextSection(l,f){this.text+=l.text,this.sections.push(eu.forText(l.scale,l.fontStack||f));const w=this.sections.length-1;for(let I=0;I=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Ma(A,l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke,$e,Ze,Rt){const Mt=so.fromFeature(A,I);let ri;Ie===i.WritingMode.vertical&&Mt.verticalizePunctuation();const{processBidirectionalText:mi,processStyledBidirectionalText:ei}=xs;if(mi&&Mt.sections.length===1){ri=[];const Fi=mi(Mt.toString(),Lf(Mt,ge,U,l,w,$e,Ze));for(const Sn of Fi){const fn=new so;fn.text=Sn,fn.sections=Mt.sections;for(let mn=0;mn0&&dh>Vs&&(Vs=dh)}else{const vr=fn[pr.fontStack],Zo=vr&&vr[Uo];if(Zo&&Zo.rect)Cc=Zo.rect,Jl=Zo.metrics;else{const dh=Sn[pr.fontStack],Td=dh&&dh[Uo];if(!Td)continue;Jl=Td.metrics}ao=(Do-pr.scale)*yo}El?(Fi.verticalizable=!0,Jr.push({glyph:Uo,imageName:Fa,x:fs,y:ws+ao,vertical:El,scale:pr.scale,fontStack:pr.fontStack,sectionIndex:qa,metrics:Jl,rect:Cc}),fs+=Ah*pr.scale+Wn):(Jr.push({glyph:Uo,imageName:Fa,x:fs,y:ws+ao,vertical:El,scale:pr.scale,fontStack:pr.fontStack,sectionIndex:qa,metrics:Jl,rect:Cc}),fs+=Jl.advance*pr.scale+Wn)}Jr.length!==0&&(Qs=Math.max(fs-Wn,Qs),TA(Jr,0,Jr.length-1,xo,Vs)),fs=0;const ms=nn*Do+Vs;pa.lineOffset=Math.max(Vs,Po),ws+=ms,Cl=Math.max(ms,Cl),++Ks}var oo;const Lo=ws-da,{horizontalAlign:$o,verticalAlign:Ia}=Df(vn);(function(io,Do,Po,pa,Jr,Vs,ms,$s,pr){const qa=(Do-Po)*Jr;let Uo=0;Uo=Vs!==ms?-$s*pa-da:(-pa*pr+.5)*ms;for(const ao of io)for(const Jl of ao.positionedGlyphs)Jl.x+=qa,Jl.y+=Uo})(Fi.positionedLines,xo,$o,Ia,Qs,Cl,nn,Lo,an.length),Fi.top+=-Ia*Lo,Fi.bottom=Fi.top+Lo,Fi.left+=-$o*Qs,Fi.right=Fi.left+Qs}(Pi,l,f,w,ri,N,Z,re,Ie,ge,ke,Rt),!function(Fi){for(const Sn of Fi)if(Sn.positionedGlyphs.length!==0)return!1;return!0}(ui)&&Pi}const md={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Ns={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 wg(A,l,f,w,I,U){if(l.imageName){const N=w[l.imageName];return N?N.displaySize[0]*l.scale*yo/U+I:0}{const N=f[l.fontStack],Z=N&&N[A];return Z?Z.metrics.advance*l.scale+I:0}}function gd(A,l,f,w){const I=Math.pow(A-l,2);return w?A=0;let Ce=0;for(let ke=0;ke-f/2;){if(N--,N<0)return!1;Z-=A[N].dist(U),U=A[N]}Z+=A[N].dist(A[N+1]),N++;const re=[];let ge=0;for(;Zw;)ge-=re.shift().angleDelta;if(ge>I)return!1;N++,Z+=Ce.dist(Ie)}return!0}function Uf(A){let l=0;for(let f=0;fge){const Ze=(ge-re)/$e,Rt=is(Ie.x,ke.x,Ze),Mt=is(Ie.y,ke.y,Ze),ri=new Iu(Rt,Mt,ke.angleTo(Ie),Ce);return ri._round(),!N||Pf(A,ri,Z,N,l)?ri:void 0}re+=$e}}function h1(A,l,f,w,I,U,N,Z,re){const ge=Rf(w,U,N),Ce=Ko(w,I),Ie=Ce*N,ke=A[0].x===0||A[0].x===re||A[0].y===0||A[0].y===re;return l-Ie=0&&ui=0&&Pi=0&&ke+ge<=Ce){const Fi=new Iu(ui,Pi,mi,Ze);Fi._round(),w&&!Pf(A,Fi,U,w,I)||$e.push(Fi)}}Ie+=ri}return Z||$e.length||N||($e=Cg(A,Ie/2,f,w,I,U,N,!0,re)),$e}function Xy(A,l,f,w,I){const U=[];for(let N=0;N=w&&Ie.x>=w||(Ce.x>=w?Ce=new xe(w,Ce.y+(w-Ce.x)/(Ie.x-Ce.x)*(Ie.y-Ce.y))._round():Ie.x>=w&&(Ie=new xe(w,Ce.y+(w-Ce.x)/(Ie.x-Ce.x)*(Ie.y-Ce.y))._round()),Ce.y>=I&&Ie.y>=I||(Ce.y>=I?Ce=new xe(Ce.x+(I-Ce.y)/(Ie.y-Ce.y)*(Ie.x-Ce.x),I)._round():Ie.y>=I&&(Ie=new xe(Ce.x+(I-Ce.y)/(Ie.y-Ce.y)*(Ie.x-Ce.x),I)._round()),re&&Ce.equals(re[re.length-1])||(re=[Ce],U.push(re)),re.push(Ie)))))}}return U}function qy(A,l,f,w){const I=[],U=A.image,N=U.pixelRatio,Z=U.paddedRect.w-2,re=U.paddedRect.h-2,ge=A.right-A.left,Ce=A.bottom-A.top,Ie=U.stretchX||[[0,Z]],ke=U.stretchY||[[0,re]],$e=(nn,vn)=>nn+vn[1]-vn[0],Ze=Ie.reduce($e,0),Rt=ke.reduce($e,0),Mt=Z-Ze,ri=re-Rt;let mi=0,ei=Ze,ui=0,Pi=Rt,Fi=0,Sn=Mt,fn=0,mn=ri;if(U.content&&w){const nn=U.content;mi=vp(Ie,0,nn[0]),ui=vp(ke,0,nn[1]),ei=vp(Ie,nn[0],nn[2]),Pi=vp(ke,nn[1],nn[3]),Fi=nn[0]-mi,fn=nn[1]-ui,Sn=nn[2]-nn[0]-ei,mn=nn[3]-nn[1]-Pi}const an=(nn,vn,gn,Ji)=>{const Wn=wp(nn.stretch-mi,ei,ge,A.left),zn=_d(nn.fixed-Fi,Sn,nn.stretch,Ze),yr=wp(vn.stretch-ui,Pi,Ce,A.top),fs=_d(vn.fixed-fn,mn,vn.stretch,Rt),ws=wp(gn.stretch-mi,ei,ge,A.left),Qs=_d(gn.fixed-Fi,Sn,gn.stretch,Ze),Cl=wp(Ji.stretch-ui,Pi,Ce,A.top),xo=_d(Ji.fixed-fn,mn,Ji.stretch,Rt),Ks=new xe(Wn,yr),oo=new xe(ws,yr),Lo=new xe(ws,Cl),$o=new xe(Wn,Cl),Ia=new xe(zn/N,fs/N),io=new xe(Qs/N,xo/N),Do=l*Math.PI/180;if(Do){const Jr=Math.sin(Do),Vs=Math.cos(Do),ms=[Vs,-Jr,Jr,Vs];Ks._matMult(ms),oo._matMult(ms),$o._matMult(ms),Lo._matMult(ms)}const Po=nn.stretch+nn.fixed,pa=vn.stretch+vn.fixed;return{tl:Ks,tr:oo,bl:$o,br:Lo,tex:{x:U.paddedRect.x+1+Po,y:U.paddedRect.y+1+pa,w:gn.stretch+gn.fixed-Po,h:Ji.stretch+Ji.fixed-pa},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ia,pixelOffsetBR:io,minFontScaleX:Sn/N/ge,minFontScaleY:mn/N/Ce,isSDF:f}};if(w&&(U.stretchX||U.stretchY)){const nn=Eg(Ie,Mt,Ze),vn=Eg(ke,ri,Rt);for(let gn=0;gn0&&(Ze=Math.max(10,Ze),this.circleDiameter=Ze)}else{let Ie=N.top*Z-re[0],ke=N.bottom*Z+re[2],$e=N.left*Z-re[3],Ze=N.right*Z+re[1];const Rt=N.collisionPadding;if(Rt&&($e-=Rt[0]*Z,Ie-=Rt[1]*Z,Ze+=Rt[2]*Z,ke+=Rt[3]*Z),Ce){const Mt=new xe($e,Ie),ri=new xe(Ze,Ie),mi=new xe($e,ke),ei=new xe(Ze,ke),ui=Ce*Math.PI/180;Mt._rotate(ui),ri._rotate(ui),mi._rotate(ui),ei._rotate(ui),$e=Math.min(Mt.x,ri.x,mi.x,ei.x),Ze=Math.max(Mt.x,ri.x,mi.x,ei.x),Ie=Math.min(Mt.y,ri.y,mi.y,ei.y),ke=Math.max(Mt.y,ri.y,mi.y,ei.y)}l.emplaceBack(f.x,f.y,$e,Ie,Ze,ke,w,I,U)}this.boxEndIndex=l.length}}class Za{constructor(l=[],f=u1){if(this.data=l,this.length=this.data.length,this.compare=f,this.length>0)for(let w=(this.length>>1)-1;w>=0;w--)this._down(w)}push(l){this.data.push(l),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const l=this.data[0],f=this.data.pop();return this.length--,this.length>0&&(this.data[0]=f,this._down(0)),l}peek(){return this.data[0]}_up(l){const{data:f,compare:w}=this,I=f[l];for(;l>0;){const U=l-1>>1,N=f[U];if(w(I,N)>=0)break;f[l]=N,l=U}f[l]=I}_down(l){const{data:f,compare:w}=this,I=this.length>>1,U=f[l];for(;l=0)break;f[l]=Z,l=N}f[l]=U}}function u1(A,l){return Al?1:0}function Tg(A,l=1,f=!1){let w=1/0,I=1/0,U=-1/0,N=-1/0;const Z=A[0];for(let $e=0;$eU)&&(U=Ze.x),(!$e||Ze.y>N)&&(N=Ze.y)}const re=Math.min(U-w,N-I);let ge=re/2;const Ce=new Za([],A1);if(re===0)return new xe(w,I);for(let $e=w;$eIe.d||!Ie.d)&&(Ie=$e,f&&console.log("found best %d after %d probes",Math.round(1e4*$e.d)/1e4,ke)),$e.max-Ie.d<=l||(ge=$e.h/2,Ce.push(new yd($e.p.x-ge,$e.p.y-ge,ge,A)),Ce.push(new yd($e.p.x+ge,$e.p.y-ge,ge,A)),Ce.push(new yd($e.p.x-ge,$e.p.y+ge,ge,A)),Ce.push(new yd($e.p.x+ge,$e.p.y+ge,ge,A)),ke+=4)}return f&&(console.log(`num probes: ${ke}`),console.log(`best distance: ${Ie.d}`)),Ie.p}function A1(A,l){return l.max-A.max}function yd(A,l,f,w){this.p=new xe(A,l),this.h=f,this.d=function(I,U){let N=!1,Z=1/0;for(let re=0;reI.y!=Ze.y>I.y&&I.x<(Ze.x-$e.x)*(I.y-$e.y)/(Ze.y-$e.y)+$e.x&&(N=!N),Z=Math.min(Z,On(I,$e,Ze))}}return(N?1:-1)*Math.sqrt(Z)}(this.p,w),this.max=this.d+this.h*Math.SQRT2}const Sg=Number.POSITIVE_INFINITY;function xd(A,l){return l[1]!==Sg?function(f,w,I){let U=0,N=0;switch(w=Math.abs(w),I=Math.abs(I),f){case"top-right":case"top-left":case"top":N=I-7;break;case"bottom-right":case"bottom-left":case"bottom":N=7-I}switch(f){case"top-right":case"bottom-right":case"right":U=-w;break;case"top-left":case"bottom-left":case"left":U=w}return[U,N]}(A,l[0],l[1]):function(f,w){let I=0,U=0;w<0&&(w=0);const N=w/Math.sqrt(2);switch(f){case"top-right":case"top-left":U=N-7;break;case"bottom-right":case"bottom-left":U=7-N;break;case"bottom":U=7-w;break;case"top":U=w-7}switch(f){case"top-right":case"bottom-right":I=-N;break;case"top-left":case"bottom-left":I=N;break;case"left":I=w;break;case"right":I=-w}return[I,U]}(A,l[0])}function vd(A){switch(A){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Yy(A,l,f,w,I,U,N,Z,re,ge,Ce){let Ie=U.textMaxSize.evaluate(l,{});Ie===void 0&&(Ie=N);const ke=A.layers[0].layout,$e=ke.get("icon-offset").evaluate(l,{},Ce),Ze=Jy(f.horizontal),Rt=N/24,Mt=A.tilePixelRatio*Rt,ri=A.tilePixelRatio*Ie/24,mi=A.tilePixelRatio*Z,ei=A.tilePixelRatio*ke.get("symbol-spacing"),ui=ke.get("text-padding")*A.tilePixelRatio,Pi=function(Ji,Wn,zn,yr=1){const fs=Ji.get("icon-padding").evaluate(Wn,{},zn),ws=fs&&fs.values;return[ws[0]*yr,ws[1]*yr,ws[2]*yr,ws[3]*yr]}(ke,l,Ce,A.tilePixelRatio),Fi=ke.get("text-max-angle")/180*Math.PI,Sn=ke.get("text-rotation-alignment")!=="viewport"&&ke.get("symbol-placement")!=="point",fn=ke.get("icon-rotation-alignment")==="map"&&ke.get("symbol-placement")!=="point",mn=ke.get("symbol-placement"),an=ei/2,nn=ke.get("icon-text-fit");let vn;w&&nn!=="none"&&(A.allowVerticalPlacement&&f.vertical&&(vn=bg(w,f.vertical,nn,ke.get("icon-text-fit-padding"),$e,Rt)),Ze&&(w=bg(w,Ze,nn,ke.get("icon-text-fit-padding"),$e,Rt)));const gn=(Ji,Wn)=>{Wn.x<0||Wn.x>=Kt||Wn.y<0||Wn.y>=Kt||function(zn,yr,fs,ws,Qs,Cl,xo,Ks,oo,Lo,$o,Ia,io,Do,Po,pa,Jr,Vs,ms,$s,pr,qa,Uo,ao,Jl){const Cc=zn.addToLineVertexArray(yr,fs);let Fa,Ah,El,vr,Zo=0,dh=0,Td=0,ph=0,Fu=-1,Hf=-1;const tu={};let l0=S.exports(""),Ug=0,Rg=0;if(Ks._unevaluatedLayout.getValue("text-radial-offset")===void 0?[Ug,Rg]=Ks.layout.get("text-offset").evaluate(pr,{},ao).map(Xo=>Xo*yo):(Ug=Ks.layout.get("text-radial-offset").evaluate(pr,{},ao)*yo,Rg=Sg),zn.allowVerticalPlacement&&ws.vertical){const Xo=Ks.layout.get("text-rotate").evaluate(pr,{},ao)+90;El=new Yl(oo,yr,Lo,$o,Ia,ws.vertical,io,Do,Po,Xo),xo&&(vr=new Yl(oo,yr,Lo,$o,Ia,xo,Jr,Vs,Po,Xo))}if(Qs){const Xo=Ks.layout.get("icon-rotate").evaluate(pr,{}),Tc=Ks.layout.get("icon-text-fit")!=="none",qo=qy(Qs,Xo,Uo,Tc),iu=xo?qy(xo,Xo,Uo,Tc):void 0;Ah=new Yl(oo,yr,Lo,$o,Ia,Qs,Jr,Vs,!1,Xo),Zo=4*qo.length;const IA=zn.iconSizeData;let nu=null;IA.kind==="source"?(nu=[uh*Ks.layout.get("icon-size").evaluate(pr,{})],nu[0]>Xa&&me(`${zn.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):IA.kind==="composite"&&(nu=[uh*qa.compositeIconSizes[0].evaluate(pr,{},ao),uh*qa.compositeIconSizes[1].evaluate(pr,{},ao)],(nu[0]>Xa||nu[1]>Xa)&&me(`${zn.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),zn.addSymbols(zn.icon,qo,nu,$s,ms,pr,i.WritingMode.none,yr,Cc.lineStartIndex,Cc.lineLength,-1,ao),Fu=zn.icon.placedSymbolArray.length-1,iu&&(dh=4*iu.length,zn.addSymbols(zn.icon,iu,nu,$s,ms,pr,i.WritingMode.vertical,yr,Cc.lineStartIndex,Cc.lineLength,-1,ao),Hf=zn.icon.placedSymbolArray.length-1)}const c0=Object.keys(ws.horizontal);for(const Xo of c0){const Tc=ws.horizontal[Xo];if(!Fa){l0=S.exports(Tc.text);const iu=Ks.layout.get("text-rotate").evaluate(pr,{},ao);Fa=new Yl(oo,yr,Lo,$o,Ia,Tc,io,Do,Po,iu)}const qo=Tc.positionedLines.length===1;if(Td+=wd(zn,yr,Tc,Cl,Ks,Po,pr,pa,Cc,ws.vertical?i.WritingMode.horizontal:i.WritingMode.horizontalOnly,qo?c0:[Xo],tu,Fu,qa,ao),qo)break}ws.vertical&&(ph+=wd(zn,yr,ws.vertical,Cl,Ks,Po,pr,pa,Cc,i.WritingMode.vertical,["vertical"],tu,Hf,qa,ao));const x1=Fa?Fa.boxStartIndex:zn.collisionBoxArray.length,v1=Fa?Fa.boxEndIndex:zn.collisionBoxArray.length,w1=El?El.boxStartIndex:zn.collisionBoxArray.length,b1=El?El.boxEndIndex:zn.collisionBoxArray.length,Gf=Ah?Ah.boxStartIndex:zn.collisionBoxArray.length,Sd=Ah?Ah.boxEndIndex:zn.collisionBoxArray.length,h0=vr?vr.boxStartIndex:zn.collisionBoxArray.length,B1=vr?vr.boxEndIndex:zn.collisionBoxArray.length;let Ec=-1;const Wf=(Xo,Tc)=>Xo&&Xo.circleDiameter?Math.max(Xo.circleDiameter,Tc):Tc;Ec=Wf(Fa,Ec),Ec=Wf(El,Ec),Ec=Wf(Ah,Ec),Ec=Wf(vr,Ec);const jf=Ec>-1?1:0;jf&&(Ec*=Jl/yo),zn.glyphOffsetArray.length>=Bc.MAX_GLYPHS&&me("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),pr.sortKey!==void 0&&zn.addToSortKeyRanges(zn.symbolInstances.length,pr.sortKey),zn.symbolInstances.emplaceBack(yr.x,yr.y,tu.right>=0?tu.right:-1,tu.center>=0?tu.center:-1,tu.left>=0?tu.left:-1,tu.vertical||-1,Fu,Hf,l0,x1,v1,w1,b1,Gf,Sd,h0,B1,Lo,Td,ph,Zo,dh,jf,0,io,Ug,Rg,Ec)}(A,Wn,Ji,f,w,I,vn,A.layers[0],A.collisionBoxArray,l.index,l.sourceLayerIndex,A.index,Mt,[ui,ui,ui,ui],Sn,re,mi,Pi,fn,$e,l,U,ge,Ce,N)};if(mn==="line")for(const Ji of Xy(l.geometry,0,0,Kt,Kt)){const Wn=h1(Ji,ei,Fi,f.vertical||Ze,w,24,ri,A.overscaling,Kt);for(const zn of Wn){const yr=Ze;yr&&d1(A,yr.text,an,zn)||gn(Ji,zn)}}else if(mn==="line-center"){for(const Ji of l.geometry)if(Ji.length>1){const Wn=Zy(Ji,Fi,f.vertical||Ze,w,24,ri);Wn&&gn(Ji,Wn)}}else if(l.type==="Polygon")for(const Ji of lh(l.geometry,0)){const Wn=Tg(Ji,16);gn(Ji[0],new Iu(Wn.x,Wn.y,0))}else if(l.type==="LineString")for(const Ji of l.geometry)gn(Ji,new Iu(Ji[0].x,Ji[0].y,0));else if(l.type==="Point")for(const Ji of l.geometry)for(const Wn of Ji)gn([Wn],new Iu(Wn.x,Wn.y,0))}const Xa=32640;function wd(A,l,f,w,I,U,N,Z,re,ge,Ce,Ie,ke,$e,Ze){const Rt=function(mi,ei,ui,Pi,Fi,Sn,fn,mn){const an=Pi.layout.get("text-rotate").evaluate(Sn,{})*Math.PI/180,nn=[];for(const vn of ei.positionedLines)for(const gn of vn.positionedGlyphs){if(!gn.rect)continue;const Ji=gn.rect||{};let Wn=4,zn=!0,yr=1,fs=0;const ws=(Fi||mn)&&gn.vertical,Qs=gn.metrics.advance*gn.scale/2;if(mn&&ei.verticalizable){const ms=(gn.scale-1)*yo,$s=(yo-gn.metrics.width*gn.scale)/2;fs=vn.lineOffset/2-(gn.imageName?-$s:ms)}if(gn.imageName){const ms=fn[gn.imageName];zn=ms.sdf,yr=ms.pixelRatio,Wn=1/yr}const Cl=Fi?[gn.x+Qs,gn.y]:[0,0];let xo=Fi?[0,0]:[gn.x+Qs+ui[0],gn.y+ui[1]-fs],Ks=[0,0];ws&&(Ks=xo,xo=[0,0]);const oo=(gn.metrics.left-Wn)*gn.scale-Qs+xo[0],Lo=(-gn.metrics.top-Wn)*gn.scale+xo[1],$o=oo+Ji.w*gn.scale/yr,Ia=Lo+Ji.h*gn.scale/yr,io=new xe(oo,Lo),Do=new xe($o,Lo),Po=new xe(oo,Ia),pa=new xe($o,Ia);if(ws){const ms=new xe(-Qs,Qs-da),$s=-Math.PI/2,pr=12-Qs,qa=new xe(22-pr,-(gn.imageName?pr:0)),Uo=new xe(...Ks);io._rotateAround($s,ms)._add(qa)._add(Uo),Do._rotateAround($s,ms)._add(qa)._add(Uo),Po._rotateAround($s,ms)._add(qa)._add(Uo),pa._rotateAround($s,ms)._add(qa)._add(Uo)}if(an){const ms=Math.sin(an),$s=Math.cos(an),pr=[$s,-ms,ms,$s];io._matMult(pr),Do._matMult(pr),Po._matMult(pr),pa._matMult(pr)}const Jr=new xe(0,0),Vs=new xe(0,0);nn.push({tl:io,tr:Do,bl:Po,br:pa,tex:Ji,writingMode:ei.writingMode,glyphOffset:Cl,sectionIndex:gn.sectionIndex,isSDF:zn,pixelOffsetTL:Jr,pixelOffsetBR:Vs,minFontScaleX:0,minFontScaleY:0})}return nn}(0,f,Z,I,U,N,w,A.allowVerticalPlacement),Mt=A.textSizeData;let ri=null;Mt.kind==="source"?(ri=[uh*I.layout.get("text-size").evaluate(N,{})],ri[0]>Xa&&me(`${A.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):Mt.kind==="composite"&&(ri=[uh*$e.compositeTextSizes[0].evaluate(N,{},Ze),uh*$e.compositeTextSizes[1].evaluate(N,{},Ze)],(ri[0]>Xa||ri[1]>Xa)&&me(`${A.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),A.addSymbols(A.text,Rt,ri,Z,U,N,ge,l,re.lineStartIndex,re.lineLength,ke,Ze);for(const mi of Ce)Ie[mi]=A.text.placedSymbolArray.length-1;return 4*Rt.length}function Jy(A){for(const l in A)return A[l];return null}function d1(A,l,f,w){const I=A.compareText;if(l in I){const U=I[l];for(let N=U.length-1;N>=0;N--)if(w.dist(U[N])N.id),this.index=l.index,this.pixelRatio=l.pixelRatio,this.sourceLayerIndex=l.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Fr([]),this.placementViewportMatrix=Fr([]);const f=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Bg(this.zoom,f["text-size"]),this.iconSizeData=Bg(this.zoom,f["icon-size"]);const w=this.layers[0].layout,I=w.get("symbol-sort-key"),U=w.get("symbol-z-order");this.canOverlap=bd(w,"text-overlap","text-allow-overlap")!=="never"||bd(w,"icon-overlap","icon-allow-overlap")!=="never"||w.get("text-ignore-placement")||w.get("icon-ignore-placement"),this.sortFeaturesByKey=U!=="viewport-y"&&!I.isConstant(),this.sortFeaturesByY=(U==="viewport-y"||U==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,w.get("symbol-placement")==="point"&&(this.writingModes=w.get("text-writing-mode").map(N=>i.WritingMode[N])),this.stateDependentLayerIds=this.layers.filter(N=>N.isStateDependent()).map(N=>N.id),this.sourceID=l.sourceID}createArrays(){this.text=new bp(new si(this.layers,this.zoom,l=>/^text/.test(l))),this.icon=new bp(new si(this.layers,this.zoom,l=>/^icon/.test(l))),this.glyphOffsetArray=new cn,this.lineVertexArray=new Bn,this.symbolInstances=new xn}calculateGlyphDependencies(l,f,w,I,U){for(let N=0;N0)&&(N.value.kind!=="constant"||N.value.value.length>0),Ce=re.value.kind!=="constant"||!!re.value.value||Object.keys(re.parameters).length>0,Ie=U.get("symbol-sort-key");if(this.features=[],!ge&&!Ce)return;const ke=f.iconDependencies,$e=f.glyphDependencies,Ze=f.availableImages,Rt=new Zr(this.zoom);for(const{feature:Mt,id:ri,index:mi,sourceLayerIndex:ei}of l){const ui=I._featureFilter.needGeometry,Pi=Ai(Mt,ui);if(!I._featureFilter.filter(Rt,Pi,w))continue;let Fi,Sn;if(ui||(Pi.geometry=Ri(Mt)),ge){const mn=I.getValueAndResolveTokens("text-field",Pi,w,Ze),an=He.factory(mn);m1(an)&&(this.hasRTLText=!0),(!this.hasRTLText||_l()==="unavailable"||this.hasRTLText&&xs.isParsed())&&(Fi=vA(an,I,Pi))}if(Ce){const mn=I.getValueAndResolveTokens("icon-image",Pi,w,Ze);Sn=mn instanceof pt?mn:pt.fromString(mn)}if(!Fi&&!Sn)continue;const fn=this.sortFeaturesByKey?Ie.evaluate(Pi,{},w):void 0;if(this.features.push({id:ri,text:Fi,icon:Sn,index:mi,sourceLayerIndex:ei,geometry:Pi.geometry,properties:Mt.properties,type:p1[Mt.type],sortKey:fn}),Sn&&(ke[Sn.name]=!0),Fi){const mn=N.evaluate(Pi,{},w).join(","),an=U.get("text-rotation-alignment")!=="viewport"&&U.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(i.WritingMode.vertical)>=0;for(const nn of Fi.sections)if(nn.image)ke[nn.image.name]=!0;else{const vn=th(Fi.toString()),gn=nn.fontStack||mn,Ji=$e[gn]=$e[gn]||{};this.calculateGlyphDependencies(nn.text,Ji,an,this.allowVerticalPlacement,vn)}}}U.get("symbol-placement")==="line"&&(this.features=function(Mt){const ri={},mi={},ei=[];let ui=0;function Pi(mn){ei.push(Mt[mn]),ui++}function Fi(mn,an,nn){const vn=mi[mn];return delete mi[mn],mi[an]=vn,ei[vn].geometry[0].pop(),ei[vn].geometry[0]=ei[vn].geometry[0].concat(nn[0]),vn}function Sn(mn,an,nn){const vn=ri[an];return delete ri[an],ri[mn]=vn,ei[vn].geometry[0].shift(),ei[vn].geometry[0]=nn[0].concat(ei[vn].geometry[0]),vn}function fn(mn,an,nn){const vn=nn?an[0][an[0].length-1]:an[0][0];return`${mn}:${vn.x}:${vn.y}`}for(let mn=0;mnmn.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((Mt,ri)=>Mt.sortKey-ri.sortKey)}update(l,f,w){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(l,f,this.layers,w),this.icon.programConfigurations.updatePaintArrays(l,f,this.layers,w))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(l){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(l),this.iconCollisionBox.upload(l)),this.text.upload(l,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(l,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(l,f){const w=this.lineVertexArray.length;if(l.segment!==void 0){let I=l.dist(f[l.segment+1]),U=l.dist(f[l.segment]);const N={};for(let Z=l.segment+1;Z=0;Z--)N[Z]={x:f[Z].x,y:f[Z].y,tileUnitDistanceFromAnchor:U},Z>0&&(U+=f[Z-1].dist(f[Z]));for(let Z=0;Z0}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(l,f){const w=l.placedSymbolArray.get(f),I=w.vertexStartIndex+4*w.numGlyphs;for(let U=w.vertexStartIndex;UI[Z]-I[re]||U[re]-U[Z]),N}addToSortKeyRanges(l,f){const w=this.sortKeyRanges[this.sortKeyRanges.length-1];w&&w.sortKey===f?w.symbolInstanceEnd=l+1:this.sortKeyRanges.push({sortKey:f,symbolInstanceStart:l,symbolInstanceEnd:l+1})}sortFeatures(l){if(this.sortFeaturesByY&&this.sortedAngle!==l&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(l),this.sortedAngle=l,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const f of this.symbolInstanceIndexes){const w=this.symbolInstances.get(f);this.featureSortOrder.push(w.featureIndex),[w.rightJustifiedTextSymbolIndex,w.centerJustifiedTextSymbolIndex,w.leftJustifiedTextSymbolIndex].forEach((I,U,N)=>{I>=0&&N.indexOf(I)===U&&this.addIndicesForPlacedSymbol(this.text,I)}),w.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,w.verticalPlacedTextSymbolIndex),w.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,w.placedIconSymbolIndex),w.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,w.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}pn("SymbolBucket",Bc,{omit:["layers","collisionBoxArray","features","compareText"]}),Bc.MAX_GLYPHS=65535,Bc.addDynamicAttributes=Mg;const g1=new Cs({"symbol-placement":new Fn($t.layout_symbol["symbol-placement"]),"symbol-spacing":new Fn($t.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Fn($t.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Vn($t.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Fn($t.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Fn($t.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Fn($t.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Fn($t.layout_symbol["icon-ignore-placement"]),"icon-optional":new Fn($t.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Fn($t.layout_symbol["icon-rotation-alignment"]),"icon-size":new Vn($t.layout_symbol["icon-size"]),"icon-text-fit":new Fn($t.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Fn($t.layout_symbol["icon-text-fit-padding"]),"icon-image":new Vn($t.layout_symbol["icon-image"]),"icon-rotate":new Vn($t.layout_symbol["icon-rotate"]),"icon-padding":new Vn($t.layout_symbol["icon-padding"]),"icon-keep-upright":new Fn($t.layout_symbol["icon-keep-upright"]),"icon-offset":new Vn($t.layout_symbol["icon-offset"]),"icon-anchor":new Vn($t.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Fn($t.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Fn($t.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Fn($t.layout_symbol["text-rotation-alignment"]),"text-field":new Vn($t.layout_symbol["text-field"]),"text-font":new Vn($t.layout_symbol["text-font"]),"text-size":new Vn($t.layout_symbol["text-size"]),"text-max-width":new Vn($t.layout_symbol["text-max-width"]),"text-line-height":new Fn($t.layout_symbol["text-line-height"]),"text-letter-spacing":new Vn($t.layout_symbol["text-letter-spacing"]),"text-justify":new Vn($t.layout_symbol["text-justify"]),"text-radial-offset":new Vn($t.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Fn($t.layout_symbol["text-variable-anchor"]),"text-anchor":new Vn($t.layout_symbol["text-anchor"]),"text-max-angle":new Fn($t.layout_symbol["text-max-angle"]),"text-writing-mode":new Fn($t.layout_symbol["text-writing-mode"]),"text-rotate":new Vn($t.layout_symbol["text-rotate"]),"text-padding":new Fn($t.layout_symbol["text-padding"]),"text-keep-upright":new Fn($t.layout_symbol["text-keep-upright"]),"text-transform":new Vn($t.layout_symbol["text-transform"]),"text-offset":new Vn($t.layout_symbol["text-offset"]),"text-allow-overlap":new Fn($t.layout_symbol["text-allow-overlap"]),"text-overlap":new Fn($t.layout_symbol["text-overlap"]),"text-ignore-placement":new Fn($t.layout_symbol["text-ignore-placement"]),"text-optional":new Fn($t.layout_symbol["text-optional"])});var Ds={paint:new Cs({"icon-opacity":new Vn($t.paint_symbol["icon-opacity"]),"icon-color":new Vn($t.paint_symbol["icon-color"]),"icon-halo-color":new Vn($t.paint_symbol["icon-halo-color"]),"icon-halo-width":new Vn($t.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Vn($t.paint_symbol["icon-halo-blur"]),"icon-translate":new Fn($t.paint_symbol["icon-translate"]),"icon-translate-anchor":new Fn($t.paint_symbol["icon-translate-anchor"]),"text-opacity":new Vn($t.paint_symbol["text-opacity"]),"text-color":new Vn($t.paint_symbol["text-color"],{runtimeType:wi,getOverride:A=>A.textColor,hasOverride:A=>!!A.textColor}),"text-halo-color":new Vn($t.paint_symbol["text-halo-color"]),"text-halo-width":new Vn($t.paint_symbol["text-halo-width"]),"text-halo-blur":new Vn($t.paint_symbol["text-halo-blur"]),"text-translate":new Fn($t.paint_symbol["text-translate"]),"text-translate-anchor":new Fn($t.paint_symbol["text-translate-anchor"])}),layout:g1};class Bp{constructor(l){if(l.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=l.property.overrides?l.property.overrides.runtimeType:nr,this.defaultValue=l}evaluate(l){if(l.formattedSection){const f=this.defaultValue.property.overrides;if(f&&f.hasOverride(l.formattedSection))return f.getOverride(l.formattedSection)}return l.feature&&l.featureState?this.defaultValue.evaluate(l.feature,l.featureState):this.defaultValue.property.specification.default}eachChild(l){this.defaultValue.isConstant()||l(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}pn("FormatSectionOverride",Bp,{omit:["defaultValue"]});class Cp extends Go{constructor(l){super(l,Ds)}recalculate(l,f){if(super.recalculate(l,f),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 w=this.layout.get("text-writing-mode");if(w){const I=[];for(const U of w)I.indexOf(U)<0&&I.push(U);this.layout._values["text-writing-mode"]=I}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(l,f,w,I){const U=this.layout.get(l).evaluate(f,{},w,I),N=this._unevaluatedLayout._values[l];return N.isDataDriven()||Vc(N.value)||!U?U:function(Z,re){return re.replace(/{([^{}]+)}/g,(ge,Ce)=>Ce in Z?String(Z[Ce]):"")}(f.properties,U)}createBucket(l){return new Bc(l)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const l of Ds.paint.overridableProperties){if(!Cp.hasPaintOverride(this.layout,l))continue;const f=this.paint.get(l),w=new Bp(f),I=new dc(w,f.property.specification);let U=null;U=f.value.kind==="constant"||f.value.kind==="source"?new Lh("source",I):new Gc("composite",I,f.value.zoomStops),this.paint._values[l]=new uo(f.property,U,f.parameters)}}_handleOverridablePaintPropertyUpdate(l,f,w){return!(!this.layout||f.isDataDriven()||w.isDataDriven())&&Cp.hasPaintOverride(this.layout,l)}static hasPaintOverride(l,f){const w=l.get("text-field"),I=Ds.paint.properties[f];let U=!1;const N=Z=>{for(const re of Z)if(I.overrides&&I.overrides.hasOverride(re))return void(U=!0)};if(w.value.kind==="constant"&&w.value.value instanceof He)N(w.value.value.sections);else if(w.value.kind==="source"){const Z=ge=>{U||(ge instanceof bi&&Wt(ge.value)===qn?N(ge.value.sections):ge instanceof Oc?N(ge.sections):ge.eachChild(Z))},re=w.value;re._styleExpression&&Z(re._styleExpression.expression)}return U}}function bd(A,l,f){let w="never";const I=A.get(l);return I?w=I:A.get(f)&&(w="always"),w}var kf={paint:new Cs({"background-color":new Fn($t.paint_background["background-color"]),"background-pattern":new dA($t.paint_background["background-pattern"]),"background-opacity":new Fn($t.paint_background["background-opacity"])})},Ep={paint:new Cs({"raster-opacity":new Fn($t.paint_raster["raster-opacity"]),"raster-hue-rotate":new Fn($t.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Fn($t.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Fn($t.paint_raster["raster-brightness-max"]),"raster-saturation":new Fn($t.paint_raster["raster-saturation"]),"raster-contrast":new Fn($t.paint_raster["raster-contrast"]),"raster-resampling":new Fn($t.paint_raster["raster-resampling"]),"raster-fade-duration":new Fn($t.paint_raster["raster-fade-duration"])})};class e0 extends Go{constructor(l){super(l,{}),this.onAdd=f=>{this.implementation.onAdd&&this.implementation.onAdd(f,f.painter.context.gl)},this.onRemove=f=>{this.implementation.onRemove&&this.implementation.onRemove(f,f.painter.context.gl)},this.implementation=l}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")}}const t0={circle:class extends Go{constructor(A){super(A,jo)}createBucket(A){return new $i(A)}queryRadius(A){const l=A;return Nr("circle-radius",this,l)+Nr("circle-stroke-width",this,l)+Qr(this.paint.get("circle-translate"))}queryIntersectsFeature(A,l,f,w,I,U,N,Z){const re=go(A,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),U.angle,N),ge=this.paint.get("circle-radius").evaluate(l,f)+this.paint.get("circle-stroke-width").evaluate(l,f),Ce=this.paint.get("circle-pitch-alignment")==="map",Ie=Ce?re:function($e,Ze){return $e.map(Rt=>Ea(Rt,Ze))}(re,Z),ke=Ce?ge*N:ge;for(const $e of w)for(const Ze of $e){const Rt=Ce?Ze:Ea(Ze,Z);let Mt=ke;const ri=ja([],[Ze.x,Ze.y,0,1],Z);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?Mt*=ri[3]/U.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(Mt*=U.cameraToCenterDistance/ri[3]),pi(Ie,Rt,Mt))return!0}return!1}},heatmap:class extends Go{constructor(A){super(A,Zl),this._updateColorRamp()}createBucket(A){return new vl(A)}_handleSpecialPaintPropertyUpdate(A){A==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=rg({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}},hillshade:class extends Go{constructor(A){super(A,sg)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}},fill:class extends Go{constructor(A){super(A,Uy)}recalculate(A,l){super.recalculate(A,l);const f=this.paint._values["fill-outline-color"];f.value.kind==="constant"&&f.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(A){return new cg(A)}queryRadius(){return Qr(this.paint.get("fill-translate"))}queryIntersectsFeature(A,l,f,w,I,U,N){return In(go(A,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),U.angle,N),w)}isTileClipped(){return!0}},"fill-extrusion":class extends Go{constructor(A){super(A,zy)}createBucket(A){return new Mf(A)}queryRadius(){return Qr(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(A,l,f,w,I,U,N,Z){const re=go(A,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),U.angle,N),ge=this.paint.get("fill-extrusion-height").evaluate(l,f),Ce=this.paint.get("fill-extrusion-base").evaluate(l,f),Ie=function($e,Ze,Rt,Mt){const ri=[];for(const mi of $e){const ei=[mi.x,mi.y,0,1];ja(ei,ei,Ze),ri.push(new xe(ei[0]/ei[3],ei[1]/ei[3]))}return ri}(re,Z),ke=function($e,Ze,Rt,Mt){const ri=[],mi=[],ei=Mt[8]*Ze,ui=Mt[9]*Ze,Pi=Mt[10]*Ze,Fi=Mt[11]*Ze,Sn=Mt[8]*Rt,fn=Mt[9]*Rt,mn=Mt[10]*Rt,an=Mt[11]*Rt;for(const nn of $e){const vn=[],gn=[];for(const Ji of nn){const Wn=Ji.x,zn=Ji.y,yr=Mt[0]*Wn+Mt[4]*zn+Mt[12],fs=Mt[1]*Wn+Mt[5]*zn+Mt[13],ws=Mt[2]*Wn+Mt[6]*zn+Mt[14],Qs=Mt[3]*Wn+Mt[7]*zn+Mt[15],Cl=ws+Pi,xo=Qs+Fi,Ks=yr+Sn,oo=fs+fn,Lo=ws+mn,$o=Qs+an,Ia=new xe((yr+ei)/xo,(fs+ui)/xo);Ia.z=Cl/xo,vn.push(Ia);const io=new xe(Ks/$o,oo/$o);io.z=Lo/$o,gn.push(io)}ri.push(vn),mi.push(gn)}return[ri,mi]}(w,Ce,ge,Z);return function($e,Ze,Rt){let Mt=1/0;In(Rt,Ze)&&(Mt=ky(Rt,Ze[0]));for(let ri=0;ri=3){for(let Rt=0;Rt{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 Of=63710088e-1;class Es{constructor(l,f){if(isNaN(l)||isNaN(f))throw new Error(`Invalid LngLat object: (${l}, ${f})`);if(this.lng=+l,this.lat=+f,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Es(G(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(l){const f=Math.PI/180,w=this.lat*f,I=l.lat*f,U=Math.sin(w)*Math.sin(I)+Math.cos(w)*Math.cos(I)*Math.cos((l.lng-this.lng)*f);return Of*Math.acos(Math.min(U,1))}toBounds(l=0){const f=360*l/40075017,w=f/Math.cos(Math.PI/180*this.lat);return new SA(new Es(this.lng-w,this.lat-f),new Es(this.lng+w,this.lat+f))}static convert(l){if(l instanceof Es)return l;if(Array.isArray(l)&&(l.length===2||l.length===3))return new Es(Number(l[0]),Number(l[1]));if(!Array.isArray(l)&&typeof l=="object"&&l!==null)return new Es(Number("lng"in l?l.lng:l.lon),Number(l.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 [, ]")}}class SA{constructor(l,f){l&&(f?this.setSouthWest(l).setNorthEast(f):l.length===4?this.setSouthWest([l[0],l[1]]).setNorthEast([l[2],l[3]]):this.setSouthWest(l[0]).setNorthEast(l[1]))}setNorthEast(l){return this._ne=l instanceof Es?new Es(l.lng,l.lat):Es.convert(l),this}setSouthWest(l){return this._sw=l instanceof Es?new Es(l.lng,l.lat):Es.convert(l),this}extend(l){const f=this._sw,w=this._ne;let I,U;if(l instanceof Es)I=l,U=l;else{if(!(l instanceof SA))return Array.isArray(l)?l.length===4||l.every(Array.isArray)?this.extend(SA.convert(l)):this.extend(Es.convert(l)):this;if(I=l._sw,U=l._ne,!I||!U)return this}return f||w?(f.lng=Math.min(I.lng,f.lng),f.lat=Math.min(I.lat,f.lat),w.lng=Math.max(U.lng,w.lng),w.lat=Math.max(U.lat,w.lat)):(this._sw=new Es(I.lng,I.lat),this._ne=new Es(U.lng,U.lat)),this}getCenter(){return new Es((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 Es(this.getWest(),this.getNorth())}getSouthEast(){return new Es(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(l){const{lng:f,lat:w}=Es.convert(l);let I=this._sw.lng<=f&&f<=this._ne.lng;return this._sw.lng>this._ne.lng&&(I=this._sw.lng>=f&&f>=this._ne.lng),this._sw.lat<=w&&w<=this._ne.lat&&I}static convert(l){return l instanceof SA?l:l&&new SA(l)}}const Fg=2*Math.PI*Of;function Bd(A){return Fg*Math.cos(A*Math.PI/180)}function i0(A){return(180+A)/360}function Nf(A){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+A*Math.PI/360)))/360}function n0(A,l){return A/Bd(l)}function Sp(A){return 360/Math.PI*Math.atan(Math.exp((180-360*A)*Math.PI/180))-90}class Cd{constructor(l,f,w=0){this.x=+l,this.y=+f,this.z=+w}static fromLngLat(l,f=0){const w=Es.convert(l);return new Cd(i0(w.lng),Nf(w.lat),n0(f,w.lat))}toLngLat(){return new Es(360*this.x-180,Sp(this.y))}toAltitude(){return this.z*Bd(Sp(this.y))}meterInMercatorCoordinateUnits(){return 1/Fg*(l=Sp(this.y),1/Math.cos(l*Math.PI/180));var l}}function Mp(A,l,f){var w=2*Math.PI*6378137/256/Math.pow(2,f);return[A*w-2*Math.PI*6378137/2,l*w-2*Math.PI*6378137/2]}class Lg{constructor(l,f,w){if(l<0||l>25||w<0||w>=Math.pow(2,l)||f<0||f>=Math.pow(2,l))throw new Error(`x=${f}, y=${w}, z=${l} outside of bounds. 0<=x<${Math.pow(2,l)}, 0<=y<${Math.pow(2,l)} 0<=z<=25 `);this.z=l,this.x=f,this.y=w,this.key=Ip(0,l,l,f,w)}equals(l){return this.z===l.z&&this.x===l.x&&this.y===l.y}url(l,f,w){const I=(N=this.y,Z=this.z,re=Mp(256*(U=this.x),256*(N=Math.pow(2,Z)-N-1),Z),ge=Mp(256*(U+1),256*(N+1),Z),re[0]+","+re[1]+","+ge[0]+","+ge[1]);var U,N,Z,re,ge;const Ce=function(Ie,ke,$e){let Ze,Rt="";for(let Mt=Ie;Mt>0;Mt--)Ze=1<1?"@2x":"").replace(/{quadkey}/g,Ce).replace(/{bbox-epsg-3857}/g,I)}isChildOf(l){const f=this.z-l.z;return f>0&&l.x===this.x>>f&&l.y===this.y>>f}getTilePoint(l){const f=Math.pow(2,this.z);return new xe((l.x*f-this.x)*Kt,(l.y*f-this.y)*Kt)}toString(){return`${this.z}/${this.x}/${this.y}`}}class r0{constructor(l,f){this.wrap=l,this.canonical=f,this.key=Ip(l,f.z,f.z,f.x,f.y)}}class Bl{constructor(l,f,w,I,U){if(l= z; overscaledZ = ${l}; z = ${w}`);this.overscaledZ=l,this.wrap=f,this.canonical=new Lg(w,+I,+U),this.key=Ip(f,l,w,I,U)}clone(){return new Bl(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(l){return this.overscaledZ===l.overscaledZ&&this.wrap===l.wrap&&this.canonical.equals(l.canonical)}scaledTo(l){if(l>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${l}; overscaledZ = ${this.overscaledZ}`);const f=this.canonical.z-l;return l>this.canonical.z?new Bl(l,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Bl(l,this.wrap,l,this.canonical.x>>f,this.canonical.y>>f)}calculateScaledKey(l,f){if(l>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${l}; overscaledZ = ${this.overscaledZ}`);const w=this.canonical.z-l;return l>this.canonical.z?Ip(this.wrap*+f,l,this.canonical.z,this.canonical.x,this.canonical.y):Ip(this.wrap*+f,l,l,this.canonical.x>>w,this.canonical.y>>w)}isChildOf(l){if(l.wrap!==this.wrap)return!1;const f=this.canonical.z-l.canonical.z;return l.overscaledZ===0||l.overscaledZ>f&&l.canonical.y===this.canonical.y>>f}children(l){if(this.overscaledZ>=l)return[new Bl(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const f=this.canonical.z+1,w=2*this.canonical.x,I=2*this.canonical.y;return[new Bl(f,this.wrap,f,w,I),new Bl(f,this.wrap,f,w+1,I),new Bl(f,this.wrap,f,w,I+1),new Bl(f,this.wrap,f,w+1,I+1)]}isLessThan(l){return this.wrapl.wrap)&&(this.overscaledZl.overscaledZ)&&(this.canonical.xl.canonical.x)&&this.canonical.ythis.max&&(this.max=Z),Z=this.dim+1||f<-1||f>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(f+1)*this.stride+(l+1)}_unpackMapbox(l,f,w){return(256*l*256+256*f+w)/10-1e4}_unpackTerrarium(l,f,w){return 256*l+f+w/256-32768}getPixels(){return new Aa({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(l,f,w){if(this.dim!==l.dim)throw new Error("dem dimension mismatch");let I=f*this.dim,U=f*this.dim+this.dim,N=w*this.dim,Z=w*this.dim+this.dim;switch(f){case-1:I=U-1;break;case 1:U=I+1}switch(w){case-1:N=Z-1;break;case 1:Z=N+1}const re=-f*this.dim,ge=-w*this.dim;for(let Ce=N;Ce=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${l} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[l]}}class Fp{constructor(l,f,w,I,U){this.type="Feature",this._vectorTileFeature=l,l._z=f,l._x=w,l._y=I,this.properties=l.properties,this.id=U}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(l){this._geometry=l}toJSON(){const l={geometry:this.geometry};for(const f in this)f!=="_geometry"&&f!=="_vectorTileFeature"&&(l[f]=this[f]);return l}}class a0{constructor(l,f){this.tileID=l,this.x=l.canonical.x,this.y=l.canonical.y,this.z=l.canonical.z,this.grid=new mc(Kt,16,0),this.grid3D=new mc(Kt,16,0),this.featureIndexArray=new ur,this.promoteId=f}insert(l,f,w,I,U,N){const Z=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(w,I,U);const re=N?this.grid3D:this.grid;for(let ge=0;ge=0&&Ie[3]>=0&&re.insert(Z,Ie[0],Ie[1],Ie[2],Ie[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Tu.VectorTile(new Su(this.rawTileData)).layers,this.sourceLayerCoder=new o0(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(l,f,w,I){this.loadVTLayers();const U=l.params||{},N=Kt/l.tileSize/l.scale,Z=Ho(U.filter),re=l.queryGeometry,ge=l.queryPadding*N,Ce=MA(re),Ie=this.grid.query(Ce.minX-ge,Ce.minY-ge,Ce.maxX+ge,Ce.maxY+ge),ke=MA(l.cameraQueryGeometry),$e=this.grid3D.query(ke.minX-ge,ke.minY-ge,ke.maxX+ge,ke.maxY+ge,(Mt,ri,mi,ei)=>function(ui,Pi,Fi,Sn,fn){for(const an of ui)if(Pi<=an.x&&Fi<=an.y&&Sn>=an.x&&fn>=an.y)return!0;const mn=[new xe(Pi,Fi),new xe(Pi,fn),new xe(Sn,fn),new xe(Sn,Fi)];if(ui.length>2){for(const an of mn)if(Dr(ui,an))return!0}for(let an=0;an(ei||(ei=Ri(ui)),Pi.queryIntersectsFeature(re,ui,Fi,ei,this.z,l.transform,N,l.pixelPosMatrix)))}return Ze}loadMatchingFeature(l,f,w,I,U,N,Z,re,ge,Ce,Ie){const ke=this.bucketLayerIDs[f];if(N&&!function(Mt,ri){for(let mi=0;mi=0)return!0;return!1}(N,ke))return;const $e=this.sourceLayerCoder.decode(w),Ze=this.vtLayers[$e].feature(I);if(U.needGeometry){const Mt=Ai(Ze,!0);if(!U.filter(new Zr(this.tileID.overscaledZ),Mt,this.tileID.canonical))return}else if(!U.filter(new Zr(this.tileID.overscaledZ),Ze))return;const Rt=this.getId(Ze,$e);for(let Mt=0;Mt{const Z=l instanceof Js?l.get(N):null;return Z&&Z.evaluate?Z.evaluate(f,w,I):Z})}function MA(A){let l=1/0,f=1/0,w=-1/0,I=-1/0;for(const U of A)l=Math.min(l,U.x),f=Math.min(f,U.y),w=Math.max(w,U.x),I=Math.max(I,U.y);return{minX:l,minY:f,maxX:w,maxY:I}}function _1(A,l){return l-A}var Pg;pn("FeatureIndex",a0,{omit:["rawTileData","sourceLayerCoder"]}),i.PerformanceMarkers=void 0,(Pg=i.PerformanceMarkers||(i.PerformanceMarkers={})).create="create",Pg.load="load",Pg.fullLoad="fullLoad";let Qf=null,Ed=[];const Vf=1e3/30,y1={mark(A){performance.mark(A)},frame(A){const l=A;Qf!=null&&Ed.push(l-Qf),Qf=l},clearMetrics(){Qf=null,Ed=[],performance.clearMeasures("loadTime"),performance.clearMeasures("fullLoadTime");for(const A in i.PerformanceMarkers)performance.clearMarks(i.PerformanceMarkers[A])},getPerformanceMetrics(){performance.measure("loadTime",i.PerformanceMarkers.create,i.PerformanceMarkers.load),performance.measure("fullLoadTime",i.PerformanceMarkers.create,i.PerformanceMarkers.fullLoad);const A=performance.getEntriesByName("loadTime")[0].duration,l=performance.getEntriesByName("fullLoadTime")[0].duration,f=Ed.length,w=1/(Ed.reduce((U,N)=>U+N,0)/f/1e3),I=Ed.filter(U=>U>Vf).reduce((U,N)=>U+(N-Vf)/Vf,0);return{loadTime:A,fullLoadTime:l,fps:w,percentDroppedFrames:I/(f+I)*100}}};i.AJAXError=Ft,i.ARRAY_TYPE=_r,i.Actor=class{constructor(A,l,f){this.target=A,this.parent=l,this.mapId=f,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},B(["receive","process"],this),this.invoker=new Tp(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=Fe()?A:window}send(A,l,f,w,I=!1){const U=Math.round(1e18*Math.random()).toString(36).substring(0,10);f&&(this.callbacks[U]=f);const N=te(this.globalScope)?void 0:[];return this.target.postMessage({id:U,type:A,hasCallback:!!f,targetMapId:w,mustQueue:I,sourceMapId:this.mapId,data:Wl(l,N)},N),{cancel:()=>{f&&delete this.callbacks[U],this.target.postMessage({id:U,type:"",targetMapId:w,sourceMapId:this.mapId})}}}receive(A){const l=A.data,f=l.id;if(f&&(!l.targetMapId||this.mapId===l.targetMapId))if(l.type===""){delete this.tasks[f];const w=this.cancelCallbacks[f];delete this.cancelCallbacks[f],w&&w()}else Fe()||l.mustQueue?(this.tasks[f]=l,this.taskQueue.push(f),this.invoker.trigger()):this.processTask(f,l)}process(){if(!this.taskQueue.length)return;const A=this.taskQueue.shift(),l=this.tasks[A];delete this.tasks[A],this.taskQueue.length&&this.invoker.trigger(),l&&this.processTask(A,l)}processTask(A,l){if(l.type===""){const f=this.callbacks[A];delete this.callbacks[A],f&&(l.error?f(Os(l.error)):f(null,Os(l.data)))}else{let f=!1;const w=te(this.globalScope)?void 0:[],I=l.hasCallback?(Z,re)=>{f=!0,delete this.cancelCallbacks[A],this.target.postMessage({id:A,type:"",sourceMapId:this.mapId,error:Z?Wl(Z):null,data:Wl(re,w)},w)}:Z=>{f=!0};let U=null;const N=Os(l.data);if(this.parent[l.type])U=this.parent[l.type](l.sourceMapId,N,I);else if(this.parent.getWorkerSource){const Z=l.type.split(".");U=this.parent.getWorkerSource(l.sourceMapId,Z[0],N.source)[Z[1]](N,I)}else I(new Error(`Could not find function ${l.type}`));!f&&U&&U.cancel&&(this.cancelCallbacks[A]=U.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.AlphaImage=Xh,i.CanonicalTileID=Lg,i.CollisionBoxArray=Ei,i.CollisionCircleLayoutArray=class extends Te{},i.Color=de,i.DEMData=s0,i.DataConstantProperty=Fn,i.DictionaryCoder=o0,i.EXTENT=Kt,i.ErrorEvent=qi,i.EvaluationParameters=Zr,i.Event=Ni,i.Evented=en,i.FeatureIndex=a0,i.FillBucket=cg,i.FillExtrusionBucket=Mf,i.GeoJSONFeature=Fp,i.ImageAtlas=fd,i.ImagePosition=EA,i.LineBucket=gp,i.LineStripIndexArray=class extends St{},i.LngLat=Es,i.LngLatBounds=SA,i.MercatorCoordinate=Cd,i.ONE_EM=yo,i.OverscaledTileID=Bl,i.PerformanceUtils=y1,i.PosArray=Un,i.Properties=Cs,i.QuadTriangleArray=class extends je{},i.RGBAImage=Aa,i.RasterBoundsArray=class extends M{},i.RequestPerformance=class{constructor(A){this._marks={start:[A.url,"start"].join("#"),end:[A.url,"end"].join("#"),measure:A.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let A=performance.getEntriesByName(this._marks.measure);return A.length===0&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),A=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),A}},i.ResourceType=Ct,i.SegmentVector=a,i.SymbolBucket=Bc,i.Transitionable=xc,i.TriangleIndexArray=mo,i.Uniform1f=it,i.Uniform1i=class extends st{constructor(A,l){super(A,l),this.current=0}set(A){this.current!==A&&(this.current=A,this.gl.uniform1i(this.location,A))}},i.Uniform2f=class extends st{constructor(A,l){super(A,l),this.current=[0,0]}set(A){A[0]===this.current[0]&&A[1]===this.current[1]||(this.current=A,this.gl.uniform2f(this.location,A[0],A[1]))}},i.Uniform3f=class extends st{constructor(A,l){super(A,l),this.current=[0,0,0]}set(A){A[0]===this.current[0]&&A[1]===this.current[1]&&A[2]===this.current[2]||(this.current=A,this.gl.uniform3f(this.location,A[0],A[1],A[2]))}},i.Uniform4f=lt,i.UniformColor=qe,i.UniformMatrix4f=class extends st{constructor(A,l){super(A,l),this.current=Ye}set(A){if(A[12]!==this.current[12]||A[0]!==this.current[0])return this.current=A,void this.gl.uniformMatrix4fv(this.location,!1,A);for(let l=1;l<16;l++)if(A[l]!==this.current[l]){this.current=A,this.gl.uniformMatrix4fv(this.location,!1,A);break}}},i.UnwrappedTileID=r0,i.ValidationError=at,i.ZoomHistory=gl,i.add=function(A,l,f){return A[0]=l[0]+f[0],A[1]=l[1]+f[1],A[2]=l[2]+f[2],A},i.addDynamicAttributes=Mg,i.asyncAll=function(A,l,f){if(!A.length)return f(null,[]);let w=A.length;const I=new Array(A.length);let U=null;A.forEach((N,Z)=>{l(N,(re,ge)=>{re&&(U=re),I[Z]=ge,--w==0&&f(U,I)})})},i.bezier=R,i.bindAll=B,i.cacheEntryPossiblyAdded=function(A){vt++,vt>Ke&&(A.getActor().send("enforceCacheSizeLimit",Se),vt=0)},i.clamp=z,i.clearTileCache=function(A){const l=caches.delete(We);A&&l.catch(A).then(()=>A())},i.clipLine=Xy,i.clone=function(A){var l=new _r(16);return l[0]=A[0],l[1]=A[1],l[2]=A[2],l[3]=A[3],l[4]=A[4],l[5]=A[5],l[6]=A[6],l[7]=A[7],l[8]=A[8],l[9]=A[9],l[10]=A[10],l[11]=A[11],l[12]=A[12],l[13]=A[13],l[14]=A[14],l[15]=A[15],l},i.clone$1=Ae,i.clone$2=function(A){var l=new _r(3);return l[0]=A[0],l[1]=A[1],l[2]=A[2],l},i.collisionCircleLayout=Hy,i.config=Oe,i.copy=function(A,l){return A[0]=l[0],A[1]=l[1],A[2]=l[2],A[3]=l[3],A[4]=l[4],A[5]=l[5],A[6]=l[6],A[7]=l[7],A[8]=l[8],A[9]=l[9],A[10]=l[10],A[11]=l[11],A[12]=l[12],A[13]=l[13],A[14]=l[14],A[15]=l[15],A},i.create=function(){var A=new _r(16);return _r!=Float32Array&&(A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[11]=0,A[12]=0,A[13]=0,A[14]=0),A[0]=1,A[5]=1,A[10]=1,A[15]=1,A},i.create$1=Xr,i.createExpression=Hc,i.createFilter=Ho,i.createLayout=Is,i.createStyleLayer=function(A){return A.type==="custom"?new e0(A):new t0[A.type](A)},i.cross=function(A,l,f){var w=l[0],I=l[1],U=l[2],N=f[0],Z=f[1],re=f[2];return A[0]=I*re-U*Z,A[1]=U*N-w*re,A[2]=w*Z-I*N,A},i.dot=function(A,l){return A[0]*l[0]+A[1]*l[1]+A[2]*l[2]},i.dot$1=function(A,l){return A[0]*l[0]+A[1]*l[1]+A[2]*l[2]+A[3]*l[3]},i.ease=Q,i.emitValidationErrors=Nh,i.enforceCacheSizeLimit=function(A){nt(),Ve&&Ve.then(l=>{l.keys().then(f=>{for(let w=0;w{}}},i.identity=Fr,i.invert=function(A,l){var f=l[0],w=l[1],I=l[2],U=l[3],N=l[4],Z=l[5],re=l[6],ge=l[7],Ce=l[8],Ie=l[9],ke=l[10],$e=l[11],Ze=l[12],Rt=l[13],Mt=l[14],ri=l[15],mi=f*Z-w*N,ei=f*re-I*N,ui=f*ge-U*N,Pi=w*re-I*Z,Fi=w*ge-U*Z,Sn=I*ge-U*re,fn=Ce*Rt-Ie*Ze,mn=Ce*Mt-ke*Ze,an=Ce*ri-$e*Ze,nn=Ie*Mt-ke*Rt,vn=Ie*ri-$e*Rt,gn=ke*ri-$e*Mt,Ji=mi*gn-ei*vn+ui*nn+Pi*an-Fi*mn+Sn*fn;return Ji?(A[0]=(Z*gn-re*vn+ge*nn)*(Ji=1/Ji),A[1]=(I*vn-w*gn-U*nn)*Ji,A[2]=(Rt*Sn-Mt*Fi+ri*Pi)*Ji,A[3]=(ke*Fi-Ie*Sn-$e*Pi)*Ji,A[4]=(re*an-N*gn-ge*mn)*Ji,A[5]=(f*gn-I*an+U*mn)*Ji,A[6]=(Mt*ui-Ze*Sn-ri*ei)*Ji,A[7]=(Ce*Sn-ke*ui+$e*ei)*Ji,A[8]=(N*vn-Z*an+ge*fn)*Ji,A[9]=(w*an-f*vn-U*fn)*Ji,A[10]=(Ze*Fi-Rt*ui+ri*mi)*Ji,A[11]=(Ie*ui-Ce*Fi-$e*mi)*Ji,A[12]=(Z*mn-N*nn-re*fn)*Ji,A[13]=(f*nn-w*mn+I*fn)*Ji,A[14]=(Rt*ei-Ze*Pi-Mt*mi)*Ji,A[15]=(Ce*Pi-Ie*ei+ke*mi)*Ji,A):null},i.isImageBitmap=le,i.isSafari=te,i.isWorker=Fe,i.keysDifference=function(A,l){const f=[];for(const w in A)w in l||f.push(w);return f},i.lazyLoadRTLTextPlugin=function(){xs.isLoading()||xs.isLoaded()||_l()!=="deferred"||An()},i.makeRequest=fi,i.mapObject=ae,i.mercatorXfromLng=i0,i.mercatorYfromLat=Nf,i.mercatorZfromAltitude=n0,i.mul=ns,i.mul$1=function(A,l,f){return A[0]=l[0]*f[0],A[1]=l[1]*f[1],A[2]=l[2]*f[2],A[3]=l[3]*f[3],A},i.multiply=Fs,i.nextPowerOfTwo=function(A){return A<=1?1:Math.pow(2,Math.ceil(Math.log(A)/Math.LN2))},i.normalize=function(A,l){var f=l[0],w=l[1],I=l[2],U=f*f+w*w+I*I;return U>0&&(U=1/Math.sqrt(U)),A[0]=l[0]*U,A[1]=l[1]*U,A[2]=l[2]*U,A},i.number=is,i.ortho=function(A,l,f,w,I,U,N){var Z=1/(l-f),re=1/(w-I),ge=1/(U-N);return A[0]=-2*Z,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=-2*re,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[10]=2*ge,A[11]=0,A[12]=(l+f)*Z,A[13]=(I+w)*re,A[14]=(N+U)*ge,A[15]=1,A},i.parseCacheControl=Ge,i.parseGlyphPbf=function(A){return new Su(A).readFields(pd,[])},i.pbf=Su,i.performSymbolLayout=function(A){A.bucket.createArrays(),A.bucket.tilePixelRatio=Kt/(512*A.bucket.overscaling),A.bucket.compareText={},A.bucket.iconsNeedLinear=!1;const l=A.bucket.layers[0].layout,f=A.bucket.layers[0]._unevaluatedLayout._values,w={layoutIconSize:f["icon-size"].possiblyEvaluate(new Zr(A.bucket.zoom+1),A.canonical),layoutTextSize:f["text-size"].possiblyEvaluate(new Zr(A.bucket.zoom+1),A.canonical),textMaxSize:f["text-size"].possiblyEvaluate(new Zr(18))};if(A.bucket.textSizeData.kind==="composite"){const{minZoom:re,maxZoom:ge}=A.bucket.textSizeData;w.compositeTextSizes=[f["text-size"].possiblyEvaluate(new Zr(re),A.canonical),f["text-size"].possiblyEvaluate(new Zr(ge),A.canonical)]}if(A.bucket.iconSizeData.kind==="composite"){const{minZoom:re,maxZoom:ge}=A.bucket.iconSizeData;w.compositeIconSizes=[f["icon-size"].possiblyEvaluate(new Zr(re),A.canonical),f["icon-size"].possiblyEvaluate(new Zr(ge),A.canonical)]}const I=l.get("text-line-height")*yo,U=l.get("text-rotation-alignment")!=="viewport"&&l.get("symbol-placement")!=="point",N=l.get("text-keep-upright"),Z=l.get("text-size");for(const re of A.bucket.features){const ge=l.get("text-font").evaluate(re,{},A.canonical).join(","),Ce=Z.evaluate(re,{},A.canonical),Ie=w.layoutTextSize.evaluate(re,{},A.canonical),ke=w.layoutIconSize.evaluate(re,{},A.canonical),$e={horizontal:{},vertical:void 0},Ze=re.text;let Rt,Mt=[0,0];if(Ze){const ei=Ze.toString(),ui=l.get("text-letter-spacing").evaluate(re,{},A.canonical)*yo,Pi=Ur(ei)?ui:0,Fi=l.get("text-anchor").evaluate(re,{},A.canonical),Sn=l.get("text-variable-anchor");if(!Sn){const vn=l.get("text-radial-offset").evaluate(re,{},A.canonical);Mt=vn?xd(Fi,[vn*yo,Sg]):l.get("text-offset").evaluate(re,{},A.canonical).map(gn=>gn*yo)}let fn=U?"center":l.get("text-justify").evaluate(re,{},A.canonical);const mn=l.get("symbol-placement"),an=mn==="point"?l.get("text-max-width").evaluate(re,{},A.canonical)*yo:0,nn=()=>{A.bucket.allowVerticalPlacement&&th(ei)&&($e.vertical=Ma(Ze,A.glyphMap,A.glyphPositions,A.imagePositions,ge,an,I,Fi,"left",Pi,Mt,i.WritingMode.vertical,!0,mn,Ie,Ce))};if(!U&&Sn){const vn=fn==="auto"?Sn.map(Ji=>vd(Ji)):[fn];let gn=!1;for(let Ji=0;Jithis._layers[jt.id]),tt=Ue[0];if(tt.visibility==="none")continue;const He=tt.source||"";let et=this.familiesBySource[He];et||(et=this.familiesBySource[He]={});const pt=tt.sourceLayer||"_geojsonTileLayer";let Lt=et[pt];Lt||(Lt=et[pt]=[]),Lt.push(Ue)}}}class Q{constructor(j){const ie={},ne=[];for(const He in j){const et=j[He],pt=ie[He]={};for(const Lt in et){const jt=et[+Lt];if(!jt||jt.bitmap.width===0||jt.bitmap.height===0)continue;const Wt={x:0,y:0,w:jt.bitmap.width+2,h:jt.bitmap.height+2};ne.push(Wt),pt[Lt]={rect:Wt,metrics:jt.metrics}}}const{w:de,h:Ue}=i.potpack(ne),tt=new i.AlphaImage({width:de||1,height:Ue||1});for(const He in j){const et=j[He];for(const pt in et){const Lt=et[+pt];if(!Lt||Lt.bitmap.width===0||Lt.bitmap.height===0)continue;const jt=ie[He][pt].rect;i.AlphaImage.copy(Lt.bitmap,tt,{x:0,y:0},{x:jt.x+1,y:jt.y+1},Lt.bitmap)}}this.image=tt,this.positions=ie}}i.register("GlyphAtlas",Q);class z{constructor(j){this.tileID=new i.OverscaledTileID(j.tileID.overscaledZ,j.tileID.wrap,j.tileID.canonical.z,j.tileID.canonical.x,j.tileID.canonical.y),this.uid=j.uid,this.zoom=j.zoom,this.pixelRatio=j.pixelRatio,this.tileSize=j.tileSize,this.source=j.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=j.showCollisionBoxes,this.collectResourceTiming=!!j.collectResourceTiming,this.returnDependencies=!!j.returnDependencies,this.promoteId=j.promoteId}parse(j,ie,ne,de,Ue){this.status="parsing",this.data=j,this.collisionBoxArray=new i.CollisionBoxArray;const tt=new i.DictionaryCoder(Object.keys(j.layers).sort()),He=new i.FeatureIndex(this.tileID,this.promoteId);He.bucketLayerIDs=[];const et={},pt={featureIndex:He,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:ne},Lt=ie.familiesBySource[this.source];for(const yn in Lt){const Yt=j.layers[yn];if(!Yt)continue;Yt.version===1&&i.warnOnce(`Vector tile source "${this.source}" layer "${yn}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const sr=tt.encode(yn),Yn=[];for(let Wr=0;Wr=mr.maxzoom||mr.visibility!=="none"&&(G(Wr,this.zoom,ne),(et[mr.id]=mr.createBucket({index:He.bucketLayerIDs.length,layers:Wr,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:sr,sourceID:this.source})).populate(Yn,pt,this.tileID.canonical),He.bucketLayerIDs.push(Wr.map(Mr=>Mr.id)))}}let jt,Wt,ki,bi;const Oi=i.mapObject(pt.glyphDependencies,yn=>Object.keys(yn).map(Number));Object.keys(Oi).length?de.send("getGlyphs",{uid:this.uid,stacks:Oi},(yn,Yt)=>{jt||(jt=yn,Wt=Yt,rr.call(this))}):Wt={};const Yi=Object.keys(pt.iconDependencies);Yi.length?de.send("getImages",{icons:Yi,source:this.source,tileID:this.tileID,type:"icons"},(yn,Yt)=>{jt||(jt=yn,ki=Yt,rr.call(this))}):ki={};const tn=Object.keys(pt.patternDependencies);function rr(){if(jt)return Ue(jt);if(Wt&&ki&&bi){const yn=new Q(Wt),Yt=new i.ImageAtlas(ki,bi);for(const sr in et){const Yn=et[sr];Yn instanceof i.SymbolBucket?(G(Yn.layers,this.zoom,ne),i.performSymbolLayout({bucket:Yn,glyphMap:Wt,glyphPositions:yn.positions,imageMap:ki,imagePositions:Yt.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):Yn.hasPattern&&(Yn instanceof i.LineBucket||Yn instanceof i.FillBucket||Yn instanceof i.FillExtrusionBucket)&&(G(Yn.layers,this.zoom,ne),Yn.addFeatures(pt,this.tileID.canonical,Yt.patternPositions))}this.status="done",Ue(null,{buckets:Object.values(et).filter(sr=>!sr.isEmpty()),featureIndex:He,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:yn.image,imageAtlas:Yt,glyphMap:this.returnDependencies?Wt:null,iconMap:this.returnDependencies?ki:null,glyphPositions:this.returnDependencies?yn.positions:null})}}tn.length?de.send("getImages",{icons:tn,source:this.source,tileID:this.tileID,type:"patterns"},(yn,Yt)=>{jt||(jt=yn,bi=Yt,rr.call(this))}):bi={},rr.call(this)}}function G(X,j,ie){const ne=new i.EvaluationParameters(j);for(const de of X)de.recalculate(ne,ie)}function J(X,j){const ie=i.getArrayBuffer(X.request,(ne,de,Ue,tt)=>{ne?j(ne):de&&j(null,{vectorTile:new i.vectorTile.VectorTile(new i.pbf(de)),rawData:de,cacheControl:Ue,expires:tt})});return()=>{ie.cancel(),j()}}class Y{constructor(j,ie,ne,de){this.actor=j,this.layerIndex=ie,this.availableImages=ne,this.loadVectorData=de||J,this.loading={},this.loaded={}}loadTile(j,ie){const ne=j.uid;this.loading||(this.loading={});const de=!!(j&&j.request&&j.request.collectResourceTiming)&&new i.RequestPerformance(j.request),Ue=this.loading[ne]=new z(j);Ue.abort=this.loadVectorData(j,(tt,He)=>{if(delete this.loading[ne],tt||!He)return Ue.status="done",this.loaded[ne]=Ue,ie(tt);const et=He.rawData,pt={};He.expires&&(pt.expires=He.expires),He.cacheControl&&(pt.cacheControl=He.cacheControl);const Lt={};if(de){const jt=de.finish();jt&&(Lt.resourceTiming=JSON.parse(JSON.stringify(jt)))}Ue.vectorTile=He.vectorTile,Ue.parse(He.vectorTile,this.layerIndex,this.availableImages,this.actor,(jt,Wt)=>{if(jt||!Wt)return ie(jt);ie(null,i.extend({rawTileData:et.slice(0)},Wt,pt,Lt))}),this.loaded=this.loaded||{},this.loaded[ne]=Ue})}reloadTile(j,ie){const ne=this.loaded,de=j.uid,Ue=this;if(ne&&ne[de]){const tt=ne[de];tt.showCollisionBoxes=j.showCollisionBoxes;const He=(et,pt)=>{const Lt=tt.reloadCallback;Lt&&(delete tt.reloadCallback,tt.parse(tt.vectorTile,Ue.layerIndex,this.availableImages,Ue.actor,Lt)),ie(et,pt)};tt.status==="parsing"?tt.reloadCallback=He:tt.status==="done"&&(tt.vectorTile?tt.parse(tt.vectorTile,this.layerIndex,this.availableImages,this.actor,He):He())}}abortTile(j,ie){const ne=this.loading,de=j.uid;ne&&ne[de]&&ne[de].abort&&(ne[de].abort(),delete ne[de]),ie()}removeTile(j,ie){const ne=this.loaded,de=j.uid;ne&&ne[de]&&delete ne[de],ie()}}class B{constructor(){this.loaded={}}loadTile(j,ie){const{uid:ne,encoding:de,rawImageData:Ue}=j,tt=i.isImageBitmap(Ue)?this.getImageData(Ue):Ue,He=new i.DEMData(ne,tt,de);this.loaded=this.loaded||{},this.loaded[ne]=He,ie(null,He)}getImageData(j){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(j.width,j.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=j.width,this.offscreenCanvas.height=j.height,this.offscreenCanvasContext.drawImage(j,0,0,j.width,j.height);const ie=this.offscreenCanvasContext.getImageData(-1,-1,j.width+2,j.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new i.RGBAImage({width:ie.width,height:ie.height},ie.data)}removeTile(j){const ie=this.loaded,ne=j.uid;ie&&ie[ne]&&delete ie[ne]}}var ae=function X(j,ie){var ne,de=j&&j.type;if(de==="FeatureCollection")for(ne=0;ne=Math.abs(He)?ie-et+He:He-et+ie,ie=et}ie+ne>=0!=!!j&&X.reverse()}const we=i.vectorTile.VectorTileFeature.prototype.toGeoJSON;class me{constructor(j){this._feature=j,this.extent=i.EXTENT,this.type=j.type,this.properties=j.tags,"id"in j&&!isNaN(j.id)&&(this.id=parseInt(j.id,10))}loadGeometry(){if(this._feature.type===1){const j=[];for(const ie of this._feature.geometry)j.push([new i.pointGeometry(ie[0],ie[1])]);return j}{const j=[];for(const ie of this._feature.geometry){const ne=[];for(const de of ie)ne.push(new i.pointGeometry(de[0],de[1]));j.push(ne)}return j}}toGeoJSON(j,ie,ne){return we.call(this,j,ie,ne)}}class De{constructor(j){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=j.length,this._features=j}feature(j){return new me(this._features[j])}}var Je={exports:{}},Fe=i.pointGeometry,Ge=i.vectorTile.VectorTileFeature,Et=li;function li(X,j){this.options=j||{},this.features=X,this.length=X.length}function xi(X,j){this.id=typeof X.id=="number"?X.id:void 0,this.type=X.type,this.rawGeometry=X.type===1?[X.geometry]:X.geometry,this.properties=X.tags,this.extent=j||4096}li.prototype.feature=function(X){return new xi(this.features[X],this.options.extent)},xi.prototype.loadGeometry=function(){var X=this.rawGeometry;this.geometry=[];for(var j=0;j>31}function Qe(X,j){for(var ie=X.loadGeometry(),ne=X.type,de=0,Ue=0,tt=ie.length,He=0;He>1;nt(X,j,tt,ne,de,Ue%2),Ke(X,j,ie,ne,tt-1,Ue+1),Ke(X,j,ie,tt+1,de,Ue+1)}function nt(X,j,ie,ne,de,Ue){for(;de>ne;){if(de-ne>600){const pt=de-ne+1,Lt=ie-ne+1,jt=Math.log(pt),Wt=.5*Math.exp(2*jt/3),ki=.5*Math.sqrt(jt*Wt*(pt-Wt)/pt)*(Lt-pt/2<0?-1:1);nt(X,j,ie,Math.max(ne,Math.floor(ie-Lt*Wt/pt+ki)),Math.min(de,Math.floor(ie+(pt-Lt)*Wt/pt+ki)),Ue)}const tt=j[2*ie+Ue];let He=ne,et=de;for(vt(X,j,ne,ie),j[2*de+Ue]>tt&&vt(X,j,ne,de);Hett;)et--}j[2*ne+Ue]===tt?vt(X,j,ne,et):(et++,vt(X,j,et,de)),et<=ie&&(ne=et+1),ie<=et&&(de=et-1)}}function vt(X,j,ie,ne){be(X,ie,ne),be(j,2*ie,2*ne),be(j,2*ie+1,2*ne+1)}function be(X,j,ie){const ne=X[j];X[j]=X[ie],X[ie]=ne}function At(X,j,ie,ne){const de=X-ie,Ue=j-ne;return de*de+Ue*Ue}Je.exports=ye,Je.exports.fromVectorTileJs=ye,Je.exports.fromGeojsonVt=function(X,j){j=j||{};var ie={};for(var ne in X)ie[ne]=new le(X[ne].features,j),ie[ne].name=ne,ie[ne].version=j.version,ie[ne].extent=j.extent;return ye({layers:ie})},Je.exports.GeoJSONWrapper=le;const ut=X=>X[0],Nt=X=>X[1];class Gt{constructor(j,ie=ut,ne=Nt,de=64,Ue=Float64Array){this.nodeSize=de,this.points=j;const tt=j.length<65536?Uint16Array:Uint32Array,He=this.ids=new tt(j.length),et=this.coords=new Ue(2*j.length);for(let pt=0;pt=He&&bi<=pt&&Oi>=et&&Oi<=Lt&&ki.push(Ue[sr]);continue}const yn=Math.floor((rr+tn)/2);bi=tt[2*yn],Oi=tt[2*yn+1],bi>=He&&bi<=pt&&Oi>=et&&Oi<=Lt&&ki.push(Ue[yn]);const Yt=(Yi+1)%2;(Yi===0?He<=bi:et<=Oi)&&(Wt.push(rr),Wt.push(yn-1),Wt.push(Yt)),(Yi===0?pt>=bi:Lt>=Oi)&&(Wt.push(yn+1),Wt.push(tn),Wt.push(Yt))}return ki}(this.ids,this.coords,j,ie,ne,de,this.nodeSize)}within(j,ie,ne){return function(de,Ue,tt,He,et,pt){const Lt=[0,de.length-1,0],jt=[],Wt=et*et;for(;Lt.length;){const ki=Lt.pop(),bi=Lt.pop(),Oi=Lt.pop();if(bi-Oi<=pt){for(let Yt=Oi;Yt<=bi;Yt++)At(Ue[2*Yt],Ue[2*Yt+1],tt,He)<=Wt&&jt.push(de[Yt]);continue}const Yi=Math.floor((Oi+bi)/2),tn=Ue[2*Yi],rr=Ue[2*Yi+1];At(tn,rr,tt,He)<=Wt&&jt.push(de[Yi]);const yn=(ki+1)%2;(ki===0?tt-et<=tn:He-et<=rr)&&(Lt.push(Oi),Lt.push(Yi-1),Lt.push(yn)),(ki===0?tt+et>=tn:He+et>=rr)&&(Lt.push(Yi+1),Lt.push(bi),Lt.push(yn))}return jt}(this.ids,this.coords,j,ie,ne,this.nodeSize)}}const Qt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:X=>X},Ct=Math.fround||(Ft=new Float32Array(1),X=>(Ft[0]=+X,Ft[0]));var Ft;class Xt{constructor(j){this.options=yt(Object.create(Qt),j),this.trees=new Array(this.options.maxZoom+1)}load(j){const{log:ie,minZoom:ne,maxZoom:de,nodeSize:Ue}=this.options;ie&&console.time("total time");const tt=`prepare ${j.length} points`;ie&&console.time(tt),this.points=j;let He=[];for(let et=0;et=ne;et--){const pt=+Date.now();He=this._cluster(He,et),this.trees[et]=new Gt(He,rt,ti,Ue,Float32Array),ie&&console.log("z%d: %d clusters in %dms",et,He.length,+Date.now()-pt)}return ie&&console.timeEnd("total time"),this}getClusters(j,ie){let ne=((j[0]+180)%360+360)%360-180;const de=Math.max(-90,Math.min(90,j[1]));let Ue=j[2]===180?180:((j[2]+180)%360+360)%360-180;const tt=Math.max(-90,Math.min(90,j[3]));if(j[2]-j[0]>=360)ne=-180,Ue=180;else if(ne>Ue){const Lt=this.getClusters([ne,de,180,tt],ie),jt=this.getClusters([-180,de,Ue,tt],ie);return Lt.concat(jt)}const He=this.trees[this._limitZoom(ie)],et=He.range(zi(ne),Gn(tt),zi(Ue),Gn(de)),pt=[];for(const Lt of et){const jt=He.points[Lt];pt.push(jt.numPoints?Gi(jt):this.points[jt.index])}return pt}getChildren(j){const ie=this._getOriginId(j),ne=this._getOriginZoom(j),de="No cluster with the specified id.",Ue=this.trees[ne];if(!Ue)throw new Error(de);const tt=Ue.points[ie];if(!tt)throw new Error(de);const He=this.options.radius/(this.options.extent*Math.pow(2,ne-1)),et=Ue.within(tt.x,tt.y,He),pt=[];for(const Lt of et){const jt=Ue.points[Lt];jt.parentId===j&&pt.push(jt.numPoints?Gi(jt):this.points[jt.index])}if(pt.length===0)throw new Error(de);return pt}getLeaves(j,ie,ne){const de=[];return this._appendLeaves(de,j,ie=ie||10,ne=ne||0,0),de}getTile(j,ie,ne){const de=this.trees[this._limitZoom(j)],Ue=Math.pow(2,j),{extent:tt,radius:He}=this.options,et=He/tt,pt=(ne-et)/Ue,Lt=(ne+1+et)/Ue,jt={features:[]};return this._addTileFeatures(de.range((ie-et)/Ue,pt,(ie+1+et)/Ue,Lt),de.points,ie,ne,Ue,jt),ie===0&&this._addTileFeatures(de.range(1-et/Ue,pt,1,Lt),de.points,Ue,ne,Ue,jt),ie===Ue-1&&this._addTileFeatures(de.range(0,pt,et/Ue,Lt),de.points,-1,ne,Ue,jt),jt.features.length?jt:null}getClusterExpansionZoom(j){let ie=this._getOriginZoom(j)-1;for(;ie<=this.options.maxZoom;){const ne=this.getChildren(j);if(ie++,ne.length!==1)break;j=ne[0].properties.cluster_id}return ie}_appendLeaves(j,ie,ne,de,Ue){const tt=this.getChildren(ie);for(const He of tt){const et=He.properties;if(et&&et.cluster?Ue+et.point_count<=de?Ue+=et.point_count:Ue=this._appendLeaves(j,et.cluster_id,ne,de,Ue):Ueie&&(bi+=Yi.numPoints||1)}if(bi>ki&&bi>=He){let Oi=Lt.x*ki,Yi=Lt.y*ki,tn=tt&&ki>1?this._map(Lt,!0):null;const rr=(pt<<5)+(ie+1)+this.points.length;for(const yn of Wt){const Yt=jt.points[yn];if(Yt.zoom<=ie)continue;Yt.zoom=ie;const sr=Yt.numPoints||1;Oi+=Yt.x*sr,Yi+=Yt.y*sr,Yt.parentId=rr,tt&&(tn||(tn=this._map(Lt,!0)),tt(tn,this._map(Yt)))}Lt.parentId=rr,ne.push(_i(Oi/bi,Yi/bi,rr,bi,tn))}else if(ne.push(Lt),bi>1)for(const Oi of Wt){const Yi=jt.points[Oi];Yi.zoom<=ie||(Yi.zoom=ie,ne.push(Yi))}}return ne}_getOriginId(j){return j-this.points.length>>5}_getOriginZoom(j){return(j-this.points.length)%32}_map(j,ie){if(j.numPoints)return ie?yt({},j.properties):j.properties;const ne=this.points[j.index].properties,de=this.options.map(ne);return ie&&de===ne?yt({},de):de}}function _i(X,j,ie,ne,de){return{x:Ct(X),y:Ct(j),zoom:1/0,id:ie,parentId:-1,numPoints:ne,properties:de}}function fi(X,j){const[ie,ne]=X.geometry.coordinates;return{x:Ct(zi(ie)),y:Ct(Gn(ne)),zoom:1/0,index:j,parentId:-1}}function Gi(X){return{type:"Feature",id:X.id,properties:wn(X),geometry:{type:"Point",coordinates:[(j=X.x,360*(j-.5)),kn(X.y)]}};var j}function wn(X){const j=X.numPoints,ie=j>=1e4?`${Math.round(j/1e3)}k`:j>=1e3?Math.round(j/100)/10+"k":j;return yt(yt({},X.properties),{cluster:!0,cluster_id:X.id,point_count:j,point_count_abbreviated:ie})}function zi(X){return X/360+.5}function Gn(X){const j=Math.sin(X*Math.PI/180),ie=.5-.25*Math.log((1+j)/(1-j))/Math.PI;return ie<0?0:ie>1?1:ie}function kn(X){const j=(180-360*X)*Math.PI/180;return 360*Math.atan(Math.exp(j))/Math.PI-90}function yt(X,j){for(const ie in j)X[ie]=j[ie];return X}function rt(X){return X.x}function ti(X){return X.y}function Ni(X,j,ie,ne){for(var de,Ue=ne,tt=ie-j>>1,He=ie-j,et=X[j],pt=X[j+1],Lt=X[ie],jt=X[ie+1],Wt=j+3;WtUe)de=Wt,Ue=ki;else if(ki===Ue){var bi=Math.abs(Wt-tt);bine&&(de-j>3&&Ni(X,j,de,ne),X[de+2]=Ue,ie-de>3&&Ni(X,de,ie,ne))}function qi(X,j,ie,ne,de,Ue){var tt=de-ie,He=Ue-ne;if(tt!==0||He!==0){var et=((X-ie)*tt+(j-ne)*He)/(tt*tt+He*He);et>1?(ie=de,ne=Ue):et>0&&(ie+=tt*et,ne+=He*et)}return(tt=X-ie)*tt+(He=j-ne)*He}function en(X,j,ie,ne){var de={id:X===void 0?null:X,type:j,geometry:ie,tags:ne,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(Ue){var tt=Ue.geometry,He=Ue.type;if(He==="Point"||He==="MultiPoint"||He==="LineString")$t(Ue,tt);else if(He==="Polygon"||He==="MultiLineString")for(var et=0;et0&&(tt+=ne?(de*pt-et*Ue)/2:Math.sqrt(Math.pow(et-de,2)+Math.pow(pt-Ue,2))),de=et,Ue=pt}var Lt=j.length-3;j[2]=1,Ni(j,0,Lt,ie),j[Lt+2]=1,j.size=Math.abs(tt),j.start=0,j.end=j.size}function Xi(X,j,ie,ne){for(var de=0;de1?1:ie}function Tn(X,j,ie,ne,de,Ue,tt,He){if(ne/=j,Ue>=(ie/=j)&&tt=ne)return null;for(var et=[],pt=0;pt=ie&&bi=ne)){var Oi=[];if(Wt==="Point"||Wt==="MultiPoint")nr(jt,Oi,ie,ne,de);else if(Wt==="LineString")Ii(jt,Oi,ie,ne,de,!1,He.lineMetrics);else if(Wt==="MultiLineString")Ot(jt,Oi,ie,ne,de,!1);else if(Wt==="Polygon")Ot(jt,Oi,ie,ne,de,!0);else if(Wt==="MultiPolygon")for(var Yi=0;Yi=ie&&tt<=ne&&(j.push(X[Ue]),j.push(X[Ue+1]),j.push(X[Ue+2]))}}function Ii(X,j,ie,ne,de,Ue,tt){for(var He,et,pt=bn(X),Lt=de===0?Wi:Ui,jt=X.start,Wt=0;Wtie&&(et=Lt(pt,ki,bi,Yi,tn,ie),tt&&(pt.start=jt+He*et)):rr>ne?yn=ie&&(et=Lt(pt,ki,bi,Yi,tn,ie),Yt=!0),yn>ne&&rr<=ne&&(et=Lt(pt,ki,bi,Yi,tn,ne),Yt=!0),!Ue&&Yt&&(tt&&(pt.end=jt+He*et),j.push(pt),pt=bn(X)),tt&&(jt+=He)}var sr=X.length-3;ki=X[sr],bi=X[sr+1],Oi=X[sr+2],(rr=de===0?ki:bi)>=ie&&rr<=ne&&wi(pt,ki,bi,Oi),sr=pt.length-3,Ue&&sr>=3&&(pt[sr]!==pt[0]||pt[sr+1]!==pt[1])&&wi(pt,pt[0],pt[1],pt[2]),pt.length&&j.push(pt)}function bn(X){var j=[];return j.size=X.size,j.start=X.start,j.end=X.end,j}function Ot(X,j,ie,ne,de,Ue){for(var tt=0;tttt.maxX&&(tt.maxX=Lt),jt>tt.maxY&&(tt.maxY=jt)}return tt}function Qn(X,j,ie,ne){var de=j.geometry,Ue=j.type,tt=[];if(Ue==="Point"||Ue==="MultiPoint")for(var He=0;He0&&j.size<(de?tt:ne))ie.numPoints+=j.length/3;else{for(var He=[],et=0;ettt)&&(ie.numSimplified++,He.push(j[et]),He.push(j[et+1])),ie.numPoints++;de&&function(pt,Lt){for(var jt=0,Wt=0,ki=pt.length,bi=ki-2;Wt0===Lt)for(Wt=0,ki=pt.length;Wt24)throw new Error("maxZoom should be in the 0-24 range");if(j.promoteId&&j.generateId)throw new Error("promoteId and generateId cannot be used together.");var ne=function(de,Ue){var tt=[];if(de.type==="FeatureCollection")for(var He=0;He1&&console.time("creation"),Wt=this.tiles[jt]=kr(X,j,ie,ne,et),this.tileCoords.push({z:j,x:ie,y:ne}),pt)){pt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",j,ie,ne,Wt.numFeatures,Wt.numPoints,Wt.numSimplified),console.timeEnd("creation"));var ki="z"+j;this.stats[ki]=(this.stats[ki]||0)+1,this.total++}if(Wt.source=X,de){if(j===et.maxZoom||j===de)continue;var bi=1<1&&console.time("clipping");var Oi,Yi,tn,rr,yn,Yt,sr=.5*et.buffer/et.extent,Yn=.5-sr,Wr=.5+sr,mr=1+sr;Oi=Yi=tn=rr=null,yn=Tn(X,Lt,ie-sr,ie+Wr,0,Wt.minX,Wt.maxX,et),Yt=Tn(X,Lt,ie+Yn,ie+mr,0,Wt.minX,Wt.maxX,et),X=null,yn&&(Oi=Tn(yn,Lt,ne-sr,ne+Wr,1,Wt.minY,Wt.maxY,et),Yi=Tn(yn,Lt,ne+Yn,ne+mr,1,Wt.minY,Wt.maxY,et),yn=null),Yt&&(tn=Tn(Yt,Lt,ne-sr,ne+Wr,1,Wt.minY,Wt.maxY,et),rr=Tn(Yt,Lt,ne+Yn,ne+mr,1,Wt.minY,Wt.maxY,et),Yt=null),pt>1&&console.timeEnd("clipping"),He.push(Oi||[],j+1,2*ie,2*ne),He.push(Yi||[],j+1,2*ie,2*ne+1),He.push(tn||[],j+1,2*ie+1,2*ne),He.push(rr||[],j+1,2*ie+1,2*ne+1)}}},ot.prototype.getTile=function(X,j,ie){var ne=this.options,de=ne.extent,Ue=ne.debug;if(X<0||X>24)return null;var tt=1<1&&console.log("drilling down to z%d-%d-%d",X,j,ie);for(var et,pt=X,Lt=j,jt=ie;!et&&pt>0;)pt--,Lt=Math.floor(Lt/2),jt=Math.floor(jt/2),et=this.tiles[Ee(pt,Lt,jt)];return et&&et.source?(Ue>1&&console.log("found parent tile z%d-%d-%d",pt,Lt,jt),Ue>1&&console.time("drilling down"),this.splitTile(et.source,pt,Lt,jt,X,j,ie),Ue>1&&console.timeEnd("drilling down"),this.tiles[He]?Hr(this.tiles[He],de):null):null};class ct extends Y{constructor(j,ie,ne,de){super(j,ie,ne,Pe),de&&(this.loadGeoJSON=de)}loadData(j,ie){var ne;(ne=this._pendingRequest)===null||ne===void 0||ne.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const de=!!(j&&j.request&&j.request.collectResourceTiming)&&new i.RequestPerformance(j.request);this._pendingCallback=ie,this._pendingRequest=this.loadGeoJSON(j,(Ue,tt)=>{if(delete this._pendingCallback,delete this._pendingRequest,Ue||!tt)return ie(Ue);if(typeof tt!="object")return ie(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`));{ae(tt,!0);try{if(j.filter){const et=i.createExpression(j.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(et.result==="error")throw new Error(et.value.map(Lt=>`${Lt.key}: ${Lt.message}`).join(", "));tt={type:"FeatureCollection",features:tt.features.filter(Lt=>et.value.evaluate({zoom:0},Lt))}}this._geoJSONIndex=j.cluster?new Xt(function({superclusterOptions:et,clusterProperties:pt}){if(!pt||!et)return et;const Lt={},jt={},Wt={accumulated:null,zoom:0},ki={properties:null},bi=Object.keys(pt);for(const Oi of bi){const[Yi,tn]=pt[Oi],rr=i.createExpression(tn),yn=i.createExpression(typeof Yi=="string"?[Yi,["accumulated"],["get",Oi]]:Yi);Lt[Oi]=rr.value,jt[Oi]=yn.value}return et.map=Oi=>{ki.properties=Oi;const Yi={};for(const tn of bi)Yi[tn]=Lt[tn].evaluate(Wt,ki);return Yi},et.reduce=(Oi,Yi)=>{ki.properties=Yi;for(const tn of bi)Wt.accumulated=Oi[tn],Oi[tn]=jt[tn].evaluate(Wt,ki)},et}(j)).load(tt.features):function(et,pt){return new ot(et,pt)}(tt,j.geojsonVtOptions)}catch(et){return ie(et)}this.loaded={};const He={};if(de){const et=de.finish();et&&(He.resourceTiming={},He.resourceTiming[j.source]=JSON.parse(JSON.stringify(et)))}ie(null,He)}})}reloadTile(j,ie){const ne=this.loaded;return ne&&ne[j.uid]?super.reloadTile(j,ie):this.loadTile(j,ie)}loadGeoJSON(j,ie){if(j.request)return i.getJSON(j.request,ie);if(typeof j.data=="string")try{ie(null,JSON.parse(j.data))}catch{ie(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`))}else ie(new Error(`Input data given to '${j.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}}removeSource(j,ie){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),ie()}getClusterExpansionZoom(j,ie){try{ie(null,this._geoJSONIndex.getClusterExpansionZoom(j.clusterId))}catch(ne){ie(ne)}}getClusterChildren(j,ie){try{ie(null,this._geoJSONIndex.getChildren(j.clusterId))}catch(ne){ie(ne)}}getClusterLeaves(j,ie){try{ie(null,this._geoJSONIndex.getLeaves(j.clusterId,j.limit,j.offset))}catch(ne){ie(ne)}}}class wt{constructor(j){this.self=j,this.actor=new i.Actor(j,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:Y,geojson:ct},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(ie,ne)=>{if(this.workerSourceTypes[ie])throw new Error(`Worker source with name "${ie}" already registered.`);this.workerSourceTypes[ie]=ne},this.self.registerRTLTextPlugin=ie=>{if(i.plugin.isParsed())throw new Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=ie.applyArabicShaping,i.plugin.processBidirectionalText=ie.processBidirectionalText,i.plugin.processStyledBidirectionalText=ie.processStyledBidirectionalText}}setReferrer(j,ie){this.referrer=ie}setImages(j,ie,ne){this.availableImages[j]=ie;for(const de in this.workerSources[j]){const Ue=this.workerSources[j][de];for(const tt in Ue)Ue[tt].availableImages=ie}ne()}setLayers(j,ie,ne){this.getLayerIndex(j).replace(ie),ne()}updateLayers(j,ie,ne){this.getLayerIndex(j).update(ie.layers,ie.removedIds),ne()}loadTile(j,ie,ne){this.getWorkerSource(j,ie.type,ie.source).loadTile(ie,ne)}loadDEMTile(j,ie,ne){this.getDEMWorkerSource(j,ie.source).loadTile(ie,ne)}reloadTile(j,ie,ne){this.getWorkerSource(j,ie.type,ie.source).reloadTile(ie,ne)}abortTile(j,ie,ne){this.getWorkerSource(j,ie.type,ie.source).abortTile(ie,ne)}removeTile(j,ie,ne){this.getWorkerSource(j,ie.type,ie.source).removeTile(ie,ne)}removeDEMTile(j,ie){this.getDEMWorkerSource(j,ie.source).removeTile(ie)}removeSource(j,ie,ne){if(!this.workerSources[j]||!this.workerSources[j][ie.type]||!this.workerSources[j][ie.type][ie.source])return;const de=this.workerSources[j][ie.type][ie.source];delete this.workerSources[j][ie.type][ie.source],de.removeSource!==void 0?de.removeSource(ie,ne):ne()}loadWorkerSource(j,ie,ne){try{this.self.importScripts(ie.url),ne()}catch(de){ne(de.toString())}}syncRTLPluginState(j,ie,ne){try{i.plugin.setState(ie);const de=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&de!=null){this.self.importScripts(de);const Ue=i.plugin.isParsed();ne(Ue?void 0:new Error(`RTL Text Plugin failed to import scripts from ${de}`),Ue)}}catch(de){ne(de.toString())}}getAvailableImages(j){let ie=this.availableImages[j];return ie||(ie=[]),ie}getLayerIndex(j){let ie=this.layerIndexes[j];return ie||(ie=this.layerIndexes[j]=new R),ie}getWorkerSource(j,ie,ne){if(this.workerSources[j]||(this.workerSources[j]={}),this.workerSources[j][ie]||(this.workerSources[j][ie]={}),!this.workerSources[j][ie][ne]){const de={send:(Ue,tt,He)=>{this.actor.send(Ue,tt,He,j)}};this.workerSources[j][ie][ne]=new this.workerSourceTypes[ie](de,this.getLayerIndex(j),this.getAvailableImages(j))}return this.workerSources[j][ie][ne]}getDEMWorkerSource(j,ie){return this.demWorkerSources[j]||(this.demWorkerSources[j]={}),this.demWorkerSources[j][ie]||(this.demWorkerSources[j][ie]=new B),this.demWorkerSources[j][ie]}enforceCacheSizeLimit(j,ie){i.enforceCacheSizeLimit(ie)}}return i.isWorker()&&(self.worker=new wt(self)),wt}),p(["./shared"],function(i){var C=D;function D(M){return!function(h){return typeof window>"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var T,F,O=new Blob([""],{type:"text/javascript"}),K=URL.createObjectURL(O);try{F=new Worker(K),T=!0}catch{T=!1}return F&&F.terminate(),URL.revokeObjectURL(K),T}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var T=document.createElement("canvas");T.width=T.height=1;var F=T.getContext("2d");if(!F)return!1;var O=F.getImageData(0,0,1,1);return O&&O.width===T.width}()?(R[_=h&&h.failIfMajorPerformanceCaveat]===void 0&&(R[_]=function(T){var F,O=function(K){var oe=document.createElement("canvas"),ue=Object.create(D.webGLContextAttributes);return ue.failIfMajorPerformanceCaveat=K,oe.getContext("webgl",ue)||oe.getContext("experimental-webgl",ue)}(T);if(!O)return!1;try{F=O.createShader(O.VERTEX_SHADER)}catch{return!1}return!(!F||O.isContextLost())&&(O.shaderSource(F,"void main() {}"),O.compileShader(F),O.getShaderParameter(F,O.COMPILE_STATUS)===!0)}(_)),R[_]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var _}(M)}var R={};function Q(M,h){if(Array.isArray(M)){if(!Array.isArray(h)||M.length!==h.length)return!1;for(let _=0;_{window.removeEventListener("click",z.suppressClickInternal,!0)},0)}static mousePos(h,_){const T=h.getBoundingClientRect();return new i.pointGeometry(_.clientX-T.left-h.clientLeft,_.clientY-T.top-h.clientTop)}static touchPos(h,_){const T=h.getBoundingClientRect(),F=[];for(let O=0;O<_.length;O++)F.push(new i.pointGeometry(_[O].clientX-T.left-h.clientLeft,_[O].clientY-T.top-h.clientTop));return F}static mouseButton(h){return h.button}static remove(h){h.parentNode&&h.parentNode.removeChild(h)}}z.docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style,z.selectProp=z.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]),z.transformProp=z.testProp(["transform","WebkitTransform"]);class G{constructor(h){this._transformRequestFn=h}transformRequest(h,_){return this._transformRequestFn&&this._transformRequestFn(h,_)||{url:h}}normalizeSpriteURL(h,_,T){const F=function(O){const K=O.match(J);if(!K)throw new Error(`Unable to parse URL "${O}"`);return{protocol:K[1],authority:K[2],path:K[3]||"/",params:K[4]?K[4].split("&"):[]}}(h);return F.path+=`${_}${T}`,function(O){const K=O.params.length?`?${O.params.join("&")}`:"";return`${O.protocol}://${O.authority}${O.path}${K}`}(F)}setTransformRequest(h){this._transformRequestFn=h}}const J=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;class Y{constructor(h,_,T,F){this.context=h,this.format=T,this.texture=h.gl.createTexture(),this.update(_,F)}update(h,_,T){const{width:F,height:O}=h,K=!(this.size&&this.size[0]===F&&this.size[1]===O||T),{context:oe}=this,{gl:ue}=oe;if(this.useMipmap=Boolean(_&&_.useMipmap),ue.bindTexture(ue.TEXTURE_2D,this.texture),oe.pixelStoreUnpackFlipY.set(!1),oe.pixelStoreUnpack.set(1),oe.pixelStoreUnpackPremultiplyAlpha.set(this.format===ue.RGBA&&(!_||_.premultiply!==!1)),K)this.size=[F,O],h instanceof HTMLImageElement||h instanceof HTMLCanvasElement||h instanceof HTMLVideoElement||h instanceof ImageData||i.isImageBitmap(h)?ue.texImage2D(ue.TEXTURE_2D,0,this.format,this.format,ue.UNSIGNED_BYTE,h):ue.texImage2D(ue.TEXTURE_2D,0,this.format,F,O,0,this.format,ue.UNSIGNED_BYTE,h.data);else{const{x:ve,y:Te}=T||{x:0,y:0};h instanceof HTMLImageElement||h instanceof HTMLCanvasElement||h instanceof HTMLVideoElement||h instanceof ImageData||i.isImageBitmap(h)?ue.texSubImage2D(ue.TEXTURE_2D,0,ve,Te,ue.RGBA,ue.UNSIGNED_BYTE,h):ue.texSubImage2D(ue.TEXTURE_2D,0,ve,Te,F,O,ue.RGBA,ue.UNSIGNED_BYTE,h.data)}this.useMipmap&&this.isSizePowerOfTwo()&&ue.generateMipmap(ue.TEXTURE_2D)}bind(h,_,T){const{context:F}=this,{gl:O}=F;O.bindTexture(O.TEXTURE_2D,this.texture),T!==O.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(T=O.LINEAR),h!==this.filter&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MAG_FILTER,h),O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,T||h),this.filter=h),_!==this.wrap&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,_),O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,_),this.wrap=_)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:h}=this.context;h.deleteTexture(this.texture),this.texture=null}}function B(M){const{userImage:h}=M;return!!(h&&h.render&&h.render())&&(M.data.replace(new Uint8Array(h.data.buffer)),!0)}class ae extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(h){if(this.loaded!==h&&(this.loaded=h,h)){for(const{ids:_,callback:T}of this.requestors)this._notify(_,T);this.requestors=[]}}getImage(h){return this.images[h]}addImage(h,_){if(this.images[h])throw new Error(`Image id ${h} already exist, use updateImage instead`);this._validate(h,_)&&(this.images[h]=_)}_validate(h,_){let T=!0;return this._validateStretch(_.stretchX,_.data&&_.data.width)||(this.fire(new i.ErrorEvent(new Error(`Image "${h}" has invalid "stretchX" value`))),T=!1),this._validateStretch(_.stretchY,_.data&&_.data.height)||(this.fire(new i.ErrorEvent(new Error(`Image "${h}" has invalid "stretchY" value`))),T=!1),this._validateContent(_.content,_)||(this.fire(new i.ErrorEvent(new Error(`Image "${h}" has invalid "content" value`))),T=!1),T}_validateStretch(h,_){if(!h)return!0;let T=0;for(const F of h){if(F[0]-1);ue++,O[ue]=oe,K[ue]=ve,K[ue+1]=ce}for(let oe=0,ue=0;oe{let oe=this.entries[F];oe||(oe=this.entries[F]={glyphs:{},requests:{},ranges:{}});let ue=oe.glyphs[O];if(ue!==void 0)return void K(null,{stack:F,id:O,glyph:ue});if(ue=this._tinySDF(oe,F,O),ue)return oe.glyphs[O]=ue,void K(null,{stack:F,id:O,glyph:ue});const ve=Math.floor(O/256);if(256*ve>65535)return void K(new Error("glyphs > 65535 not supported"));if(oe.ranges[ve])return void K(null,{stack:F,id:O,glyph:ue});let Te=oe.requests[ve];Te||(Te=oe.requests[ve]=[],me.loadGlyphRange(F,ve,this.url,this.requestManager,(ze,je)=>{if(je){for(const bt in je)this._doesCharSupportLocalGlyph(+bt)||(oe.glyphs[+bt]=je[+bt]);oe.ranges[ve]=!0}for(const bt of Te)bt(ze,je);delete oe.requests[ve]})),Te.push((ze,je)=>{ze?K(ze):je&&K(null,{stack:F,id:O,glyph:je[O]||null})})},(F,O)=>{if(F)_(F);else if(O){const K={};for(const{stack:oe,id:ue,glyph:ve}of O)(K[oe]||(K[oe]={}))[ue]=ve&&{id:ve.id,bitmap:ve.bitmap.clone(),metrics:ve.metrics};_(null,K)}})}_doesCharSupportLocalGlyph(h){return!!this.localIdeographFontFamily&&(i.unicodeBlockLookup["CJK Unified Ideographs"](h)||i.unicodeBlockLookup["Hangul Syllables"](h)||i.unicodeBlockLookup.Hiragana(h)||i.unicodeBlockLookup.Katakana(h))}_tinySDF(h,_,T){const F=this.localIdeographFontFamily;if(!F||!this._doesCharSupportLocalGlyph(T))return;let O=h.tinySDF;if(!O){let oe="400";/bold/i.test(_)?oe="900":/medium/i.test(_)?oe="500":/light/i.test(_)&&(oe="200"),O=h.tinySDF=new me.TinySDF({fontSize:24,buffer:3,radius:8,cutoff:.25,fontFamily:F,fontWeight:oe})}const K=O.draw(String.fromCharCode(T));return{id:T,bitmap:new i.AlphaImage({width:K.width||30,height:K.height||30},K.data),metrics:{width:K.glyphWidth||24,height:K.glyphHeight||24,left:K.glyphLeft||0,top:K.glyphTop-27||-8,advance:K.glyphAdvance||24}}}}me.loadGlyphRange=function(M,h,_,T,F){const O=256*h,K=O+255,oe=T.transformRequest(_.replace("{fontstack}",M).replace("{range}",`${O}-${K}`),i.ResourceType.Glyphs);i.getArrayBuffer(oe,(ue,ve)=>{if(ue)F(ue);else if(ve){const Te={};for(const ze of i.parseGlyphPbf(ve))Te[ze.id]=ze;F(null,Te)}})},me.TinySDF=class{constructor({fontSize:M=24,buffer:h=3,radius:_=8,cutoff:T=.25,fontFamily:F="sans-serif",fontWeight:O="normal",fontStyle:K="normal"}={}){this.buffer=h,this.cutoff=T,this.radius=_;const oe=this.size=M+4*h,ue=this._createCanvas(oe),ve=this.ctx=ue.getContext("2d",{willReadFrequently:!0});ve.font=`${K} ${O} ${M}px ${F}`,ve.textBaseline="alphabetic",ve.textAlign="left",ve.fillStyle="black",this.gridOuter=new Float64Array(oe*oe),this.gridInner=new Float64Array(oe*oe),this.f=new Float64Array(oe),this.z=new Float64Array(oe+1),this.v=new Uint16Array(oe)}_createCanvas(M){const h=document.createElement("canvas");return h.width=h.height=M,h}draw(M){const{width:h,actualBoundingBoxAscent:_,actualBoundingBoxDescent:T,actualBoundingBoxLeft:F,actualBoundingBoxRight:O}=this.ctx.measureText(M),K=Math.ceil(_),oe=Math.min(this.size-this.buffer,Math.ceil(O-F)),ue=Math.min(this.size-this.buffer,K+Math.ceil(T)),ve=oe+2*this.buffer,Te=ue+2*this.buffer,ze=Math.max(ve*Te,0),je=new Uint8ClampedArray(ze),bt={data:je,width:ve,height:Te,glyphWidth:oe,glyphHeight:ue,glyphTop:K,glyphLeft:0,glyphAdvance:h};if(oe===0||ue===0)return bt;const{ctx:mt,buffer:gt,gridInner:Vt,gridOuter:Zt}=this;mt.clearRect(gt,gt,oe,ue),mt.fillText(M,gt,gt+K);const ni=mt.getImageData(gt,gt,oe,ue);Zt.fill(ce,0,ze),Vt.fill(0,0,ze);for(let St=0;St0?Bi*Bi:0,Vt[Ei]=Bi<0?Bi*Bi:0}}Ae(Zt,0,0,ve,Te,ve,this.f,this.v,this.z),Ae(Vt,gt,gt,oe,ue,ve,this.f,this.v,this.z);for(let St=0;St1&&(ue=h[++oe]);const Te=Math.abs(ve-ue.left),ze=Math.abs(ve-ue.right),je=Math.min(Te,ze);let bt;const mt=O/T*(F+1);if(ue.isDash){const gt=F-Math.abs(mt);bt=Math.sqrt(je*je+gt*gt)}else bt=F-Math.sqrt(je*je+mt*mt);this.data[K+ve]=Math.max(0,Math.min(255,bt+128))}}}addRegularDash(h){for(let oe=h.length-1;oe>=0;--oe){const ue=h[oe],ve=h[oe+1];ue.zeroLength?h.splice(oe,1):ve&&ve.isDash===ue.isDash&&(ve.left=ue.left,h.splice(oe,1))}const _=h[0],T=h[h.length-1];_.isDash===T.isDash&&(_.left=T.left-this.width,T.right=_.right+this.width);const F=this.width*this.nextRow;let O=0,K=h[O];for(let oe=0;oe1&&(K=h[++O]);const ue=Math.abs(oe-K.left),ve=Math.abs(oe-K.right),Te=Math.min(ue,ve);this.data[F+oe]=Math.max(0,Math.min(255,(K.isDash?Te:-Te)+128))}}addDash(h,_){const T=_?7:0,F=2*T+1;if(this.nextRow+F>this.height)return i.warnOnce("LineAtlas out of space"),null;let O=0;for(let oe=0;oe{F.send(h,_,O)},T=T||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(h=>{h.remove()}),this.actors=[],this.workerPool.release(this.id)}}function li(M,h,_){const T=function(F,O){if(F)return _(F);if(O){const K=i.pick(i.extend(O,M),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);O.vector_layers&&(K.vectorLayers=O.vector_layers,K.vectorLayerIds=K.vectorLayers.map(oe=>oe.id)),_(null,K)}};return M.url?i.getJSON(h.transformRequest(M.url,i.ResourceType.Source),T):i.exported.frame(()=>T(null,M))}Et.Actor=i.Actor;class xi{constructor(h,_,T){this.bounds=i.LngLatBounds.convert(this.validateBounds(h)),this.minzoom=_||0,this.maxzoom=T||24}validateBounds(h){return Array.isArray(h)&&h.length===4?[Math.max(-180,h[0]),Math.max(-90,h[1]),Math.min(180,h[2]),Math.min(90,h[3])]:[-180,-90,180,90]}contains(h){const _=Math.pow(2,h.z),T=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*_),F=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*_),O=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*_),K=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*_);return h.x>=T&&h.x=F&&h.y{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),h?this.fire(new i.ErrorEvent(h)):_&&(i.extend(this,_),_.bounds&&(this.tileBounds=new xi(_.bounds,this.minzoom,this.maxzoom)),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}onAdd(h){this.map=h,this.load()}setSourceProperty(h){this._tileJSONRequest&&this._tileJSONRequest.cancel(),h(),this.load()}setTiles(h){return this.setSourceProperty(()=>{this._options.tiles=h}),this}setUrl(h){return this.setSourceProperty(()=>{this.url=h,this._options.url=h}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}loadTile(h,_){const T=h.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),F={request:this.map._requestManager.transformRequest(T,i.ResourceType.Tile),uid:h.uid,tileID:h.tileID,zoom:h.tileID.overscaledZ,tileSize:this.tileSize*h.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function O(K,oe){return delete h.request,h.aborted?_(null):K&&K.status!==404?_(K):(oe&&oe.resourceTiming&&(h.resourceTiming=oe.resourceTiming),this.map._refreshExpiredTiles&&oe&&h.setExpiryData(oe),h.loadVectorData(oe,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),_(null),void(h.reloadCallback&&(this.loadTile(h,h.reloadCallback),h.reloadCallback=null)))}F.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired"?h.state==="loading"?h.reloadCallback=_:h.request=h.actor.send("reloadTile",F,O.bind(this)):(h.actor=this.dispatcher.getActor(),h.request=h.actor.send("loadTile",F,O.bind(this)))}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.actor&&h.actor.send("abortTile",{uid:h.uid,type:this.type,source:this.id},void 0)}unloadTile(h){h.unloadVectorData(),h.actor&&h.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class le extends i.Evented{constructor(h,_,T,F){super(),this.id=h,this.dispatcher=T,this.setEventedParent(F),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=i.extend({type:"raster"},_),i.extend(this,i.pick(_,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=li(this._options,this.map._requestManager,(h,_)=>{this._tileJSONRequest=null,this._loaded=!0,h?this.fire(new i.ErrorEvent(h)):_&&(i.extend(this,_),_.bounds&&(this.tileBounds=new xi(_.bounds,this.minzoom,this.maxzoom)),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(h){this.map=h,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(h){return!this.tileBounds||this.tileBounds.contains(h.canonical)}loadTile(h,_){const T=h.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);h.request=i.getImage(this.map._requestManager.transformRequest(T,i.ResourceType.Tile),(F,O,K)=>{if(delete h.request,h.aborted)h.state="unloaded",_(null);else if(F)h.state="errored",_(F);else if(O){this.map._refreshExpiredTiles&&h.setExpiryData(K);const oe=this.map.painter.context,ue=oe.gl;h.texture=this.map.painter.getTileTexture(O.width),h.texture?h.texture.update(O,{useMipmap:!0}):(h.texture=new Y(oe,O,ue.RGBA,{useMipmap:!0}),h.texture.bind(ue.LINEAR,ue.CLAMP_TO_EDGE,ue.LINEAR_MIPMAP_NEAREST),oe.extTextureFilterAnisotropic&&ue.texParameterf(ue.TEXTURE_2D,oe.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,oe.extTextureFilterAnisotropicMax)),h.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),_(null)}})}abortTile(h,_){h.request&&(h.request.cancel(),delete h.request),_()}unloadTile(h,_){h.texture&&this.map.painter.saveTileTexture(h.texture),_()}hasTransition(){return!1}}let ye;class xe extends le{constructor(h,_,T,F){super(h,_,T,F),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},_),this.encoding=_.encoding||"mapbox"}serialize(){return{type:"raster-dem",url:this.url,tileSize:this.tileSize,tiles:this.tiles,bounds:this.bounds,encoding:this.encoding}}loadTile(h,_){const T=h.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);function F(O,K){O&&(h.state="errored",_(O)),K&&(h.dem=K,h.needsHillshadePrepare=!0,h.needsTerrainPrepare=!0,h.state="loaded",_(null))}h.request=i.getImage(this.map._requestManager.transformRequest(T,i.ResourceType.Tile),function(O,K){if(delete h.request,h.aborted)h.state="unloaded",_(null);else if(O)h.state="errored",_(O);else if(K){this.map._refreshExpiredTiles&&h.setExpiryData(K),delete K.cacheControl,delete K.expires;const oe=i.isImageBitmap(K)&&(ye==null&&(ye=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),ye)?K:i.exported.getImageData(K,1),ue={uid:h.uid,coord:h.tileID,source:this.id,rawImageData:oe,encoding:this.encoding};h.actor&&h.state!=="expired"||(h.actor=this.dispatcher.getActor(),h.actor.send("loadDEMTile",ue,F.bind(this)))}}.bind(this)),h.neighboringTiles=this._getNeighboringTiles(h.tileID)}_getNeighboringTiles(h){const _=h.canonical,T=Math.pow(2,_.z),F=(_.x-1+T)%T,O=_.x===0?h.wrap-1:h.wrap,K=(_.x+1+T)%T,oe=_.x+1===T?h.wrap+1:h.wrap,ue={};return ue[new i.OverscaledTileID(h.overscaledZ,O,_.z,F,_.y).key]={backfilled:!1},ue[new i.OverscaledTileID(h.overscaledZ,oe,_.z,K,_.y).key]={backfilled:!1},_.y>0&&(ue[new i.OverscaledTileID(h.overscaledZ,O,_.z,F,_.y-1).key]={backfilled:!1},ue[new i.OverscaledTileID(h.overscaledZ,h.wrap,_.z,_.x,_.y-1).key]={backfilled:!1},ue[new i.OverscaledTileID(h.overscaledZ,oe,_.z,K,_.y-1).key]={backfilled:!1}),_.y+1{if(this._pendingLoads--,this._removed||O&&O.abandoned)return void this.fire(new i.Event("dataabort",{dataType:"source",sourceDataType:h}));let K=null;if(O&&O.resourceTiming&&O.resourceTiming[this.id]&&(K=O.resourceTiming[this.id].slice(0)),F)return void this.fire(new i.ErrorEvent(F));const oe={dataType:"source",sourceDataType:h};this._collectResourceTiming&&K&&K.length>0&&i.extend(oe,{resourceTiming:K}),this.fire(new i.Event("data",oe))})}loaded(){return this._pendingLoads===0}loadTile(h,_){const T=h.actor?"reloadTile":"loadTile";h.actor=this.actor;const F={type:this.type,uid:h.uid,tileID:h.tileID,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};h.request=this.actor.send(T,F,(O,K)=>(delete h.request,h.unloadVectorData(),h.aborted?_(null):O?_(O):(h.loadVectorData(K,this.map.painter,T==="reloadTile"),_(null))))}abortTile(h){h.request&&(h.request.cancel(),delete h.request),h.aborted=!0}unloadTile(h){h.unloadVectorData(),this.actor.send("removeTile",{uid:h.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var Oe=i.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class We extends i.Evented{constructor(h,_,T,F){super(),this.id=h,this.dispatcher=T,this.coordinates=_.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(F),this.options=_}load(h,_){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(T,F)=>{this._loaded=!0,T?this.fire(new i.ErrorEvent(T)):F&&(this.image=F,h&&(this.coordinates=h),_&&_(),this._finishLoading())})}loaded(){return this._loaded}updateImage(h){return this.image&&h.url?(this.options.url=h.url,this.load(h.coordinates,()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(h){this.map=h,this.load()}setCoordinates(h){this.coordinates=h;const _=h.map(i.MercatorCoordinate.fromLngLat);this.tileID=function(F){let O=1/0,K=1/0,oe=-1/0,ue=-1/0;for(const je of F)O=Math.min(O,je.x),K=Math.min(K,je.y),oe=Math.max(oe,je.x),ue=Math.max(ue,je.y);const ve=Math.max(oe-O,ue-K),Te=Math.max(0,Math.floor(-Math.log(ve)/Math.LN2)),ze=Math.pow(2,Te);return new i.CanonicalTileID(Te,Math.floor((O+oe)/2*ze),Math.floor((K+ue)/2*ze))}(_),this.minzoom=this.maxzoom=this.tileID.z;const T=_.map(F=>this.tileID.getTilePoint(F)._round());return this._boundsArray=new i.RasterBoundsArray,this._boundsArray.emplaceBack(T[0].x,T[0].y,0,0),this._boundsArray.emplaceBack(T[1].x,T[1].y,i.EXTENT,0),this._boundsArray.emplaceBack(T[3].x,T[3].y,0,i.EXTENT),this._boundsArray.emplaceBack(T[2].x,T[2].y,i.EXTENT,i.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const h=this.map.painter.context,_=h.gl;this.boundsBuffer||(this.boundsBuffer=h.createVertexBuffer(this._boundsArray,Oe.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new Y(h,this.image,_.RGBA),this.texture.bind(_.LINEAR,_.CLAMP_TO_EDGE));for(const T in this.tiles){const F=this.tiles[T];F.state!=="loaded"&&(F.state="loaded",F.texture=this.texture)}}loadTile(h,_){this.tileID&&this.tileID.equals(h.tileID.canonical)?(this.tiles[String(h.tileID.wrap)]=h,h.buckets={},_(null)):(h.state="errored",_(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class Ve extends We{constructor(h,_,T,F){super(h,_,T,F),this.roundZoom=!0,this.type="video",this.options=_}load(){this._loaded=!1;const h=this.options;this.urls=[];for(const _ of h.urls)this.urls.push(this.map._requestManager.transformRequest(_,i.ResourceType.Source).url);i.getVideo(this.urls,(_,T)=>{this._loaded=!0,_?this.fire(new i.ErrorEvent(_)):T&&(this.video=T,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(h){if(this.video){const _=this.video.seekable;h<_.start(0)||h>_.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${_.start(0)} and ${_.end(0)}-second mark.`))):this.video.currentTime=h}}getVideo(){return this.video}onAdd(h){this.map||(this.map=h,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const h=this.map.painter.context,_=h.gl;this.boundsBuffer||(this.boundsBuffer=h.createVertexBuffer(this._boundsArray,Oe.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?this.video.paused||(this.texture.bind(_.LINEAR,_.CLAMP_TO_EDGE),_.texSubImage2D(_.TEXTURE_2D,0,0,0,_.RGBA,_.UNSIGNED_BYTE,this.video)):(this.texture=new Y(h,this.video,_.RGBA),this.texture.bind(_.LINEAR,_.CLAMP_TO_EDGE));for(const T in this.tiles){const F=this.tiles[T];F.state!=="loaded"&&(F.state="loaded",F.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Qe extends We{constructor(h,_,T,F){super(h,_,T,F),_.coordinates?Array.isArray(_.coordinates)&&_.coordinates.length===4&&!_.coordinates.some(O=>!Array.isArray(O)||O.length!==2||O.some(K=>typeof K!="number"))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${h}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${h}`,null,'missing required property "coordinates"'))),_.animate&&typeof _.animate!="boolean"&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${h}`,null,'optional "animate" property must be a boolean value'))),_.canvas?typeof _.canvas=="string"||_.canvas instanceof HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${h}`,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 i.ErrorEvent(new i.ValidationError(`sources.${h}`,null,'missing required property "canvas"'))),this.options=_,this.animate=_.animate===void 0||_.animate}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 i.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(h){this.map=h,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let h=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,h=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,h=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const _=this.map.painter.context,T=_.gl;this.boundsBuffer||(this.boundsBuffer=_.createVertexBuffer(this._boundsArray,Oe.members)),this.boundsSegments||(this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(h||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new Y(_,this.canvas,T.RGBA,{premultiply:!0});for(const F in this.tiles){const O=this.tiles[F];O.state!=="loaded"&&(O.state="loaded",O.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const h of[this.canvas.width,this.canvas.height])if(isNaN(h)||h<=0)return!0;return!1}}const Se={vector:te,raster:le,"raster-dem":xe,geojson:Re,video:Ve,image:We,canvas:Qe};function Ke(M,h){const _=i.create();return i.translate(_,_,[1,1,0]),i.scale(_,_,[.5*M.width,.5*M.height,1]),i.multiply(_,_,M.calculatePosMatrix(h.toUnwrapped()))}function nt(M,h,_,T,F,O){const K=function(ze,je,bt){if(ze)for(const mt of ze){const gt=je[mt];if(gt&>.source===bt&>.type==="fill-extrusion")return!0}else for(const mt in je){const gt=je[mt];if(gt.source===bt&>.type==="fill-extrusion")return!0}return!1}(F&&F.layers,h,M.id),oe=O.maxPitchScaleFactor(),ue=M.tilesIn(T,oe,K);ue.sort(vt);const ve=[];for(const ze of ue)ve.push({wrappedTileID:ze.tileID.wrapped().key,queryResults:ze.tile.queryRenderedFeatures(h,_,M._state,ze.queryGeometry,ze.cameraQueryGeometry,ze.scale,F,O,oe,Ke(M.transform,ze.tileID))});const Te=function(ze){const je={},bt={};for(const mt of ze){const gt=mt.queryResults,Vt=mt.wrappedTileID,Zt=bt[Vt]=bt[Vt]||{};for(const ni in gt){const St=gt[ni],zt=Zt[ni]=Zt[ni]||{},ai=je[ni]=je[ni]||[];for(const Ei of St)zt[Ei.featureIndex]||(zt[Ei.featureIndex]=!0,ai.push(Ei))}}return je}(ve);for(const ze in Te)Te[ze].forEach(je=>{const bt=je.feature,mt=M.getFeatureState(bt.layer["source-layer"],bt.id);bt.source=bt.layer.source,bt.layer["source-layer"]&&(bt.sourceLayer=bt.layer["source-layer"]),bt.state=mt});return Te}function vt(M,h){const _=M.tileID,T=h.tileID;return _.overscaledZ-T.overscaledZ||_.canonical.y-T.canonical.y||_.wrap-T.wrap||_.canonical.x-T.canonical.x}class be{constructor(h,_){this.tileID=h,this.uid=i.uniqueId(),this.uses=0,this.tileSize=_,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.textures=[],this.textureCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(h){const _=h+this.timeAdded;_h.saveTileTexture(_)),this.demTexture=null,this.textures=[],this.textureCoords={}}loadVectorData(h,_,T){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",h){h.featureIndex&&(this.latestFeatureIndex=h.featureIndex,h.rawTileData?(this.latestRawTileData=h.rawTileData,this.latestFeatureIndex.rawTileData=h.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=h.collisionBoxArray,this.buckets=function(F,O){const K={};if(!O)return K;for(const oe of F){const ue=oe.layerIds.map(ve=>O.getLayer(ve)).filter(Boolean);if(ue.length!==0){oe.layers=ue,oe.stateDependentLayerIds&&(oe.stateDependentLayers=oe.stateDependentLayerIds.map(ve=>ue.filter(Te=>Te.id===ve)[0]));for(const ve of ue)K[ve.id]=oe}}return K}(h.buckets,_.style),this.hasSymbolBuckets=!1;for(const F in this.buckets){const O=this.buckets[F];if(O instanceof i.SymbolBucket){if(this.hasSymbolBuckets=!0,!T)break;O.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const F in this.buckets){const O=this.buckets[F];if(O instanceof i.SymbolBucket&&O.hasRTLText){this.hasRTLText=!0,i.lazyLoadRTLTextPlugin();break}}this.queryPadding=0;for(const F in this.buckets){const O=this.buckets[F];this.queryPadding=Math.max(this.queryPadding,_.style.getLayer(F).queryRadius(O))}h.imageAtlas&&(this.imageAtlas=h.imageAtlas),h.glyphAtlasImage&&(this.glyphAtlasImage=h.glyphAtlasImage)}else this.collisionBoxArray=new i.CollisionBoxArray}unloadVectorData(){for(const h in this.buckets)this.buckets[h].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(h){return this.buckets[h.id]}upload(h){for(const T in this.buckets){const F=this.buckets[T];F.uploadPending()&&F.upload(h)}const _=h.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Y(h,this.imageAtlas.image,_.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Y(h,this.glyphAtlasImage,_.ALPHA),this.glyphAtlasImage=null)}prepare(h){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(h,this.imageAtlasTexture)}queryRenderedFeatures(h,_,T,F,O,K,oe,ue,ve,Te){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:F,cameraQueryGeometry:O,scale:K,tileSize:this.tileSize,pixelPosMatrix:Te,transform:ue,params:oe,queryPadding:this.queryPadding*ve},h,_,T):{}}querySourceFeatures(h,_){const T=this.latestFeatureIndex;if(!T||!T.rawTileData)return;const F=T.loadVTLayers(),O=_?_.sourceLayer:"",K=F._geojsonTileLayer||F[O];if(!K)return;const oe=i.createFilter(_&&_.filter),{z:ue,x:ve,y:Te}=this.tileID.canonical,ze={z:ue,x:ve,y:Te};for(let je=0;jeT)F=!1;else if(_)if(this.expirationTime<_)F=!0;else{const O=this.expirationTime-_;O?this.expirationTime=T+Math.max(O,3e4):F=!0}else F=!0;F?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<{this.remove(h,O)},T)),this.data[F].push(O),this.order.push(F),this.order.length>this.max){const K=this._getAndRemoveByKey(this.order[0]);K&&this.onRemove(K)}return this}has(h){return h.wrapped().key in this.data}getAndRemove(h){return this.has(h)?this._getAndRemoveByKey(h.wrapped().key):null}_getAndRemoveByKey(h){const _=this.data[h].shift();return _.timeout&&clearTimeout(_.timeout),this.data[h].length===0&&delete this.data[h],this.order.splice(this.order.indexOf(h),1),_.value}getByKey(h){const _=this.data[h];return _?_[0].value:null}get(h){return this.has(h)?this.data[h.wrapped().key][0].value:null}remove(h,_){if(!this.has(h))return this;const T=h.wrapped().key,F=_===void 0?0:this.data[T].indexOf(_),O=this.data[T][F];return this.data[T].splice(F,1),O.timeout&&clearTimeout(O.timeout),this.data[T].length===0&&delete this.data[T],this.onRemove(O.value),this.order.splice(this.order.indexOf(T),1),this}setMaxSize(h){for(this.max=h;this.order.length>this.max;){const _=this._getAndRemoveByKey(this.order[0]);_&&this.onRemove(_)}return this}filter(h){const _=[];for(const T in this.data)for(const F of this.data[T])h(F.value)||_.push(F);for(const T of _)this.remove(T.value.tileID,T)}}class ut{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(h,_,T){const F=String(_);if(this.stateChanges[h]=this.stateChanges[h]||{},this.stateChanges[h][F]=this.stateChanges[h][F]||{},i.extend(this.stateChanges[h][F],T),this.deletedStates[h]===null){this.deletedStates[h]={};for(const O in this.state[h])O!==F&&(this.deletedStates[h][O]=null)}else if(this.deletedStates[h]&&this.deletedStates[h][F]===null){this.deletedStates[h][F]={};for(const O in this.state[h][F])T[O]||(this.deletedStates[h][F][O]=null)}else for(const O in T)this.deletedStates[h]&&this.deletedStates[h][F]&&this.deletedStates[h][F][O]===null&&delete this.deletedStates[h][F][O]}removeFeatureState(h,_,T){if(this.deletedStates[h]===null)return;const F=String(_);if(this.deletedStates[h]=this.deletedStates[h]||{},T&&_!==void 0)this.deletedStates[h][F]!==null&&(this.deletedStates[h][F]=this.deletedStates[h][F]||{},this.deletedStates[h][F][T]=null);else if(_!==void 0)if(this.stateChanges[h]&&this.stateChanges[h][F])for(T in this.deletedStates[h][F]={},this.stateChanges[h][F])this.deletedStates[h][F][T]=null;else this.deletedStates[h][F]=null;else this.deletedStates[h]=null}getState(h,_){const T=String(_),F=i.extend({},(this.state[h]||{})[T],(this.stateChanges[h]||{})[T]);if(this.deletedStates[h]===null)return{};if(this.deletedStates[h]){const O=this.deletedStates[h][_];if(O===null)return{};for(const K in O)delete F[K]}return F}initializeTileState(h,_){h.setFeatureState(this.state,_)}coalesceChanges(h,_){const T={};for(const F in this.stateChanges){this.state[F]=this.state[F]||{};const O={};for(const K in this.stateChanges[F])this.state[F][K]||(this.state[F][K]={}),i.extend(this.state[F][K],this.stateChanges[F][K]),O[K]=this.state[F][K];T[F]=O}for(const F in this.deletedStates){this.state[F]=this.state[F]||{};const O={};if(this.deletedStates[F]===null)for(const K in this.state[F])O[K]={},this.state[F][K]={};else for(const K in this.deletedStates[F]){if(this.deletedStates[F][K]===null)this.state[F][K]={};else for(const oe of Object.keys(this.deletedStates[F][K]))delete this.state[F][K][oe];O[K]=this.state[F][K]}T[F]=T[F]||{},i.extend(T[F],O)}if(this.stateChanges={},this.deletedStates={},Object.keys(T).length!==0)for(const F in h)h[F].setFeatureState(T,_)}}class Nt extends i.Evented{constructor(h,_,T){super(),this.id=h,this.dispatcher=T,this.on("data",F=>{F.dataType==="source"&&F.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&F.dataType==="source"&&F.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain))}),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=function(F,O,K,oe){const ue=new Se[O.type](F,O,K,oe);if(ue.id!==F)throw new Error(`Expected Source id to be ${F} instead of ${ue.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],ue),ue}(h,_,T,this),this._tiles={},this._cache=new At(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new ut}onAdd(h){this.map=h,this._maxTileCacheSize=h?h._maxTileCacheSize:null,this._source&&this._source.onAdd&&this._source.onAdd(h)}onRemove(h){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(h)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const h in this._tiles){const _=this._tiles[h];if(_.state!=="loaded"&&_.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const h=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,h&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(h,_){return this._source.loadTile(h,_)}_unloadTile(h){if(this._source.unloadTile)return this._source.unloadTile(h,()=>{})}_abortTile(h){this._source.abortTile&&this._source.abortTile(h,()=>{}),this._source.fire(new i.Event("dataabort",{tile:h,coord:h.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(h){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const _ in this._tiles){const T=this._tiles[_];T.upload(h),T.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(h=>h.tileID).sort(Gt).map(h=>h.key)}getRenderableIds(h){const _=[];for(const T in this._tiles)this._isIdRenderable(T,h)&&_.push(this._tiles[T]);return h?_.sort((T,F)=>{const O=T.tileID,K=F.tileID,oe=new i.pointGeometry(O.canonical.x,O.canonical.y)._rotate(this.transform.angle),ue=new i.pointGeometry(K.canonical.x,K.canonical.y)._rotate(this.transform.angle);return O.overscaledZ-K.overscaledZ||ue.y-oe.y||ue.x-oe.x}).map(T=>T.tileID.key):_.map(T=>T.tileID).sort(Gt).map(T=>T.key)}hasRenderableParent(h){const _=this.findLoadedParent(h,0);return!!_&&this._isIdRenderable(_.tileID.key)}_isIdRenderable(h,_){return this._tiles[h]&&this._tiles[h].hasData()&&!this._coveredTiles[h]&&(_||!this._tiles[h].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const h in this._tiles)this._tiles[h].state!=="errored"&&this._reloadTile(h,"reloading")}}_reloadTile(h,_){const T=this._tiles[h];T&&(T.state!=="loading"&&(T.state=_),this._loadTile(T,this._tileLoaded.bind(this,T,h,_)))}_tileLoaded(h,_,T,F){if(F)return h.state="errored",void(F.status!==404?this._source.fire(new i.ErrorEvent(F,{tile:h})):this.update(this.transform,this.terrain));h.timeAdded=i.exported.now(),T==="expired"&&(h.refreshedUponExpiration=!0),this._setTileReloadTimer(_,h),this.getSource().type==="raster-dem"&&h.dem&&this._backfillDEM(h),this._state.initializeTileState(h,this.map?this.map.painter:null),h.aborted||this._source.fire(new i.Event("data",{dataType:"source",tile:h,coord:h.tileID}))}_backfillDEM(h){const _=this.getRenderableIds();for(let F=0;F<_.length;F++){const O=_[F];if(h.neighboringTiles&&h.neighboringTiles[O]){const K=this.getTileByID(O);T(h,K),T(K,h)}}function T(F,O){F.needsHillshadePrepare=!0,F.needsTerrainPrepare=!0;let K=O.tileID.canonical.x-F.tileID.canonical.x;const oe=O.tileID.canonical.y-F.tileID.canonical.y,ue=Math.pow(2,F.tileID.canonical.z),ve=O.tileID.key;K===0&&oe===0||Math.abs(oe)>1||(Math.abs(K)>1&&(Math.abs(K+ue)===1?K+=ue:Math.abs(K-ue)===1&&(K-=ue)),O.dem&&F.dem&&(F.dem.backfillBorder(O.dem,K,oe),F.neighboringTiles&&F.neighboringTiles[ve]&&(F.neighboringTiles[ve].backfilled=!0)))}}getTile(h){return this.getTileByID(h.key)}getTileByID(h){return this._tiles[h]}_retainLoadedChildren(h,_,T,F){for(const O in this._tiles){let K=this._tiles[O];if(F[O]||!K.hasData()||K.tileID.overscaledZ<=_||K.tileID.overscaledZ>T)continue;let oe=K.tileID;for(;K&&K.tileID.overscaledZ>_+1;){const ve=K.tileID.scaledTo(K.tileID.overscaledZ-1);K=this._tiles[ve.key],K&&K.hasData()&&(oe=ve)}let ue=oe;for(;ue.overscaledZ>_;)if(ue=ue.scaledTo(ue.overscaledZ-1),h[ue.key]){F[oe.key]=oe;break}}}findLoadedParent(h,_){if(h.key in this._loadedParentTiles){const T=this._loadedParentTiles[h.key];return T&&T.tileID.overscaledZ>=_?T:null}for(let T=h.overscaledZ-1;T>=_;T--){const F=h.scaledTo(T),O=this._getLoadedTile(F);if(O)return O}}_getLoadedTile(h){const _=this._tiles[h.key];return _&&_.hasData()?_:this._cache.getByKey(h.wrapped().key)}updateCacheSize(h){const _=Math.ceil(h.width/this._source.tileSize)+1,T=Math.ceil(h.height/this._source.tileSize)+1,F=Math.floor(_*T*5),O=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,F):F;this._cache.setMaxSize(O)}handleWrapJump(h){const _=Math.round((h-(this._prevLng===void 0?h:this._prevLng))/360);if(this._prevLng=h,_){const T={};for(const F in this._tiles){const O=this._tiles[F];O.tileID=O.tileID.unwrapTo(O.tileID.wrap+_),T[O.tileID.key]=O}this._tiles=T;for(const F in this._timers)clearTimeout(this._timers[F]),delete this._timers[F];for(const F in this._tiles)this._setTileReloadTimer(F,this._tiles[F])}}update(h,_){if(this.transform=h,this.terrain=_,!this._sourceLoaded||this._paused)return;let T;this.updateCacheSize(h),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?T=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(ve=>new i.OverscaledTileID(ve.canonical.z,ve.wrap,ve.canonical.z,ve.canonical.x,ve.canonical.y)):(T=h.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:_}),this._source.hasTile&&(T=T.filter(ve=>this._source.hasTile(ve)))):T=[];const F=h.coveringZoomLevel(this._source),O=Math.max(F-Nt.maxOverzooming,this._source.minzoom),K=Math.max(F+Nt.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const ve={};for(const Te of T)if(Te.canonical.z>this._source.minzoom){const ze=Te.scaledTo(Te.canonical.z-1);ve[ze.key]=ze;const je=Te.scaledTo(Math.max(this._source.minzoom,Math.min(Te.canonical.z,5)));ve[je.key]=je}T=T.concat(Object.values(ve))}const oe=this._updateRetainedTiles(T,F);if(Qt(this._source.type)){const ve={},Te={},ze=Object.keys(oe);for(const je of ze){const bt=oe[je],mt=this._tiles[je];if(!mt||mt.fadeEndTime&&mt.fadeEndTime<=i.exported.now())continue;const gt=this.findLoadedParent(bt,O);gt&&(this._addTile(gt.tileID),ve[gt.tileID.key]=gt.tileID),Te[je]=bt}this._retainLoadedChildren(Te,F,K,oe);for(const je in ve)oe[je]||(this._coveredTiles[je]=!0,oe[je]=ve[je]);if(_){const je={},bt={};for(const mt of T)this._tiles[mt.key].hasData()?je[mt.key]=mt:bt[mt.key]=mt;for(const mt in bt){const gt=bt[mt].children(this._source.maxzoom);this._tiles[gt[0].key]&&this._tiles[gt[1].key]&&this._tiles[gt[2].key]&&this._tiles[gt[3].key]&&(je[gt[0].key]=oe[gt[0].key]=gt[0],je[gt[1].key]=oe[gt[1].key]=gt[1],je[gt[2].key]=oe[gt[2].key]=gt[2],je[gt[3].key]=oe[gt[3].key]=gt[3],delete bt[mt])}for(const mt in bt){const gt=this.findLoadedParent(bt[mt],this._source.minzoom);if(gt){je[gt.tileID.key]=oe[gt.tileID.key]=gt.tileID;for(const Vt in je)je[Vt].isChildOf(gt.tileID)&&delete je[Vt]}}for(const mt in this._tiles)je[mt]||(this._coveredTiles[mt]=!0)}}for(const ve in oe)this._tiles[ve].clearFadeHold();const ue=i.keysDifference(this._tiles,oe);for(const ve of ue){const Te=this._tiles[ve];Te.hasSymbolBuckets&&!Te.holdingForFade()?Te.setHoldDuration(this.map._fadeDuration):Te.hasSymbolBuckets&&!Te.symbolFadeFinished()||this._removeTile(ve)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const h in this._tiles)this._tiles[h].holdingForFade()&&this._removeTile(h)}_updateRetainedTiles(h,_){const T={},F={},O=Math.max(_-Nt.maxOverzooming,this._source.minzoom),K=Math.max(_+Nt.maxUnderzooming,this._source.minzoom),oe={};for(const ue of h){const ve=this._addTile(ue);T[ue.key]=ue,ve.hasData()||_this._source.maxzoom){const ze=ue.children(this._source.maxzoom)[0],je=this.getTile(ze);if(je&&je.hasData()){T[ze.key]=ze;continue}}else{const ze=ue.children(this._source.maxzoom);if(T[ze[0].key]&&T[ze[1].key]&&T[ze[2].key]&&T[ze[3].key])continue}let Te=ve.wasRequested();for(let ze=ue.overscaledZ-1;ze>=O;--ze){const je=ue.scaledTo(ze);if(F[je.key]||(F[je.key]=!0,ve=this.getTile(je),!ve&&Te&&(ve=this._addTile(je)),ve&&(T[je.key]=je,Te=ve.wasRequested(),ve.hasData())))break}}return T}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const h in this._tiles){const _=[];let T,F=this._tiles[h].tileID;for(;F.overscaledZ>0;){if(F.key in this._loadedParentTiles){T=this._loadedParentTiles[F.key];break}_.push(F.key);const O=F.scaledTo(F.overscaledZ-1);if(T=this._getLoadedTile(O),T)break;F=O}for(const O of _)this._loadedParentTiles[O]=T}}_addTile(h){let _=this._tiles[h.key];if(_)return _;_=this._cache.getAndRemove(h),_&&(this._setTileReloadTimer(h.key,_),_.tileID=h,this._state.initializeTileState(_,this.map?this.map.painter:null),this._cacheTimers[h.key]&&(clearTimeout(this._cacheTimers[h.key]),delete this._cacheTimers[h.key],this._setTileReloadTimer(h.key,_)));const T=_;return _||(_=new be(h,this._source.tileSize*h.overscaleFactor()),this._loadTile(_,this._tileLoaded.bind(this,_,h.key,_.state))),_.uses++,this._tiles[h.key]=_,T||this._source.fire(new i.Event("dataloading",{tile:_,coord:_.tileID,dataType:"source"})),_}_setTileReloadTimer(h,_){h in this._timers&&(clearTimeout(this._timers[h]),delete this._timers[h]);const T=_.getExpiryTimeout();T&&(this._timers[h]=setTimeout(()=>{this._reloadTile(h,"expired"),delete this._timers[h]},T))}_removeTile(h){const _=this._tiles[h];_&&(_.uses--,delete this._tiles[h],this._timers[h]&&(clearTimeout(this._timers[h]),delete this._timers[h]),_.uses>0||(_.hasData()&&_.state!=="reloading"?this._cache.add(_.tileID,_,_.getExpiryTimeout()):(_.aborted=!0,this._abortTile(_),this._unloadTile(_))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const h in this._tiles)this._removeTile(h);this._cache.reset()}tilesIn(h,_,T){const F=[],O=this.transform;if(!O)return F;const K=T?O.getCameraQueryGeometry(h):h,oe=h.map(mt=>O.pointCoordinate(mt,this.terrain)),ue=K.map(mt=>O.pointCoordinate(mt,this.terrain)),ve=this.getIds();let Te=1/0,ze=1/0,je=-1/0,bt=-1/0;for(const mt of ue)Te=Math.min(Te,mt.x),ze=Math.min(ze,mt.y),je=Math.max(je,mt.x),bt=Math.max(bt,mt.y);for(let mt=0;mt=0&&St[1].y+ni>=0){const zt=oe.map(Ei=>Vt.getTilePoint(Ei)),ai=ue.map(Ei=>Vt.getTilePoint(Ei));F.push({tile:gt,tileID:Vt,queryGeometry:zt,cameraQueryGeometry:ai,scale:Zt})}}return F}getVisibleCoordinates(h){const _=this.getRenderableIds(h).map(T=>this._tiles[T].tileID);for(const T of _)T.posMatrix=this.transform.calculatePosMatrix(T.toUnwrapped());return _}hasTransition(){if(this._source.hasTransition())return!0;if(Qt(this._source.type))for(const h in this._tiles){const _=this._tiles[h];if(_.fadeEndTime!==void 0&&_.fadeEndTime>=i.exported.now())return!0}return!1}setFeatureState(h,_,T){this._state.updateState(h=h||"_geojsonTileLayer",_,T)}removeFeatureState(h,_,T){this._state.removeFeatureState(h=h||"_geojsonTileLayer",_,T)}getFeatureState(h,_){return this._state.getState(h=h||"_geojsonTileLayer",_)}setDependencies(h,_,T){const F=this._tiles[h];F&&F.setDependencies(_,T)}reloadTilesForDependencies(h,_){for(const T in this._tiles)this._tiles[T].hasDependency(h,_)&&this._reloadTile(T,"reloading");this._cache.filter(T=>!T.hasDependency(h,_))}}function Gt(M,h){const _=Math.abs(2*M.wrap)-+(M.wrap<0),T=Math.abs(2*h.wrap)-+(h.wrap<0);return M.overscaledZ-h.overscaledZ||T-_||h.canonical.y-M.canonical.y||h.canonical.x-M.canonical.x}function Qt(M){return M==="raster"||M==="image"||M==="video"}Nt.maxOverzooming=10,Nt.maxUnderzooming=3;const Ct="mapboxgl_preloaded_worker_pool";class Ft{constructor(){this.active={}}acquire(h){if(!this.workers)for(this.workers=[];this.workers.length{_.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ct]}numActive(){return Object.keys(this.active).length}}const Xt=Math.floor(i.exported.hardwareConcurrency/2);let _i;function fi(){return _i||(_i=new Ft),_i}function Gi(M,h){const _={};for(const T in M)T!=="ref"&&(_[T]=M[T]);return i.refProperties.forEach(T=>{T in h&&(_[T]=h[T])}),_}function wn(M){M=M.slice();const h=Object.create(null);for(let _=0;_0?(F-K)/oe:0;return this.points[O].mult(1-ue).add(this.points[_].mult(ue))}}function $t(M,h){let _=!0;return M==="always"||M!=="never"&&h!=="never"||(_=!1),_}class at{constructor(h,_,T){const F=this.boxCells=[],O=this.circleCells=[];this.xCellCount=Math.ceil(h/T),this.yCellCount=Math.ceil(_/T);for(let K=0;Kthis.width||F<0||_>this.height)return[];const ue=[];if(h<=0&&_<=0&&this.width<=T&&this.height<=F){if(O)return[{key:null,x1:h,y1:_,x2:T,y2:F}];for(let ve=0;ve0}hitTestCircle(h,_,T,F,O){const K=h-T,oe=h+T,ue=_-T,ve=_+T;if(oe<0||K>this.width||ve<0||ue>this.height)return!1;const Te=[];return this._forEachCell(K,ue,oe,ve,this._queryCellCircle,Te,{hitTest:!0,overlapMode:F,circle:{x:h,y:_,radius:T},seenUids:{box:{},circle:{}}},O),Te.length>0}_queryCell(h,_,T,F,O,K,oe,ue){const{seenUids:ve,hitTest:Te,overlapMode:ze}=oe,je=this.boxCells[O];if(je!==null){const mt=this.bboxes;for(const gt of je)if(!ve.box[gt]){ve.box[gt]=!0;const Vt=4*gt,Zt=this.boxKeys[gt];if(h<=mt[Vt+2]&&_<=mt[Vt+3]&&T>=mt[Vt+0]&&F>=mt[Vt+1]&&(!ue||ue(Zt))&&(!Te||!$t(ze,Zt.overlapMode))&&(K.push({key:Zt,x1:mt[Vt],y1:mt[Vt+1],x2:mt[Vt+2],y2:mt[Vt+3]}),Te))return!0}}const bt=this.circleCells[O];if(bt!==null){const mt=this.circles;for(const gt of bt)if(!ve.circle[gt]){ve.circle[gt]=!0;const Vt=3*gt,Zt=this.circleKeys[gt];if(this._circleAndRectCollide(mt[Vt],mt[Vt+1],mt[Vt+2],h,_,T,F)&&(!ue||ue(Zt))&&(!Te||!$t(ze,Zt.overlapMode))){const ni=mt[Vt],St=mt[Vt+1],zt=mt[Vt+2];if(K.push({key:Zt,x1:ni-zt,y1:St-zt,x2:ni+zt,y2:St+zt}),Te)return!0}}}return!1}_queryCellCircle(h,_,T,F,O,K,oe,ue){const{circle:ve,seenUids:Te,overlapMode:ze}=oe,je=this.boxCells[O];if(je!==null){const mt=this.bboxes;for(const gt of je)if(!Te.box[gt]){Te.box[gt]=!0;const Vt=4*gt,Zt=this.boxKeys[gt];if(this._circleAndRectCollide(ve.x,ve.y,ve.radius,mt[Vt+0],mt[Vt+1],mt[Vt+2],mt[Vt+3])&&(!ue||ue(Zt))&&!$t(ze,Zt.overlapMode))return K.push(!0),!0}}const bt=this.circleCells[O];if(bt!==null){const mt=this.circles;for(const gt of bt)if(!Te.circle[gt]){Te.circle[gt]=!0;const Vt=3*gt,Zt=this.circleKeys[gt];if(this._circlesCollide(mt[Vt],mt[Vt+1],mt[Vt+2],ve.x,ve.y,ve.radius)&&(!ue||ue(Zt))&&!$t(ze,Zt.overlapMode))return K.push(!0),!0}}}_forEachCell(h,_,T,F,O,K,oe,ue){const ve=this._convertToXCellCoord(h),Te=this._convertToYCellCoord(_),ze=this._convertToXCellCoord(T),je=this._convertToYCellCoord(F);for(let bt=ve;bt<=ze;bt++)for(let mt=Te;mt<=je;mt++)if(O.call(this,h,_,T,F,this.xCellCount*mt+bt,K,oe,ue))return}_convertToXCellCoord(h){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(h*this.xScale)))}_convertToYCellCoord(h){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(h*this.yScale)))}_circlesCollide(h,_,T,F,O,K){const oe=F-h,ue=O-_,ve=T+K;return ve*ve>oe*oe+ue*ue}_circleAndRectCollide(h,_,T,F,O,K,oe){const ue=(K-F)/2,ve=Math.abs(h-(F+ue));if(ve>ue+T)return!1;const Te=(oe-O)/2,ze=Math.abs(_-(O+Te));if(ze>Te+T)return!1;if(ve<=ue||ze<=Te)return!0;const je=ve-ue,bt=ze-Te;return je*je+bt*bt<=T*T}}function ii(M,h,_,T,F){const O=i.create();return h?(i.scale(O,O,[1/F,1/F,1]),_||i.rotateZ(O,O,T.angle)):i.multiply(O,T.labelPlaneMatrix,M),O}function hn(M,h,_,T,F){if(h){const O=i.clone(M);return i.scale(O,O,[F,F,1]),_||i.rotateZ(O,O,-T.angle),O}return T.glCoordMatrix}function Xi(M,h,_){let T;_?(T=[M.x,M.y,_(M.x,M.y),1],i.transformMat4(T,T,h)):(T=[M.x,M.y,0,1],Pn(T,T,h));const F=T[3];return{point:new i.pointGeometry(T[0]/F,T[1]/F),signedDistanceFromCamera:F}}function on(M,h){return .5+M/h*.5}function Cn(M,h){const _=M[0]/M[3],T=M[1]/M[3];return _>=-h[0]&&_<=h[0]&&T>=-h[1]&&T<=h[1]}function Tn(M,h,_,T,F,O,K,oe,ue,ve){const Te=T?M.textSizeData:M.iconSizeData,ze=i.evaluateSizeForZoom(Te,_.transform.zoom),je=[256/_.width*2+1,256/_.height*2+1],bt=T?M.text.dynamicLayoutVertexArray:M.icon.dynamicLayoutVertexArray;bt.clear();const mt=M.lineVertexArray,gt=T?M.text.placedSymbolArray:M.icon.placedSymbolArray,Vt=_.transform.width/_.transform.height;let Zt=!1;for(let ni=0;niMath.abs(_.x-h.x)*T?{useVertical:!0}:(M===i.WritingMode.vertical?h.y<_.y:h.x>_.x)?{needsFlipping:!0}:null}function bn(M,h,_,T,F,O,K,oe,ue,ve,Te,ze,je,bt,mt,gt){const Vt=h/24,Zt=M.lineOffsetX*Vt,ni=M.lineOffsetY*Vt;let St;if(M.numGlyphs>1){const zt=M.glyphStartIndex+M.numGlyphs,ai=M.lineStartIndex,Ei=M.lineStartIndex+M.lineLength,Bi=nr(Vt,oe,Zt,ni,_,Te,ze,M,ue,O,je,mt,gt);if(!Bi)return{notEnoughRoom:!0};const Hi=Xi(Bi.first.point,K,gt).point,vi=Xi(Bi.last.point,K,gt).point;if(T&&!_){const xn=Ii(M.writingMode,Hi,vi,bt);if(xn)return xn}St=[Bi.first];for(let xn=M.glyphStartIndex+1;xn0?Hi.point:Ot(ze,Bi,ai,1,F,gt),xn=Ii(M.writingMode,ai,vi,bt);if(xn)return xn}const zt=wi(Vt*oe.getoffsetX(M.glyphStartIndex),Zt,ni,_,Te,ze,M.segment,M.lineStartIndex,M.lineStartIndex+M.lineLength,ue,O,je,mt,gt);if(!zt)return{notEnoughRoom:!0};St=[zt]}for(const zt of St)i.addDynamicAttributes(ve,zt.point,zt.angle);return{}}function Ot(M,h,_,T,F,O){const K=Xi(M.add(M.sub(h)._unit()),F,O).point,oe=_.sub(K);return _.add(oe._mult(T/oe.mag()))}function wi(M,h,_,T,F,O,K,oe,ue,ve,Te,ze,je,bt){const mt=T?M-h:M+h;let gt=mt>0?1:-1,Vt=0;T&&(gt*=-1,Vt=Math.PI),gt<0&&(Vt+=Math.PI);let Zt=gt>0?oe+K:oe+K+1,ni=F,St=F,zt=0,ai=0;const Ei=Math.abs(mt),Bi=[];for(;zt+ai<=Ei;){if(Zt+=gt,Zt=ue)return null;if(St=ni,Bi.push(ni),ni=ze[Zt],ni===void 0){const Bn=new i.pointGeometry(ve.getx(Zt),ve.gety(Zt)),tr=Xi(Bn,Te,bt);if(tr.signedDistanceFromCamera>0)ni=ze[Zt]=tr.point;else{const ur=Zt-gt;ni=Ot(zt===0?O:new i.pointGeometry(ve.getx(ur),ve.gety(ur)),Bn,St,Ei-zt+1,Te,bt)}}zt+=ai,ai=St.dist(ni)}const Hi=(Ei-zt)/ai,vi=ni.sub(St),xn=vi.mult(Hi)._add(St);xn._add(vi._unit()._perp()._mult(_*gt));const cn=Vt+Math.atan2(ni.y-St.y,ni.x-St.x);return Bi.push(xn),{point:xn,angle:je?cn:0,path:Bi}}const Wi=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Ui(M,h){for(let _=0;_=1;Cr--)Un.push(tr.path[Cr]);for(let Cr=1;CrXi(Er,ue,mt));Un=Cr.some(Er=>Er.signedDistanceFromCamera<=0)?[]:Cr.map(Er=>Er.point)}let Rr=[];if(Un.length>0){const Cr=Un[0].clone(),Er=Un[0].clone();for(let Gr=1;Gr=xn.x&&Er.x<=cn.x&&Cr.y>=xn.y&&Er.y<=cn.y?[Un]:Er.xcn.x||Er.ycn.y?[]:i.clipLine([Un],xn.x,xn.y,cn.x,cn.y)}for(const Cr of Rr){Bn.reset(Cr,.25*vi);let Er=0;Er=Bn.length<=.5*vi?1:Math.ceil(Bn.paddedLength/Lr)+1;for(let Gr=0;Gr=this.screenRightBoundary||Fthis.screenBottomBoundary}isInsideGrid(h,_,T,F){return T>=0&&h=0&&_T.collisionGroupID===_}}return this.collisionGroups[h]}}function ct(M,h,_,T,F){const{horizontalAlign:O,verticalAlign:K}=i.getAnchorAlignment(M),oe=-(O-.5)*h,ue=-(K-.5)*_,ve=i.evaluateVariableOffset(M,T);return new i.pointGeometry(oe+ve[0]*F,ue+ve[1]*F)}function wt(M,h,_,T,F,O){const{x1:K,x2:oe,y1:ue,y2:ve,anchorPointX:Te,anchorPointY:ze}=M,je=new i.pointGeometry(h,_);return T&&je._rotate(F?O:-O),{x1:K+je.x,y1:ue+je.y,x2:oe+je.x,y2:ve+je.y,anchorPointX:Te,anchorPointY:ze}}class X{constructor(h,_,T,F,O){this.transform=h.clone(),this.terrain=_,this.collisionIndex=new Hr(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=T,this.retainedQueryData={},this.collisionGroups=new Pe(F),this.collisionCircleArrays={},this.prevPlacement=O,O&&(O.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(h,_,T,F){const O=T.getBucket(_),K=T.latestFeatureIndex;if(!O||!K||_.id!==O.layerIds[0])return;const oe=T.collisionBoxArray,ue=O.layers[0].layout,ve=Math.pow(2,this.transform.zoom-T.tileID.overscaledZ),Te=T.tileSize/i.EXTENT,ze=this.transform.calculatePosMatrix(T.tileID.toUnwrapped()),je=ue.get("text-pitch-alignment")==="map",bt=ue.get("text-rotation-alignment")==="map",mt=fr(T,1,this.transform.zoom),gt=ii(ze,je,bt,this.transform,mt);let Vt=null;if(je){const ni=hn(ze,je,bt,this.transform,mt);Vt=i.multiply([],this.transform.labelPlaneMatrix,ni)}this.retainedQueryData[O.bucketInstanceId]=new Ee(O.bucketInstanceId,K,O.sourceLayerIndex,O.index,T.tileID);const Zt={bucket:O,layout:ue,posMatrix:ze,textLabelPlaneMatrix:gt,labelToScreenMatrix:Vt,scale:ve,textPixelRatio:Te,holdingForFade:T.holdingForFade(),collisionBoxArray:oe,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(O.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(O.sourceID)};if(F)for(const ni of O.sortKeyRanges){const{sortKey:St,symbolInstanceStart:zt,symbolInstanceEnd:ai}=ni;h.push({sortKey:St,symbolInstanceStart:zt,symbolInstanceEnd:ai,parameters:Zt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:O.symbolInstances.length,parameters:Zt})}attemptAnchorPlacement(h,_,T,F,O,K,oe,ue,ve,Te,ze,je,bt,mt,gt,Vt){const Zt=[je.textOffset0,je.textOffset1],ni=ct(h,T,F,Zt,O),St=this.collisionIndex.placeCollisionBox(wt(_,ni.x,ni.y,K,oe,this.transform.angle),ze,ue,ve,Te.predicate,Vt);if((!gt||this.collisionIndex.placeCollisionBox(wt(gt,ni.x,ni.y,K,oe,this.transform.angle),ze,ue,ve,Te.predicate,Vt).box.length!==0)&&St.box.length>0){let zt;if(this.prevPlacement&&this.prevPlacement.variableOffsets[je.crossTileID]&&this.prevPlacement.placements[je.crossTileID]&&this.prevPlacement.placements[je.crossTileID].text&&(zt=this.prevPlacement.variableOffsets[je.crossTileID].anchor),je.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[je.crossTileID]={textOffset:Zt,width:T,height:F,anchor:h,textBoxScale:O,prevAnchor:zt},this.markUsedJustification(bt,h,je,mt),bt.allowVerticalPlacement&&(this.markUsedOrientation(bt,mt,je),this.placedOrientations[je.crossTileID]=mt),{shift:ni,placedGlyphBoxes:St}}}placeLayerBucketPart(h,_,T){const{bucket:F,layout:O,posMatrix:K,textLabelPlaneMatrix:oe,labelToScreenMatrix:ue,textPixelRatio:ve,holdingForFade:Te,collisionBoxArray:ze,partiallyEvaluatedTextSize:je,collisionGroup:bt}=h.parameters,mt=O.get("text-optional"),gt=O.get("icon-optional"),Vt=i.getOverlapMode(O,"text-overlap","text-allow-overlap"),Zt=Vt==="always",ni=i.getOverlapMode(O,"icon-overlap","icon-allow-overlap"),St=ni==="always",zt=O.get("text-rotation-alignment")==="map",ai=O.get("text-pitch-alignment")==="map",Ei=O.get("icon-text-fit")!=="none",Bi=O.get("symbol-z-order")==="viewport-y",Hi=Zt&&(St||!F.hasIconData()||gt),vi=St&&(Zt||!F.hasTextData()||mt);!F.collisionArrays&&ze&&F.deserializeCollisionBoxes(ze);const xn=(cn,Bn)=>{if(_[cn.crossTileID])return;if(Te)return void(this.placements[cn.crossTileID]=new Rs(!1,!1,!1));let tr=!1,ur=!1,Un=!0,Lr=null,Rr={box:null,offscreen:null},Cr={box:null,offscreen:null},Er=null,Gr=null,js=null,wa=0,ua=0,ba=0;Bn.textFeatureIndex?wa=Bn.textFeatureIndex:cn.useRuntimeCollisionCircles&&(wa=cn.featureIndex),Bn.verticalTextFeatureIndex&&(ua=Bn.verticalTextFeatureIndex);const Wa=this.retainedQueryData[F.bucketInstanceId].tileID,Wo=this.terrain?(x,a)=>this.terrain.getElevation(Wa,x,a):null;for(const x of["textBox","verticalTextBox","iconBox","verticalIconBox"]){const a=Bn[x];a&&(a.elevation=Wo?Wo(a.anchorPointX,a.anchorPointY):0)}const mo=Bn.textBox;if(mo){const x=m=>{let b=i.WritingMode.horizontal;if(F.allowVerticalPlacement&&!m&&this.prevPlacement){const S=this.prevPlacement.placedOrientations[cn.crossTileID];S&&(this.placedOrientations[cn.crossTileID]=S,b=S,this.markUsedOrientation(F,b,cn))}return b},a=(m,b)=>{if(F.allowVerticalPlacement&&cn.numVerticalGlyphVertices>0&&Bn.verticalTextBox){for(const S of F.writingModes)if(S===i.WritingMode.vertical?(Rr=b(),Cr=Rr):Rr=m(),Rr&&Rr.box&&Rr.box.length)break}else Rr=m()};if(O.get("text-variable-anchor")){let m=O.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[cn.crossTileID]){const P=this.prevPlacement.variableOffsets[cn.crossTileID];m.indexOf(P.anchor)>0&&(m=m.filter(H=>H!==P.anchor),m.unshift(P.anchor))}const b=(P,H,W)=>{const ee=P.x2-P.x1,pe=P.y2-P.y1,fe=cn.textBoxScale,Me=Ei&&ni==="never"?H:null;let Ne={box:[],offscreen:!1};const st=Vt!=="never"?2*m.length:m.length;for(let it=0;it=m.length?Vt:"never",cn,F,W,Me,Wo);if(lt&&(Ne=lt.placedGlyphBoxes,Ne&&Ne.box&&Ne.box.length)){tr=!0,Lr=lt.shift;break}}return Ne};a(()=>b(mo,Bn.iconBox,i.WritingMode.horizontal),()=>{const P=Bn.verticalTextBox;return F.allowVerticalPlacement&&!(Rr&&Rr.box&&Rr.box.length)&&cn.numVerticalGlyphVertices>0&&P?b(P,Bn.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null}}),Rr&&(tr=Rr.box,Un=Rr.offscreen);const S=x(Rr&&Rr.box);if(!tr&&this.prevPlacement){const P=this.prevPlacement.variableOffsets[cn.crossTileID];P&&(this.variableOffsets[cn.crossTileID]=P,this.markUsedJustification(F,P.anchor,cn,S))}}else{const m=(b,S)=>{const P=this.collisionIndex.placeCollisionBox(b,Vt,ve,K,bt.predicate,Wo);return P&&P.box&&P.box.length&&(this.markUsedOrientation(F,S,cn),this.placedOrientations[cn.crossTileID]=S),P};a(()=>m(mo,i.WritingMode.horizontal),()=>{const b=Bn.verticalTextBox;return F.allowVerticalPlacement&&cn.numVerticalGlyphVertices>0&&b?m(b,i.WritingMode.vertical):{box:null,offscreen:null}}),x(Rr&&Rr.box&&Rr.box.length)}}if(Er=Rr,tr=Er&&Er.box&&Er.box.length>0,Un=Er&&Er.offscreen,cn.useRuntimeCollisionCircles){const x=F.text.placedSymbolArray.get(cn.centerJustifiedTextSymbolIndex),a=i.evaluateSizeForFeature(F.textSizeData,je,x),m=O.get("text-padding");Gr=this.collisionIndex.placeCollisionCircles(Vt,x,F.lineVertexArray,F.glyphOffsetArray,a,K,oe,ue,T,ai,bt.predicate,cn.collisionCircleDiameter,m,Wo),Gr.circles.length&&Gr.collisionDetected&&!T&&i.warnOnce("Collisions detected, but collision boxes are not shown"),tr=Zt||Gr.circles.length>0&&!Gr.collisionDetected,Un=Un&&Gr.offscreen}if(Bn.iconFeatureIndex&&(ba=Bn.iconFeatureIndex),Bn.iconBox){const x=a=>{const m=Ei&&Lr?wt(a,Lr.x,Lr.y,zt,ai,this.transform.angle):a;return this.collisionIndex.placeCollisionBox(m,ni,ve,K,bt.predicate,Wo)};Cr&&Cr.box&&Cr.box.length&&Bn.verticalIconBox?(js=x(Bn.verticalIconBox),ur=js.box.length>0):(js=x(Bn.iconBox),ur=js.box.length>0),Un=Un&&js.offscreen}const Ba=mt||cn.numHorizontalGlyphVertices===0&&cn.numVerticalGlyphVertices===0,$l=gt||cn.numIconVertices===0;if(Ba||$l?$l?Ba||(ur=ur&&tr):tr=ur&&tr:ur=tr=ur&&tr,tr&&Er&&Er.box&&this.collisionIndex.insertCollisionBox(Er.box,Vt,O.get("text-ignore-placement"),F.bucketInstanceId,Cr&&Cr.box&&ua?ua:wa,bt.ID),ur&&js&&this.collisionIndex.insertCollisionBox(js.box,ni,O.get("icon-ignore-placement"),F.bucketInstanceId,ba,bt.ID),Gr&&(tr&&this.collisionIndex.insertCollisionCircles(Gr.circles,Vt,O.get("text-ignore-placement"),F.bucketInstanceId,wa,bt.ID),T)){const x=F.bucketInstanceId;let a=this.collisionCircleArrays[x];a===void 0&&(a=this.collisionCircleArrays[x]=new ot);for(let m=0;m=0;--Bn){const tr=cn[Bn];xn(F.symbolInstances.get(tr),F.collisionArrays[tr])}}else for(let cn=h.symbolInstanceStart;cn=0&&(h.text.placedSymbolArray.get(oe).crossTileID=O>=0&&oe!==O?0:T.crossTileID)}markUsedOrientation(h,_,T){const F=_===i.WritingMode.horizontal||_===i.WritingMode.horizontalOnly?_:0,O=_===i.WritingMode.vertical?_:0,K=[T.leftJustifiedTextSymbolIndex,T.centerJustifiedTextSymbolIndex,T.rightJustifiedTextSymbolIndex];for(const oe of K)h.text.placedSymbolArray.get(oe).placedOrientation=F;T.verticalPlacedTextSymbolIndex&&(h.text.placedSymbolArray.get(T.verticalPlacedTextSymbolIndex).placedOrientation=O)}commit(h){this.commitTime=h,this.zoomAtLastRecencyCheck=this.transform.zoom;const _=this.prevPlacement;let T=!1;this.prevZoomAdjustment=_?_.zoomAdjustment(this.transform.zoom):0;const F=_?_.symbolFadeChange(h):1,O=_?_.opacities:{},K=_?_.variableOffsets:{},oe=_?_.placedOrientations:{};for(const ue in this.placements){const ve=this.placements[ue],Te=O[ue];Te?(this.opacities[ue]=new Qn(Te,F,ve.text,ve.icon),T=T||ve.text!==Te.text.placed||ve.icon!==Te.icon.placed):(this.opacities[ue]=new Qn(null,F,ve.text,ve.icon,ve.skipFade),T=T||ve.text||ve.icon)}for(const ue in O){const ve=O[ue];if(!this.opacities[ue]){const Te=new Qn(ve,F,!1,!1);Te.isHidden()||(this.opacities[ue]=Te,T=T||ve.text.placed||ve.icon.placed)}}for(const ue in K)this.variableOffsets[ue]||!this.opacities[ue]||this.opacities[ue].isHidden()||(this.variableOffsets[ue]=K[ue]);for(const ue in oe)this.placedOrientations[ue]||!this.opacities[ue]||this.opacities[ue].isHidden()||(this.placedOrientations[ue]=oe[ue]);if(_&&_.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");T?this.lastPlacementChangeTime=h:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=_?_.lastPlacementChangeTime:h)}updateLayerOpacities(h,_){const T={};for(const F of _){const O=F.getBucket(h);O&&F.latestFeatureIndex&&h.id===O.layerIds[0]&&this.updateBucketOpacities(O,T,F.collisionBoxArray)}}updateBucketOpacities(h,_,T){h.hasTextData()&&h.text.opacityVertexArray.clear(),h.hasIconData()&&h.icon.opacityVertexArray.clear(),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexArray.clear(),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexArray.clear();const F=h.layers[0].layout,O=new Qn(null,0,!1,!1,!0),K=F.get("text-allow-overlap"),oe=F.get("icon-allow-overlap"),ue=F.get("text-variable-anchor"),ve=F.get("text-rotation-alignment")==="map",Te=F.get("text-pitch-alignment")==="map",ze=F.get("icon-text-fit")!=="none",je=new Qn(null,0,K&&(oe||!h.hasIconData()||F.get("icon-optional")),oe&&(K||!h.hasTextData()||F.get("text-optional")),!0);!h.collisionArrays&&T&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(T);const bt=(mt,gt,Vt)=>{for(let Zt=0;Zt0,ai=this.placedOrientations[gt.crossTileID],Ei=ai===i.WritingMode.vertical,Bi=ai===i.WritingMode.horizontal||ai===i.WritingMode.horizontalOnly;if(Vt>0||Zt>0){const Hi=pt(St.text);bt(h.text,Vt,Ei?Lt:Hi),bt(h.text,Zt,Bi?Lt:Hi);const vi=St.text.isHidden();[gt.rightJustifiedTextSymbolIndex,gt.centerJustifiedTextSymbolIndex,gt.leftJustifiedTextSymbolIndex].forEach(Bn=>{Bn>=0&&(h.text.placedSymbolArray.get(Bn).hidden=vi||Ei?1:0)}),gt.verticalPlacedTextSymbolIndex>=0&&(h.text.placedSymbolArray.get(gt.verticalPlacedTextSymbolIndex).hidden=vi||Bi?1:0);const xn=this.variableOffsets[gt.crossTileID];xn&&this.markUsedJustification(h,xn.anchor,gt,ai);const cn=this.placedOrientations[gt.crossTileID];cn&&(this.markUsedJustification(h,"left",gt,cn),this.markUsedOrientation(h,cn,gt))}if(zt){const Hi=pt(St.icon),vi=!(ze&>.verticalPlacedIconSymbolIndex&&Ei);gt.placedIconSymbolIndex>=0&&(bt(h.icon,gt.numIconVertices,vi?Hi:Lt),h.icon.placedSymbolArray.get(gt.placedIconSymbolIndex).hidden=St.icon.isHidden()),gt.verticalPlacedIconSymbolIndex>=0&&(bt(h.icon,gt.numVerticalIconVertices,vi?Lt:Hi),h.icon.placedSymbolArray.get(gt.verticalPlacedIconSymbolIndex).hidden=St.icon.isHidden())}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const Hi=h.collisionArrays[mt];if(Hi){let vi=new i.pointGeometry(0,0);if(Hi.textBox||Hi.verticalTextBox){let cn=!0;if(ue){const Bn=this.variableOffsets[ni];Bn?(vi=ct(Bn.anchor,Bn.width,Bn.height,Bn.textOffset,Bn.textBoxScale),ve&&vi._rotate(Te?this.transform.angle:-this.transform.angle)):cn=!1}Hi.textBox&&j(h.textCollisionBox.collisionVertexArray,St.text.placed,!cn||Ei,vi.x,vi.y),Hi.verticalTextBox&&j(h.textCollisionBox.collisionVertexArray,St.text.placed,!cn||Bi,vi.x,vi.y)}const xn=Boolean(!Bi&&Hi.verticalIconBox);Hi.iconBox&&j(h.iconCollisionBox.collisionVertexArray,St.icon.placed,xn,ze?vi.x:0,ze?vi.y:0),Hi.verticalIconBox&&j(h.iconCollisionBox.collisionVertexArray,St.icon.placed,!xn,ze?vi.x:0,ze?vi.y:0)}}}if(h.sortFeatures(this.transform.angle),this.retainedQueryData[h.bucketInstanceId]&&(this.retainedQueryData[h.bucketInstanceId].featureSortOrder=h.featureSortOrder),h.hasTextData()&&h.text.opacityVertexBuffer&&h.text.opacityVertexBuffer.updateData(h.text.opacityVertexArray),h.hasIconData()&&h.icon.opacityVertexBuffer&&h.icon.opacityVertexBuffer.updateData(h.icon.opacityVertexArray),h.hasIconCollisionBoxData()&&h.iconCollisionBox.collisionVertexBuffer&&h.iconCollisionBox.collisionVertexBuffer.updateData(h.iconCollisionBox.collisionVertexArray),h.hasTextCollisionBoxData()&&h.textCollisionBox.collisionVertexBuffer&&h.textCollisionBox.collisionVertexBuffer.updateData(h.textCollisionBox.collisionVertexArray),h.text.opacityVertexArray.length!==h.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${h.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${h.text.layoutVertexArray.length}) / 4`);if(h.icon.opacityVertexArray.length!==h.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${h.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${h.icon.layoutVertexArray.length}) / 4`);if(h.bucketInstanceId in this.collisionCircleArrays){const mt=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=mt.invProjMatrix,h.placementViewportMatrix=mt.viewportMatrix,h.collisionCircleArray=mt.circles,delete this.collisionCircleArrays[h.bucketInstanceId]}}symbolFadeChange(h){return this.fadeDuration===0?1:(h-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(h){return Math.max(0,(this.transform.zoom-h)/1.5)}hasTransitions(h){return this.stale||h-this.lastPlacementChangeTimeh}setStale(){this.stale=!0}}function j(M,h,_,T,F){M.emplaceBack(h?1:0,_?1:0,T||0,F||0),M.emplaceBack(h?1:0,_?1:0,T||0,F||0),M.emplaceBack(h?1:0,_?1:0,T||0,F||0),M.emplaceBack(h?1:0,_?1:0,T||0,F||0)}const ie=Math.pow(2,25),ne=Math.pow(2,24),de=Math.pow(2,17),Ue=Math.pow(2,16),tt=Math.pow(2,9),He=Math.pow(2,8),et=Math.pow(2,1);function pt(M){if(M.opacity===0&&!M.placed)return 0;if(M.opacity===1&&M.placed)return 4294967295;const h=M.placed?1:0,_=Math.floor(127*M.opacity);return _*ie+h*ne+_*de+h*Ue+_*tt+h*He+_*et+h}const Lt=0;class jt{constructor(h){this._sortAcrossTiles=h.layout.get("symbol-z-order")!=="viewport-y"&&!h.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(h,_,T,F,O){const K=this._bucketParts;for(;this._currentTileIndexoe.sortKey-ue.sortKey));this._currentPartIndex{const K=i.exported.now()-F;return!this._forceFullPlacement&&K>2};for(;this._currentPlacementIndex>=0;){const K=_[h[this._currentPlacementIndex]],oe=this.placement.collisionIndex.transform.zoom;if(K.type==="symbol"&&(!K.minzoom||K.minzoom<=oe)&&(!K.maxzoom||K.maxzoom>oe)){if(this._inProgressLayer||(this._inProgressLayer=new jt(K)),this._inProgressLayer.continuePlacement(T[K.source],this.placement,this._showCollisionBoxes,K,O))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const ki=512/i.EXTENT/2;class bi{constructor(h,_,T){this.tileID=h,this.indexedSymbolInstances={},this.bucketInstanceId=T;for(let F=0;F<_.length;F++){const O=_.get(F),K=O.key;this.indexedSymbolInstances[K]||(this.indexedSymbolInstances[K]=[]),this.indexedSymbolInstances[K].push({crossTileID:O.crossTileID,coord:this.getScaledCoordinates(O,h)})}}getScaledCoordinates(h,_){const T=ki/Math.pow(2,_.canonical.z-this.tileID.canonical.z);return{x:Math.floor((_.canonical.x*i.EXTENT+h.anchorX)*T),y:Math.floor((_.canonical.y*i.EXTENT+h.anchorY)*T)}}findMatches(h,_,T){const F=this.tileID.canonical.z<_.canonical.z?1:Math.pow(2,this.tileID.canonical.z-_.canonical.z);for(let O=0;Oh.overscaledZ)for(const oe in K){const ue=K[oe];ue.tileID.isChildOf(h)&&ue.findMatches(_.symbolInstances,h,F)}else{const oe=K[h.scaledTo(Number(O)).key];oe&&oe.findMatches(_.symbolInstances,h,F)}}for(let O=0;O<_.symbolInstances.length;O++){const K=_.symbolInstances.get(O);K.crossTileID||(K.crossTileID=T.generate(),F[K.crossTileID]=!0)}return this.indexes[h.overscaledZ]===void 0&&(this.indexes[h.overscaledZ]={}),this.indexes[h.overscaledZ][h.key]=new bi(h,_.symbolInstances,_.bucketInstanceId),!0}removeBucketCrossTileIDs(h,_){for(const T in _.indexedSymbolInstances)for(const F of _.indexedSymbolInstances[T])delete this.usedCrossTileIDs[h][F.crossTileID]}removeStaleBuckets(h){let _=!1;for(const T in this.indexes){const F=this.indexes[T];for(const O in F)h[F[O].bucketInstanceId]||(this.removeBucketCrossTileIDs(T,F[O]),delete F[O],_=!0)}return _}}class tn{constructor(){this.layerIndexes={},this.crossTileIDs=new Oi,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(h,_,T){let F=this.layerIndexes[h.id];F===void 0&&(F=this.layerIndexes[h.id]=new Yi);let O=!1;const K={};F.handleWrapJump(T);for(const oe of _){const ue=oe.getBucket(h);ue&&h.id===ue.layerIds[0]&&(ue.bucketInstanceId||(ue.bucketInstanceId=++this.maxBucketInstanceId),F.addBucket(oe.tileID,ue,this.crossTileIDs)&&(O=!0),K[ue.bucketInstanceId]=!0)}return F.removeStaleBuckets(K)&&(O=!0),O}pruneUnusedLayers(h){const _={};h.forEach(T=>{_[T]=!0});for(const T in this.layerIndexes)_[T]||delete this.layerIndexes[T]}}var rr=i.createLayout([{name:"a_pos",type:"Int16",components:2}]);class yn extends i.Evented{constructor(h){super(),this.sourceCache=h,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.renderHistory=[],this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,this.renderHistorySize=h._cache.max,h.usedForTerrain=!0,h.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;for(const h in this._tiles){const _=this._tiles[h];_.textures.forEach(T=>T.destroy()),_.textures=[]}}update(h,_){this.sourceCache.update(h,_),this._renderableTilesKeys=[];for(const T of h.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:_}))this._renderableTilesKeys.push(T.key),this._tiles[T.key]||(T.posMatrix=new Float64Array(16),i.ortho(T.posMatrix,0,i.EXTENT,0,i.EXTENT,0,1),this._tiles[T.key]=new be(T,this.tileSize))}removeOutdated(h){const _={};this.renderHistory=this.renderHistory.filter((T,F)=>this.renderHistory.indexOf(T)===F).slice(0,this.renderHistorySize);for(const T of this._renderableTilesKeys)_[T]=!0;for(const T of this.renderHistory)_[T]=!0;for(const T in this._tiles)_[T]||(this._tiles[T].clearTextures(h),delete this._tiles[T])}getRenderableTiles(){return this._renderableTilesKeys.map(h=>this.getTileByID(h))}getTileByID(h){return this._tiles[h]}getTerrainCoords(h){const _={};for(const T of this._renderableTilesKeys){const F=this._tiles[T].tileID;if(F.canonical.equals(h.canonical)){const O=h.clone();O.posMatrix=new Float64Array(16),i.ortho(O.posMatrix,0,i.EXTENT,0,i.EXTENT,0,1),_[T]=O}else if(F.canonical.isChildOf(h.canonical)){const O=h.clone();O.posMatrix=new Float64Array(16);const K=F.canonical.z-h.canonical.z,oe=F.canonical.x-(F.canonical.x>>K<>K<>K;i.ortho(O.posMatrix,0,ve,0,ve,0,1),i.translate(O.posMatrix,O.posMatrix,[-oe*ve,-ue*ve,0]),_[T]=O}else if(h.canonical.isChildOf(F.canonical)){const O=h.clone();O.posMatrix=new Float64Array(16);const K=h.canonical.z-F.canonical.z,oe=h.canonical.x-(h.canonical.x>>K<>K<>K;i.ortho(O.posMatrix,0,i.EXTENT,0,i.EXTENT,0,1),i.translate(O.posMatrix,O.posMatrix,[oe*ve,ue*ve,0]),i.scale(O.posMatrix,O.posMatrix,[1/2**K,1/2**K,0]),_[T]=O}}return _}getSourceTile(h,_){const T=this.sourceCache._source;let F=h.overscaledZ-this.deltaZoom;if(F>T.maxzoom&&(F=T.maxzoom),F=T.minzoom&&(!O||!O.dem);)O=this.sourceCache.getTileByID(h.scaledTo(F--).key);return O}tilesAfterTime(h=Date.now()){return Object.values(this._tiles).filter(_=>_.timeLoaded>=h)}}class Yt{constructor(h,_,T){this.style=h,this.sourceCache=new yn(_),this.options=T,this.exaggeration=typeof T.exaggeration=="number"?T.exaggeration:1,this.elevationOffset=typeof T.elevationOffset=="number"?T.elevationOffset:450,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024,this.clearRerenderCache()}getDEMElevation(h,_,T,F=i.EXTENT){if(!(_>=0&&_=0&&Th.canonical.z&&(h.canonical.z>=F?O=h.canonical.z-F:i.warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const K=h.canonical.x-(h.canonical.x>>O<>O<>8<<4|O>>8,_[K+3]=0;const T=new i.RGBAImage({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(_.buffer)),F=new Y(h,T,h.gl.RGBA,{premultiply:!1});return F.bind(h.gl.NEAREST,h.gl.CLAMP_TO_EDGE),this._coordsTexture=F,F}pointCoordinate(h){const _=new Uint8Array(4),T=this.style.map.painter,F=T.context,O=F.gl;F.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),O.readPixels(h.x,T.height/devicePixelRatio-h.y-1,1,1,O.RGBA,O.UNSIGNED_BYTE,_),F.bindFramebuffer.set(null);const K=_[0]+(_[2]>>4<<8),oe=_[1]+((15&_[2])<<8),ue=this.coordsIndex[255-_[3]],ve=ue&&this.sourceCache.getTileByID(ue);if(!ve)return null;const Te=this._coordsTextureSize,ze=(1<i.emitValidationErrors(M,h&&h.filter(_=>_.identifier!=="source.canvas")),Yn=i.pick(zi,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData"]),Wr=i.pick(zi,["setCenter","setZoom","setBearing","setPitch"]),mr=function(){const M={},h=i.spec.$version;for(const _ in i.spec.$root){const T=i.spec.$root[_];if(T.required){let F=null;F=_==="version"?h:T.type==="array"?[]:{},F!=null&&(M[_]=F)}}return M}();class Mr extends i.Evented{constructor(h,_={}){super(),this.map=h,this.dispatcher=new Et(fi(),this),this.imageManager=new ae,this.imageManager.setEventedParent(this),this.glyphManager=new me(h._requestManager,_.localIdeographFontFamily),this.lineAtlas=new Ge(256,512),this.crossTileSymbolIndex=new tn,this._layers={},this._serializedLayers={},this._order=[],this.sourceCaches={},this.zoomHistory=new i.ZoomHistory,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const T=this;this._rtlTextPluginCallback=Mr.registerForPluginStateChange(F=>{T.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:F.pluginStatus,pluginURL:F.pluginURL},(O,K)=>{if(i.triggerPluginCompletionEvent(O),K&&K.every(oe=>oe))for(const oe in T.sourceCaches)T.sourceCaches[oe].reload()})}),this.on("data",F=>{if(F.dataType!=="source"||F.sourceDataType!=="metadata")return;const O=this.sourceCaches[F.sourceId];if(!O)return;const K=O.getSource();if(K&&K.vectorLayerIds)for(const oe in this._layers){const ue=this._layers[oe];ue.source===K.id&&this._validateLayer(ue)}})}loadURL(h,_={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const T=typeof _.validate!="boolean"||_.validate,F=this.map._requestManager.transformRequest(h,i.ResourceType.Style);this._request=i.getJSON(F,(O,K)=>{this._request=null,O?this.fire(new i.ErrorEvent(O)):K&&this._load(K,T)})}loadJSON(h,_={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(h,_.validate!==!1)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(mr,!1)}_load(h,_){if(_&&sr(this,i.validateStyle(h)))return;this._loaded=!0,this.stylesheet=h;for(const F in h.sources)this.addSource(F,h.sources[F],{validate:!1});h.sprite?this._loadSprite(h.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(h.glyphs);const T=wn(this.stylesheet.layers);this._order=T.map(F=>F.id),this._layers={},this._serializedLayers={};for(let F of T)F=i.createStyleLayer(F),F.setEventedParent(this,{layer:{id:F.id}}),this._layers[F.id]=F,this._serializedLayers[F.id]=F.serialize();this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new Fe(this.stylesheet.light),this.setTerrain(this.stylesheet.terrain),this.fire(new i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}_loadSprite(h){this._spriteRequest=function(_,T,F,O){let K,oe,ue;const ve=F>1?"@2x":"";let Te=i.getJSON(T.transformRequest(T.normalizeSpriteURL(_,ve,".json"),i.ResourceType.SpriteJSON),(bt,mt)=>{Te=null,ue||(ue=bt,K=mt,je())}),ze=i.getImage(T.transformRequest(T.normalizeSpriteURL(_,ve,".png"),i.ResourceType.SpriteImage),(bt,mt)=>{ze=null,ue||(ue=bt,oe=mt,je())});function je(){if(ue)O(ue);else if(K&&oe){const bt=i.exported.getImageData(oe),mt={};for(const gt in K){const{width:Vt,height:Zt,x:ni,y:St,sdf:zt,pixelRatio:ai,stretchX:Ei,stretchY:Bi,content:Hi}=K[gt],vi=new i.RGBAImage({width:Vt,height:Zt});i.RGBAImage.copy(bt,vi,{x:ni,y:St},{x:0,y:0},{width:Vt,height:Zt}),mt[gt]={data:vi,pixelRatio:ai,sdf:zt,stretchX:Ei,stretchY:Bi,content:Hi}}O(null,mt)}}return{cancel(){Te&&(Te.cancel(),Te=null),ze&&(ze.cancel(),ze=null)}}}(h,this.map._requestManager,this.map.getPixelRatio(),(_,T)=>{if(this._spriteRequest=null,_)this.fire(new i.ErrorEvent(_));else if(T)for(const F in T)this.imageManager.addImage(F,T[F]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(h){const _=this.sourceCaches[h.source];if(!_)return;const T=h.sourceLayer;if(!T)return;const F=_.getSource();(F.type==="geojson"||F.vectorLayerIds&&F.vectorLayerIds.indexOf(T)===-1)&&this.fire(new i.ErrorEvent(new Error(`Source layer "${T}" does not exist on source "${F.id}" as specified by style layer "${h.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const h in this.sourceCaches)if(!this.sourceCaches[h].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(h){const _=[];for(const T of h){const F=this._layers[T];F.type!=="custom"&&_.push(F.serialize())}return _}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const h in this.sourceCaches)if(this.sourceCaches[h].hasTransition())return!0;for(const h in this._layers)if(this._layers[h].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(h){if(!this._loaded)return;const _=this._changed;if(this._changed){const F=Object.keys(this._updatedLayers),O=Object.keys(this._removedLayers);(F.length||O.length)&&this._updateWorkerLayers(F,O);for(const K in this._updatedSources){const oe=this._updatedSources[K];if(oe==="reload")this._reloadSource(K);else{if(oe!=="clear")throw new Error(`Invalid action ${oe}`);this._clearSource(K)}}this._updateTilesForChangedImages();for(const K in this._updatedPaintProps)this._layers[K].updateTransitions(h);this.light.updateTransitions(h),this._resetUpdates()}const T={};for(const F in this.sourceCaches){const O=this.sourceCaches[F];T[F]=O.used,O.used=!1}for(const F of this._order){const O=this._layers[F];O.recalculate(h,this._availableImages),!O.isHidden(h.zoom)&&O.source&&(this.sourceCaches[O.source].used=!0)}for(const F in T){const O=this.sourceCaches[F];T[F]!==O.used&&O.fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:F}))}this.light.recalculate(h),this.z=h.zoom,_&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const h=Object.keys(this._changedImages);if(h.length){for(const _ in this.sourceCaches)this.sourceCaches[_].reloadTilesForDependencies(["icons","patterns"],h);this._changedImages={}}}_updateWorkerLayers(h,_){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(h),removedIds:_})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setTerrain(h){if(this._checkLoaded(),this._terrainDataCallback&&this.off("data",this._terrainDataCallback),this._terrainfreezeElevationCallback&&this.map.off("freezeElevation",this._terrainfreezeElevationCallback),h){const _=this.sourceCaches[h.source];if(!_)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain=new Yt(this,_,h),this.map.transform.updateElevation(this.terrain),this._terrainfreezeElevationCallback=T=>{T.freeze?this.map.transform.freezeElevation=!0:(this.map.transform.freezeElevation=!1,this.map.transform.recalculateZoom(this.terrain))},this._terrainDataCallback=T=>{T.tile&&(T.sourceId===h.source?(this.map.transform.updateElevation(this.terrain),this.terrain.rememberForRerender(T.sourceId,T.tile.tileID)):T.source.type==="geojson"&&this.terrain.rememberForRerender(T.sourceId,T.tile.tileID))},this.on("data",this._terrainDataCallback),this.map.on("freezeElevation",this._terrainfreezeElevationCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.map.transform.updateElevation(this.terrain);this.map.fire(new i.Event("terrain",{terrain:h}))}setState(h){if(this._checkLoaded(),sr(this,i.validateStyle(h)))return!1;(h=i.clone$1(h)).layers=wn(h.layers);const _=function(F,O){if(!F)return[{command:zi.setStyle,args:[O]}];let K=[];try{if(!Q(F.version,O.version))return[{command:zi.setStyle,args:[O]}];Q(F.center,O.center)||K.push({command:zi.setCenter,args:[O.center]}),Q(F.zoom,O.zoom)||K.push({command:zi.setZoom,args:[O.zoom]}),Q(F.bearing,O.bearing)||K.push({command:zi.setBearing,args:[O.bearing]}),Q(F.pitch,O.pitch)||K.push({command:zi.setPitch,args:[O.pitch]}),Q(F.sprite,O.sprite)||K.push({command:zi.setSprite,args:[O.sprite]}),Q(F.glyphs,O.glyphs)||K.push({command:zi.setGlyphs,args:[O.glyphs]}),Q(F.transition,O.transition)||K.push({command:zi.setTransition,args:[O.transition]}),Q(F.light,O.light)||K.push({command:zi.setLight,args:[O.light]});const oe={},ue=[];(function(Te,ze,je,bt){let mt;for(mt in ze=ze||{},Te=Te||{})Object.prototype.hasOwnProperty.call(Te,mt)&&(Object.prototype.hasOwnProperty.call(ze,mt)||kn(mt,je,bt));for(mt in ze)Object.prototype.hasOwnProperty.call(ze,mt)&&(Object.prototype.hasOwnProperty.call(Te,mt)?Q(Te[mt],ze[mt])||(Te[mt].type==="geojson"&&ze[mt].type==="geojson"&&rt(Te,ze,mt)?je.push({command:zi.setGeoJSONSourceData,args:[mt,ze[mt].data]}):yt(mt,ze,je,bt)):Gn(mt,ze,je))})(F.sources,O.sources,ue,oe);const ve=[];F.layers&&F.layers.forEach(Te=>{oe[Te.source]?K.push({command:zi.removeLayer,args:[Te.id]}):ve.push(Te)}),K=K.concat(ue),function(Te,ze,je){ze=ze||[];const bt=(Te=Te||[]).map(Ni),mt=ze.map(Ni),gt=Te.reduce(qi,{}),Vt=ze.reduce(qi,{}),Zt=bt.slice(),ni=Object.create(null);let St,zt,ai,Ei,Bi,Hi,vi;for(St=0,zt=0;St!(F.command in Wr));if(_.length===0)return!1;const T=_.filter(F=>!(F.command in Yn));if(T.length>0)throw new Error(`Unimplemented: ${T.map(F=>F.command).join(", ")}.`);return _.forEach(F=>{F.command!=="setTransition"&&this[F.command].apply(this,F.args)}),this.stylesheet=h,!0}addImage(h,_){if(this.getImage(h))return this.fire(new i.ErrorEvent(new Error(`An image named "${h}" already exists.`)));this.imageManager.addImage(h,_),this._afterImageUpdated(h)}updateImage(h,_){this.imageManager.updateImage(h,_)}getImage(h){return this.imageManager.getImage(h)}removeImage(h){if(!this.getImage(h))return this.fire(new i.ErrorEvent(new Error(`An image named "${h}" does not exist.`)));this.imageManager.removeImage(h),this._afterImageUpdated(h)}_afterImageUpdated(h){this._availableImages=this.imageManager.listImages(),this._changedImages[h]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(h,_,T={}){if(this._checkLoaded(),this.sourceCaches[h]!==void 0)throw new Error(`Source "${h}" already exists.`);if(!_.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(_).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(_.type)>=0&&this._validate(i.validateStyle.source,`sources.${h}`,_,null,T))return;this.map&&this.map._collectResourceTiming&&(_.collectResourceTiming=!0);const F=this.sourceCaches[h]=new Nt(h,_,this.dispatcher);F.style=this,F.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:F.serialize(),sourceId:h})),F.onAdd(this.map),this._changed=!0}removeSource(h){if(this._checkLoaded(),this.sourceCaches[h]===void 0)throw new Error("There is no source with this ID");for(const T in this._layers)if(this._layers[T].source===h)return this.fire(new i.ErrorEvent(new Error(`Source "${h}" cannot be removed while layer "${T}" is using it.`)));const _=this.sourceCaches[h];delete this.sourceCaches[h],delete this._updatedSources[h],_.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:h})),_.setEventedParent(null),_.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(h,_){if(this._checkLoaded(),this.sourceCaches[h]===void 0)throw new Error(`There is no source with this ID=${h}`);const T=this.sourceCaches[h].getSource();if(T.type!=="geojson")throw new Error(`geojsonSource.type is ${T.type}, which is !== 'geojson`);T.setData(_),this._changed=!0}getSource(h){return this.sourceCaches[h]&&this.sourceCaches[h].getSource()}addLayer(h,_,T={}){this._checkLoaded();const F=h.id;if(this.getLayer(F))return void this.fire(new i.ErrorEvent(new Error(`Layer "${F}" already exists on this map.`)));let O;if(h.type==="custom"){if(sr(this,i.validateCustomStyleLayer(h)))return;O=i.createStyleLayer(h)}else{if(typeof h.source=="object"&&(this.addSource(F,h.source),h=i.clone$1(h),h=i.extend(h,{source:F})),this._validate(i.validateStyle.layer,`layers.${F}`,h,{arrayIndex:-1},T))return;O=i.createStyleLayer(h),this._validateLayer(O),O.setEventedParent(this,{layer:{id:F}}),this._serializedLayers[O.id]=O.serialize()}const K=_?this._order.indexOf(_):this._order.length;if(_&&K===-1)this.fire(new i.ErrorEvent(new Error(`Cannot add layer "${F}" before non-existing layer "${_}".`)));else{if(this._order.splice(K,0,F),this._layerOrderChanged=!0,this._layers[F]=O,this._removedLayers[F]&&O.source&&O.type!=="custom"){const oe=this._removedLayers[F];delete this._removedLayers[F],oe.type!==O.type?this._updatedSources[O.source]="clear":(this._updatedSources[O.source]="reload",this.sourceCaches[O.source].pause())}this._updateLayer(O),O.onAdd&&O.onAdd(this.map)}}moveLayer(h,_){if(this._checkLoaded(),this._changed=!0,!this._layers[h])return void this.fire(new i.ErrorEvent(new Error(`The layer '${h}' does not exist in the map's style and cannot be moved.`)));if(h===_)return;const T=this._order.indexOf(h);this._order.splice(T,1);const F=_?this._order.indexOf(_):this._order.length;_&&F===-1?this.fire(new i.ErrorEvent(new Error(`Cannot move layer "${h}" before non-existing layer "${_}".`))):(this._order.splice(F,0,h),this._layerOrderChanged=!0)}removeLayer(h){this._checkLoaded();const _=this._layers[h];if(!_)return void this.fire(new i.ErrorEvent(new Error(`Cannot remove non-existing layer "${h}".`)));_.setEventedParent(null);const T=this._order.indexOf(h);this._order.splice(T,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[h]=_,delete this._layers[h],delete this._serializedLayers[h],delete this._updatedLayers[h],delete this._updatedPaintProps[h],_.onRemove&&_.onRemove(this.map)}getLayer(h){return this._layers[h]}hasLayer(h){return h in this._layers}setLayerZoomRange(h,_,T){this._checkLoaded();const F=this.getLayer(h);F?F.minzoom===_&&F.maxzoom===T||(_!=null&&(F.minzoom=_),T!=null&&(F.maxzoom=T),this._updateLayer(F)):this.fire(new i.ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer "${h}".`)))}setFilter(h,_,T={}){this._checkLoaded();const F=this.getLayer(h);if(F){if(!Q(F.filter,_))return _==null?(F.filter=void 0,void this._updateLayer(F)):void(this._validate(i.validateStyle.filter,`layers.${F.id}.filter`,_,null,T)||(F.filter=i.clone$1(_),this._updateLayer(F)))}else this.fire(new i.ErrorEvent(new Error(`Cannot filter non-existing layer "${h}".`)))}getFilter(h){return i.clone$1(this.getLayer(h).filter)}setLayoutProperty(h,_,T,F={}){this._checkLoaded();const O=this.getLayer(h);O?Q(O.getLayoutProperty(_),T)||(O.setLayoutProperty(_,T,F),this._updateLayer(O)):this.fire(new i.ErrorEvent(new Error(`Cannot style non-existing layer "${h}".`)))}getLayoutProperty(h,_){const T=this.getLayer(h);if(T)return T.getLayoutProperty(_);this.fire(new i.ErrorEvent(new Error(`Cannot get style of non-existing layer "${h}".`)))}setPaintProperty(h,_,T,F={}){this._checkLoaded();const O=this.getLayer(h);O?Q(O.getPaintProperty(_),T)||(O.setPaintProperty(_,T,F)&&this._updateLayer(O),this._changed=!0,this._updatedPaintProps[h]=!0):this.fire(new i.ErrorEvent(new Error(`Cannot style non-existing layer "${h}".`)))}getPaintProperty(h,_){return this.getLayer(h).getPaintProperty(_)}setFeatureState(h,_){this._checkLoaded();const T=h.source,F=h.sourceLayer,O=this.sourceCaches[T];if(O===void 0)return void this.fire(new i.ErrorEvent(new Error(`The source '${T}' does not exist in the map's style.`)));const K=O.getSource().type;K==="geojson"&&F?this.fire(new i.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):K!=="vector"||F?(h.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided."))),O.setFeatureState(F,h.id,_)):this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(h,_){this._checkLoaded();const T=h.source,F=this.sourceCaches[T];if(F===void 0)return void this.fire(new i.ErrorEvent(new Error(`The source '${T}' does not exist in the map's style.`)));const O=F.getSource().type,K=O==="vector"?h.sourceLayer:void 0;O!=="vector"||K?_&&typeof h.id!="string"&&typeof h.id!="number"?this.fire(new i.ErrorEvent(new Error("A feature id is required to remove its specific state property."))):F.removeFeatureState(K,h.id,_):this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(h){this._checkLoaded();const _=h.source,T=h.sourceLayer,F=this.sourceCaches[_];if(F!==void 0)return F.getSource().type!=="vector"||T?(h.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided."))),F.getFeatureState(T,h.id)):void this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new i.ErrorEvent(new Error(`The source '${_}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){return i.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:i.mapObject(this.sourceCaches,h=>h.serialize()),layers:this._serializeLayers(this._order)},h=>h!==void 0)}_updateLayer(h){this._updatedLayers[h.id]=!0,h.source&&!this._updatedSources[h.source]&&this.sourceCaches[h.source].getSource().type!=="raster"&&(this._updatedSources[h.source]="reload",this.sourceCaches[h.source].pause()),this._changed=!0}_flattenAndSortRenderedFeatures(h){const _=K=>this._layers[K].type==="fill-extrusion",T={},F=[];for(let K=this._order.length-1;K>=0;K--){const oe=this._order[K];if(_(oe)){T[oe]=K;for(const ue of h){const ve=ue[oe];if(ve)for(const Te of ve)F.push(Te)}}}F.sort((K,oe)=>oe.intersectionZ-K.intersectionZ);const O=[];for(let K=this._order.length-1;K>=0;K--){const oe=this._order[K];if(_(oe))for(let ue=F.length-1;ue>=0;ue--){const ve=F[ue].feature;if(T[ve.layer.id]{const Bi=Vt.featureSortOrder;if(Bi){const Hi=Bi.indexOf(ai.featureIndex);return Bi.indexOf(Ei.featureIndex)-Hi}return Ei.featureIndex-ai.featureIndex});for(const ai of zt)St.push(ai)}}for(const Vt in bt)bt[Vt].forEach(Zt=>{const ni=Zt.feature,St=ue[K[Vt].source].getFeatureState(ni.layer["source-layer"],ni.id);ni.source=ni.layer.source,ni.layer["source-layer"]&&(ni.sourceLayer=ni.layer["source-layer"]),ni.state=St});return bt}(this._layers,this._serializedLayers,this.sourceCaches,h,_,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(O)}querySourceFeatures(h,_){_&&_.filter&&this._validate(i.validateStyle.filter,"querySourceFeatures.filter",_.filter,null,_);const T=this.sourceCaches[h];return T?function(F,O){const K=F.getRenderableIds().map(ve=>F.getTileByID(ve)),oe=[],ue={};for(let ve=0;veje.getTileByID(bt)).sort((bt,mt)=>mt.tileID.overscaledZ-bt.tileID.overscaledZ||(bt.tileID.isLessThan(mt.tileID)?-1:1))}const ze=this.crossTileSymbolIndex.addLayer(Te,ue[Te.source],h.center.lng);K=K||ze}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((O=O||this._layerOrderChanged||T===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),h.zoom))&&(this.pauseablePlacement=new Wt(h,this.terrain,this._order,O,_,T,F,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,ue),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),oe=!0),K&&this.pauseablePlacement.placement.setStale()),oe||K)for(const ve of this._order){const Te=this._layers[ve];Te.type==="symbol"&&this.placement.updateLayerOpacities(Te,ue[Te.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const h in this.sourceCaches)this.sourceCaches[h].releaseSymbolFadeTiles()}getImages(h,_,T){this.imageManager.getImages(_.icons,T),this._updateTilesForChangedImages();const F=this.sourceCaches[_.source];F&&F.setDependencies(_.tileID.key,_.type,_.icons)}getGlyphs(h,_,T){this.glyphManager.getGlyphs(_.stacks,T)}getResource(h,_,T){return i.makeRequest(_,T)}}Mr.getSourceType=function(M){return Se[M]},Mr.setSourceType=function(M,h){Se[M]=h},Mr.registerForPluginStateChange=i.registerForPluginStateChange;var Oo="attribute vec2 a_pos;uniform mat4 u_matrix;varying vec2 v_texture_pos;varying float v_depth;void main() {v_texture_pos=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);v_depth=gl_Position.z/gl_Position.w;}";const zs={prelude:or(`#ifdef GL_ES precision mediump float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif`,`#ifdef GL_ES precision highp float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;} #ifdef TERRAIN3D uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_offset;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth; #endif const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) { #ifdef TERRAIN3D highp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0)); #else return 1.0; #endif }float calculate_visibility(vec4 pos) { #ifdef TERRAIN3D vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0; #else return 1.0; #endif }float ele(vec2 pos) { #ifdef TERRAIN3D vec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a; #else return 0.0; #endif }float get_elevation(vec2 pos) { #ifdef TERRAIN3D vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return (elevation+u_terrain_offset)*u_terrain_exaggeration; #else return 0.0; #endif }`),background:or(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:or(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:or(`varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main(void) { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:or("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:or(`uniform highp float u_intensity;varying vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}`),heatmapTexture:or(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(0.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:or("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:or("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:or("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:or(`#pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_FragColor=color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);}`),fillOutline:or(`varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillOutlinePattern:or(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillPattern:or(`#ifdef GL_ES precision highp float; #endif uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:or(`varying vec4 v_color;void main() {gl_FragColor=v_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec4 v_color; #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color vec3 normal=a_normal_ed.xyz; #ifdef TERRAIN3D float baseDelta=10.0;float ele=get_elevation(a_centroid); #else float baseDelta=0.0;float ele=0.0; #endif base=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:or(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to; #ifdef TERRAIN3D float baseDelta=10.0;float ele=get_elevation(a_centroid); #else float baseDelta=0.0;float ele=0.0; #endif base=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0 ? a_pos : vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:or(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:or(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent; #define PI 3.141592653589793 void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:or(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),lineGradient:or(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),linePattern:or(`#ifdef GL_ES precision highp float; #endif uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:or(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:or(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:or(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity 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);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;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=u_is_text ? size/24.0 : size;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*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:or(`#define SDF_PX 8.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #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);vec2 a_pxoffset=a_pixeloffset.xy;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=u_is_text ? size/24.0 : size;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+a_pxoffset),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=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:or(`#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #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:or("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",Oo),terrainDepth:or("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);}",Oo),terrainCoords:or("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);}",Oo)};function or(M,h){const _=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,T=h.match(/attribute ([\w]+) ([\w]+)/g),F=M.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),O=h.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),K=O?O.concat(F):F,oe={};return{fragmentSource:M=M.replace(_,(ue,ve,Te,ze,je)=>(oe[je]=!0,ve==="define"?` #ifndef HAS_UNIFORM_u_${je} varying ${Te} ${ze} ${je}; #else uniform ${Te} ${ze} u_${je}; #endif `:` #ifdef HAS_UNIFORM_u_${je} ${Te} ${ze} ${je} = u_${je}; #endif `)),vertexSource:h=h.replace(_,(ue,ve,Te,ze,je)=>{const bt=ze==="float"?"vec2":"vec4",mt=je.match(/color/)?"color":bt;return oe[je]?ve==="define"?` #ifndef HAS_UNIFORM_u_${je} uniform lowp float u_${je}_t; attribute ${Te} ${bt} a_${je}; varying ${Te} ${ze} ${je}; #else uniform ${Te} ${ze} u_${je}; #endif `:mt==="vec4"?` #ifndef HAS_UNIFORM_u_${je} ${je} = a_${je}; #else ${Te} ${ze} ${je} = u_${je}; #endif `:` #ifndef HAS_UNIFORM_u_${je} ${je} = unpack_mix_${mt}(a_${je}, u_${je}_t); #else ${Te} ${ze} ${je} = u_${je}; #endif `:ve==="define"?` #ifndef HAS_UNIFORM_u_${je} uniform lowp float u_${je}_t; attribute ${Te} ${bt} a_${je}; #else uniform ${Te} ${ze} u_${je}; #endif `:mt==="vec4"?` #ifndef HAS_UNIFORM_u_${je} ${Te} ${ze} ${je} = a_${je}; #else ${Te} ${ze} ${je} = u_${je}; #endif `:` #ifndef HAS_UNIFORM_u_${je} ${Te} ${ze} ${je} = unpack_mix_${mt}(a_${je}, u_${je}_t); #else ${Te} ${ze} ${je} = u_${je}; #endif `}),staticAttributes:T,staticUniforms:K}}class rn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(h,_,T,F,O,K,oe,ue,ve){this.context=h;let Te=this.boundPaintVertexBuffers.length!==F.length;for(let ze=0;!Te&&ze({u_depth:new i.Uniform1i(Bi,Hi.u_depth),u_terrain:new i.Uniform1i(Bi,Hi.u_terrain),u_terrain_dim:new i.Uniform1f(Bi,Hi.u_terrain_dim),u_terrain_matrix:new i.UniformMatrix4f(Bi,Hi.u_terrain_matrix),u_terrain_unpack:new i.Uniform4f(Bi,Hi.u_terrain_unpack),u_terrain_offset:new i.Uniform1f(Bi,Hi.u_terrain_offset),u_terrain_exaggeration:new i.Uniform1f(Bi,Hi.u_terrain_exaggeration)}))(h,Ei),this.binderUniforms=F?F.getUniforms(h,Ei):[]}draw(h,_,T,F,O,K,oe,ue,ve,Te,ze,je,bt,mt,gt,Vt,Zt,ni){const St=h.gl;if(this.failedToCreate)return;if(h.program.set(this.program),h.setDepthMode(T),h.setStencilMode(F),h.setColorMode(O),h.setCullFace(K),ue){h.activeTexture.set(St.TEXTURE2),St.bindTexture(St.TEXTURE_2D,ue.depthTexture),h.activeTexture.set(St.TEXTURE3),St.bindTexture(St.TEXTURE_2D,ue.texture);for(const ai in this.terrainUniforms)this.terrainUniforms[ai].set(ue[ai])}for(const ai in this.fixedUniforms)this.fixedUniforms[ai].set(oe[ai]);gt&>.setUniforms(h,this.binderUniforms,bt,{zoom:mt});let zt=0;switch(_){case St.LINES:zt=2;break;case St.TRIANGLES:zt=3;break;case St.LINE_STRIP:zt=1}for(const ai of je.get()){const Ei=ai.vaos||(ai.vaos={});(Ei[ve]||(Ei[ve]=new rn)).bind(h,this,Te,gt?gt.getPaintVertexBuffers():[],ze,ai.vertexOffset,Vt,Zt,ni),St.drawElements(_,ai.primitiveLength*zt,St.UNSIGNED_SHORT,ai.primitiveOffset*zt*2)}}}function aa(M,h,_){const T=1/fr(_,1,h.transform.tileZoom),F=Math.pow(2,_.tileID.overscaledZ),O=_.tileSize*Math.pow(2,h.transform.tileZoom)/F,K=O*(_.tileID.canonical.x+_.tileID.wrap*F),oe=O*_.tileID.canonical.y;return{u_image:0,u_texsize:_.imageAtlasTexture.size,u_scale:[T,M.fromScale,M.toScale],u_fade:M.t,u_pixel_coord_upper:[K>>16,oe>>16],u_pixel_coord_lower:[65535&K,65535&oe]}}const al=(M,h,_,T)=>{const F=h.style.light,O=F.properties.get("position"),K=[O.x,O.y,O.z],oe=i.create$1();F.properties.get("anchor")==="viewport"&&i.fromRotation(oe,-h.transform.angle),i.transformMat3(K,K,oe);const ue=F.properties.get("color");return{u_matrix:M,u_lightpos:K,u_lightintensity:F.properties.get("intensity"),u_lightcolor:[ue.r,ue.g,ue.b],u_vertical_gradient:+_,u_opacity:T}},dr=(M,h,_,T,F,O,K)=>i.extend(al(M,h,_,T),aa(O,h,K),{u_height_factor:-Math.pow(2,F.overscaledZ)/K.tileSize/8}),Ul=M=>({u_matrix:M}),Rl=(M,h,_,T)=>i.extend(Ul(M),aa(_,h,T)),ll=(M,h)=>({u_matrix:M,u_world:h}),qs=(M,h,_,T,F)=>i.extend(Rl(M,h,_,T),{u_world:F}),cs=(M,h,_,T)=>{const F=M.transform;let O,K;if(T.paint.get("circle-pitch-alignment")==="map"){const oe=fr(_,1,F.zoom);O=!0,K=[oe,oe]}else O=!1,K=F.pixelsToGLUnits;return{u_camera_to_center_distance:F.cameraToCenterDistance,u_scale_with_map:+(T.paint.get("circle-pitch-scale")==="map"),u_matrix:M.translatePosMatrix(h.posMatrix,_,T.paint.get("circle-translate"),T.paint.get("circle-translate-anchor")),u_pitch_with_map:+O,u_device_pixel_ratio:M.pixelRatio,u_extrude_scale:K}},ho=(M,h,_)=>{const T=fr(_,1,h.zoom),F=Math.pow(2,h.zoom-_.tileID.overscaledZ),O=_.tileID.overscaleFactor();return{u_matrix:M,u_camera_to_center_distance:h.cameraToCenterDistance,u_pixels_to_tile_units:T,u_extrude_scale:[h.pixelsToGLUnits[0]/(T*F),h.pixelsToGLUnits[1]/(T*F)],u_overscale_factor:O}},cl=(M,h,_=1)=>({u_matrix:M,u_color:h,u_overlay:0,u_overlay_scale:_}),Oa=M=>({u_matrix:M}),zl=(M,h,_,T)=>({u_matrix:M,u_extrude_scale:fr(h,1,_),u_intensity:T});function kl(M,h){const _=Math.pow(2,h.canonical.z),T=h.canonical.y;return[new i.MercatorCoordinate(0,T/_).toLngLat().lat,new i.MercatorCoordinate(0,(T+1)/_).toLngLat().lat]}const Ol=(M,h,_,T)=>{const F=M.transform;return{u_matrix:Ys(M,h,_,T),u_ratio:1/fr(h,1,F.zoom),u_device_pixel_ratio:M.pixelRatio,u_units_to_pixels:[1/F.pixelsToGLUnits[0],1/F.pixelsToGLUnits[1]]}},Na=(M,h,_,T,F)=>i.extend(Ol(M,h,_,F),{u_image:0,u_image_height:T}),Nl=(M,h,_,T,F)=>{const O=M.transform,K=is(h,O);return{u_matrix:Ys(M,h,_,F),u_texsize:h.imageAtlasTexture.size,u_ratio:1/fr(h,1,O.zoom),u_device_pixel_ratio:M.pixelRatio,u_image:0,u_scale:[K,T.fromScale,T.toScale],u_fade:T.t,u_units_to_pixels:[1/O.pixelsToGLUnits[0],1/O.pixelsToGLUnits[1]]}},Ql=(M,h,_,T,F,O)=>{const K=M.lineAtlas,oe=is(h,M.transform),ue=_.layout.get("line-cap")==="round",ve=K.getDash(T.from,ue),Te=K.getDash(T.to,ue),ze=ve.width*F.fromScale,je=Te.width*F.toScale;return i.extend(Ol(M,h,_,O),{u_patternscale_a:[oe/ze,-ve.height/2],u_patternscale_b:[oe/je,-Te.height/2],u_sdfgamma:K.width/(256*Math.min(ze,je)*M.pixelRatio)/2,u_image:0,u_tex_y_a:ve.y,u_tex_y_b:Te.y,u_mix:F.t})};function is(M,h){return 1/fr(M,1,h.tileZoom)}function Ys(M,h,_,T){return M.translatePosMatrix(T?T.posMatrix:h.tileID.posMatrix,h,_.paint.get("line-translate"),_.paint.get("line-translate-anchor"))}const ps=(M,h,_,T,F)=>{return{u_matrix:M,u_tl_parent:h,u_scale_parent:_,u_buffer_scale:1,u_fade_t:T.mix,u_opacity:T.opacity*F.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:F.paint.get("raster-brightness-min"),u_brightness_high:F.paint.get("raster-brightness-max"),u_saturation_factor:(K=F.paint.get("raster-saturation"),K>0?1-1/(1.001-K):-K),u_contrast_factor:(O=F.paint.get("raster-contrast"),O>0?1/(1-O):1+O),u_spin_weights:Rc(F.paint.get("raster-hue-rotate"))};var O,K};function Rc(M){M*=Math.PI/180;const h=Math.sin(M),_=Math.cos(M);return[(2*_+1)/3,(-Math.sqrt(3)*h-_+1)/3,(Math.sqrt(3)*h-_+1)/3]}const Eh=(M,h,_,T,F,O,K,oe,ue,ve)=>{const Te=F.transform;return{u_is_size_zoom_constant:+(M==="constant"||M==="source"),u_is_size_feature_constant:+(M==="constant"||M==="camera"),u_size_t:h?h.uSizeT:0,u_size:h?h.uSize:0,u_camera_to_center_distance:Te.cameraToCenterDistance,u_pitch:Te.pitch/360*2*Math.PI,u_rotate_symbol:+_,u_aspect_ratio:Te.width/Te.height,u_fade_change:F.options.fadeDuration?F.symbolFadeChange:1,u_matrix:O,u_label_plane_matrix:K,u_coord_matrix:oe,u_is_text:+ue,u_pitch_with_map:+T,u_texsize:ve,u_texture:0}},ks=(M,h,_,T,F,O,K,oe,ue,ve,Te)=>{const ze=F.transform;return i.extend(Eh(M,h,_,T,F,O,K,oe,ue,ve),{u_gamma_scale:T?Math.cos(ze._pitch)*ze.cameraToCenterDistance:1,u_device_pixel_ratio:F.pixelRatio,u_is_halo:+Te})},No=(M,h,_,T,F,O,K,oe,ue,ve)=>i.extend(ks(M,h,_,T,F,O,K,oe,!0,ue,!0),{u_texsize_icon:ve,u_texture_icon:1}),JA=(M,h,_)=>({u_matrix:M,u_opacity:h,u_color:_}),fu=(M,h,_,T,F,O)=>i.extend(function(K,oe,ue,ve){const Te=ue.imageManager.getPattern(K.from.toString()),ze=ue.imageManager.getPattern(K.to.toString()),{width:je,height:bt}=ue.imageManager.getPixelSize(),mt=Math.pow(2,ve.tileID.overscaledZ),gt=ve.tileSize*Math.pow(2,ue.transform.tileZoom)/mt,Vt=gt*(ve.tileID.canonical.x+ve.tileID.wrap*mt),Zt=gt*ve.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:Te.tl,u_pattern_br_a:Te.br,u_pattern_tl_b:ze.tl,u_pattern_br_b:ze.br,u_texsize:[je,bt],u_mix:oe.t,u_pattern_size_a:Te.displaySize,u_pattern_size_b:ze.displaySize,u_scale_a:oe.fromScale,u_scale_b:oe.toScale,u_tile_units_to_pixels:1/fr(ve,1,ue.transform.tileZoom),u_pixel_coord_upper:[Vt>>16,Zt>>16],u_pixel_coord_lower:[65535&Vt,65535&Zt]}}(T,O,_,F),{u_matrix:M,u_opacity:h}),Bs={fillExtrusion:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_lightpos:new i.Uniform3f(M,h.u_lightpos),u_lightintensity:new i.Uniform1f(M,h.u_lightintensity),u_lightcolor:new i.Uniform3f(M,h.u_lightcolor),u_vertical_gradient:new i.Uniform1f(M,h.u_vertical_gradient),u_opacity:new i.Uniform1f(M,h.u_opacity)}),fillExtrusionPattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_lightpos:new i.Uniform3f(M,h.u_lightpos),u_lightintensity:new i.Uniform1f(M,h.u_lightintensity),u_lightcolor:new i.Uniform3f(M,h.u_lightcolor),u_vertical_gradient:new i.Uniform1f(M,h.u_vertical_gradient),u_height_factor:new i.Uniform1f(M,h.u_height_factor),u_image:new i.Uniform1i(M,h.u_image),u_texsize:new i.Uniform2f(M,h.u_texsize),u_pixel_coord_upper:new i.Uniform2f(M,h.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(M,h.u_pixel_coord_lower),u_scale:new i.Uniform3f(M,h.u_scale),u_fade:new i.Uniform1f(M,h.u_fade),u_opacity:new i.Uniform1f(M,h.u_opacity)}),fill:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),fillPattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_image:new i.Uniform1i(M,h.u_image),u_texsize:new i.Uniform2f(M,h.u_texsize),u_pixel_coord_upper:new i.Uniform2f(M,h.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(M,h.u_pixel_coord_lower),u_scale:new i.Uniform3f(M,h.u_scale),u_fade:new i.Uniform1f(M,h.u_fade)}),fillOutline:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_world:new i.Uniform2f(M,h.u_world)}),fillOutlinePattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_world:new i.Uniform2f(M,h.u_world),u_image:new i.Uniform1i(M,h.u_image),u_texsize:new i.Uniform2f(M,h.u_texsize),u_pixel_coord_upper:new i.Uniform2f(M,h.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(M,h.u_pixel_coord_lower),u_scale:new i.Uniform3f(M,h.u_scale),u_fade:new i.Uniform1f(M,h.u_fade)}),circle:(M,h)=>({u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_scale_with_map:new i.Uniform1i(M,h.u_scale_with_map),u_pitch_with_map:new i.Uniform1i(M,h.u_pitch_with_map),u_extrude_scale:new i.Uniform2f(M,h.u_extrude_scale),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),collisionBox:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_pixels_to_tile_units:new i.Uniform1f(M,h.u_pixels_to_tile_units),u_extrude_scale:new i.Uniform2f(M,h.u_extrude_scale),u_overscale_factor:new i.Uniform1f(M,h.u_overscale_factor)}),collisionCircle:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_inv_matrix:new i.UniformMatrix4f(M,h.u_inv_matrix),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_viewport_size:new i.Uniform2f(M,h.u_viewport_size)}),debug:(M,h)=>({u_color:new i.UniformColor(M,h.u_color),u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_overlay:new i.Uniform1i(M,h.u_overlay),u_overlay_scale:new i.Uniform1f(M,h.u_overlay_scale)}),clippingMask:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),heatmap:(M,h)=>({u_extrude_scale:new i.Uniform1f(M,h.u_extrude_scale),u_intensity:new i.Uniform1f(M,h.u_intensity),u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),heatmapTexture:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_world:new i.Uniform2f(M,h.u_world),u_image:new i.Uniform1i(M,h.u_image),u_color_ramp:new i.Uniform1i(M,h.u_color_ramp),u_opacity:new i.Uniform1f(M,h.u_opacity)}),hillshade:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_image:new i.Uniform1i(M,h.u_image),u_latrange:new i.Uniform2f(M,h.u_latrange),u_light:new i.Uniform2f(M,h.u_light),u_shadow:new i.UniformColor(M,h.u_shadow),u_highlight:new i.UniformColor(M,h.u_highlight),u_accent:new i.UniformColor(M,h.u_accent)}),hillshadePrepare:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_image:new i.Uniform1i(M,h.u_image),u_dimension:new i.Uniform2f(M,h.u_dimension),u_zoom:new i.Uniform1f(M,h.u_zoom),u_unpack:new i.Uniform4f(M,h.u_unpack)}),line:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_ratio:new i.Uniform1f(M,h.u_ratio),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_units_to_pixels:new i.Uniform2f(M,h.u_units_to_pixels)}),lineGradient:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_ratio:new i.Uniform1f(M,h.u_ratio),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_units_to_pixels:new i.Uniform2f(M,h.u_units_to_pixels),u_image:new i.Uniform1i(M,h.u_image),u_image_height:new i.Uniform1f(M,h.u_image_height)}),linePattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_texsize:new i.Uniform2f(M,h.u_texsize),u_ratio:new i.Uniform1f(M,h.u_ratio),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_image:new i.Uniform1i(M,h.u_image),u_units_to_pixels:new i.Uniform2f(M,h.u_units_to_pixels),u_scale:new i.Uniform3f(M,h.u_scale),u_fade:new i.Uniform1f(M,h.u_fade)}),lineSDF:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_ratio:new i.Uniform1f(M,h.u_ratio),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_units_to_pixels:new i.Uniform2f(M,h.u_units_to_pixels),u_patternscale_a:new i.Uniform2f(M,h.u_patternscale_a),u_patternscale_b:new i.Uniform2f(M,h.u_patternscale_b),u_sdfgamma:new i.Uniform1f(M,h.u_sdfgamma),u_image:new i.Uniform1i(M,h.u_image),u_tex_y_a:new i.Uniform1f(M,h.u_tex_y_a),u_tex_y_b:new i.Uniform1f(M,h.u_tex_y_b),u_mix:new i.Uniform1f(M,h.u_mix)}),raster:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_tl_parent:new i.Uniform2f(M,h.u_tl_parent),u_scale_parent:new i.Uniform1f(M,h.u_scale_parent),u_buffer_scale:new i.Uniform1f(M,h.u_buffer_scale),u_fade_t:new i.Uniform1f(M,h.u_fade_t),u_opacity:new i.Uniform1f(M,h.u_opacity),u_image0:new i.Uniform1i(M,h.u_image0),u_image1:new i.Uniform1i(M,h.u_image1),u_brightness_low:new i.Uniform1f(M,h.u_brightness_low),u_brightness_high:new i.Uniform1f(M,h.u_brightness_high),u_saturation_factor:new i.Uniform1f(M,h.u_saturation_factor),u_contrast_factor:new i.Uniform1f(M,h.u_contrast_factor),u_spin_weights:new i.Uniform3f(M,h.u_spin_weights)}),symbolIcon:(M,h)=>({u_is_size_zoom_constant:new i.Uniform1i(M,h.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(M,h.u_is_size_feature_constant),u_size_t:new i.Uniform1f(M,h.u_size_t),u_size:new i.Uniform1f(M,h.u_size),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_pitch:new i.Uniform1f(M,h.u_pitch),u_rotate_symbol:new i.Uniform1i(M,h.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(M,h.u_aspect_ratio),u_fade_change:new i.Uniform1f(M,h.u_fade_change),u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(M,h.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(M,h.u_coord_matrix),u_is_text:new i.Uniform1i(M,h.u_is_text),u_pitch_with_map:new i.Uniform1i(M,h.u_pitch_with_map),u_texsize:new i.Uniform2f(M,h.u_texsize),u_texture:new i.Uniform1i(M,h.u_texture)}),symbolSDF:(M,h)=>({u_is_size_zoom_constant:new i.Uniform1i(M,h.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(M,h.u_is_size_feature_constant),u_size_t:new i.Uniform1f(M,h.u_size_t),u_size:new i.Uniform1f(M,h.u_size),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_pitch:new i.Uniform1f(M,h.u_pitch),u_rotate_symbol:new i.Uniform1i(M,h.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(M,h.u_aspect_ratio),u_fade_change:new i.Uniform1f(M,h.u_fade_change),u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(M,h.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(M,h.u_coord_matrix),u_is_text:new i.Uniform1i(M,h.u_is_text),u_pitch_with_map:new i.Uniform1i(M,h.u_pitch_with_map),u_texsize:new i.Uniform2f(M,h.u_texsize),u_texture:new i.Uniform1i(M,h.u_texture),u_gamma_scale:new i.Uniform1f(M,h.u_gamma_scale),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_is_halo:new i.Uniform1i(M,h.u_is_halo)}),symbolTextAndIcon:(M,h)=>({u_is_size_zoom_constant:new i.Uniform1i(M,h.u_is_size_zoom_constant),u_is_size_feature_constant:new i.Uniform1i(M,h.u_is_size_feature_constant),u_size_t:new i.Uniform1f(M,h.u_size_t),u_size:new i.Uniform1f(M,h.u_size),u_camera_to_center_distance:new i.Uniform1f(M,h.u_camera_to_center_distance),u_pitch:new i.Uniform1f(M,h.u_pitch),u_rotate_symbol:new i.Uniform1i(M,h.u_rotate_symbol),u_aspect_ratio:new i.Uniform1f(M,h.u_aspect_ratio),u_fade_change:new i.Uniform1f(M,h.u_fade_change),u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_label_plane_matrix:new i.UniformMatrix4f(M,h.u_label_plane_matrix),u_coord_matrix:new i.UniformMatrix4f(M,h.u_coord_matrix),u_is_text:new i.Uniform1i(M,h.u_is_text),u_pitch_with_map:new i.Uniform1i(M,h.u_pitch_with_map),u_texsize:new i.Uniform2f(M,h.u_texsize),u_texsize_icon:new i.Uniform2f(M,h.u_texsize_icon),u_texture:new i.Uniform1i(M,h.u_texture),u_texture_icon:new i.Uniform1i(M,h.u_texture_icon),u_gamma_scale:new i.Uniform1f(M,h.u_gamma_scale),u_device_pixel_ratio:new i.Uniform1f(M,h.u_device_pixel_ratio),u_is_halo:new i.Uniform1i(M,h.u_is_halo)}),background:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_opacity:new i.Uniform1f(M,h.u_opacity),u_color:new i.UniformColor(M,h.u_color)}),backgroundPattern:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_opacity:new i.Uniform1f(M,h.u_opacity),u_image:new i.Uniform1i(M,h.u_image),u_pattern_tl_a:new i.Uniform2f(M,h.u_pattern_tl_a),u_pattern_br_a:new i.Uniform2f(M,h.u_pattern_br_a),u_pattern_tl_b:new i.Uniform2f(M,h.u_pattern_tl_b),u_pattern_br_b:new i.Uniform2f(M,h.u_pattern_br_b),u_texsize:new i.Uniform2f(M,h.u_texsize),u_mix:new i.Uniform1f(M,h.u_mix),u_pattern_size_a:new i.Uniform2f(M,h.u_pattern_size_a),u_pattern_size_b:new i.Uniform2f(M,h.u_pattern_size_b),u_scale_a:new i.Uniform1f(M,h.u_scale_a),u_scale_b:new i.Uniform1f(M,h.u_scale_b),u_pixel_coord_upper:new i.Uniform2f(M,h.u_pixel_coord_upper),u_pixel_coord_lower:new i.Uniform2f(M,h.u_pixel_coord_lower),u_tile_units_to_pixels:new i.Uniform1f(M,h.u_tile_units_to_pixels)}),terrain:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_texture:new i.Uniform1i(M,h.u_texture)}),terrainDepth:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix)}),terrainCoords:(M,h)=>({u_matrix:new i.UniformMatrix4f(M,h.u_matrix),u_texture:new i.Uniform1i(M,h.u_texture),u_terrain_coords_id:new i.Uniform1f(M,h.u_terrain_coords_id)})};class sc{constructor(h,_,T){this.context=h;const F=h.gl;this.buffer=F.createBuffer(),this.dynamicDraw=Boolean(T),this.context.unbindVAO(),h.bindElementBuffer.set(this.buffer),F.bufferData(F.ELEMENT_ARRAY_BUFFER,_.arrayBuffer,this.dynamicDraw?F.DYNAMIC_DRAW:F.STATIC_DRAW),this.dynamicDraw||delete _.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(h){const _=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),_.bufferSubData(_.ELEMENT_ARRAY_BUFFER,0,h.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Th={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class oc{constructor(h,_,T,F){this.length=_.length,this.attributes=T,this.itemSize=_.bytesPerElement,this.dynamicDraw=F,this.context=h;const O=h.gl;this.buffer=O.createBuffer(),h.bindVertexBuffer.set(this.buffer),O.bufferData(O.ARRAY_BUFFER,_.arrayBuffer,this.dynamicDraw?O.DYNAMIC_DRAW:O.STATIC_DRAW),this.dynamicDraw||delete _.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(h){if(h.length!==this.length)throw new Error(`Length of new data is ${h.length}, which doesn't match current length of ${this.length}`);const _=this.context.gl;this.bind(),_.bufferSubData(_.ARRAY_BUFFER,0,h.arrayBuffer)}enableAttributes(h,_){for(let T=0;T0){const xn=i.create(),cn=Bi;i.mul(xn,Ei.placementInvProjMatrix,M.transform.glCoordMatrix),i.mul(xn,xn,Ei.placementViewportMatrix),Te.push({circleArray:vi,circleOffset:je,transform:cn,invTransform:xn,coord:zt}),ze+=vi.length/4,je=ze}Hi&&ve.draw(oe,ue.LINES,hr.disabled,jr.disabled,M.colorModeForRenderPass(),$r.disabled,ho(Bi,M.transform,ai),M.style.terrain&&M.style.terrain.getTerrainData(zt),_.id,Hi.layoutVertexBuffer,Hi.indexBuffer,Hi.segments,null,M.transform.zoom,null,null,Hi.collisionVertexBuffer)}if(!K||!Te.length)return;const bt=M.useProgram("collisionCircle"),mt=new i.CollisionCircleLayoutArray;mt.resize(4*ze),mt._trim();let gt=0;for(const St of Te)for(let zt=0;zt=0&&(mt[Vt.associatedIconIndex]={shiftedAnchor:tr,angle:ur})}else Ui(Vt.numGlyphs,je)}if(ve){bt.clear();const gt=M.icon.placedSymbolArray;for(let Vt=0;VtM.style.terrain.getElevation(Hi,ee,pe):null,W=_.layout.get("text-rotation-alignment")==="map";Tn(xn,Hi.posMatrix,M,F,Wo,mo,Vt,ve,W,H)}const x=M.translatePosMatrix(Hi.posMatrix,vi,O,K),a=Zt||F&&Ei||$l?xu:Wo,m=M.translatePosMatrix(mo,vi,O,K,!0),b=tr&&_.paint.get(F?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let S;S=tr?xn.iconsInText?No(ur.kind,Rr,ni,Vt,M,x,a,m,Er,ua):ks(ur.kind,Rr,ni,Vt,M,x,a,m,F,Er,!0):Eh(ur.kind,Rr,ni,Vt,M,x,a,m,F,Er);const P={program:Lr,buffers:cn,uniformValues:S,atlasTexture:Gr,atlasTextureIcon:ba,atlasInterpolation:js,atlasInterpolationIcon:wa,isSDF:tr,hasHalo:b};if(St&&xn.canOverlap){zt=!0;const H=cn.segments.get();for(const W of H)Bi.push({segments:new i.SegmentVector([W]),sortKey:W.sortKey,state:P,terrainData:Cr})}else Bi.push({segments:cn.segments,sortKey:0,state:P,terrainData:Cr})}zt&&Bi.sort((Hi,vi)=>Hi.sortKey-vi.sortKey);for(const Hi of Bi){const vi=Hi.state;if(je.activeTexture.set(bt.TEXTURE0),vi.atlasTexture.bind(vi.atlasInterpolation,bt.CLAMP_TO_EDGE),vi.atlasTextureIcon&&(je.activeTexture.set(bt.TEXTURE1),vi.atlasTextureIcon&&vi.atlasTextureIcon.bind(vi.atlasInterpolationIcon,bt.CLAMP_TO_EDGE)),vi.isSDF){const xn=vi.uniformValues;vi.hasHalo&&(xn.u_is_halo=1,Vc(vi.buffers,Hi.segments,_,M,vi.program,ai,Te,ze,xn,Hi.terrainData)),xn.u_is_halo=0}Vc(vi.buffers,Hi.segments,_,M,vi.program,ai,Te,ze,vi.uniformValues,Hi.terrainData)}}function Vc(M,h,_,T,F,O,K,oe,ue,ve){const Te=T.context;F.draw(Te,Te.gl.TRIANGLES,O,K,oe,$r.disabled,ue,ve,_.id,M.layoutVertexBuffer,M.indexBuffer,h,_.paint,T.transform.zoom,M.programConfigurations.get(_.id),M.dynamicLayoutVertexBuffer,M.opacityVertexBuffer)}function Hc(M,h,_,T,F,O,K){const oe=M.context.gl,ue=_.paint.get("fill-pattern"),ve=ue&&ue.constantOr(1),Te=_.getCrossfadeParameters();let ze,je,bt,mt,gt;K?(je=ve&&!_.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ze=oe.LINES):(je=ve?"fillPattern":"fill",ze=oe.TRIANGLES);for(const Vt of T){const Zt=h.getTile(Vt);if(ve&&!Zt.patternsLoaded())continue;const ni=Zt.getBucket(_);if(!ni)continue;const St=ni.programConfigurations.get(_.id),zt=M.useProgram(je,St),ai=M.style.terrain&&M.style.terrain.getTerrainData(Vt);ve&&(M.context.activeTexture.set(oe.TEXTURE0),Zt.imageAtlasTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),St.updatePaintBuffers(Te));const Ei=ue.constantOr(null);if(Ei&&Zt.imageAtlas){const vi=Zt.imageAtlas,xn=vi.patternPositions[Ei.to.toString()],cn=vi.patternPositions[Ei.from.toString()];xn&&cn&&St.setConstantPatternPositions(xn,cn)}const Bi=ai?Vt:null,Hi=M.translatePosMatrix(Bi?Bi.posMatrix:Vt.posMatrix,Zt,_.paint.get("fill-translate"),_.paint.get("fill-translate-anchor"));if(K){mt=ni.indexBuffer2,gt=ni.segments2;const vi=[oe.drawingBufferWidth,oe.drawingBufferHeight];bt=je==="fillOutlinePattern"&&ve?qs(Hi,M,Te,Zt,vi):ll(Hi,vi)}else mt=ni.indexBuffer,gt=ni.segments,bt=ve?Rl(Hi,M,Te,Zt):Ul(Hi);zt.draw(M.context,ze,F,M.stencilModeForClipping(Vt),O,$r.disabled,bt,ai,_.id,ni.layoutVertexBuffer,mt,gt,_.paint,M.transform.zoom,St)}}function Lh(M,h,_,T,F,O,K){const oe=M.context,ue=oe.gl,ve=_.paint.get("fill-extrusion-pattern"),Te=ve.constantOr(1),ze=_.getCrossfadeParameters(),je=_.paint.get("fill-extrusion-opacity");for(const bt of T){const mt=h.getTile(bt),gt=mt.getBucket(_);if(!gt)continue;const Vt=M.style.terrain&&M.style.terrain.getTerrainData(bt),Zt=gt.programConfigurations.get(_.id),ni=M.useProgram(Te?"fillExtrusionPattern":"fillExtrusion",Zt);Te&&(M.context.activeTexture.set(ue.TEXTURE0),mt.imageAtlasTexture.bind(ue.LINEAR,ue.CLAMP_TO_EDGE),Zt.updatePaintBuffers(ze));const St=ve.constantOr(null);if(St&&mt.imageAtlas){const Bi=mt.imageAtlas,Hi=Bi.patternPositions[St.to.toString()],vi=Bi.patternPositions[St.from.toString()];Hi&&vi&&Zt.setConstantPatternPositions(Hi,vi)}const zt=M.translatePosMatrix(bt.posMatrix,mt,_.paint.get("fill-extrusion-translate"),_.paint.get("fill-extrusion-translate-anchor")),ai=_.paint.get("fill-extrusion-vertical-gradient"),Ei=Te?dr(zt,M,ai,je,bt,ze,mt):al(zt,M,ai,je);ni.draw(oe,oe.gl.TRIANGLES,F,O,K,$r.backCCW,Ei,Vt,_.id,gt.layoutVertexBuffer,gt.indexBuffer,gt.segments,_.paint,M.transform.zoom,Zt,M.style.terrain&>.centroidVertexBuffer)}}function Gc(M,h,_,T,F,O,K){const oe=M.context,ue=oe.gl,ve=_.fbo;if(!ve)return;const Te=M.useProgram("hillshade"),ze=M.style.terrain&&M.style.terrain.getTerrainData(h);oe.activeTexture.set(ue.TEXTURE0),ue.bindTexture(ue.TEXTURE_2D,ve.colorAttachment.get()),Te.draw(oe,ue.TRIANGLES,F,O,K,$r.disabled,((je,bt,mt,gt)=>{const Vt=mt.paint.get("hillshade-shadow-color"),Zt=mt.paint.get("hillshade-highlight-color"),ni=mt.paint.get("hillshade-accent-color");let St=mt.paint.get("hillshade-illumination-direction")*(Math.PI/180);mt.paint.get("hillshade-illumination-anchor")==="viewport"&&(St-=je.transform.angle);const zt=!je.options.moving;return{u_matrix:gt?gt.posMatrix:je.transform.calculatePosMatrix(bt.tileID.toUnwrapped(),zt),u_image:0,u_latrange:kl(0,bt.tileID),u_light:[mt.paint.get("hillshade-exaggeration"),St],u_shadow:Vt,u_highlight:Zt,u_accent:ni}})(M,_,T,ze?h:null),ze,T.id,M.rasterBoundsBuffer,M.quadTriangleIndexBuffer,M.rasterBoundsSegments)}function Dh(M,h,_,T,F,O){const K=M.context,oe=K.gl,ue=h.dem;if(ue&&ue.data){const ve=ue.dim,Te=ue.stride,ze=ue.getPixels();if(K.activeTexture.set(oe.TEXTURE1),K.pixelStoreUnpackPremultiplyAlpha.set(!1),h.demTexture=h.demTexture||M.getTileTexture(Te),h.demTexture){const bt=h.demTexture;bt.update(ze,{premultiply:!1}),bt.bind(oe.NEAREST,oe.CLAMP_TO_EDGE)}else h.demTexture=new Y(K,ze,oe.RGBA,{premultiply:!1}),h.demTexture.bind(oe.NEAREST,oe.CLAMP_TO_EDGE);K.activeTexture.set(oe.TEXTURE0);let je=h.fbo;if(!je){const bt=new Y(K,{width:ve,height:ve,data:null},oe.RGBA);bt.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),je=h.fbo=K.createFramebuffer(ve,ve,!0),je.colorAttachment.set(bt.texture)}K.bindFramebuffer.set(je.framebuffer),K.viewport.set([0,0,ve,ve]),M.useProgram("hillshadePrepare").draw(K,oe.TRIANGLES,T,F,O,$r.disabled,((bt,mt)=>{const gt=mt.stride,Vt=i.create();return i.ortho(Vt,0,i.EXTENT,-i.EXTENT,0,0,1),i.translate(Vt,Vt,[0,-i.EXTENT,0]),{u_matrix:Vt,u_image:1,u_dimension:[gt,gt],u_zoom:bt.overscaledZ,u_unpack:mt.getUnpackVector()}})(h.tileID,ue),null,_.id,M.rasterBoundsBuffer,M.quadTriangleIndexBuffer,M.rasterBoundsSegments),h.needsHillshadePrepare=!1}}function Wc(M,h,_,T,F,O){const K=T.paint.get("raster-fade-duration");if(!O&&K>0){const oe=i.exported.now(),ue=(oe-M.timeAdded)/K,ve=h?(oe-h.timeAdded)/K:-1,Te=_.getSource(),ze=F.coveringZoomLevel({tileSize:Te.tileSize,roundZoom:Te.roundZoom}),je=!h||Math.abs(h.tileID.overscaledZ-ze)>Math.abs(M.tileID.overscaledZ-ze),bt=je&&M.refreshedUponExpiration?1:i.clamp(je?ue:1-ve,0,1);return M.refreshedUponExpiration&&ue>=1&&(M.refreshedUponExpiration=!1),h?{opacity:1,mix:1-bt}:{opacity:bt,mix:0}}return{opacity:1,mix:0}}const jc=new i.Color(1,0,0,1),la=new i.Color(0,1,0,1),sA=new i.Color(0,0,1,1),oA=new i.Color(1,0,1,1),Kc=new i.Color(0,1,1,1);function ca(M,h,_,T){pl(M,0,h+_/2,M.transform.width,_,T)}function $c(M,h,_,T){pl(M,h-_/2,0,_,M.transform.height,T)}function pl(M,h,_,T,F,O){const K=M.context,oe=K.gl;oe.enable(oe.SCISSOR_TEST),oe.scissor(h*M.pixelRatio,_*M.pixelRatio,T*M.pixelRatio,F*M.pixelRatio),K.clear({color:O}),oe.disable(oe.SCISSOR_TEST)}function aA(M,h,_){const T=M.context,F=T.gl,O=_.posMatrix,K=M.useProgram("debug"),oe=hr.disabled,ue=jr.disabled,ve=M.colorModeForRenderPass(),Te="$debug",ze=M.style.terrain&&M.style.terrain.getTerrainData(_);T.activeTexture.set(F.TEXTURE0),M.emptyTexture.bind(F.LINEAR,F.CLAMP_TO_EDGE);const je=h.getTileByID(_.key).latestRawTileData,bt=Math.floor((je&&je.byteLength||0)/1024),mt=h.getTile(_).tileSize,gt=512/Math.min(mt,512)*(_.overscaledZ/M.transform.zoom)*.5;let Vt=_.canonical.toString();_.overscaledZ!==_.canonical.z&&(Vt+=` => ${_.overscaledZ}`),function(Zt,ni){Zt.initDebugOverlayCanvas();const St=Zt.debugOverlayCanvas,zt=Zt.context.gl,ai=Zt.debugOverlayCanvas.getContext("2d");ai.clearRect(0,0,St.width,St.height),ai.shadowColor="white",ai.shadowBlur=2,ai.lineWidth=1.5,ai.strokeStyle="white",ai.textBaseline="top",ai.font="bold 36px Open Sans, sans-serif",ai.fillText(ni,5,5),ai.strokeText(ni,5,5),Zt.debugOverlayTexture.update(St),Zt.debugOverlayTexture.bind(zt.LINEAR,zt.CLAMP_TO_EDGE)}(M,`${Vt} ${bt}kB`),K.draw(T,F.TRIANGLES,oe,ue,qr.alphaBlended,$r.disabled,cl(O,i.Color.transparent,gt),null,Te,M.debugBuffer,M.quadTriangleIndexBuffer,M.debugSegments),K.draw(T,F.LINE_STRIP,oe,ue,ve,$r.disabled,cl(O,i.Color.red),ze,Te,M.debugBuffer,M.tileBorderIndexBuffer,M.debugSegments)}function Ho(M,h,_){const T=M.context,F=T.gl,O=M.colorModeForRenderPass(),K=new hr(F.LEQUAL,hr.ReadWrite,M.depthRangeFor3D),oe=M.useProgram("terrain"),ue=h.getTerrainMesh(),ve=h.getTerrainData(_.tileID);T.bindFramebuffer.set(null),T.viewport.set([0,0,M.width,M.height]),T.activeTexture.set(F.TEXTURE0),F.bindTexture(F.TEXTURE_2D,h.getRTTFramebuffer().colorAttachment.get());const Te=M.transform.calculatePosMatrix(_.tileID.toUnwrapped());oe.draw(T,F.TRIANGLES,K,jr.disabled,O,$r.backCCW,{u_matrix:Te,u_texture:0},ve,"terrain",ue.vertexBuffer,ue.indexBuffer,ue.segments)}function Ph(M,h,_,T){const F=M.context,O=_.tileSize*h.qualityFactor;_.textures[T]||(_.textures[T]=M.getTileTexture(O)||new Y(F,{width:O,height:O,data:null},F.gl.RGBA),_.textures[T].bind(F.gl.LINEAR,F.gl.CLAMP_TO_EDGE),T===0&&h.sourceCache.renderHistory.unshift(_.tileID.key));const K=h.getRTTFramebuffer();K.colorAttachment.set(_.textures[T].texture),F.bindFramebuffer.set(K.framebuffer),F.viewport.set([0,0,O,O])}class vu{constructor(h){this._coordsDescendingInv={},this._coordsDescendingInvStr={},this.painter=h,this._renderToTexture={background:!0,fill:!0,line:!0,raster:!0},this._coordsDescendingInv={},this._coordsDescendingInvStr={},this._stacks=[],this._prevType=null,this._rerender={},this._renderableTiles=h.style.terrain.sourceCache.getRenderableTiles(),this._init()}_init(){const h=this.painter.style,_=h.terrain;for(const T in h.sourceCaches){this._coordsDescendingInv[T]={};const F=h.sourceCaches[T].getVisibleCoordinates();for(const O of F){const K=_.sourceCache.getTerrainCoords(O);for(const oe in K)this._coordsDescendingInv[T][oe]||(this._coordsDescendingInv[T][oe]=[]),this._coordsDescendingInv[T][oe].push(K[oe])}}for(const T of h._order){const F=h._layers[T],O=F.source;if(this._renderToTexture[F.type]&&!this._coordsDescendingInvStr[O]){this._coordsDescendingInvStr[O]={};for(const K in this._coordsDescendingInv[O])this._coordsDescendingInvStr[O][K]=this._coordsDescendingInv[O][K].map(oe=>oe.key).sort().join()}}return this._renderableTiles.forEach(T=>{for(const F in this._coordsDescendingInvStr){const O=this._coordsDescendingInvStr[F][T.tileID.key];O&&O!==T.textureCoords[F]&&T.clearTextures(this.painter),_.needsRerender(F,T.tileID)&&T.clearTextures(this.painter)}this._rerender[T.tileID.key]=!T.textures.length}),_.clearRerenderCache(),_.sourceCache.removeOutdated(this.painter),this}renderLayer(h){const _=h.type,T=this.painter,F=T.style._order,O=T.currentLayer,K=O+1===F.length;if(this._renderToTexture[_]&&(this._prevType&&this._renderToTexture[this._prevType]||this._stacks.push([]),this._prevType=_,this._stacks[this._stacks.length-1].push(F[O]),!K))return!0;if(this._renderToTexture[this._prevType]||_==="hillshade"||this._renderToTexture[_]&&K){this._prevType=_;const oe=this._stacks.length-1,ue=this._stacks[oe]||[];for(const ve of this._renderableTiles){if(Ph(T,T.style.terrain,ve,oe),this._rerender[ve.tileID.key]){T.context.clear({color:i.Color.transparent});for(let Te=0;Teue.style.terrain.getElevation(Zt,vi,xn):null)}}}(T,M,_,h,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),F),_.paint.get("icon-opacity").constantOr(1)!==0&&dc(M,h,_,T,!1,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),_.layout.get("icon-rotation-alignment"),_.layout.get("icon-pitch-alignment"),_.layout.get("icon-keep-upright"),O,K),_.paint.get("text-opacity").constantOr(1)!==0&&dc(M,h,_,T,!0,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.layout.get("text-keep-upright"),O,K),h.map.showCollisionBoxes&&(gr(M,h,_,T,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),!0),gr(M,h,_,T,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),!1))},circle:function(M,h,_,T){if(M.renderPass!=="translucent")return;const F=_.paint.get("circle-opacity"),O=_.paint.get("circle-stroke-width"),K=_.paint.get("circle-stroke-opacity"),oe=!_.layout.get("circle-sort-key").isConstant();if(F.constantOr(1)===0&&(O.constantOr(1)===0||K.constantOr(1)===0))return;const ue=M.context,ve=ue.gl,Te=M.depthModeForSublayer(0,hr.ReadOnly),ze=jr.disabled,je=M.colorModeForRenderPass(),bt=[];for(let mt=0;mtmt.sortKey-gt.sortKey);for(const mt of bt){const{programConfiguration:gt,program:Vt,layoutVertexBuffer:Zt,indexBuffer:ni,uniformValues:St,terrainData:zt}=mt.state;Vt.draw(ue,ve.TRIANGLES,Te,ze,je,$r.disabled,St,zt,_.id,Zt,ni,mt.segments,_.paint,M.transform.zoom,gt)}},heatmap:function(M,h,_,T){if(_.paint.get("heatmap-opacity")!==0)if(M.renderPass==="offscreen"){const F=M.context,O=F.gl,K=jr.disabled,oe=new qr([O.ONE,O.ONE],i.Color.transparent,[!0,!0,!0,!0]);(function(ue,ve,Te){const ze=ue.gl;ue.activeTexture.set(ze.TEXTURE1),ue.viewport.set([0,0,ve.width/4,ve.height/4]);let je=Te.heatmapFbo;if(je)ze.bindTexture(ze.TEXTURE_2D,je.colorAttachment.get()),ue.bindFramebuffer.set(je.framebuffer);else{const bt=ze.createTexture();ze.bindTexture(ze.TEXTURE_2D,bt),ze.texParameteri(ze.TEXTURE_2D,ze.TEXTURE_WRAP_S,ze.CLAMP_TO_EDGE),ze.texParameteri(ze.TEXTURE_2D,ze.TEXTURE_WRAP_T,ze.CLAMP_TO_EDGE),ze.texParameteri(ze.TEXTURE_2D,ze.TEXTURE_MIN_FILTER,ze.LINEAR),ze.texParameteri(ze.TEXTURE_2D,ze.TEXTURE_MAG_FILTER,ze.LINEAR),je=Te.heatmapFbo=ue.createFramebuffer(ve.width/4,ve.height/4,!1),function(mt,gt,Vt,Zt){const ni=mt.gl;ni.texImage2D(ni.TEXTURE_2D,0,ni.RGBA,gt.width/4,gt.height/4,0,ni.RGBA,mt.extRenderToTextureHalfFloat?mt.extTextureHalfFloat.HALF_FLOAT_OES:ni.UNSIGNED_BYTE,null),Zt.colorAttachment.set(Vt)}(ue,ve,bt,je)}})(F,M,_),F.clear({color:i.Color.transparent});for(let ue=0;ue{const mt=i.create();i.ortho(mt,0,Te.width,Te.height,0,0,1);const gt=Te.context.gl;return{u_matrix:mt,u_world:[gt.drawingBufferWidth,gt.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:ze.paint.get("heatmap-opacity")}})(F,O),null,O.id,F.viewportBuffer,F.quadTriangleIndexBuffer,F.viewportSegments,O.paint,F.transform.zoom)}(M,_))},line:function(M,h,_,T){if(M.renderPass!=="translucent")return;const F=_.paint.get("line-opacity"),O=_.paint.get("line-width");if(F.constantOr(1)===0||O.constantOr(1)===0)return;const K=M.depthModeForSublayer(0,hr.ReadOnly),oe=M.colorModeForRenderPass(),ue=_.paint.get("line-dasharray"),ve=_.paint.get("line-pattern"),Te=ve.constantOr(1),ze=_.paint.get("line-gradient"),je=_.getCrossfadeParameters(),bt=Te?"linePattern":ue?"lineSDF":ze?"lineGradient":"line",mt=M.context,gt=mt.gl;let Vt=!0;for(const Zt of T){const ni=h.getTile(Zt);if(Te&&!ni.patternsLoaded())continue;const St=ni.getBucket(_);if(!St)continue;const zt=St.programConfigurations.get(_.id),ai=M.context.program.get(),Ei=M.useProgram(bt,zt),Bi=Vt||Ei.program!==ai,Hi=M.style.terrain&&M.style.terrain.getTerrainData(Zt),vi=ve.constantOr(null);if(vi&&ni.imageAtlas){const Bn=ni.imageAtlas,tr=Bn.patternPositions[vi.to.toString()],ur=Bn.patternPositions[vi.from.toString()];tr&&ur&&zt.setConstantPatternPositions(tr,ur)}const xn=Hi?Zt:null,cn=Te?Nl(M,ni,_,je,xn):ue?Ql(M,ni,_,ue,je,xn):ze?Na(M,ni,_,St.lineClipsArray.length,xn):Ol(M,ni,_,xn);if(Te)mt.activeTexture.set(gt.TEXTURE0),ni.imageAtlasTexture.bind(gt.LINEAR,gt.CLAMP_TO_EDGE),zt.updatePaintBuffers(je);else if(ue&&(Bi||M.lineAtlas.dirty))mt.activeTexture.set(gt.TEXTURE0),M.lineAtlas.bind(mt);else if(ze){const Bn=St.gradients[_.id];let tr=Bn.texture;if(_.gradientVersion!==Bn.version){let ur=256;if(_.stepInterpolant){const Un=h.getSource().maxzoom,Lr=Zt.canonical.z===Un?Math.ceil(1<256&&this.clearStencil(),T.setColorMode(qr.disabled),T.setDepthMode(hr.disabled);const O=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const K of _){const oe=this._tileClippingMaskIDs[K.key]=this.nextStencilID++,ue=this.style.terrain&&this.style.terrain.getTerrainData(K);O.draw(T,F.TRIANGLES,hr.disabled,new jr({func:F.ALWAYS,mask:0},oe,255,F.KEEP,F.KEEP,F.REPLACE),qr.disabled,$r.disabled,Oa(K.posMatrix),ue,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,_=this.context.gl;return new jr({func:_.NOTEQUAL,mask:255},h,255,_.KEEP,_.KEEP,_.REPLACE)}stencilModeForClipping(h){const _=this.context.gl;return new jr({func:_.EQUAL,mask:255},this._tileClippingMaskIDs[h.key],0,_.KEEP,_.KEEP,_.REPLACE)}stencilConfigForOverlap(h){const _=this.context.gl,T=h.sort((K,oe)=>oe.overscaledZ-K.overscaledZ),F=T[T.length-1].overscaledZ,O=T[0].overscaledZ-F+1;if(O>1){this.currentStencilSource=void 0,this.nextStencilID+O>256&&this.clearStencil();const K={};for(let oe=0;oe=0;this.currentLayer--){const ve=this.style._layers[T[this.currentLayer]],Te=F[ve.source],ze=K[ve.source];this._renderTileClippingMasks(ve,ze),this.renderLayer(this,Te,ve,ze)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer{ze.source&&!ze.isHidden(this.transform.zoom)&&(ze.source!==(Te&&Te.id)&&(Te=this.style.sourceCaches[ze.source]),(!ve||ve.getSource().maxzoom0?_.pop():null}isPatternMissing(h){if(!h)return!1;if(!h.from||!h.to)return!0;const _=this.imageManager.getPattern(h.from.toString()),T=this.imageManager.getPattern(h.to.toString());return!_||!T}useProgram(h,_){this.cache=this.cache||{};const T=h+(_?_.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.terrain?"/terrain":"");return this.cache[T]||(this.cache[T]=new Ar(this.context,h,zs[h],_,Bs[h],this._showOverdrawInspector,this.style.terrain)),this.cache[T]}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 h=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(h.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Y(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}}class Zc{constructor(h,_){this.points=h,this.planes=_}static fromInvProjectionMatrix(h,_,T){const F=Math.pow(2,T),O=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(oe=>{const ue=1/(oe=i.transformMat4([],oe,h))[3]/_*F;return i.mul$1(oe,oe,[ue,ue,1/oe[3],ue])}),K=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(oe=>{const ue=i.sub([],O[oe[0]],O[oe[1]]),ve=i.sub([],O[oe[2]],O[oe[1]]),Te=i.normalize([],i.cross([],ue,ve)),ze=-i.dot(Te,O[oe[1]]);return Te.concat(ze)});return new Zc(O,K)}}class Xc{constructor(h,_){this.min=h,this.max=_,this.center=i.scale$1([],i.add([],this.min,this.max),.5)}quadrant(h){const _=[h%2==0,h<2],T=i.clone$2(this.min),F=i.clone$2(this.max);for(let O=0;O<_.length;O++)T[O]=_[O]?this.min[O]:this.center[O],F[O]=_[O]?this.center[O]:this.max[O];return F[2]=this.max[2],new Xc(T,F)}distanceX(h){return Math.max(Math.min(this.max[0],h[0]),this.min[0])-h[0]}distanceY(h){return Math.max(Math.min(this.max[1],h[1]),this.min[1])-h[1]}intersects(h){const _=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]];let T=!0;for(let F=0;F=0&&K++;if(K===0)return 0;K!==_.length&&(T=!1)}if(T)return 2;for(let F=0;F<3;F++){let O=Number.MAX_VALUE,K=-Number.MAX_VALUE;for(let oe=0;oethis.max[F]-this.min[F])return 0}return 1}}class fl{constructor(h=0,_=0,T=0,F=0){if(isNaN(h)||h<0||isNaN(_)||_<0||isNaN(T)||T<0||isNaN(F)||F<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=h,this.bottom=_,this.left=T,this.right=F}interpolate(h,_,T){return _.top!=null&&h.top!=null&&(this.top=i.number(h.top,_.top,T)),_.bottom!=null&&h.bottom!=null&&(this.bottom=i.number(h.bottom,_.bottom,T)),_.left!=null&&h.left!=null&&(this.left=i.number(h.left,_.left,T)),_.right!=null&&h.right!=null&&(this.right=i.number(h.right,_.right,T)),this}getCenter(h,_){const T=i.clamp((this.left+h-this.right)/2,0,h),F=i.clamp((this.top+_-this.bottom)/2,0,_);return new i.pointGeometry(T,F)}equals(h){return this.top===h.top&&this.bottom===h.bottom&&this.left===h.left&&this.right===h.right}clone(){return new fl(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class qc{constructor(h,_,T,F,O){this.tileSize=512,this.maxValidLatitude=85.051129,this.freezeElevation=!1,this._renderWorldCopies=O===void 0||!!O,this._minZoom=h||0,this._maxZoom=_||22,this._minPitch=T==null?0:T,this._maxPitch=F==null?60:F,this.setMaxBounds(),this.width=0,this.height=0,this._center=new i.LngLat(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new fl,this._posMatrixCache={},this._alignedPosMatrixCache={}}clone(){const h=new qc(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return h.tileSize=this.tileSize,h.latRange=this.latRange,h.width=this.width,h.height=this.height,h._center=this._center,h._elevation=this._elevation,h.zoom=this.zoom,h.angle=this.angle,h._fov=this._fov,h._pitch=this._pitch,h._unmodified=this._unmodified,h._edgeInsets=this._edgeInsets.clone(),h._calcMatrices(),h}get minZoom(){return this._minZoom}set minZoom(h){this._minZoom!==h&&(this._minZoom=h,this.zoom=Math.max(this.zoom,h))}get maxZoom(){return this._maxZoom}set maxZoom(h){this._maxZoom!==h&&(this._maxZoom=h,this.zoom=Math.min(this.zoom,h))}get minPitch(){return this._minPitch}set minPitch(h){this._minPitch!==h&&(this._minPitch=h,this.pitch=Math.max(this.pitch,h))}get maxPitch(){return this._maxPitch}set maxPitch(h){this._maxPitch!==h&&(this._maxPitch=h,this.pitch=Math.min(this.pitch,h))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(h){h===void 0?h=!0:h===null&&(h=!1),this._renderWorldCopies=h}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new i.pointGeometry(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(h){const _=-i.wrap(h,-180,180)*Math.PI/180;var T;this.angle!==_&&(this._unmodified=!1,this.angle=_,this._calcMatrices(),this.rotationMatrix=(T=new i.ARRAY_TYPE(4),i.ARRAY_TYPE!=Float32Array&&(T[1]=0,T[2]=0),T[0]=1,T[3]=1,T),function(F,O,K){var oe=O[0],ue=O[1],ve=O[2],Te=O[3],ze=Math.sin(K),je=Math.cos(K);F[0]=oe*je+ve*ze,F[1]=ue*je+Te*ze,F[2]=oe*-ze+ve*je,F[3]=ue*-ze+Te*je}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(h){const _=i.clamp(h,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==_&&(this._unmodified=!1,this._pitch=_,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(h){h=Math.max(.01,Math.min(60,h)),this._fov!==h&&(this._unmodified=!1,this._fov=h/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(h){const _=Math.min(Math.max(h,this.minZoom),this.maxZoom);this._zoom!==_&&(this._unmodified=!1,this._zoom=_,this.scale=this.zoomScale(_),this.tileZoom=Math.floor(_),this.zoomFraction=_-this.tileZoom,this._constrain(),this._calcMatrices())}get center(){return this._center}set center(h){h.lat===this._center.lat&&h.lng===this._center.lng||(this._unmodified=!1,this._center=h,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(h){h!==this._elevation&&(this._elevation=h,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(h){this._edgeInsets.equals(h)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,h,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(h){return this._edgeInsets.equals(h)}interpolatePadding(h,_,T){this._unmodified=!1,this._edgeInsets.interpolate(h,_,T),this._constrain(),this._calcMatrices()}coveringZoomLevel(h){const _=(h.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/h.tileSize));return Math.max(0,_)}getVisibleUnwrappedCoordinates(h){const _=[new i.UnwrappedTileID(0,h)];if(this._renderWorldCopies){const T=this.pointCoordinate(new i.pointGeometry(0,0)),F=this.pointCoordinate(new i.pointGeometry(this.width,0)),O=this.pointCoordinate(new i.pointGeometry(this.width,this.height)),K=this.pointCoordinate(new i.pointGeometry(0,this.height)),oe=Math.floor(Math.min(T.x,F.x,O.x,K.x)),ue=Math.floor(Math.max(T.x,F.x,O.x,K.x)),ve=1;for(let Te=oe-ve;Te<=ue+ve;Te++)Te!==0&&_.push(new i.UnwrappedTileID(Te,h))}return _}coveringTiles(h){var _,T;let F=this.coveringZoomLevel(h);const O=F;if(h.minzoom!==void 0&&Fh.maxzoom&&(F=h.maxzoom);const K=this.pointCoordinate(this.getCameraPoint()),oe=i.MercatorCoordinate.fromLngLat(this.center),ue=Math.pow(2,F),ve=[ue*K.x,ue*K.y,0],Te=[ue*oe.x,ue*oe.y,0],ze=Zc.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,F);let je=h.minzoom||0;!h.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(je=F);const bt=h.terrain?2/Math.min(this.tileSize,h.tileSize)*this.tileSize:3,mt=St=>({aabb:new Xc([St*ue,0,0],[(St+1)*ue,ue,0]),zoom:0,x:0,y:0,wrap:St,fullyVisible:!1}),gt=[],Vt=[],Zt=F,ni=h.reparseOverscaled?O:F;if(this._renderWorldCopies)for(let St=1;St<=3;St++)gt.push(mt(-St)),gt.push(mt(St));for(gt.push(mt(0));gt.length>0;){const St=gt.pop(),zt=St.x,ai=St.y;let Ei=St.fullyVisible;if(!Ei){const Bn=St.aabb.intersects(ze);if(Bn===0)continue;Ei=Bn===2}const Bi=h.terrain?ve:Te,Hi=St.aabb.distanceX(Bi),vi=St.aabb.distanceY(Bi),xn=Math.max(Math.abs(Hi),Math.abs(vi)),cn=bt+(1<cn&&St.zoom>=je){const Bn=Zt-St.zoom,tr=ve[0]-.5-(zt<>1),Un=St.zoom+1;let Lr=St.aabb.quadrant(Bn);if(h.terrain){const Rr=new i.OverscaledTileID(Un,St.wrap,Un,tr,ur),Cr=h.terrain.getMinMaxElevation(Rr),Er=(_=Cr.minElevation)!==null&&_!==void 0?_:this.elevation,Gr=(T=Cr.maxElevation)!==null&&T!==void 0?T:this.elevation;Lr=new Xc([Lr.min[0],Lr.min[1],Er],[Lr.max[0],Lr.max[1],Gr])}gt.push({aabb:Lr,zoom:Un,x:tr,y:ur,wrap:St.wrap,fullyVisible:Ei})}}return Vt.sort((St,zt)=>St.distanceSq-zt.distanceSq).map(St=>St.tileID)}resize(h,_){this.width=h,this.height=_,this.pixelsToGLUnits=[2/h,-2/_],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(h){return Math.pow(2,h)}scaleZoom(h){return Math.log(h)/Math.LN2}project(h){const _=i.clamp(h.lat,-this.maxValidLatitude,this.maxValidLatitude);return new i.pointGeometry(i.mercatorXfromLng(h.lng)*this.worldSize,i.mercatorYfromLat(_)*this.worldSize)}unproject(h){return new i.MercatorCoordinate(h.x/this.worldSize,h.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}updateElevation(h){this.freezeElevation||(this.elevation=h?this.getElevation(this._center,h):0)}getElevation(h,_){const T=i.MercatorCoordinate.fromLngLat(h),F=(1<K&&(F=K-mt)}if(this.lngRange){const bt=(oe+ue)/2,mt=i.wrap(ze.x,bt-this.worldSize/2,bt+this.worldSize/2),gt=ve.x/2;mt-gtue&&(T=ue-gt)}T===void 0&&F===void 0||(this.center=this.unproject(new i.pointGeometry(T!==void 0?T:ze.x,F!==void 0?F:ze.y)).wrap()),this._unmodified=Te,this._constraining=!1}_calcMatrices(){if(!this.height)return;const h=this.centerOffset,_=this.point.x,T=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=i.mercatorZfromAltitude(1,this.center.lat)*this.worldSize;let F=i.identity(new Float64Array(16));i.scale(F,F,[this.width/2,-this.height/2,1]),i.translate(F,F,[1,-1,0]),this.labelPlaneMatrix=F,F=i.identity(new Float64Array(16)),i.scale(F,F,[1,-1,1]),i.translate(F,F,[-1,-1,0]),i.scale(F,F,[2/this.width,2/this.height,1]),this.glCoordMatrix=F,this.cameraToSeaLevelDistance=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch);const O=Math.PI/2+this._pitch,K=this._fov*(.5+h.y/this.height),oe=Math.sin(K)*this.cameraToSeaLevelDistance/Math.sin(i.clamp(Math.PI-O-K,.01,Math.PI-.01)),ue=this.getHorizon(),ve=2*Math.atan(ue/this.cameraToCenterDistance)*(.5+h.y/(2*ue)),Te=Math.sin(ve)*this.cameraToSeaLevelDistance/Math.sin(i.clamp(Math.PI-O-ve,.01,Math.PI-.01)),ze=Math.cos(Math.PI/2-this._pitch)*oe+this.cameraToSeaLevelDistance,je=Math.cos(Math.PI/2-this._pitch)*Te+this.cameraToSeaLevelDistance,bt=1.01*Math.min(ze,je),mt=this.height/50;F=new Float64Array(16),i.perspective(F,this._fov,this.width/this.height,mt,bt),F[8]=2*-h.x/this.width,F[9]=2*h.y/this.height,i.scale(F,F,[1,-1,1]),i.translate(F,F,[0,0,-this.cameraToCenterDistance]),i.rotateX(F,F,this._pitch),i.rotateZ(F,F,this.angle),i.translate(F,F,[-_,-T,0]),this.mercatorMatrix=i.scale([],F,[this.worldSize,this.worldSize,this.worldSize]),i.scale(F,F,[1,1,this._pixelPerMeter]),this.pixelMatrix=i.multiply(new Float64Array(16),this.labelPlaneMatrix,F),i.translate(F,F,[0,0,-this.elevation]),this.projMatrix=F,this.invProjMatrix=i.invert([],F),this.pixelMatrix3D=i.multiply(new Float64Array(16),this.labelPlaneMatrix,F);const gt=this.width%2/2,Vt=this.height%2/2,Zt=Math.cos(this.angle),ni=Math.sin(this.angle),St=_-Math.round(_)+Zt*gt+ni*Vt,zt=T-Math.round(T)+Zt*Vt+ni*gt,ai=new Float64Array(F);if(i.translate(ai,ai,[St>.5?St-1:St,zt>.5?zt-1:zt,0]),this.alignedProjMatrix=ai,F=i.invert(new Float64Array(16),this.pixelMatrix),!F)throw new Error("failed to invert matrix");this.pixelMatrixInverse=F,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const h=this.pointCoordinate(new i.pointGeometry(0,0)),_=[h.x*this.worldSize,h.y*this.worldSize,0,1];return i.transformMat4(_,_,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const h=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.pointGeometry(0,h))}getCameraQueryGeometry(h){const _=this.getCameraPoint();if(h.length===1)return[h[0],_];{let T=_.x,F=_.y,O=_.x,K=_.y;for(const oe of h)T=Math.min(T,oe.x),F=Math.min(F,oe.y),O=Math.max(O,oe.x),K=Math.max(K,oe.y);return[new i.pointGeometry(T,F),new i.pointGeometry(O,F),new i.pointGeometry(O,K),new i.pointGeometry(T,K),new i.pointGeometry(T,F)]}}}class Uh{constructor(h){this._hashName=h&&encodeURIComponent(h),i.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=function(_,T){let F=!1,O=null;const K=()=>{O=null,F&&(_(),O=setTimeout(K,300),F=!1)};return()=>(F=!0,O||K(),O)}(this._updateHashUnthrottled.bind(this))}addTo(h){return this._map=h,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(h){const _=this._map.getCenter(),T=Math.round(100*this._map.getZoom())/100,F=Math.ceil((T*Math.LN2+Math.log(512/360/.5))/Math.LN10),O=Math.pow(10,F),K=Math.round(_.lng*O)/O,oe=Math.round(_.lat*O)/O,ue=this._map.getBearing(),ve=this._map.getPitch();let Te="";if(Te+=h?`/${K}/${oe}/${T}`:`${T}/${oe}/${K}`,(ue||ve)&&(Te+="/"+Math.round(10*ue)/10),ve&&(Te+=`/${Math.round(ve)}`),this._hashName){const ze=this._hashName;let je=!1;const bt=window.location.hash.slice(1).split("&").map(mt=>{const gt=mt.split("=")[0];return gt===ze?(je=!0,`${gt}=${Te}`):mt}).filter(mt=>mt);return je||bt.push(`${ze}=${Te}`),`#${bt.join("&")}`}return`#${Te}`}_getCurrentHash(){const h=window.location.hash.replace("#","");if(this._hashName){let _;return h.split("&").map(T=>T.split("=")).forEach(T=>{T[0]===this._hashName&&(_=T)}),(_&&_[1]||"").split("/")}return h.split("/")}_onHashChange(){const h=this._getCurrentHash();if(h.length>=3&&!h.some(_=>isNaN(_))){const _=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(h[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+h[2],+h[1]],zoom:+h[0],bearing:_,pitch:+(h[4]||0)}),!0}return!1}_updateHashUnthrottled(){const h=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,h)}catch{}}}const Rh={linearity:.3,easing:i.bezier(0,0,.3,1)},bu=i.extend({deceleration:2500,maxSpeed:1400},Rh),id=i.extend({deceleration:20,maxSpeed:1400},Rh),pc=i.extend({deceleration:1e3,maxSpeed:360},Rh),fc=i.extend({deceleration:1e3,maxSpeed:90},Rh);class Yc{constructor(h){this._map=h,this.clear()}clear(){this._inertiaBuffer=[]}record(h){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.exported.now(),settings:h})}_drainInertiaBuffer(){const h=this._inertiaBuffer,_=i.exported.now();for(;h.length>0&&_-h[0].time>160;)h.shift()}_onMoveEnd(h){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const _={zoom:0,bearing:0,pitch:0,pan:new i.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:O}of this._inertiaBuffer)_.zoom+=O.zoomDelta||0,_.bearing+=O.bearingDelta||0,_.pitch+=O.pitchDelta||0,O.panDelta&&_.pan._add(O.panDelta),O.around&&(_.around=O.around),O.pinchAround&&(_.pinchAround=O.pinchAround);const T=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,F={};if(_.pan.mag()){const O=Jc(_.pan.mag(),T,i.extend({},bu,h||{}));F.offset=_.pan.mult(O.amount/_.pan.mag()),F.center=this._map.transform.center,zh(F,O)}if(_.zoom){const O=Jc(_.zoom,T,id);F.zoom=this._map.transform.zoom+O.amount,zh(F,O)}if(_.bearing){const O=Jc(_.bearing,T,pc);F.bearing=this._map.transform.bearing+i.clamp(O.amount,-179,179),zh(F,O)}if(_.pitch){const O=Jc(_.pitch,T,fc);F.pitch=this._map.transform.pitch+O.amount,zh(F,O)}if(F.zoom||F.bearing){const O=_.pinchAround===void 0?_.around:_.pinchAround;F.around=O?this._map.unproject(O):this._map.getCenter()}return this.clear(),i.extend(F,{noMoveStart:!0})}}function zh(M,h){(!M.duration||M.duration_.unproject(ue)),oe=O.reduce((ue,ve,Te,ze)=>ue.add(ve.div(ze.length)),new i.pointGeometry(0,0));super(h,{points:O,point:oe,lngLats:K,lngLat:_.unproject(oe),originalEvent:T}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class Mo extends i.Event{constructor(h,_,T){super(h,{originalEvent:T}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class nd{constructor(h,_){this._map=h,this._clickTolerance=_.clickTolerance}reset(){delete this._mousedownPos}wheel(h){return this._firePreventable(new Mo(h.type,this._map,h))}mousedown(h,_){return this._mousedownPos=_,this._firePreventable(new So(h.type,this._map,h))}mouseup(h){this._map.fire(new So(h.type,this._map,h))}click(h,_){this._mousedownPos&&this._mousedownPos.dist(_)>=this._clickTolerance||this._map.fire(new So(h.type,this._map,h))}dblclick(h){return this._firePreventable(new So(h.type,this._map,h))}mouseover(h){this._map.fire(new So(h.type,this._map,h))}mouseout(h){this._map.fire(new So(h.type,this._map,h))}touchstart(h){return this._firePreventable(new xa(h.type,this._map,h))}touchmove(h){this._map.fire(new xa(h.type,this._map,h))}touchend(h){this._map.fire(new xa(h.type,this._map,h))}touchcancel(h){this._map.fire(new xa(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ha{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(h){this._map.fire(new So(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new So("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._ignoreContextMenu||this._map.fire(new So(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class rd{constructor(h,_){this._map=h,this._el=h.getCanvasContainer(),this._container=h.getContainer(),this._clickTolerance=_.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(h,_){this.isEnabled()&&h.shiftKey&&h.button===0&&(z.disableDrag(),this._startPos=this._lastPos=_,this._active=!0)}mousemoveWindow(h,_){if(!this._active)return;const T=_;if(this._lastPos.equals(T)||!this._box&&T.dist(this._startPos)O.fitScreenCoordinates(T,F,this._map.getBearing(),{linear:!0})};this._fireEvent("boxzoomcancel",h)}keydown(h){this._active&&h.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",h))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair","mapboxgl-crosshair"),this._box&&(z.remove(this._box),this._box=null),z.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(h,_){return this._map.fire(new i.Event(h,{originalEvent:_}))}}function ml(M,h){if(M.length!==h.length)throw new Error(`The number of touches and points are not equal - touches ${M.length}, points ${h.length}`);const _={};for(let T=0;Tthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=h.timeStamp),T.length===this.numTouches&&(this.centroid=function(F){const O=new i.pointGeometry(0,0);for(const K of F)O._add(K);return O.div(F.length)}(_),this.touches=ml(T,_)))}touchmove(h,_,T){if(this.aborted||!this.centroid)return;const F=ml(T,_);for(const O in this.touches){const K=this.touches[O],oe=F[O];(!oe||oe.dist(K)>30)&&(this.aborted=!0)}}touchend(h,_,T){if((!this.centroid||h.timeStamp-this.startTime>500)&&(this.aborted=!0),T.length===0){const F=!this.aborted&&this.centroid;if(this.reset(),F)return F}}}class Oh{constructor(h){this.singleTap=new kh(h),this.numTaps=h.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(h,_,T){this.singleTap.touchstart(h,_,T)}touchmove(h,_,T){this.singleTap.touchmove(h,_,T)}touchend(h,_,T){const F=this.singleTap.touchend(h,_,T);if(F){const O=h.timeStamp-this.lastTime<500,K=!this.lastTap||this.lastTap.dist(F)<30;if(O&&K||this.reset(),this.count++,this.lastTime=h.timeStamp,this.lastTap=F,this.count===this.numTaps)return this.reset(),F}}}class lA{constructor(){this._zoomIn=new Oh({numTouches:1,numTaps:2}),this._zoomOut=new Oh({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(h,_,T){this._zoomIn.touchstart(h,_,T),this._zoomOut.touchstart(h,_,T)}touchmove(h,_,T){this._zoomIn.touchmove(h,_,T),this._zoomOut.touchmove(h,_,T)}touchend(h,_,T){const F=this._zoomIn.touchend(h,_,T),O=this._zoomOut.touchend(h,_,T);return F?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:K=>K.easeTo({duration:300,zoom:K.getZoom()+1,around:K.unproject(F)},{originalEvent:h})}):O?(this._active=!0,h.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:K=>K.easeTo({duration:300,zoom:K.getZoom()-1,around:K.unproject(O)},{originalEvent:h})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const sd={0:1,2:2};class Nh{constructor(h){this.reset(),this._clickTolerance=h.clickTolerance||1}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(h,_){return!1}_move(h,_){return{}}mousedown(h,_){if(this._lastPoint)return;const T=z.mouseButton(h);this._correctButton(h,T)&&(this._lastPoint=_,this._eventButton=T)}mousemoveWindow(h,_){const T=this._lastPoint;if(T){if(h.preventDefault(),function(F,O){const K=sd[O];return F.buttons===void 0||(F.buttons&K)!==K}(h,this._eventButton))this.reset();else if(this._moved||!(_.dist(T){this._cancelCooperativeMessage=!1},200)}touchstart(h,_,T){return this._calculateTransform(h,_,T)}touchmove(h,_,T){if(this._map._cooperativeGestures&&(this._minTouches===2&&T.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(h,!1,T.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(T.length0&&(this._active=!0);const F=ml(T,_),O=new i.pointGeometry(0,0),K=new i.pointGeometry(0,0);let oe=0;for(const ve in F){const Te=F[ve],ze=this._touches[ve];ze&&(O._add(Te),K._add(Te.sub(ze)),oe++,F[ve]=Te)}if(this._touches=F,oeMath.abs(M.x)}class cA extends Wl{constructor(h){super(),this._map=h}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(h,_,T){super.touchstart(h,_,T),this._currentTouchCount=T.length}_start(h){this._lastPoints=h,gc(h[0].sub(h[1]))&&(this._valid=!1)}_move(h,_,T){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const F=h[0].sub(this._lastPoints[0]),O=h[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(F,O,T.timeStamp),this._valid?(this._lastPoints=h,this._active=!0,{pitchDelta:(F.y+O.y)/2*-.5}):void 0}gestureBeginsVertically(h,_,T){if(this._valid!==void 0)return this._valid;const F=h.mag()>=2,O=_.mag()>=2;if(!F&&!O)return;if(!F||!O)return this._firstMove===void 0&&(this._firstMove=T),T-this._firstMove<100&&void 0;const K=h.y>0==_.y>0;return gc(h)&&gc(_)&&K}}const Qh={panStep:100,bearingStep:15,pitchStep:10};class _c{constructor(){const h=Qh;this._panStep=h.panStep,this._bearingStep=h.bearingStep,this._pitchStep=h.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(h){if(h.altKey||h.ctrlKey||h.metaKey)return;let _=0,T=0,F=0,O=0,K=0;switch(h.keyCode){case 61:case 107:case 171:case 187:_=1;break;case 189:case 109:case 173:_=-1;break;case 37:h.shiftKey?T=-1:(h.preventDefault(),O=-1);break;case 39:h.shiftKey?T=1:(h.preventDefault(),O=1);break;case 38:h.shiftKey?F=1:(h.preventDefault(),K=-1);break;case 40:h.shiftKey?F=-1:(h.preventDefault(),K=1);break;default:return}return this._rotationDisabled&&(T=0,F=0),{cameraAnimation:oe=>{const ue=oe.getZoom();oe.easeTo({duration:300,easeId:"keyboardHandler",easing:hA,zoom:_?Math.round(ue)+_*(h.shiftKey?2:1):ue,bearing:oe.getBearing()+T*this._bearingStep,pitch:oe.getPitch()+F*this._pitchStep,offset:[-O*this._panStep,-K*this._panStep],center:oe.getCenter()},{originalEvent:h})}}}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 hA(M){return M*(2-M)}const uA=4.000244140625;class Vh{constructor(h,_){this._map=h,this._el=h.getCanvasContainer(),this._handler=_,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,i.bindAll(["_onTimeout"],this)}setZoomRate(h){this._defaultZoomRate=h}setWheelZoomRate(h){this._wheelZoomRate=h}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(h){this.isEnabled()||(this._enabled=!0,this._aroundCenter=h&&h.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(h){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!this._map._metaPress)return;h.preventDefault()}let _=h.deltaMode===WheelEvent.DOM_DELTA_LINE?40*h.deltaY:h.deltaY;const T=i.exported.now(),F=T-(this._lastWheelEventTime||0);this._lastWheelEventTime=T,_!==0&&_%uA==0?this._type="wheel":_!==0&&Math.abs(_)<4?this._type="trackpad":F>400?(this._type=null,this._lastValue=_,this._timeout=setTimeout(this._onTimeout,40,h)):this._type||(this._type=Math.abs(F*_)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,_+=this._lastValue)),h.shiftKey&&_&&(_/=4),this._type&&(this._lastWheelEvent=h,this._delta-=_,this._active||this._start(h)),h.preventDefault()}_onTimeout(h){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(h)}_start(h){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 _=z.mousePos(this._el,h);this._around=i.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(_)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const h=this._map.transform;if(this._delta!==0){const oe=this._type==="wheel"&&Math.abs(this._delta)>uA?this._wheelZoomRate:this._defaultZoomRate;let ue=2/(1+Math.exp(-Math.abs(this._delta*oe)));this._delta<0&&ue!==0&&(ue=1/ue);const ve=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):h.scale;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(ve*ue))),this._type==="wheel"&&(this._startZoom=h.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const _=typeof this._targetZoom=="number"?this._targetZoom:h.zoom,T=this._startZoom,F=this._easing;let O,K=!1;if(this._type==="wheel"&&T&&F){const oe=Math.min((i.exported.now()-this._lastWheelEventTime)/200,1),ue=F(oe);O=i.number(T,_,ue),oe<1?this._frameId||(this._frameId=!0):K=!0}else O=_,K=!0;return this._active=!0,K&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!K,zoomDelta:O-h.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(h){let _=i.ease;if(this._prevEase){const T=this._prevEase,F=(i.exported.now()-T.start)/T.duration,O=T.easing(F+.01)-T.easing(F),K=.27/Math.sqrt(O*O+1e-4)*.01,oe=Math.sqrt(.0729-K*K);_=i.bezier(K,oe,.25,1)}return this._prevEase={start:i.exported.now(),duration:h,easing:_},_}reset(){this._active=!1}}class Hh{constructor(h,_){this._clickZoom=h,this._tapZoom=_}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 ih{constructor(){this.reset()}reset(){this._active=!1}dblclick(h,_){return h.preventDefault(),{cameraAnimation:T=>{T.easeTo({duration:300,zoom:T.getZoom()+(h.shiftKey?-1:1),around:T.unproject(_)},{originalEvent:h})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class yc{constructor(){this._tap=new Oh({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(h,_,T){this._swipePoint||(this._tapTime&&h.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?T.length>0&&(this._swipePoint=_[0],this._swipeTouch=T[0].identifier):this._tap.touchstart(h,_,T))}touchmove(h,_,T){if(this._tapTime){if(this._swipePoint){if(T[0].identifier!==this._swipeTouch)return;const F=_[0],O=F.y-this._swipePoint.y;return this._swipePoint=F,h.preventDefault(),this._active=!0,{zoomDelta:O/128}}}else this._tap.touchmove(h,_,T)}touchend(h,_,T){this._tapTime?this._swipePoint&&T.length===0&&this.reset():this._tap.touchend(h,_,T)&&(this._tapTime=h.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ms{constructor(h,_,T){this._el=h,this._mousePan=_,this._touchPan=T}enable(h){this._inertiaOptions=h||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class fo{constructor(h,_,T){this._pitchWithRotate=h.pitchWithRotate,this._mouseRotate=_,this._mousePitch=T}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 Gh{constructor(h,_,T,F){this._el=h,this._touchZoom=_,this._touchRotate=T,this._tapDragZoom=F,this._rotationDisabled=!1,this._enabled=!0}enable(h){this._touchZoom.enable(h),this._rotationDisabled||this._touchRotate.enable(h),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const jl=M=>M.zoom||M.drag||M.pitch||M.rotate;class Kl extends i.Event{}function _l(M){return M.panDelta&&M.panDelta.mag()||M.zoomDelta||M.bearingDelta||M.pitchDelta}class An{constructor(h,_){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Yc(h),this._bearingSnap=_.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(_),i.bindAll(["handleEvent","handleWindowEvent"],this);const T=this._el;this._listeners=[[T,"touchstart",{passive:!0}],[T,"touchmove",{passive:!1}],[T,"touchend",void 0],[T,"touchcancel",void 0],[T,"mousedown",void 0],[T,"mousemove",void 0],[T,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[T,"mouseover",void 0],[T,"mouseout",void 0],[T,"dblclick",void 0],[T,"click",void 0],[T,"keydown",{capture:!1}],[T,"keyup",void 0],[T,"wheel",{passive:!1}],[T,"contextmenu",void 0],[window,"blur",void 0]];for(const[F,O,K]of this._listeners)z.addEventListener(F,O,F===document?this.handleWindowEvent:this.handleEvent,K)}destroy(){for(const[h,_,T]of this._listeners)z.removeEventListener(h,_,h===document?this.handleWindowEvent:this.handleEvent,T)}_addDefaultHandlers(h){const _=this._map,T=_.getCanvasContainer();this._add("mapEvent",new nd(_,h));const F=_.boxZoom=new rd(_,h);this._add("boxZoom",F);const O=new lA,K=new ih;_.doubleClickZoom=new Hh(K,O),this._add("tapZoom",O),this._add("clickZoom",K);const oe=new yc;this._add("tapDragZoom",oe);const ue=_.touchPitch=new cA(_);this._add("touchPitch",ue);const ve=new ha(h),Te=new pn(h);_.dragRotate=new fo(h,ve,Te),this._add("mouseRotate",ve,["mousePitch"]),this._add("mousePitch",Te,["mouseRotate"]);const ze=new mc(h),je=new eh(h,_);_.dragPan=new Ms(T,ze,je),this._add("mousePan",ze),this._add("touchPan",je,["touchZoom","touchRotate"]);const bt=new Ur,mt=new un;_.touchZoomRotate=new Gh(T,mt,bt,oe),this._add("touchRotate",bt,["touchPan","touchZoom"]),this._add("touchZoom",mt,["touchPan","touchRotate"]);const gt=_.scrollZoom=new Vh(_,this);this._add("scrollZoom",gt,["mousePan"]);const Vt=_.keyboard=new _c;this._add("keyboard",Vt),this._add("blockableMapEvent",new Ha(_));for(const Zt of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Zt]&&_[Zt].enable(h[Zt])}_add(h,_,T){this._handlers.push({handlerName:h,handler:_,allowed:T}),this._handlersById[h]=_}stop(h){if(!this._updatingCamera){for(const{handler:_}of this._handlers)_.reset();this._inertia.clear(),this._fireEvents({},{},h),this._changes=[]}}isActive(){for(const{handler:h}of this._handlers)if(h.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(jl(this._eventsInProgress))||this.isZooming()}_blockedByActive(h,_,T){for(const F in h)if(F!==T&&(!_||_.indexOf(F)<0))return!0;return!1}handleWindowEvent(h){this.handleEvent(h,`${h.type}Window`)}_getMapTouches(h){const _=[];for(const T of h)this._el.contains(T.target)&&_.push(T);return _}handleEvent(h,_){if(h.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const T=h.type==="renderFrame"?void 0:h,F={needsRenderFrame:!1},O={},K={},oe=h.touches,ue=oe?this._getMapTouches(oe):void 0,ve=ue?z.touchPos(this._el,ue):z.mousePos(this._el,h);for(const{handlerName:je,handler:bt,allowed:mt}of this._handlers){if(!bt.isEnabled())continue;let gt;this._blockedByActive(K,mt,je)?bt.reset():bt[_||h.type]&&(gt=bt[_||h.type](h,ve,ue),this.mergeHandlerResult(F,O,gt,je,T),gt&>.needsRenderFrame&&this._triggerRenderFrame()),(gt||bt.isActive())&&(K[je]=bt)}const Te={};for(const je in this._previousActiveHandlers)K[je]||(Te[je]=T);this._previousActiveHandlers=K,(Object.keys(Te).length||_l(F))&&(this._changes.push([F,O,Te]),this._triggerRenderFrame()),(Object.keys(K).length||_l(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ze}=F;ze&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ze(this._map))}mergeHandlerResult(h,_,T,F,O){if(!T)return;i.extend(h,T);const K={handlerName:F,originalEvent:T.originalEvent||O};T.zoomDelta!==void 0&&(_.zoom=K),T.panDelta!==void 0&&(_.drag=K),T.pitchDelta!==void 0&&(_.pitch=K),T.bearingDelta!==void 0&&(_.rotate=K)}_applyChanges(){const h={},_={},T={};for(const[F,O,K]of this._changes)F.panDelta&&(h.panDelta=(h.panDelta||new i.pointGeometry(0,0))._add(F.panDelta)),F.zoomDelta&&(h.zoomDelta=(h.zoomDelta||0)+F.zoomDelta),F.bearingDelta&&(h.bearingDelta=(h.bearingDelta||0)+F.bearingDelta),F.pitchDelta&&(h.pitchDelta=(h.pitchDelta||0)+F.pitchDelta),F.around!==void 0&&(h.around=F.around),F.pinchAround!==void 0&&(h.pinchAround=F.pinchAround),F.noInertia&&(h.noInertia=F.noInertia),i.extend(_,O),i.extend(T,K);this._updateMapTransform(h,_,T),this._changes=[]}_updateMapTransform(h,_,T){const F=this._map,O=F.transform,K=F.style&&F.style.terrain;if(!(_l(h)||K&&this._drag))return this._fireEvents(_,T,!0);let{panDelta:oe,zoomDelta:ue,bearingDelta:ve,pitchDelta:Te,around:ze,pinchAround:je}=h;je!==void 0&&(ze=je),F._stop(!0),ze=ze||F.transform.centerPoint;const bt=O.pointLocation(oe?ze.sub(oe):ze);ve&&(O.bearing+=ve),Te&&(O.pitch+=Te),ue&&(O.zoom+=ue),K?_.drag&&!this._drag?(this._drag={center:O.centerPoint,lngLat:O.pointLocation(ze),point:ze,handlerName:_.drag.handlerName},F.fire(new i.Event("freezeElevation",{freeze:!0}))):this._drag&&T[this._drag.handlerName]?(F.fire(new i.Event("freezeElevation",{freeze:!1})),this._drag=null):_.drag&&this._drag&&(O.center=O.pointLocation(O.centerPoint.sub(oe))):O.setLocationAtPoint(bt,ze),this._map._update(),h.noInertia||this._inertia.record(h),this._fireEvents(_,T,!0)}_fireEvents(h,_,T){const F=jl(this._eventsInProgress),O=jl(h),K={};for(const Te in h){const{originalEvent:ze}=h[Te];this._eventsInProgress[Te]||(K[`${Te}start`]=ze),this._eventsInProgress[Te]=h[Te]}!F&&O&&this._fireEvent("movestart",O.originalEvent);for(const Te in K)this._fireEvent(Te,K[Te]);O&&this._fireEvent("move",O.originalEvent);for(const Te in h){const{originalEvent:ze}=h[Te];this._fireEvent(Te,ze)}const oe={};let ue;for(const Te in this._eventsInProgress){const{handlerName:ze,originalEvent:je}=this._eventsInProgress[Te];this._handlersById[ze].isActive()||(delete this._eventsInProgress[Te],ue=_[ze]||je,oe[`${Te}end`]=ue)}for(const Te in oe)this._fireEvent(Te,oe[Te]);const ve=jl(this._eventsInProgress);if(T&&(F||O)&&!ve){this._updatingCamera=!0;const Te=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),ze=je=>je!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Kl("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const xs={extend:(M,...h)=>i.extend(M,...h),run(M){M()},logToElement(M,h=!1,_="log"){const T=window.document.getElementById(_);T&&(h&&(T.innerHTML=""),T.innerHTML+=`
${M}`)}};class Zr extends i.Evented{constructor(h,_){super(),this._moving=!1,this._zooming=!1,this.transform=h,this._bearingSnap=_.bearingSnap,i.bindAll(["_renderFrameCallback"],this)}getCenter(){return new i.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(h,_){return this.jumpTo({center:h},_)}panBy(h,_,T){return h=i.pointGeometry.convert(h).mult(-1),this.panTo(this.transform.center,i.extend({offset:h},_),T)}panTo(h,_,T){return this.easeTo(i.extend({center:h},_),T)}getZoom(){return this.transform.zoom}setZoom(h,_){return this.jumpTo({zoom:h},_),this}zoomTo(h,_,T){return this.easeTo(i.extend({zoom:h},_),T)}zoomIn(h,_){return this.zoomTo(this.getZoom()+1,h,_),this}zoomOut(h,_){return this.zoomTo(this.getZoom()-1,h,_),this}getBearing(){return this.transform.bearing}setBearing(h,_){return this.jumpTo({bearing:h},_),this}getPadding(){return this.transform.padding}setPadding(h,_){return this.jumpTo({padding:h},_),this}rotateTo(h,_,T){return this.easeTo(i.extend({bearing:h},_),T)}resetNorth(h,_){return this.rotateTo(0,i.extend({duration:1e3},h),_),this}resetNorthPitch(h,_){return this.easeTo(i.extend({bearing:0,pitch:0,duration:1e3},h),_),this}snapToNorth(h,_){return Math.abs(this.getBearing()){if(this._zooming&&(T.zoom=i.number(F,ue,Ei)),this._rotating&&(T.bearing=i.number(O,ve,Ei)),this._pitching&&(T.pitch=i.number(K,Te,Ei)),this._padding&&(T.interpolatePadding(oe,ze,Ei),bt=T.centerPoint.add(je)),St)T.setLocationAtPoint(St,zt);else{const Bi=T.zoomScale(T.zoom-F),Hi=ue>F?Math.min(2,ni):Math.max(.5,ni),vi=Math.pow(Hi,1-Ei),xn=T.unproject(Vt.add(Zt.mult(Ei*vi)).mult(Bi));T.setLocationAtPoint(T.renderWorldCopies?xn.wrap():xn,bt)}this._fireMoveEvents(_)},Ei=>{this._afterEase(_,Ei)},h),this}_prepareEase(h,_,T={}){this._moving=!0,this.fire(new i.Event("freezeElevation",{freeze:!0})),_||T.moving||this.fire(new i.Event("movestart",h)),this._zooming&&!T.zooming&&this.fire(new i.Event("zoomstart",h)),this._rotating&&!T.rotating&&this.fire(new i.Event("rotatestart",h)),this._pitching&&!T.pitching&&this.fire(new i.Event("pitchstart",h))}_fireMoveEvents(h){this.fire(new i.Event("move",h)),this._zooming&&this.fire(new i.Event("zoom",h)),this._rotating&&this.fire(new i.Event("rotate",h)),this._pitching&&this.fire(new i.Event("pitch",h))}_afterEase(h,_){if(this._easeId&&_&&this._easeId===_)return;delete this._easeId,this.fire(new i.Event("freezeElevation",{freeze:!1}));const T=this._zooming,F=this._rotating,O=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,T&&this.fire(new i.Event("zoomend",h)),F&&this.fire(new i.Event("rotateend",h)),O&&this.fire(new i.Event("pitchend",h)),this.fire(new i.Event("moveend",h))}flyTo(h,_){if(!h.essential&&i.exported.prefersReducedMotion){const Un=i.pick(h,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Un,_)}this.stop(),h=i.extend({offset:[0,0],speed:1.2,curve:1.42,easing:i.ease},h);const T=this.transform,F=this.getZoom(),O=this.getBearing(),K=this.getPitch(),oe=this.getPadding(),ue="zoom"in h?i.clamp(+h.zoom,T.minZoom,T.maxZoom):F,ve="bearing"in h?this._normalizeBearing(h.bearing,O):O,Te="pitch"in h?+h.pitch:K,ze="padding"in h?h.padding:T.padding,je=T.zoomScale(ue-F),bt=i.pointGeometry.convert(h.offset);let mt=T.centerPoint.add(bt);const gt=T.pointLocation(mt),Vt=i.LngLat.convert(h.center||gt);this._normalizeCenter(Vt);const Zt=T.project(gt),ni=T.project(Vt).sub(Zt);let St=h.curve;const zt=Math.max(T.width,T.height),ai=zt/je,Ei=ni.mag();if("minZoom"in h){const Un=i.clamp(Math.min(h.minZoom,F,ue),T.minZoom,T.maxZoom),Lr=zt/T.zoomScale(Un-F);St=Math.sqrt(Lr/Ei*2)}const Bi=St*St;function Hi(Un){const Lr=(ai*ai-zt*zt+(Un?-1:1)*Bi*Bi*Ei*Ei)/(2*(Un?ai:zt)*Bi*Ei);return Math.log(Math.sqrt(Lr*Lr+1)-Lr)}function vi(Un){return(Math.exp(Un)-Math.exp(-Un))/2}function xn(Un){return(Math.exp(Un)+Math.exp(-Un))/2}const cn=Hi(0);let Bn=function(Un){return xn(cn)/xn(cn+St*Un)},tr=function(Un){return zt*((xn(cn)*(vi(Lr=cn+St*Un)/xn(Lr))-vi(cn))/Bi)/Ei;var Lr},ur=(Hi(1)-cn)/St;if(Math.abs(Ei)<1e-6||!isFinite(ur)){if(Math.abs(zt-ai)<1e-6)return this.easeTo(h,_);const Un=aih.maxDuration&&(h.duration=0),this._zooming=!0,this._rotating=O!==ve,this._pitching=Te!==K,this._padding=!T.isPaddingEqual(ze),this._prepareEase(_,!1),this._ease(Un=>{const Lr=Un*ur,Rr=1/Bn(Lr);T.zoom=Un===1?ue:F+T.scaleZoom(Rr),this._rotating&&(T.bearing=i.number(O,ve,Un)),this._pitching&&(T.pitch=i.number(K,Te,Un)),this._padding&&(T.interpolatePadding(oe,ze,Un),mt=T.centerPoint.add(bt));const Cr=Un===1?Vt:T.unproject(Zt.add(ni.mult(tr(Lr))).mult(Rr));T.setLocationAtPoint(T.renderWorldCopies?Cr.wrap():Cr,mt),this._fireMoveEvents(_)},()=>this._afterEase(_),h),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(h,_){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const T=this._onEaseEnd;delete this._onEaseEnd,T.call(this,_)}if(!h){const T=this.handlers;T&&T.stop(!1)}return this}_ease(h,_,T){T.animate===!1||T.duration===0?(h(1),_()):(this._easeStart=i.exported.now(),this._easeOptions=T,this._onEaseFrame=h,this._onEaseEnd=_,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const h=Math.min((i.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(h)),h<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(h,_){h=i.wrap(h,-180,180);const T=Math.abs(h-_);return Math.abs(h-360-_)180?-360:T<-180?360:0}}class nh{constructor(h={}){this.options=h,i.bindAll(["_toggleAttribution","_updateData","_updateCompact","_updateCompactMinimize"],this)}getDefaultPosition(){return"bottom-right"}onAdd(h){return this._map=h,this._compact=this.options&&this.options.compact,this._container=z.create("details","maplibregl-ctrl maplibregl-ctrl-attrib mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=z.create("summary","maplibregl-ctrl-attrib-button mapboxgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=z.create("div","maplibregl-ctrl-attrib-inner mapboxgl-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(){z.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(h,_){const T=this._map._getUIString(`AttributionControl.${_}`);h.title=T,h.setAttribute("aria-label",T)}_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","mapboxgl-compact-show")):(this._container.classList.add("maplibregl-compact-show","mapboxgl-compact-show"),this._container.removeAttribute("open")))}_updateData(h){!h||h.sourceDataType!=="metadata"&&h.sourceDataType!=="visibility"&&h.dataType!=="style"&&h.type!=="terrain"||this._updateAttributions()}_updateAttributions(){if(!this._map.style)return;let h=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?h=h.concat(this.options.customAttribution.map(F=>typeof F!="string"?"":F)):typeof this.options.customAttribution=="string"&&h.push(this.options.customAttribution)),this._map.style.stylesheet){const F=this._map.style.stylesheet;this.styleOwner=F.owner,this.styleId=F.id}const _=this._map.style.sourceCaches;for(const F in _){const O=_[F];if(O.used||O.usedForTerrain){const K=O.getSource();K.attribution&&h.indexOf(K.attribution)<0&&h.push(K.attribution)}}h=h.filter(F=>String(F).trim()),h.sort((F,O)=>F.length-O.length),h=h.filter((F,O)=>{for(let K=O+1;K=0)return!1;return!0});const T=h.join(" | ");T!==this._attribHTML&&(this._attribHTML=T,h.length?(this._innerContainer.innerHTML=T,this._container.classList.remove("maplibregl-attrib-empty","mapboxgl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty","mapboxgl-attrib-empty"),this._updateCompact(),this._editLink=null)}_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","mapboxgl-compact","maplibregl-compact-show","mapboxgl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show","mapboxgl-compact","mapboxgl-compact-show"))}_updateCompactMinimize(){this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show")}}class Wh{constructor(h={}){this.options=h,i.bindAll(["_updateCompact"],this)}getDefaultPosition(){return"bottom-left"}onAdd(h){this._map=h,this._compact=this.options&&this.options.compact,this._container=z.create("div","maplibregl-ctrl mapboxgl-ctrl");const _=z.create("a","maplibregl-ctrl-logo mapboxgl-ctrl-logo");return _.target="_blank",_.rel="noopener nofollow",_.href="https://maplibre.org/",_.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),_.setAttribute("rel","noopener nofollow"),this._container.appendChild(_),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){z.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}_updateCompact(){const h=this._container.children;if(h.length){const _=h[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&_.classList.add("maplibregl-compact","mapboxgl-compact"):_.classList.remove("maplibregl-compact","mapboxgl-compact")}}}class xc{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(h){const _=++this._id;return this._queue.push({callback:h,id:_,cancelled:!1}),_}remove(h){const _=this._currentlyRunning,T=_?this._queue.concat(_):this._queue;for(const F of T)if(F.id===h)return void(F.cancelled=!0)}run(h=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const _=this._currentlyRunning=this._queue;this._queue=[];for(const T of _)if(!T.cancelled&&(T.callback(h),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}const AA={"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"},jh={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:void 0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",transformRequest:null,fadeDuration:300,crossSourceCollisions:!0},rh={showCompass:!0,showZoom:!0,visualizePitch:!1};class uo{constructor(h,_,T=!1){this._clickTolerance=10,this.element=_,this.mouseRotate=new ha({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,T&&(this.mousePitch=new pn({clickTolerance:h.dragRotate._mousePitch._clickTolerance})),i.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),z.addEventListener(_,"mousedown",this.mousedown),z.addEventListener(_,"touchstart",this.touchstart,{passive:!1}),z.addEventListener(_,"touchmove",this.touchmove),z.addEventListener(_,"touchend",this.touchend),z.addEventListener(_,"touchcancel",this.reset)}down(h,_){this.mouseRotate.mousedown(h,_),this.mousePitch&&this.mousePitch.mousedown(h,_),z.disableDrag()}move(h,_){const T=this.map,F=this.mouseRotate.mousemoveWindow(h,_);if(F&&F.bearingDelta&&T.setBearing(T.getBearing()+F.bearingDelta),this.mousePitch){const O=this.mousePitch.mousemoveWindow(h,_);O&&O.pitchDelta&&T.setPitch(T.getPitch()+O.pitchDelta)}}off(){const h=this.element;z.removeEventListener(h,"mousedown",this.mousedown),z.removeEventListener(h,"touchstart",this.touchstart,{passive:!1}),z.removeEventListener(h,"touchmove",this.touchmove),z.removeEventListener(h,"touchend",this.touchend),z.removeEventListener(h,"touchcancel",this.reset),this.offTemp()}offTemp(){z.enableDrag(),z.removeEventListener(window,"mousemove",this.mousemove),z.removeEventListener(window,"mouseup",this.mouseup)}mousedown(h){this.down(i.extend({},h,{ctrlKey:!0,preventDefault:()=>h.preventDefault()}),z.mousePos(this.element,h)),z.addEventListener(window,"mousemove",this.mousemove),z.addEventListener(window,"mouseup",this.mouseup)}mousemove(h){this.move(h,z.mousePos(this.element,h))}mouseup(h){this.mouseRotate.mouseupWindow(h),this.mousePitch&&this.mousePitch.mouseupWindow(h),this.offTemp()}touchstart(h){h.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=z.touchPos(this.element,h.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>h.preventDefault()},this._startPos))}touchmove(h){h.targetTouches.length!==1?this.reset():(this._lastPos=z.touchPos(this.element,h.targetTouches)[0],this.move({preventDefault:()=>h.preventDefault()},this._lastPos))}touchend(h){h.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)180;){const T=_.locationPoint(M);if(T.x>=0&&T.y>=0&&T.x<=_.width&&T.y<=_.height)break;M.lng>_.center.lng?M.lng-=360:M.lng+=360}return M}const Fn={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 Vn(M,h,_){const T=M.classList;for(const F in Fn)T.remove(`maplibregl-${_}-anchor-${F}`,`mapboxgl-${_}-anchor-${F}`);T.add(`maplibregl-${_}-anchor-${h}`,`mapboxgl-${_}-anchor-${h}`)}class sh extends i.Evented{constructor(h,_){if(super(),(h instanceof HTMLElement||_)&&(h=i.extend({element:h},_)),i.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress"],this),this._anchor=h&&h.anchor||"center",this._color=h&&h.color||"#3FB1CE",this._scale=h&&h.scale||1,this._draggable=h&&h.draggable||!1,this._clickTolerance=h&&h.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=h&&h.rotation||0,this._rotationAlignment=h&&h.rotationAlignment||"auto",this._pitchAlignment=h&&h.pitchAlignment&&h.pitchAlignment!=="auto"?h.pitchAlignment:this._rotationAlignment,h&&h.element)this._element=h.element,this._offset=i.pointGeometry.convert(h&&h.offset||[0,0]);else{this._defaultMarker=!0,this._element=z.create("div"),this._element.setAttribute("aria-label","Map marker");const T=z.createNS("http://www.w3.org/2000/svg","svg"),F=41,O=27;T.setAttributeNS(null,"display","block"),T.setAttributeNS(null,"height",`${F}px`),T.setAttributeNS(null,"width",`${O}px`),T.setAttributeNS(null,"viewBox",`0 0 ${O} ${F}`);const K=z.createNS("http://www.w3.org/2000/svg","g");K.setAttributeNS(null,"stroke","none"),K.setAttributeNS(null,"stroke-width","1"),K.setAttributeNS(null,"fill","none"),K.setAttributeNS(null,"fill-rule","evenodd");const oe=z.createNS("http://www.w3.org/2000/svg","g");oe.setAttributeNS(null,"fill-rule","nonzero");const ue=z.createNS("http://www.w3.org/2000/svg","g");ue.setAttributeNS(null,"transform","translate(3.0, 29.0)"),ue.setAttributeNS(null,"fill","#000000");const ve=[{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 ni of ve){const St=z.createNS("http://www.w3.org/2000/svg","ellipse");St.setAttributeNS(null,"opacity","0.04"),St.setAttributeNS(null,"cx","10.5"),St.setAttributeNS(null,"cy","5.80029008"),St.setAttributeNS(null,"rx",ni.rx),St.setAttributeNS(null,"ry",ni.ry),ue.appendChild(St)}const Te=z.createNS("http://www.w3.org/2000/svg","g");Te.setAttributeNS(null,"fill",this._color);const ze=z.createNS("http://www.w3.org/2000/svg","path");ze.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"),Te.appendChild(ze);const je=z.createNS("http://www.w3.org/2000/svg","g");je.setAttributeNS(null,"opacity","0.25"),je.setAttributeNS(null,"fill","#000000");const bt=z.createNS("http://www.w3.org/2000/svg","path");bt.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"),je.appendChild(bt);const mt=z.createNS("http://www.w3.org/2000/svg","g");mt.setAttributeNS(null,"transform","translate(6.0, 7.0)"),mt.setAttributeNS(null,"fill","#FFFFFF");const gt=z.createNS("http://www.w3.org/2000/svg","g");gt.setAttributeNS(null,"transform","translate(8.0, 8.0)");const Vt=z.createNS("http://www.w3.org/2000/svg","circle");Vt.setAttributeNS(null,"fill","#000000"),Vt.setAttributeNS(null,"opacity","0.25"),Vt.setAttributeNS(null,"cx","5.5"),Vt.setAttributeNS(null,"cy","5.5"),Vt.setAttributeNS(null,"r","5.4999962");const Zt=z.createNS("http://www.w3.org/2000/svg","circle");Zt.setAttributeNS(null,"fill","#FFFFFF"),Zt.setAttributeNS(null,"cx","5.5"),Zt.setAttributeNS(null,"cy","5.5"),Zt.setAttributeNS(null,"r","5.4999962"),gt.appendChild(Vt),gt.appendChild(Zt),oe.appendChild(ue),oe.appendChild(Te),oe.appendChild(je),oe.appendChild(mt),oe.appendChild(gt),T.appendChild(oe),T.setAttributeNS(null,"height",F*this._scale+"px"),T.setAttributeNS(null,"width",O*this._scale+"px"),this._element.appendChild(T),this._offset=i.pointGeometry.convert(h&&h.offset||[0,-14])}this._element.classList.add("maplibregl-marker","mapboxgl-marker"),this._element.addEventListener("dragstart",T=>{T.preventDefault()}),this._element.addEventListener("mousedown",T=>{T.preventDefault()}),Vn(this._element,this._anchor,"marker"),this._popup=null}addTo(h){return this.remove(),this._map=h,h.getCanvasContainer().appendChild(this._element),h.on("move",this._update),h.on("moveend",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),z.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=i.LngLat.convert(h),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(h){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),h){if(!("offset"in h.options)){const F=Math.sqrt(Math.pow(13.5,2)/2);h.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[F,-1*(38.1-13.5+F)],"bottom-right":[-F,-1*(38.1-13.5+F)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=h,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}_onKeyPress(h){const _=h.code,T=h.charCode||h.keyCode;_!=="Space"&&_!=="Enter"&&T!==32&&T!==13||this.togglePopup()}_onMapClick(h){const _=h.originalEvent.target,T=this._element;this._popup&&(_===T||T.contains(_))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const h=this._popup;return h?(h.isOpen()?h.remove():h.addTo(this._map),this):this}_update(h){if(!this._map)return;this._map.transform.renderWorldCopies&&(this._lngLat=Js(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._offset);let _="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?_=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(_=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let T="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?T="rotateX(0deg)":this._pitchAlignment==="map"&&(T=`rotateX(${this._map.getPitch()}deg)`),h&&h.type!=="moveend"||(this._pos=this._pos.round()),z.setTransform(this._element,`${Fn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${T} ${_}`),this._map.style&&this._map.style.terrain&&!this._opacityTimeout&&(this._opacityTimeout=setTimeout(()=>{const F=this._map.unproject(this._pos),O=40075016686e-3*Math.abs(Math.cos(this._lngLat.lat*Math.PI/180))/Math.pow(2,this._map.transform.tileZoom+8);this._element.style.opacity=F.distanceTo(this._lngLat)>20*O?"0.2":"1.0",this._opacityTimeout=null},100))}getOffset(){return this._offset}setOffset(h){return this._offset=i.pointGeometry.convert(h),this._update(),this}_onMove(h){if(!this._isDragging){const _=this._clickTolerance||this._map._clickTolerance;this._isDragging=h.point.dist(this._pointerdownPos)>=_}this._isDragging&&(this._pos=h.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 i.Event("dragstart"))),this.fire(new i.Event("drag")))}_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 i.Event("dragend")),this._state="inactive"}_addDragHandler(h){this._element.contains(h.originalEvent.target)&&(h.preventDefault(),this._positionDelta=h.point.sub(this._pos).add(this._offset),this._pointerdownPos=h.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))}setDraggable(h){return this._draggable=!!h,this._map&&(h?(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(h){return this._rotation=h||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(h){return this._rotationAlignment=h||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(h){return this._pitchAlignment=h&&h!=="auto"?h:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const dA={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let yl,Cs=0,Ga=!1;const Go={maxWidth:100,unit:"metric"};function pA(M,h,_){const T=_&&_.maxWidth||100,F=M._container.clientHeight/2,O=M.unproject([0,F]),K=M.unproject([T,F]),oe=O.distanceTo(K);if(_&&_.unit==="imperial"){const ue=3.2808*oe;ue>5280?va(h,T,ue/5280,M._getUIString("ScaleControl.Miles")):va(h,T,ue,M._getUIString("ScaleControl.Feet"))}else _&&_.unit==="nautical"?va(h,T,oe/1852,M._getUIString("ScaleControl.NauticalMiles")):oe>=1e3?va(h,T,oe/1e3,M._getUIString("ScaleControl.Kilometers")):va(h,T,oe,M._getUIString("ScaleControl.Meters"))}function va(M,h,_,T){const F=function(O){const K=Math.pow(10,`${Math.floor(O)}`.length-1);let oe=O/K;return oe=oe>=10?10:oe>=5?5:oe>=3?3:oe>=2?2:oe>=1?1:function(ue){const ve=Math.pow(10,Math.ceil(-Math.log(ue)/Math.LN10));return Math.round(ue*ve)/ve}(oe),K*oe}(_);M.style.width=h*(F/_)+"px",M.innerHTML=`${F} ${T}`}const hs={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Is=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Kh(M){if(M){if(typeof M=="number"){const h=Math.round(Math.sqrt(.5*Math.pow(M,2)));return{center:new i.pointGeometry(0,0),top:new i.pointGeometry(0,M),"top-left":new i.pointGeometry(h,h),"top-right":new i.pointGeometry(-h,h),bottom:new i.pointGeometry(0,-M),"bottom-left":new i.pointGeometry(h,-h),"bottom-right":new i.pointGeometry(-h,-h),left:new i.pointGeometry(M,0),right:new i.pointGeometry(-M,0)}}if(M instanceof i.pointGeometry||Array.isArray(M)){const h=i.pointGeometry.convert(M);return{center:h,top:h,"top-left":h,"top-right":h,bottom:h,"bottom-left":h,"bottom-right":h,left:h,right:h}}return{center:i.pointGeometry.convert(M.center||[0,0]),top:i.pointGeometry.convert(M.top||[0,0]),"top-left":i.pointGeometry.convert(M["top-left"]||[0,0]),"top-right":i.pointGeometry.convert(M["top-right"]||[0,0]),bottom:i.pointGeometry.convert(M.bottom||[0,0]),"bottom-left":i.pointGeometry.convert(M["bottom-left"]||[0,0]),"bottom-right":i.pointGeometry.convert(M["bottom-right"]||[0,0]),left:i.pointGeometry.convert(M.left||[0,0]),right:i.pointGeometry.convert(M.right||[0,0])}}return Kh(new i.pointGeometry(0,0))}const xl={supported:C,setRTLTextPlugin:i.setRTLTextPlugin,getRTLTextPluginStatus:i.getRTLTextPluginStatus,Map:class extends Zr{constructor(M){var h;if(i.PerformanceUtils.mark(i.PerformanceMarkers.create),(M=i.extend({},jh,M)).minZoom!=null&&M.maxZoom!=null&&M.minZoom>M.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(M.minPitch!=null&&M.maxPitch!=null&&M.minPitch>M.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(M.minPitch!=null&&M.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(M.maxPitch!=null&&M.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new qc(M.minZoom,M.maxZoom,M.minPitch,M.maxPitch,M.renderWorldCopies),{bearingSnap:M.bearingSnap}),this._interactive=M.interactive,this._cooperativeGestures=M.cooperativeGestures,this._maxTileCacheSize=M.maxTileCacheSize,this._failIfMajorPerformanceCaveat=M.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=M.preserveDrawingBuffer,this._antialias=M.antialias,this._trackResize=M.trackResize,this._bearingSnap=M.bearingSnap,this._refreshExpiredTiles=M.refreshExpiredTiles,this._fadeDuration=M.fadeDuration,this._crossSourceCollisions=M.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=M.collectResourceTiming,this._renderTaskQueue=new xc,this._controls=[],this._mapId=i.uniqueId(),this._locale=i.extend({},AA,M.locale),this._clickTolerance=M.clickTolerance,this._pixelRatio=(h=M.pixelRatio)!==null&&h!==void 0?h:devicePixelRatio,this._requestManager=new G(M.transformRequest),typeof M.container=="string"){if(this._container=document.getElementById(M.container),!this._container)throw new Error(`Container '${M.container}' not found.`)}else{if(!(M.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=M.container}if(M.maxBounds&&this.setMaxBounds(M.maxBounds),i.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),typeof window<"u"&&(addEventListener("online",this._onWindowOnline,!1),addEventListener("resize",this._onWindowResize,!1),addEventListener("orientationchange",this._onWindowResize,!1)),this.handlers=new An(this,M),this._cooperativeGestures&&this._setupCooperativeGestures(),this._hash=M.hash&&new Uh(typeof M.hash=="string"&&M.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:M.center,zoom:M.zoom,bearing:M.bearing,pitch:M.pitch}),M.bounds&&(this.resize(),this.fitBounds(M.bounds,i.extend({},M.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=M.localIdeographFontFamily,M.style&&this.setStyle(M.style,{localIdeographFontFamily:M.localIdeographFontFamily}),M.attributionControl&&this.addControl(new nh({customAttribution:M.customAttribution})),M.maplibreLogo&&this.addControl(new Wh,M.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",_=>{this._update(_.dataType==="style"),this.fire(new i.Event(`${_.dataType}data`,_))}),this.on("dataloading",_=>{this.fire(new i.Event(`${_.dataType}dataloading`,_))}),this.on("dataabort",_=>{this.fire(new i.Event("sourcedataabort",_))})}_getMapId(){return this._mapId}addControl(M,h){if(h===void 0&&(h=M.getDefaultPosition?M.getDefaultPosition():"top-right"),!M||!M.onAdd)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const _=M.onAdd(this);this._controls.push(M);const T=this._controlPositions[h];return h.indexOf("bottom")!==-1?T.insertBefore(_,T.firstChild):T.appendChild(_),this}removeControl(M){if(!M||!M.onRemove)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const h=this._controls.indexOf(M);return h>-1&&this._controls.splice(h,1),M.onRemove(this),this}hasControl(M){return this._controls.indexOf(M)>-1}calculateCameraOptionsFromTo(M,h,_,T){return T==null&&this.style.terrain&&(T=this.transform.getElevation(_,this.style.terrain)),super.calculateCameraOptionsFromTo(M,h,_,T)}resize(M){const h=this._containerDimensions(),_=h[0],T=h[1];this._resizeCanvas(_,T,this.getPixelRatio()),this.transform.resize(_,T),this.painter.resize(_,T,this.getPixelRatio());const F=!this._moving;return F&&(this.stop(),this.fire(new i.Event("movestart",M)).fire(new i.Event("move",M))),this.fire(new i.Event("resize",M)),F&&this.fire(new i.Event("moveend",M)),this}getPixelRatio(){return this._pixelRatio}setPixelRatio(M){const[h,_]=this._containerDimensions();this._pixelRatio=M,this._resizeCanvas(h,_,M),this.painter.resize(h,_,M)}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(M){return this.transform.setMaxBounds(i.LngLatBounds.convert(M)),this._update()}setMinZoom(M){if((M=M==null?-2:M)>=-2&&M<=this.transform.maxZoom)return this.transform.minZoom=M,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=M,this._update(),this.getZoom()>M&&this.setZoom(M),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(M){if((M=M==null?0:M)<0)throw new Error("minPitch must be greater than or equal to 0");if(M>=0&&M<=this.transform.maxPitch)return this.transform.minPitch=M,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(M>=this.transform.minPitch)return this.transform.maxPitch=M,this._update(),this.getPitch()>M&&this.setPitch(M),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(M){return this.transform.renderWorldCopies=M,this._update()}project(M){return this.transform.locationPoint(i.LngLat.convert(M),this.style&&this.style.terrain)}unproject(M){return this.transform.pointLocation(i.pointGeometry.convert(M),this.style&&this.style.terrain)}isMoving(){return this._moving||this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers.isRotating()}_createDelegatedListener(M,h,_){if(M==="mouseenter"||M==="mouseover"){let T=!1;return{layer:h,listener:_,delegates:{mousemove:O=>{const K=this.getLayer(h)?this.queryRenderedFeatures(O.point,{layers:[h]}):[];K.length?T||(T=!0,_.call(this,new So(M,this,O.originalEvent,{features:K}))):T=!1},mouseout:()=>{T=!1}}}}if(M==="mouseleave"||M==="mouseout"){let T=!1;return{layer:h,listener:_,delegates:{mousemove:K=>{(this.getLayer(h)?this.queryRenderedFeatures(K.point,{layers:[h]}):[]).length?T=!0:T&&(T=!1,_.call(this,new So(M,this,K.originalEvent)))},mouseout:K=>{T&&(T=!1,_.call(this,new So(M,this,K.originalEvent)))}}}}{const T=F=>{const O=this.getLayer(h)?this.queryRenderedFeatures(F.point,{layers:[h]}):[];O.length&&(F.features=O,_.call(this,F),delete F.features)};return{layer:h,listener:_,delegates:{[M]:T}}}}on(M,h,_){if(_===void 0)return super.on(M,h);const T=this._createDelegatedListener(M,h,_);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[M]=this._delegatedListeners[M]||[],this._delegatedListeners[M].push(T);for(const F in T.delegates)this.on(F,T.delegates[F]);return this}once(M,h,_){if(_===void 0)return super.once(M,h);const T=this._createDelegatedListener(M,h,_);for(const F in T.delegates)this.once(F,T.delegates[F]);return this}off(M,h,_){return _===void 0?super.off(M,h):(this._delegatedListeners&&this._delegatedListeners[M]&&(T=>{const F=this._delegatedListeners[M];for(let O=0;O{T?this.fire(new i.ErrorEvent(T)):F&&this._updateDiff(F,h)})}else typeof M=="object"&&this._updateDiff(M,h)}_updateDiff(M,h){try{this.style.setState(M)&&this._update(!0)}catch(_){i.warnOnce(`Unable to perform style diff: ${_.message||_.error||_}. Rebuilding the style from scratch.`),this._updateStyle(M,h)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():i.warnOnce("There is no style added to the map.")}addSource(M,h){return this._lazyInitEmptyStyle(),this.style.addSource(M,h),this._update(!0)}isSourceLoaded(M){const h=this.style&&this.style.sourceCaches[M];if(h!==void 0)return h.loaded();this.fire(new i.ErrorEvent(new Error(`There is no source with ID '${M}'`)))}setTerrain(M){return this.style.setTerrain(M),this}getTerrain(){return this.style.terrain&&this.style.terrain.options}areTilesLoaded(){const M=this.style&&this.style.sourceCaches;for(const h in M){const _=M[h]._tiles;for(const T in _){const F=_[T];if(F.state!=="loaded"&&F.state!=="errored")return!1}}return!0}addSourceType(M,h,_){return this._lazyInitEmptyStyle(),this.style.addSourceType(M,h,_)}removeSource(M){return this.style.removeSource(M),this._update(!0)}getSource(M){return this.style.getSource(M)}addImage(M,h,{pixelRatio:_=1,sdf:T=!1,stretchX:F,stretchY:O,content:K}={}){if(this._lazyInitEmptyStyle(),h instanceof HTMLImageElement||i.isImageBitmap(h)){const{width:oe,height:ue,data:ve}=i.exported.getImageData(h);this.style.addImage(M,{data:new i.RGBAImage({width:oe,height:ue},ve),pixelRatio:_,stretchX:F,stretchY:O,content:K,sdf:T,version:0})}else{if(h.width===void 0||h.height===void 0)return this.fire(new i.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:oe,height:ue,data:ve}=h,Te=h;this.style.addImage(M,{data:new i.RGBAImage({width:oe,height:ue},new Uint8Array(ve)),pixelRatio:_,stretchX:F,stretchY:O,content:K,sdf:T,version:0,userImage:Te}),Te.onAdd&&Te.onAdd(this,M)}}}updateImage(M,h){const _=this.style.getImage(M);if(!_)return this.fire(new i.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const T=h instanceof HTMLImageElement||i.isImageBitmap(h)?i.exported.getImageData(h):h,{width:F,height:O,data:K}=T;if(F===void 0||O===void 0)return this.fire(new i.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(F!==_.data.width||O!==_.data.height)return this.fire(new i.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image")));const oe=!(h instanceof HTMLImageElement||i.isImageBitmap(h));_.data.replace(K,oe),this.style.updateImage(M,_)}hasImage(M){return M?!!this.style.getImage(M):(this.fire(new i.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(M){this.style.removeImage(M)}loadImage(M,h){i.getImage(this._requestManager.transformRequest(M,i.ResourceType.Image),h)}listImages(){return this.style.listImages()}addLayer(M,h){return this._lazyInitEmptyStyle(),this.style.addLayer(M,h),this._update(!0)}moveLayer(M,h){return this.style.moveLayer(M,h),this._update(!0)}removeLayer(M){return this.style.removeLayer(M),this._update(!0)}getLayer(M){return this.style.getLayer(M)}setLayerZoomRange(M,h,_){return this.style.setLayerZoomRange(M,h,_),this._update(!0)}setFilter(M,h,_={}){return this.style.setFilter(M,h,_),this._update(!0)}getFilter(M){return this.style.getFilter(M)}setPaintProperty(M,h,_,T={}){return this.style.setPaintProperty(M,h,_,T),this._update(!0)}getPaintProperty(M,h){return this.style.getPaintProperty(M,h)}setLayoutProperty(M,h,_,T={}){return this.style.setLayoutProperty(M,h,_,T),this._update(!0)}getLayoutProperty(M,h){return this.style.getLayoutProperty(M,h)}setLight(M,h={}){return this._lazyInitEmptyStyle(),this.style.setLight(M,h),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(M,h){return this.style.setFeatureState(M,h),this._update()}removeFeatureState(M,h){return this.style.removeFeatureState(M,h),this._update()}getFeatureState(M){return this.style.getFeatureState(M)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let M=0,h=0;return this._container&&(M=this._container.clientWidth||400,h=this._container.clientHeight||300),[M,h]}_setupContainer(){const M=this._container;M.classList.add("maplibregl-map","mapboxgl-map");const h=this._canvasContainer=z.create("div","maplibregl-canvas-container mapboxgl-canvas-container",M);this._interactive&&h.classList.add("maplibregl-interactive","mapboxgl-interactive"),this._canvas=z.create("canvas","maplibregl-canvas mapboxgl-canvas",h),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 _=this._containerDimensions();this._resizeCanvas(_[0],_[1],this.getPixelRatio());const T=this._controlContainer=z.create("div","maplibregl-control-container mapboxgl-control-container",M),F=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(O=>{F[O]=z.create("div",`maplibregl-ctrl-${O} mapboxgl-ctrl-${O}`,T)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_setupCooperativeGestures(){const M=this._container;this._metaPress=!1,this._cooperativeGesturesScreen=z.create("div","maplibregl-cooperative-gesture-screen",M);let h="Control",_=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.windowsHelpText?this._cooperativeGestures.windowsHelpText:"Use Ctrl + scroll to zoom the map";navigator.platform.indexOf("Mac")===0&&(_=typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.macHelpText?this._cooperativeGestures.macHelpText:"Use \u2318 + scroll to zoom the map",h="Meta"),this._cooperativeGesturesScreen.innerHTML=`
${_}
${typeof this._cooperativeGestures!="boolean"&&this._cooperativeGestures.mobileHelpText?this._cooperativeGestures.mobileHelpText:"Use two fingers to move the map"}
`,document.addEventListener("keydown",T=>{T.key===h&&(this._metaPress=!0)}),document.addEventListener("keyup",T=>{T.key===h&&(this._metaPress=!1)}),this._canvasContainer.addEventListener("wheel",T=>{this._onCooperativeGesture(T,this._metaPress,1)},!1),this._canvasContainer.classList.remove("mapboxgl-touch-drag-pan","maplibregl-touch-drag-pan")}_resizeCanvas(M,h,_){this._canvas.width=_*M,this._canvas.height=_*h,this._canvas.style.width=`${M}px`,this._canvas.style.height=`${h}px`}_setupPainter(){const M=i.extend({},C.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),h=this._canvas.getContext("webgl",M)||this._canvas.getContext("experimental-webgl",M);h?(this.painter=new wu(h,this.transform),i.exported$1.testSupport(h)):this.fire(new i.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(M){M.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.Event("webglcontextlost",{originalEvent:M}))}_contextRestored(M){this._setupPainter(),this.resize(),this._update(),this.fire(new i.Event("webglcontextrestored",{originalEvent:M}))}_onMapScroll(M){if(M.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}_onCooperativeGesture(M,h,_){return!h&&_<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(M){return this.style?(this._styleDirty=this._styleDirty||M,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(M){return this._update(),this._renderTaskQueue.add(M)}_cancelRenderFrame(M){this._renderTaskQueue.remove(M)}_render(M){let h,_=0;const T=this.painter.context.extTimerQuery;if(this.listens("gpu-timing-frame")&&(h=T.createQueryEXT(),T.beginQueryEXT(T.TIME_ELAPSED_EXT,h),_=i.exported.now()),this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(M),this._removed)return;let F=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const K=this.transform.zoom,oe=i.exported.now();this.style.zoomHistory.update(K,oe);const ue=new i.EvaluationParameters(K,{now:oe,fadeDuration:this._fadeDuration,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),ve=ue.crossFadingFactor();ve===1&&ve===this._crossFadingFactor||(F=!0,this._crossFadingFactor=ve),this.style.update(ue)}if(this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.style.terrain&&this.style.terrain.sourceCache.update(this.transform,this.style.terrain),this.transform.updateElevation(this.style.terrain),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,this._fadeDuration,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:this._fadeDuration,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer")}),this.fire(new i.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,i.PerformanceUtils.mark(i.PerformanceMarkers.load),this.fire(new i.Event("load"))),this.style&&(this.style.hasTransitions()||F)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const K=i.exported.now()-_;T.endQueryEXT(T.TIME_ELAPSED_EXT,h),setTimeout(()=>{const oe=T.getQueryObjectEXT(h,T.QUERY_RESULT_EXT)/1e6;T.deleteQueryEXT(h),this.fire(new i.Event("gpu-timing-frame",{cpuTime:K,gpuTime:oe}))},50)}if(this.listens("gpu-timing-layer")){const K=this.painter.collectGpuTimers();setTimeout(()=>{const oe=this.painter.queryGpuTimers(K);this.fire(new i.Event("gpu-timing-layer",{layerTimes:oe}))},50)}const O=this._sourcesDirty||this._styleDirty||this._placementDirty;return O||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new i.Event("idle")),!this._loaded||this._fullyLoaded||O||(this._fullyLoaded=!0,i.PerformanceUtils.mark(i.PerformanceMarkers.fullLoad)),this}redraw(){return this.style&&(this._frame&&(this._frame.cancel(),this._frame=null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(const h of this._controls)h.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("resize",this._onWindowResize,!1),removeEventListener("orientationchange",this._onWindowResize,!1),removeEventListener("online",this._onWindowOnline,!1));const M=this.painter.context.gl.getExtension("WEBGL_lose_context");M&&M.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),z.remove(this._canvasContainer),z.remove(this._controlContainer),this._cooperativeGestures&&z.remove(this._cooperativeGesturesScreen),this._container.classList.remove("maplibregl-map","mapboxgl-map"),i.PerformanceUtils.clearMetrics(),this._removed=!0,this.fire(new i.Event("remove"))}triggerRepaint(){this.style&&!this._frame&&(this._frame=i.exported.frame(M=>{i.PerformanceUtils.frame(M),this._frame=null,this._render(M)}))}_onWindowOnline(){this._update()}_onWindowResize(M){this._trackResize&&this.resize({originalEvent:M})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(M){this._showTileBoundaries!==M&&(this._showTileBoundaries=M,this._update())}get showPadding(){return!!this._showPadding}set showPadding(M){this._showPadding!==M&&(this._showPadding=M,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(M){this._showCollisionBoxes!==M&&(this._showCollisionBoxes=M,M?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(M){this._showOverdrawInspector!==M&&(this._showOverdrawInspector=M,this._update())}get repaint(){return!!this._repaint}set repaint(M){this._repaint!==M&&(this._repaint=M,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(M){this._vertices=M,this._update()}_setCacheLimits(M,h){i.setCacheLimits(M,h)}get version(){return"2.4.0"}},NavigationControl:class{constructor(M){this.options=i.extend({},rh,M),this._container=z.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",h=>h.preventDefault()),this.options.showZoom&&(i.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in mapboxgl-ctrl-zoom-in",h=>this._map.zoomIn({},{originalEvent:h})),z.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out mapboxgl-ctrl-zoom-out",h=>this._map.zoomOut({},{originalEvent:h})),z.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("maplibregl-ctrl-compass mapboxgl-ctrl-compass",h=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:h}):this._map.resetNorth({},{originalEvent:h})}),this._compassIcon=z.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const M=this._map.getZoom(),h=M===this._map.getMaxZoom(),_=M===this._map.getMinZoom();this._zoomInButton.disabled=h,this._zoomOutButton.disabled=_,this._zoomInButton.setAttribute("aria-disabled",h.toString()),this._zoomOutButton.setAttribute("aria-disabled",_.toString())}_rotateCompassArrow(){const M=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=M}onAdd(M){return this._map=M,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 uo(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){z.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(M,h){const _=z.create("button",M,this._container);return _.type="button",_.addEventListener("click",h),_}_setButtonTitle(M,h){const _=this._map._getUIString(`NavigationControl.${h}`);M.title=_,M.setAttribute("aria-label",_)}},GeolocateControl:class extends i.Evented{constructor(M){super(),this.options=i.extend({},dA,M),i.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker"],this)}onAdd(M){var h;return this._map=M,this._container=z.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),h=this._setupUI,yl!==void 0?h(yl):window.navigator.permissions!==void 0?window.navigator.permissions.query({name:"geolocation"}).then(_=>{yl=_.state!=="denied",h(yl)}):(yl=!!window.navigator.geolocation,h(yl)),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(),z.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Cs=0,Ga=!1}_isOutOfMapMaxBounds(M){const h=this._map.getMaxBounds(),_=M.coords;return h&&(_.longitudeh.getEast()||_.latitudeh.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_onSuccess(M){if(this._map){if(this._isOutOfMapMaxBounds(M))return this._setErrorState(),this.fire(new i.Event("outofmaxbounds",M)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=M,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(M),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(M),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new i.Event("geolocate",M)),this._finish()}}_updateCamera(M){const h=new i.LngLat(M.coords.longitude,M.coords.latitude),_=M.coords.accuracy,T=this._map.getBearing(),F=i.extend({bearing:T},this.options.fitBoundsOptions);this._map.fitBounds(h.toBounds(_),F,{geolocateSource:!0})}_updateMarker(M){if(M){const h=new i.LngLat(M.coords.longitude,M.coords.latitude);this._accuracyCircleMarker.setLngLat(h).addTo(this._map),this._userLocationDotMarker.setLngLat(h).addTo(this._map),this._accuracy=M.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const M=this._map._container.clientHeight/2,h=this._map.unproject([0,M]),_=this._map.unproject([1,M]),T=h.distanceTo(_),F=Math.ceil(2*this._accuracy/T);this._circleElement.style.width=`${F}px`,this._circleElement.style.height=`${F}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_onError(M){if(this._map){if(this.options.trackUserLocation)if(M.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=h,this._geolocateButton.setAttribute("aria-label",h),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(M.code===3&&Ga)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale","mapboxgl-user-location-dot-stale"),this.fire(new i.Event("error",M)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(M){if(this._container.addEventListener("contextmenu",h=>h.preventDefault()),this._geolocateButton=z.create("button","maplibregl-ctrl-geolocate mapboxgl-ctrl-geolocate",this._container),z.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",M===!1){i.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const h=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=h,this._geolocateButton.setAttribute("aria-label",h)}else{const h=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=h,this._geolocateButton.setAttribute("aria-label",h)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=z.create("div","maplibregl-user-location-dot mapboxgl-user-location-dot"),this._userLocationDotMarker=new sh(this._dotElement),this._circleElement=z.create("div","maplibregl-user-location-accuracy-circle mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new sh({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",h=>{h.geolocateSource||this._watchState!=="ACTIVE_LOCK"||h.originalEvent&&h.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this.fire(new i.Event("trackuserlocationend")))})}trigger(){if(!this._setup)return i.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Cs--,Ga=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error","mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error","mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background","mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.Event("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active","mapboxgl-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 M;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Cs++,Cs>1?(M={maximumAge:6e5,timeout:0},Ga=!0):(M=this.options.positionOptions,Ga=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,M)}}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","mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:nh,LogoControl:Wh,ScaleControl:class{constructor(M){this.options=i.extend({},Go,M),i.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){pA(this._map,this._container,this.options)}onAdd(M){return this._map=M,this._container=z.create("div","maplibregl-ctrl maplibregl-ctrl-scale mapboxgl-ctrl mapboxgl-ctrl-scale",M.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){z.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}setUnit(M){this.options.unit=M,pA(this._map,this._container,this.options)}},FullscreenControl:class{constructor(M){this._fullscreen=!1,M&&M.container&&(M.container instanceof HTMLElement?this._container=M.container:i.warnOnce("Full screen control 'container' must be a DOM element.")),i.bindAll(["_onClickFullscreen","_changeIcon"],this),"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(M){return this._map=M,this._container||(this._container=this._map.getContainer()),this._controlContainer=z.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){z.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled||document.webkitFullscreenEnabled)}_setupUI(){const M=this._fullscreenButton=z.create("button","maplibregl-ctrl-fullscreen mapboxgl-ctrl-fullscreen",this._controlContainer);z.create("span","maplibregl-ctrl-icon mapboxgl-ctrl-icon",M).setAttribute("aria-hidden","true"),M.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const M=this._getTitle();this._fullscreenButton.setAttribute("aria-label",M),this._fullscreenButton.title=M}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?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._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},TerrainControl:class{constructor(M){this.options=M,i.bindAll(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(M){return this._map=M,this._container=z.create("div","maplibregl-ctrl maplibregl-ctrl-group mapboxgl-ctrl mapboxgl-ctrl-group"),this._terrainButton=z.create("button","maplibregl-ctrl-terrain mapboxgl-ctrl-terrain",this._container),z.create("span","maplibregl-ctrl-icon mapboxgl-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(){z.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._map.style.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled","mapboxgl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.disableTerrain")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain","mapboxgl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.enableTerrain"))}},Popup:class extends i.Evented{constructor(M){super(),this.options=i.extend(Object.create(hs),M),i.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],this)}addTo(M){return this._map&&this.remove(),this._map=M,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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new i.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&z.remove(this._content),this._container&&(z.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 i.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(M){return this._lngLat=i.LngLat.convert(M),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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer","mapboxgl-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","mapboxgl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer","mapboxgl-track-pointer")),this}getElement(){return this._container}setText(M){return this.setDOMContent(document.createTextNode(M))}setHTML(M){const h=document.createDocumentFragment(),_=document.createElement("body");let T;for(_.innerHTML=M;T=_.firstChild,T;)h.appendChild(T);return this.setDOMContent(h)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(M){return this.options.maxWidth=M,this._update(),this}setDOMContent(M){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=z.create("div","maplibregl-popup-content mapboxgl-popup-content",this._container);return this._content.appendChild(M),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(M){this._container&&this._container.classList.add(M)}removeClassName(M){this._container&&this._container.classList.remove(M)}setOffset(M){return this.options.offset=M,this._update(),this}toggleClassName(M){if(this._container)return this._container.classList.toggle(M)}_createCloseButton(){this.options.closeButton&&(this._closeButton=z.create("button","maplibregl-popup-close-button mapboxgl-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))}_onMouseUp(M){this._update(M.point)}_onMouseMove(M){this._update(M.point)}_onDrag(M){this._update(M.point)}_update(M){if(!this._map||!this._lngLat&&!this._trackPointer||!this._content||(this._container||(this._container=z.create("div","maplibregl-popup mapboxgl-popup",this._map.getContainer()),this._tip=z.create("div","maplibregl-popup-tip mapboxgl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className&&this.options.className.split(" ").forEach(O=>this._container.classList.add(O)),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer","mapboxgl-popup-track-pointer")),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=Js(this._lngLat,this._pos,this._map.transform)),this._trackPointer&&!M))return;const h=this._pos=this._trackPointer&&M?M:this._map.project(this._lngLat);let _=this.options.anchor;const T=Kh(this.options.offset);if(!_){const O=this._container.offsetWidth,K=this._container.offsetHeight;let oe;oe=h.y+T.bottom.ythis._map.transform.height-K?["bottom"]:[],h.xthis._map.transform.width-O/2&&oe.push("right"),_=oe.length===0?"bottom":oe.join("-")}const F=h.add(T[_]).round();z.setTransform(this._container,`${Fn[_]} translate(${F.x}px,${F.y}px)`),Vn(this._container,_,"popup")}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const M=this._container.querySelector(Is);M&&M.focus()}_onClose(){this.remove()}},Marker:sh,Style:Mr,LngLat:i.LngLat,LngLatBounds:i.LngLatBounds,Point:i.pointGeometry,MercatorCoordinate:i.MercatorCoordinate,Evented:i.Evented,AJAXError:i.AJAXError,config:i.config,CanvasSource:Qe,GeoJSONSource:Re,ImageSource:We,RasterDEMTileSource:xe,RasterTileSource:le,VectorTileSource:te,VideoSource:Ve,prewarm:function(){fi().acquire(Ct)},clearPrewarmedResources:function(){const M=_i;M&&(M.isPreloaded()&&M.numActive()===1?(M.release(Ct),_i=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get version(){return"2.4.0"},get workerCount(){return Ft.workerCount},set workerCount(M){Ft.workerCount=M},get maxParallelImageRequests(){return i.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(M){i.config.MAX_PARALLEL_IMAGE_REQUESTS=M},clearStorage(M){i.clearTileCache(M)},workerUrl:"",addProtocol(M,h){i.config.REGISTERED_PROTOCOLS[M]=h},removeProtocol(M){delete i.config.REGISTERED_PROTOCOLS[M]}};return xs.extend(xl,{isSafari:i.isSafari,getPerformanceMetrics:i.PerformanceUtils.getPerformanceMetrics}),xl});var y=c;return y})})(Ml);const wR=Ml.exports,bR=SS({__proto__:null,default:wR},[Ml.exports]);var S_={Linear:{None:function(u){return u}},Quadratic:{In:function(u){return u*u},Out:function(u){return u*(2-u)},InOut:function(u){return(u*=2)<1?.5*u*u:-.5*(--u*(u-2)-1)}},Cubic:{In:function(u){return u*u*u},Out:function(u){return--u*u*u+1},InOut:function(u){return(u*=2)<1?.5*u*u*u:.5*((u-=2)*u*u+2)}},Quartic:{In:function(u){return u*u*u*u},Out:function(u){return 1- --u*u*u*u},InOut:function(u){return(u*=2)<1?.5*u*u*u*u:-.5*((u-=2)*u*u*u-2)}},Quintic:{In:function(u){return u*u*u*u*u},Out:function(u){return--u*u*u*u*u+1},InOut:function(u){return(u*=2)<1?.5*u*u*u*u*u:.5*((u-=2)*u*u*u*u+2)}},Sinusoidal:{In:function(u){return 1-Math.cos(u*Math.PI/2)},Out:function(u){return Math.sin(u*Math.PI/2)},InOut:function(u){return .5*(1-Math.cos(Math.PI*u))}},Exponential:{In:function(u){return u===0?0:Math.pow(1024,u-1)},Out:function(u){return u===1?1:1-Math.pow(2,-10*u)},InOut:function(u){return u===0?0:u===1?1:(u*=2)<1?.5*Math.pow(1024,u-1):.5*(-Math.pow(2,-10*(u-1))+2)}},Circular:{In:function(u){return 1-Math.sqrt(1-u*u)},Out:function(u){return Math.sqrt(1- --u*u)},InOut:function(u){return(u*=2)<1?-.5*(Math.sqrt(1-u*u)-1):.5*(Math.sqrt(1-(u-=2)*u)+1)}},Elastic:{In:function(u){return u===0?0:u===1?1:-Math.pow(2,10*(u-1))*Math.sin((u-1.1)*5*Math.PI)},Out:function(u){return u===0?0:u===1?1:Math.pow(2,-10*u)*Math.sin((u-.1)*5*Math.PI)+1},InOut:function(u){return u===0?0:u===1?1:(u*=2,u<1?-.5*Math.pow(2,10*(u-1))*Math.sin((u-1.1)*5*Math.PI):.5*Math.pow(2,-10*(u-1))*Math.sin((u-1.1)*5*Math.PI)+1)}},Back:{In:function(u){var e=1.70158;return u*u*((e+1)*u-e)},Out:function(u){var e=1.70158;return--u*u*((e+1)*u+e)+1},InOut:function(u){var e=2.5949095;return(u*=2)<1?.5*(u*u*((e+1)*u-e)):.5*((u-=2)*u*((e+1)*u+e)+2)}},Bounce:{In:function(u){return 1-S_.Bounce.Out(1-u)},Out:function(u){return u<1/2.75?7.5625*u*u:u<2/2.75?7.5625*(u-=1.5/2.75)*u+.75:u<2.5/2.75?7.5625*(u-=2.25/2.75)*u+.9375:7.5625*(u-=2.625/2.75)*u+.984375},InOut:function(u){return u<.5?S_.Bounce.In(u*2)*.5:S_.Bounce.Out(u*2-1)*.5+.5}}},x_;typeof self>"u"&&typeof process<"u"&&process.hrtime?x_=function(){var u=process.hrtime();return u[0]*1e3+u[1]/1e6}:typeof self<"u"&&self.performance!==void 0&&self.performance.now!==void 0?x_=self.performance.now.bind(self.performance):Date.now!==void 0?x_=Date.now:x_=function(){return new Date().getTime()};var Xp=x_,UM=function(){function u(){this._tweens={},this._tweensAddedDuringUpdate={}}return u.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},u.prototype.removeAll=function(){this._tweens={}},u.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},u.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},u.prototype.update=function(e,t){e===void 0&&(e=Xp()),t===void 0&&(t=!1);var r=Object.keys(this._tweens);if(r.length===0)return!1;for(;r.length>0;){this._tweensAddedDuringUpdate={};for(var c=0;c1?p(u[t],u[t-1],t-r):p(u[c],u[c+1>t?t:c+1],r-c)},Bezier:function(u,e){for(var t=0,r=u.length-1,c=Math.pow,p=Lm.Utils.Bernstein,y=0;y<=r;y++)t+=c(1-e,r-y)*c(e,y)*u[y]*p(r,y);return t},CatmullRom:function(u,e){var t=u.length-1,r=t*e,c=Math.floor(r),p=Lm.Utils.CatmullRom;return u[0]===u[t]?(e<0&&(c=Math.floor(r=t*(1+e))),p(u[(c-1+t)%t],u[c],u[(c+1)%t],u[(c+2)%t],r-c)):e<0?u[0]-(p(u[0],u[0],u[1],u[1],-r)-u[0]):e>1?u[t]-(p(u[t],u[t],u[t-1],u[t-1],r-t)-u[t]):p(u[c?c-1:0],u[c],u[t1;r--)t*=r;return u[e]=t,t}}(),CatmullRom:function(u,e,t,r,c){var p=(t-u)*.5,y=(r-e)*.5,i=c*c,C=c*i;return(2*e-2*t+p+y)*C+(-3*e+3*t-2*p-y)*i+p*c+e}}},F2=function(){function u(){}return u.nextId=function(){return u._nextId++},u._nextId=0,u}(),RM=new UM,BR=function(){function u(e,t){t===void 0&&(t=RM),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=S_.Linear.None,this._interpolationFunction=Lm.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=F2.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return u.prototype.getId=function(){return this._id},u.prototype.isPlaying=function(){return this._isPlaying},u.prototype.isPaused=function(){return this._isPaused},u.prototype.to=function(e,t){return this._valuesEnd=Object.create(e),t!==void 0&&(this._duration=t),this},u.prototype.duration=function(e){return this._duration=e,this},u.prototype.start=function(e){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var t in this._valuesStartRepeat)this._swapEndStartRepeatValues(t),this._valuesStart[t]=this._valuesStartRepeat[t]}return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e!==void 0?typeof e=="string"?Xp()+parseFloat(e):e:Xp(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},u.prototype._setupProperties=function(e,t,r,c){for(var p in r){var y=e[p],i=Array.isArray(y),C=i?"array":typeof y,D=!i&&Array.isArray(r[p]);if(!(C==="undefined"||C==="function")){if(D){var R=r[p];if(R.length===0)continue;R=R.map(this._handleRelativeValue.bind(this,y)),r[p]=[y].concat(R)}if((C==="object"||i)&&y&&!D){t[p]=i?[]:{};for(var Q in y)t[p][Q]=y[Q];c[p]=i?[]:{},this._setupProperties(y,t[p],r[p],c[p])}else typeof t[p]>"u"&&(t[p]=y),i||(t[p]*=1),D?c[p]=r[p].slice().reverse():c[p]=t[p]||0}}},u.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},u.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},u.prototype.pause=function(e){return e===void 0&&(e=Xp()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},u.prototype.resume=function(e){return e===void 0&&(e=Xp()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},u.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;ep)return!1;t&&this.start(e)}if(this._goToEnd=!1,e1?1:c;var y=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,y),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),c===1)if(this._repeat>0){isFinite(this._repeat)&&this._repeat--;for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._repeatDelayTime!==void 0?this._startTime=e+this._repeatDelayTime:this._startTime=e+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var i=0,C=this._chainedTweens.length;i>8&255]+Ja[u>>16&255]+Ja[u>>24&255]+"-"+Ja[e&255]+Ja[e>>8&255]+"-"+Ja[e>>16&15|64]+Ja[e>>24&255]+"-"+Ja[t&63|128]+Ja[t>>8&255]+"-"+Ja[t>>16&255]+Ja[t>>24&255]+Ja[r&255]+Ja[r>>8&255]+Ja[r>>16&255]+Ja[r>>24&255]).toLowerCase()}function Eo(u,e,t){return Math.max(e,Math.min(t,u))}function O2(u,e){return(u%e+e)%e}function Az(u,e,t,r,c){return r+(u-e)*(c-r)/(t-e)}function dz(u,e,t){return u!==e?(t-u)/(e-u):0}function I_(u,e,t){return(1-t)*u+t*e}function pz(u,e,t,r){return I_(u,e,1-Math.exp(-t*r))}function fz(u,e=1){return e-Math.abs(O2(u,e*2)-e)}function mz(u,e,t){return u<=e?0:u>=t?1:(u=(u-e)/(t-e),u*u*(3-2*u))}function gz(u,e,t){return u<=e?0:u>=t?1:(u=(u-e)/(t-e),u*u*u*(u*(u*6-15)+10))}function _z(u,e){return u+Math.floor(Math.random()*(e-u+1))}function yz(u,e){return u+Math.random()*(e-u)}function xz(u){return u*(.5-Math.random())}function vz(u){u!==void 0&&(zE=u);let e=zE+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function wz(u){return u*Af}function bz(u){return u*j_}function o2(u){return(u&u-1)===0&&u!==0}function DI(u){return Math.pow(2,Math.ceil(Math.log(u)/Math.LN2))}function pv(u){return Math.pow(2,Math.floor(Math.log(u)/Math.LN2))}function Bz(u,e,t,r,c){const p=Math.cos,y=Math.sin,i=p(t/2),C=y(t/2),D=p((e+r)/2),R=y((e+r)/2),Q=p((e-r)/2),z=y((e-r)/2),G=p((r-e)/2),J=y((r-e)/2);switch(c){case"XYX":u.set(i*R,C*Q,C*z,i*D);break;case"YZY":u.set(C*z,i*R,C*Q,i*D);break;case"ZXZ":u.set(C*Q,C*z,i*R,i*D);break;case"XZX":u.set(i*R,C*J,C*G,i*D);break;case"YXY":u.set(C*G,i*R,C*J,i*D);break;case"ZYZ":u.set(C*J,C*G,i*R,i*D);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+c)}}function WA(u,e){switch(e.constructor){case Float32Array:return u;case Uint16Array:return u/65535;case Uint8Array:return u/255;case Int16Array:return Math.max(u/32767,-1);case Int8Array:return Math.max(u/127,-1);default:throw new Error("Invalid component type.")}}function Us(u,e){switch(e.constructor){case Float32Array:return u;case Uint16Array:return Math.round(u*65535);case Uint8Array:return Math.round(u*255);case Int16Array:return Math.round(u*32767);case Int8Array:return Math.round(u*127);default:throw new Error("Invalid component type.")}}var PI=Object.freeze({__proto__:null,DEG2RAD:Af,RAD2DEG:j_,ceilPowerOfTwo:DI,clamp:Eo,damp:pz,degToRad:wz,denormalize:WA,euclideanModulo:O2,floorPowerOfTwo:pv,generateUUID:Pc,inverseLerp:dz,isPowerOfTwo:o2,lerp:I_,mapLinear:Az,normalize:Us,pingpong:fz,radToDeg:bz,randFloat:yz,randFloatSpread:xz,randInt:_z,seededRandom:vz,setQuaternionFromProperEuler:Bz,smootherstep:gz,smoothstep:mz});class Di{constructor(e=0,t=0){Di.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,r=this.y,c=e.elements;return this.x=c[0]*t+c[3]*r+c[6],this.y=c[1]*t+c[4]*r+c[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y;return t*t+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const r=Math.cos(t),c=Math.sin(t),p=this.x-e.x,y=this.y-e.y;return this.x=p*r-y*c+e.x,this.y=p*c+y*r+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Pl{constructor(){Pl.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,r,c,p,y,i,C,D){const R=this.elements;return R[0]=e,R[1]=c,R[2]=i,R[3]=t,R[4]=p,R[5]=C,R[6]=r,R[7]=y,R[8]=D,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this}extractBasis(e,t,r){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),r.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,c=t.elements,p=this.elements,y=r[0],i=r[3],C=r[6],D=r[1],R=r[4],Q=r[7],z=r[2],G=r[5],J=r[8],Y=c[0],B=c[3],ae=c[6],ce=c[1],Ae=c[4],we=c[7],me=c[2],De=c[5],Je=c[8];return p[0]=y*Y+i*ce+C*me,p[3]=y*B+i*Ae+C*De,p[6]=y*ae+i*we+C*Je,p[1]=D*Y+R*ce+Q*me,p[4]=D*B+R*Ae+Q*De,p[7]=D*ae+R*we+Q*Je,p[2]=z*Y+G*ce+J*me,p[5]=z*B+G*Ae+J*De,p[8]=z*ae+G*we+J*Je,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[1],c=e[2],p=e[3],y=e[4],i=e[5],C=e[6],D=e[7],R=e[8];return t*y*R-t*i*D-r*p*R+r*i*C+c*p*D-c*y*C}invert(){const e=this.elements,t=e[0],r=e[1],c=e[2],p=e[3],y=e[4],i=e[5],C=e[6],D=e[7],R=e[8],Q=R*y-i*D,z=i*C-R*p,G=D*p-y*C,J=t*Q+r*z+c*G;if(J===0)return this.set(0,0,0,0,0,0,0,0,0);const Y=1/J;return e[0]=Q*Y,e[1]=(c*D-R*r)*Y,e[2]=(i*r-c*y)*Y,e[3]=z*Y,e[4]=(R*t-c*C)*Y,e[5]=(c*p-i*t)*Y,e[6]=G*Y,e[7]=(r*C-D*t)*Y,e[8]=(y*t-r*p)*Y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,r,c,p,y,i){const C=Math.cos(p),D=Math.sin(p);return this.set(r*C,r*D,-r*(C*y+D*i)+y+e,-c*D,c*C,-c*(-D*y+C*i)+i+t,0,0,1),this}scale(e,t){return this.premultiply(yw.makeScale(e,t)),this}rotate(e){return this.premultiply(yw.makeRotation(-e)),this}translate(e,t){return this.premultiply(yw.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,r,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,r=e.elements;for(let c=0;c<9;c++)if(t[c]!==r[c])return!1;return!0}fromArray(e,t=0){for(let r=0;r<9;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const yw=new Pl;function UI(u){for(let e=u.length-1;e>=0;--e)if(u[e]>=65535)return!0;return!1}const Cz={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Pm(u,e){return new Cz[u](e)}function K_(u){return document.createElementNS("http://www.w3.org/1999/xhtml",u)}function df(u){return u<.04045?u*.0773993808:Math.pow(u*.9478672986+.0521327014,2.4)}function qx(u){return u<.0031308?u*12.92:1.055*Math.pow(u,.41666)-.055}const xw={[cu]:{[Wm]:df},[Wm]:{[cu]:qx}},el={legacyMode:!0,get workingColorSpace(){return Wm},set workingColorSpace(u){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(u,e,t){if(this.legacyMode||e===t||!e||!t)return u;if(xw[e]&&xw[e][t]!==void 0){const r=xw[e][t];return u.r=r(u.r),u.g=r(u.g),u.b=r(u.b),u}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(u,e){return this.convert(u,this.workingColorSpace,e)},toWorkingColorSpace:function(u,e){return this.convert(u,e,this.workingColorSpace)}},RI={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ia={r:0,g:0,b:0},su={h:0,s:0,l:0},X0={h:0,s:0,l:0};function vw(u,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?u+(e-u)*6*t:t<1/2?e:t<2/3?u+(e-u)*6*(2/3-t):u}function q0(u,e){return e.r=u.r,e.g=u.g,e.b=u.b,e}class Dn{constructor(e,t,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,t===void 0&&r===void 0?this.set(e):this.setRGB(e,t,r)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=cu){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,el.toWorkingColorSpace(this,t),this}setRGB(e,t,r,c=el.workingColorSpace){return this.r=e,this.g=t,this.b=r,el.toWorkingColorSpace(this,c),this}setHSL(e,t,r,c=el.workingColorSpace){if(e=O2(e,1),t=Eo(t,0,1),r=Eo(r,0,1),t===0)this.r=this.g=this.b=r;else{const p=r<=.5?r*(1+t):r+t-r*t,y=2*r-p;this.r=vw(y,p,e+1/3),this.g=vw(y,p,e),this.b=vw(y,p,e-1/3)}return el.toWorkingColorSpace(this,c),this}setStyle(e,t=cu){function r(p){p!==void 0&&parseFloat(p)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let c;if(c=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let p;const y=c[1],i=c[2];switch(y){case"rgb":case"rgba":if(p=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(p[1],10))/255,this.g=Math.min(255,parseInt(p[2],10))/255,this.b=Math.min(255,parseInt(p[3],10))/255,el.toWorkingColorSpace(this,t),r(p[4]),this;if(p=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(p[1],10))/100,this.g=Math.min(100,parseInt(p[2],10))/100,this.b=Math.min(100,parseInt(p[3],10))/100,el.toWorkingColorSpace(this,t),r(p[4]),this;break;case"hsl":case"hsla":if(p=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const C=parseFloat(p[1])/360,D=parseFloat(p[2])/100,R=parseFloat(p[3])/100;return r(p[4]),this.setHSL(C,D,R,t)}break}}else if(c=/^\#([A-Fa-f\d]+)$/.exec(e)){const p=c[1],y=p.length;if(y===3)return this.r=parseInt(p.charAt(0)+p.charAt(0),16)/255,this.g=parseInt(p.charAt(1)+p.charAt(1),16)/255,this.b=parseInt(p.charAt(2)+p.charAt(2),16)/255,el.toWorkingColorSpace(this,t),this;if(y===6)return this.r=parseInt(p.charAt(0)+p.charAt(1),16)/255,this.g=parseInt(p.charAt(2)+p.charAt(3),16)/255,this.b=parseInt(p.charAt(4)+p.charAt(5),16)/255,el.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=cu){const r=RI[e.toLowerCase()];return r!==void 0?this.setHex(r,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=df(e.r),this.g=df(e.g),this.b=df(e.b),this}copyLinearToSRGB(e){return this.r=qx(e.r),this.g=qx(e.g),this.b=qx(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=cu){return el.fromWorkingColorSpace(q0(this,ia),e),Eo(ia.r*255,0,255)<<16^Eo(ia.g*255,0,255)<<8^Eo(ia.b*255,0,255)<<0}getHexString(e=cu){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=el.workingColorSpace){el.fromWorkingColorSpace(q0(this,ia),t);const r=ia.r,c=ia.g,p=ia.b,y=Math.max(r,c,p),i=Math.min(r,c,p);let C,D;const R=(i+y)/2;if(i===y)C=0,D=0;else{const Q=y-i;switch(D=R<=.5?Q/(y+i):Q/(2-y-i),y){case r:C=(c-p)/Q+(c"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{lm===void 0&&(lm=K_("canvas")),lm.width=e.width,lm.height=e.height;const r=lm.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),t=lm}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=K_("canvas");t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const c=r.getImageData(0,0,e.width,e.height),p=c.data;for(let y=0;y0&&(r.userData=this.userData),t||(e.textures[this.uuid]=r),r}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==kv)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case HA:e.x=e.x-Math.floor(e.x);break;case nl:e.x=e.x<0?0:1;break;case Q_:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case HA:e.y=e.y-Math.floor(e.y);break;case nl:e.y=e.y<0?0:1;break;case Q_:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}To.DEFAULT_IMAGE=null;To.DEFAULT_MAPPING=kv;To.DEFAULT_ANISOTROPY=1;class as{constructor(e=0,t=0,r=0,c=1){as.prototype.isVector4=!0,this.x=e,this.y=t,this.z=r,this.w=c}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,r,c){return this.x=e,this.y=t,this.z=r,this.w=c,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,r=this.y,c=this.z,p=this.w,y=e.elements;return this.x=y[0]*t+y[4]*r+y[8]*c+y[12]*p,this.y=y[1]*t+y[5]*r+y[9]*c+y[13]*p,this.z=y[2]*t+y[6]*r+y[10]*c+y[14]*p,this.w=y[3]*t+y[7]*r+y[11]*c+y[15]*p,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,r,c,p;const C=e.elements,D=C[0],R=C[4],Q=C[8],z=C[1],G=C[5],J=C[9],Y=C[2],B=C[6],ae=C[10];if(Math.abs(R-z)<.01&&Math.abs(Q-Y)<.01&&Math.abs(J-B)<.01){if(Math.abs(R+z)<.1&&Math.abs(Q+Y)<.1&&Math.abs(J+B)<.1&&Math.abs(D+G+ae-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const Ae=(D+1)/2,we=(G+1)/2,me=(ae+1)/2,De=(R+z)/4,Je=(Q+Y)/4,Fe=(J+B)/4;return Ae>we&&Ae>me?Ae<.01?(r=0,c=.707106781,p=.707106781):(r=Math.sqrt(Ae),c=De/r,p=Je/r):we>me?we<.01?(r=.707106781,c=0,p=.707106781):(c=Math.sqrt(we),r=De/c,p=Fe/c):me<.01?(r=.707106781,c=.707106781,p=0):(p=Math.sqrt(me),r=Je/p,c=Fe/p),this.set(r,c,p,t),this}let ce=Math.sqrt((B-J)*(B-J)+(Q-Y)*(Q-Y)+(z-R)*(z-R));return Math.abs(ce)<.001&&(ce=1),this.x=(B-J)/ce,this.y=(Q-Y)/ce,this.z=(z-R)/ce,this.w=Math.acos((D+G+ae-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this.w=e.w+(t.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class rl extends Xu{constructor(e=1,t=1,r={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new as(0,0,e,t),this.scissorTest=!1,this.viewport=new as(0,0,e,t);const c={width:e,height:t,depth:1};this.texture=new To(c,r.mapping,r.wrapS,r.wrapT,r.magFilter,r.minFilter,r.format,r.type,r.anisotropy,r.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=r.generateMipmaps!==void 0?r.generateMipmaps:!1,this.texture.internalFormat=r.internalFormat!==void 0?r.internalFormat:null,this.texture.minFilter=r.minFilter!==void 0?r.minFilter:Xs,this.depthBuffer=r.depthBuffer!==void 0?r.depthBuffer:!0,this.stencilBuffer=r.stencilBuffer!==void 0?r.stencilBuffer:!1,this.depthTexture=r.depthTexture!==void 0?r.depthTexture:null,this.samples=r.samples!==void 0?r.samples:0}setSize(e,t,r=1){(this.width!==e||this.height!==t||this.depth!==r)&&(this.width=e,this.height=t,this.depth=r,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=r,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new of(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Nv extends To{constructor(e=null,t=1,r=1,c=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:r,depth:c},this.magFilter=Co,this.minFilter=Co,this.wrapR=nl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Tz extends rl{constructor(e=1,t=1,r=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=r,this.texture=new Nv(null,e,t,r),this.texture.isRenderTargetTexture=!0}}class Q2 extends To{constructor(e=null,t=1,r=1,c=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:r,depth:c},this.magFilter=Co,this.minFilter=Co,this.wrapR=nl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Sz extends rl{constructor(e=1,t=1,r=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=r,this.texture=new Q2(null,e,t,r),this.texture.isRenderTargetTexture=!0}}class Mz extends rl{constructor(e=1,t=1,r=1,c={}){super(e,t,c),this.isWebGLMultipleRenderTargets=!0;const p=this.texture;this.texture=[];for(let y=0;y=0?1:-1,Ae=1-ae*ae;if(Ae>Number.EPSILON){const me=Math.sqrt(Ae),De=Math.atan2(me,ae*ce);B=Math.sin(B*De)/me,i=Math.sin(i*De)/me}const we=i*ce;if(C=C*B+z*we,D=D*B+G*we,R=R*B+J*we,Q=Q*B+Y*we,B===1-i){const me=1/Math.sqrt(C*C+D*D+R*R+Q*Q);C*=me,D*=me,R*=me,Q*=me}}e[t]=C,e[t+1]=D,e[t+2]=R,e[t+3]=Q}static multiplyQuaternionsFlat(e,t,r,c,p,y){const i=r[c],C=r[c+1],D=r[c+2],R=r[c+3],Q=p[y],z=p[y+1],G=p[y+2],J=p[y+3];return e[t]=i*J+R*Q+C*G-D*z,e[t+1]=C*J+R*z+D*Q-i*G,e[t+2]=D*J+R*G+i*z-C*Q,e[t+3]=R*J-i*Q-C*z-D*G,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,r,c){return this._x=e,this._y=t,this._z=r,this._w=c,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const r=e._x,c=e._y,p=e._z,y=e._order,i=Math.cos,C=Math.sin,D=i(r/2),R=i(c/2),Q=i(p/2),z=C(r/2),G=C(c/2),J=C(p/2);switch(y){case"XYZ":this._x=z*R*Q+D*G*J,this._y=D*G*Q-z*R*J,this._z=D*R*J+z*G*Q,this._w=D*R*Q-z*G*J;break;case"YXZ":this._x=z*R*Q+D*G*J,this._y=D*G*Q-z*R*J,this._z=D*R*J-z*G*Q,this._w=D*R*Q+z*G*J;break;case"ZXY":this._x=z*R*Q-D*G*J,this._y=D*G*Q+z*R*J,this._z=D*R*J+z*G*Q,this._w=D*R*Q-z*G*J;break;case"ZYX":this._x=z*R*Q-D*G*J,this._y=D*G*Q+z*R*J,this._z=D*R*J-z*G*Q,this._w=D*R*Q+z*G*J;break;case"YZX":this._x=z*R*Q+D*G*J,this._y=D*G*Q+z*R*J,this._z=D*R*J-z*G*Q,this._w=D*R*Q-z*G*J;break;case"XZY":this._x=z*R*Q-D*G*J,this._y=D*G*Q-z*R*J,this._z=D*R*J+z*G*Q,this._w=D*R*Q+z*G*J;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+y)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const r=t/2,c=Math.sin(r);return this._x=e.x*c,this._y=e.y*c,this._z=e.z*c,this._w=Math.cos(r),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,r=t[0],c=t[4],p=t[8],y=t[1],i=t[5],C=t[9],D=t[2],R=t[6],Q=t[10],z=r+i+Q;if(z>0){const G=.5/Math.sqrt(z+1);this._w=.25/G,this._x=(R-C)*G,this._y=(p-D)*G,this._z=(y-c)*G}else if(r>i&&r>Q){const G=2*Math.sqrt(1+r-i-Q);this._w=(R-C)/G,this._x=.25*G,this._y=(c+y)/G,this._z=(p+D)/G}else if(i>Q){const G=2*Math.sqrt(1+i-r-Q);this._w=(p-D)/G,this._x=(c+y)/G,this._y=.25*G,this._z=(C+R)/G}else{const G=2*Math.sqrt(1+Q-r-i);this._w=(y-c)/G,this._x=(p+D)/G,this._y=(C+R)/G,this._z=.25*G}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let r=e.dot(t)+1;return rMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Eo(this.dot(e),-1,1)))}rotateTowards(e,t){const r=this.angleTo(e);if(r===0)return this;const c=Math.min(1,t/r);return this.slerp(e,c),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const r=e._x,c=e._y,p=e._z,y=e._w,i=t._x,C=t._y,D=t._z,R=t._w;return this._x=r*R+y*i+c*D-p*C,this._y=c*R+y*C+p*i-r*D,this._z=p*R+y*D+r*C-c*i,this._w=y*R-r*i-c*C-p*D,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const r=this._x,c=this._y,p=this._z,y=this._w;let i=y*e._w+r*e._x+c*e._y+p*e._z;if(i<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,i=-i):this.copy(e),i>=1)return this._w=y,this._x=r,this._y=c,this._z=p,this;const C=1-i*i;if(C<=Number.EPSILON){const G=1-t;return this._w=G*y+t*this._w,this._x=G*r+t*this._x,this._y=G*c+t*this._y,this._z=G*p+t*this._z,this.normalize(),this._onChangeCallback(),this}const D=Math.sqrt(C),R=Math.atan2(D,i),Q=Math.sin((1-t)*R)/D,z=Math.sin(t*R)/D;return this._w=y*Q+this._w*z,this._x=r*Q+this._x*z,this._y=c*Q+this._y*z,this._z=p*Q+this._z*z,this._onChangeCallback(),this}slerpQuaternions(e,t,r){return this.copy(e).slerp(t,r)}random(){const e=Math.random(),t=Math.sqrt(1-e),r=Math.sqrt(e),c=2*Math.PI*Math.random(),p=2*Math.PI*Math.random();return this.set(t*Math.cos(c),r*Math.sin(p),r*Math.cos(p),t*Math.sin(c))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ft{constructor(e=0,t=0,r=0){ft.prototype.isVector3=!0,this.x=e,this.y=t,this.z=r}set(e,t,r){return r===void 0&&(r=this.z),this.x=e,this.y=t,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(kE.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(kE.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,r=this.y,c=this.z,p=e.elements;return this.x=p[0]*t+p[3]*r+p[6]*c,this.y=p[1]*t+p[4]*r+p[7]*c,this.z=p[2]*t+p[5]*r+p[8]*c,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,r=this.y,c=this.z,p=e.elements,y=1/(p[3]*t+p[7]*r+p[11]*c+p[15]);return this.x=(p[0]*t+p[4]*r+p[8]*c+p[12])*y,this.y=(p[1]*t+p[5]*r+p[9]*c+p[13])*y,this.z=(p[2]*t+p[6]*r+p[10]*c+p[14])*y,this}applyQuaternion(e){const t=this.x,r=this.y,c=this.z,p=e.x,y=e.y,i=e.z,C=e.w,D=C*t+y*c-i*r,R=C*r+i*t-p*c,Q=C*c+p*r-y*t,z=-p*t-y*r-i*c;return this.x=D*C+z*-p+R*-i-Q*-y,this.y=R*C+z*-y+Q*-p-D*-i,this.z=Q*C+z*-i+D*-y-R*-p,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,r=this.y,c=this.z,p=e.elements;return this.x=p[0]*t+p[4]*r+p[8]*c,this.y=p[1]*t+p[5]*r+p[9]*c,this.z=p[2]*t+p[6]*r+p[10]*c,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(t,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,r){return this.x=e.x+(t.x-e.x)*r,this.y=e.y+(t.y-e.y)*r,this.z=e.z+(t.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const r=e.x,c=e.y,p=e.z,y=t.x,i=t.y,C=t.z;return this.x=c*C-p*i,this.y=p*y-r*C,this.z=r*i-c*y,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const r=e.dot(this)/t;return this.copy(e).multiplyScalar(r)}projectOnPlane(e){return bw.copy(this).projectOnVector(e),this.sub(bw)}reflect(e){return this.sub(bw.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const r=this.dot(e)/t;return Math.acos(Eo(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,r=this.y-e.y,c=this.z-e.z;return t*t+r*r+c*c}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,r){const c=Math.sin(t)*e;return this.x=c*Math.sin(r),this.y=Math.cos(t)*e,this.z=c*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,r){return this.x=e*Math.sin(t),this.y=r,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),c=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=c,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(t),this.y=r*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const bw=new ft,kE=new sl;class qu{constructor(e=new ft(1/0,1/0,1/0),t=new ft(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,r=1/0,c=1/0,p=-1/0,y=-1/0,i=-1/0;for(let C=0,D=e.length;Cp&&(p=R),Q>y&&(y=Q),z>i&&(i=z)}return this.min.set(t,r,c),this.max.set(p,y,i),this}setFromBufferAttribute(e){let t=1/0,r=1/0,c=1/0,p=-1/0,y=-1/0,i=-1/0;for(let C=0,D=e.count;Cp&&(p=R),Q>y&&(y=Q),z>i&&(i=z)}return this.min.set(t,r,c),this.max.set(p,y,i),this}setFromPoints(e){this.makeEmpty();for(let t=0,r=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,kp),kp.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(t_),Y0.subVectors(this.max,t_),cm.subVectors(e.a,t_),hm.subVectors(e.b,t_),um.subVectors(e.c,t_),Rd.subVectors(hm,cm),zd.subVectors(um,hm),Op.subVectors(cm,um);let t=[0,-Rd.z,Rd.y,0,-zd.z,zd.y,0,-Op.z,Op.y,Rd.z,0,-Rd.x,zd.z,0,-zd.x,Op.z,0,-Op.x,-Rd.y,Rd.x,0,-zd.y,zd.x,0,-Op.y,Op.x,0];return!Cw(t,cm,hm,um,Y0)||(t=[1,0,0,0,1,0,0,0,1],!Cw(t,cm,hm,um,Y0))?!1:(J0.crossVectors(Rd,zd),t=[J0.x,J0.y,J0.z],Cw(t,cm,hm,um,Y0))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return kp.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(kp).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(RA[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),RA[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),RA[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),RA[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),RA[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),RA[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),RA[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),RA[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(RA),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const RA=[new ft,new ft,new ft,new ft,new ft,new ft,new ft,new ft],kp=new ft,Bw=new qu,cm=new ft,hm=new ft,um=new ft,Rd=new ft,zd=new ft,Op=new ft,t_=new ft,Y0=new ft,J0=new ft,Np=new ft;function Cw(u,e,t,r,c){for(let p=0,y=u.length-3;p<=y;p+=3){Np.fromArray(u,p);const i=c.x*Math.abs(Np.x)+c.y*Math.abs(Np.y)+c.z*Math.abs(Np.z),C=e.dot(Np),D=t.dot(Np),R=r.dot(Np);if(Math.max(-Math.max(C,D,R),Math.min(C,D,R))>i)return!1}return!0}const Iz=new qu,i_=new ft,Ew=new ft;class XA{constructor(e=new ft,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const r=this.center;t!==void 0?r.copy(t):Iz.setFromPoints(e).getCenter(r);let c=0;for(let p=0,y=e.length;pthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;i_.subVectors(e,this.center);const t=i_.lengthSq();if(t>this.radius*this.radius){const r=Math.sqrt(t),c=(r-this.radius)*.5;this.center.addScaledVector(i_,c/r),this.radius+=c}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Ew.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(i_.copy(e.center).add(Ew)),this.expandByPoint(i_.copy(e.center).sub(Ew))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const zA=new ft,Tw=new ft,ex=new ft,kd=new ft,Sw=new ft,tx=new ft,Mw=new ft;class cy{constructor(e=new ft,t=new ft(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,zA)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const r=t.dot(this.direction);return r<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(r).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=zA.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(zA.copy(this.direction).multiplyScalar(t).add(this.origin),zA.distanceToSquared(e))}distanceSqToSegment(e,t,r,c){Tw.copy(e).add(t).multiplyScalar(.5),ex.copy(t).sub(e).normalize(),kd.copy(this.origin).sub(Tw);const p=e.distanceTo(t)*.5,y=-this.direction.dot(ex),i=kd.dot(this.direction),C=-kd.dot(ex),D=kd.lengthSq(),R=Math.abs(1-y*y);let Q,z,G,J;if(R>0)if(Q=y*C-i,z=y*i-C,J=p*R,Q>=0)if(z>=-J)if(z<=J){const Y=1/R;Q*=Y,z*=Y,G=Q*(Q+y*z+2*i)+z*(y*Q+z+2*C)+D}else z=p,Q=Math.max(0,-(y*z+i)),G=-Q*Q+z*(z+2*C)+D;else z=-p,Q=Math.max(0,-(y*z+i)),G=-Q*Q+z*(z+2*C)+D;else z<=-J?(Q=Math.max(0,-(-y*p+i)),z=Q>0?-p:Math.min(Math.max(-p,-C),p),G=-Q*Q+z*(z+2*C)+D):z<=J?(Q=0,z=Math.min(Math.max(-p,-C),p),G=z*(z+2*C)+D):(Q=Math.max(0,-(y*p+i)),z=Q>0?p:Math.min(Math.max(-p,-C),p),G=-Q*Q+z*(z+2*C)+D);else z=y>0?-p:p,Q=Math.max(0,-(y*z+i)),G=-Q*Q+z*(z+2*C)+D;return r&&r.copy(this.direction).multiplyScalar(Q).add(this.origin),c&&c.copy(ex).multiplyScalar(z).add(Tw),G}intersectSphere(e,t){zA.subVectors(e.center,this.origin);const r=zA.dot(this.direction),c=zA.dot(zA)-r*r,p=e.radius*e.radius;if(c>p)return null;const y=Math.sqrt(p-c),i=r-y,C=r+y;return i<0&&C<0?null:i<0?this.at(C,t):this.at(i,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null}intersectPlane(e,t){const r=this.distanceToPlane(e);return r===null?null:this.at(r,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let r,c,p,y,i,C;const D=1/this.direction.x,R=1/this.direction.y,Q=1/this.direction.z,z=this.origin;return D>=0?(r=(e.min.x-z.x)*D,c=(e.max.x-z.x)*D):(r=(e.max.x-z.x)*D,c=(e.min.x-z.x)*D),R>=0?(p=(e.min.y-z.y)*R,y=(e.max.y-z.y)*R):(p=(e.max.y-z.y)*R,y=(e.min.y-z.y)*R),r>y||p>c||((p>r||isNaN(r))&&(r=p),(y=0?(i=(e.min.z-z.z)*Q,C=(e.max.z-z.z)*Q):(i=(e.max.z-z.z)*Q,C=(e.min.z-z.z)*Q),r>C||i>c)||((i>r||r!==r)&&(r=i),(C=0?r:c,t)}intersectsBox(e){return this.intersectBox(e,zA)!==null}intersectTriangle(e,t,r,c,p){Sw.subVectors(t,e),tx.subVectors(r,e),Mw.crossVectors(Sw,tx);let y=this.direction.dot(Mw),i;if(y>0){if(c)return null;i=1}else if(y<0)i=-1,y=-y;else return null;kd.subVectors(this.origin,e);const C=i*this.direction.dot(tx.crossVectors(kd,tx));if(C<0)return null;const D=i*this.direction.dot(Sw.cross(kd));if(D<0||C+D>y)return null;const R=-i*kd.dot(Mw);return R<0?null:this.at(R/y,p)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ar{constructor(){ar.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,r,c,p,y,i,C,D,R,Q,z,G,J,Y,B){const ae=this.elements;return ae[0]=e,ae[4]=t,ae[8]=r,ae[12]=c,ae[1]=p,ae[5]=y,ae[9]=i,ae[13]=C,ae[2]=D,ae[6]=R,ae[10]=Q,ae[14]=z,ae[3]=G,ae[7]=J,ae[11]=Y,ae[15]=B,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ar().fromArray(this.elements)}copy(e){const t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this}copyPosition(e){const t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,r=e.elements,c=1/Am.setFromMatrixColumn(e,0).length(),p=1/Am.setFromMatrixColumn(e,1).length(),y=1/Am.setFromMatrixColumn(e,2).length();return t[0]=r[0]*c,t[1]=r[1]*c,t[2]=r[2]*c,t[3]=0,t[4]=r[4]*p,t[5]=r[5]*p,t[6]=r[6]*p,t[7]=0,t[8]=r[8]*y,t[9]=r[9]*y,t[10]=r[10]*y,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,r=e.x,c=e.y,p=e.z,y=Math.cos(r),i=Math.sin(r),C=Math.cos(c),D=Math.sin(c),R=Math.cos(p),Q=Math.sin(p);if(e.order==="XYZ"){const z=y*R,G=y*Q,J=i*R,Y=i*Q;t[0]=C*R,t[4]=-C*Q,t[8]=D,t[1]=G+J*D,t[5]=z-Y*D,t[9]=-i*C,t[2]=Y-z*D,t[6]=J+G*D,t[10]=y*C}else if(e.order==="YXZ"){const z=C*R,G=C*Q,J=D*R,Y=D*Q;t[0]=z+Y*i,t[4]=J*i-G,t[8]=y*D,t[1]=y*Q,t[5]=y*R,t[9]=-i,t[2]=G*i-J,t[6]=Y+z*i,t[10]=y*C}else if(e.order==="ZXY"){const z=C*R,G=C*Q,J=D*R,Y=D*Q;t[0]=z-Y*i,t[4]=-y*Q,t[8]=J+G*i,t[1]=G+J*i,t[5]=y*R,t[9]=Y-z*i,t[2]=-y*D,t[6]=i,t[10]=y*C}else if(e.order==="ZYX"){const z=y*R,G=y*Q,J=i*R,Y=i*Q;t[0]=C*R,t[4]=J*D-G,t[8]=z*D+Y,t[1]=C*Q,t[5]=Y*D+z,t[9]=G*D-J,t[2]=-D,t[6]=i*C,t[10]=y*C}else if(e.order==="YZX"){const z=y*C,G=y*D,J=i*C,Y=i*D;t[0]=C*R,t[4]=Y-z*Q,t[8]=J*Q+G,t[1]=Q,t[5]=y*R,t[9]=-i*R,t[2]=-D*R,t[6]=G*Q+J,t[10]=z-Y*Q}else if(e.order==="XZY"){const z=y*C,G=y*D,J=i*C,Y=i*D;t[0]=C*R,t[4]=-Q,t[8]=D*R,t[1]=z*Q+Y,t[5]=y*R,t[9]=G*Q-J,t[2]=J*Q-G,t[6]=i*R,t[10]=Y*Q+z}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Fz,e,Lz)}lookAt(e,t,r){const c=this.elements;return Sc.subVectors(e,t),Sc.lengthSq()===0&&(Sc.z=1),Sc.normalize(),Od.crossVectors(r,Sc),Od.lengthSq()===0&&(Math.abs(r.z)===1?Sc.x+=1e-4:Sc.z+=1e-4,Sc.normalize(),Od.crossVectors(r,Sc)),Od.normalize(),ix.crossVectors(Sc,Od),c[0]=Od.x,c[4]=ix.x,c[8]=Sc.x,c[1]=Od.y,c[5]=ix.y,c[9]=Sc.y,c[2]=Od.z,c[6]=ix.z,c[10]=Sc.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const r=e.elements,c=t.elements,p=this.elements,y=r[0],i=r[4],C=r[8],D=r[12],R=r[1],Q=r[5],z=r[9],G=r[13],J=r[2],Y=r[6],B=r[10],ae=r[14],ce=r[3],Ae=r[7],we=r[11],me=r[15],De=c[0],Je=c[4],Fe=c[8],Ge=c[12],Et=c[1],li=c[5],xi=c[9],te=c[13],le=c[2],ye=c[6],xe=c[10],Re=c[14],Oe=c[3],We=c[7],Ve=c[11],Qe=c[15];return p[0]=y*De+i*Et+C*le+D*Oe,p[4]=y*Je+i*li+C*ye+D*We,p[8]=y*Fe+i*xi+C*xe+D*Ve,p[12]=y*Ge+i*te+C*Re+D*Qe,p[1]=R*De+Q*Et+z*le+G*Oe,p[5]=R*Je+Q*li+z*ye+G*We,p[9]=R*Fe+Q*xi+z*xe+G*Ve,p[13]=R*Ge+Q*te+z*Re+G*Qe,p[2]=J*De+Y*Et+B*le+ae*Oe,p[6]=J*Je+Y*li+B*ye+ae*We,p[10]=J*Fe+Y*xi+B*xe+ae*Ve,p[14]=J*Ge+Y*te+B*Re+ae*Qe,p[3]=ce*De+Ae*Et+we*le+me*Oe,p[7]=ce*Je+Ae*li+we*ye+me*We,p[11]=ce*Fe+Ae*xi+we*xe+me*Ve,p[15]=ce*Ge+Ae*te+we*Re+me*Qe,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],r=e[4],c=e[8],p=e[12],y=e[1],i=e[5],C=e[9],D=e[13],R=e[2],Q=e[6],z=e[10],G=e[14],J=e[3],Y=e[7],B=e[11],ae=e[15];return J*(+p*C*Q-c*D*Q-p*i*z+r*D*z+c*i*G-r*C*G)+Y*(+t*C*G-t*D*z+p*y*z-c*y*G+c*D*R-p*C*R)+B*(+t*D*Q-t*i*G-p*y*Q+r*y*G+p*i*R-r*D*R)+ae*(-c*i*R-t*C*Q+t*i*z+c*y*Q-r*y*z+r*C*R)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,r){const c=this.elements;return e.isVector3?(c[12]=e.x,c[13]=e.y,c[14]=e.z):(c[12]=e,c[13]=t,c[14]=r),this}invert(){const e=this.elements,t=e[0],r=e[1],c=e[2],p=e[3],y=e[4],i=e[5],C=e[6],D=e[7],R=e[8],Q=e[9],z=e[10],G=e[11],J=e[12],Y=e[13],B=e[14],ae=e[15],ce=Q*B*D-Y*z*D+Y*C*G-i*B*G-Q*C*ae+i*z*ae,Ae=J*z*D-R*B*D-J*C*G+y*B*G+R*C*ae-y*z*ae,we=R*Y*D-J*Q*D+J*i*G-y*Y*G-R*i*ae+y*Q*ae,me=J*Q*C-R*Y*C-J*i*z+y*Y*z+R*i*B-y*Q*B,De=t*ce+r*Ae+c*we+p*me;if(De===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const Je=1/De;return e[0]=ce*Je,e[1]=(Y*z*p-Q*B*p-Y*c*G+r*B*G+Q*c*ae-r*z*ae)*Je,e[2]=(i*B*p-Y*C*p+Y*c*D-r*B*D-i*c*ae+r*C*ae)*Je,e[3]=(Q*C*p-i*z*p-Q*c*D+r*z*D+i*c*G-r*C*G)*Je,e[4]=Ae*Je,e[5]=(R*B*p-J*z*p+J*c*G-t*B*G-R*c*ae+t*z*ae)*Je,e[6]=(J*C*p-y*B*p-J*c*D+t*B*D+y*c*ae-t*C*ae)*Je,e[7]=(y*z*p-R*C*p+R*c*D-t*z*D-y*c*G+t*C*G)*Je,e[8]=we*Je,e[9]=(J*Q*p-R*Y*p-J*r*G+t*Y*G+R*r*ae-t*Q*ae)*Je,e[10]=(y*Y*p-J*i*p+J*r*D-t*Y*D-y*r*ae+t*i*ae)*Je,e[11]=(R*i*p-y*Q*p-R*r*D+t*Q*D+y*r*G-t*i*G)*Je,e[12]=me*Je,e[13]=(R*Y*c-J*Q*c+J*r*z-t*Y*z-R*r*B+t*Q*B)*Je,e[14]=(J*i*c-y*Y*c-J*r*C+t*Y*C+y*r*B-t*i*B)*Je,e[15]=(y*Q*c-R*i*c+R*r*C-t*Q*C-y*r*z+t*i*z)*Je,this}scale(e){const t=this.elements,r=e.x,c=e.y,p=e.z;return t[0]*=r,t[4]*=c,t[8]*=p,t[1]*=r,t[5]*=c,t[9]*=p,t[2]*=r,t[6]*=c,t[10]*=p,t[3]*=r,t[7]*=c,t[11]*=p,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],c=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,r,c))}makeTranslation(e,t,r){return this.set(1,0,0,e,0,1,0,t,0,0,1,r,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,t,-r,0,0,r,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,0,r,0,0,1,0,0,-r,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),r=Math.sin(e);return this.set(t,-r,0,0,r,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const r=Math.cos(t),c=Math.sin(t),p=1-r,y=e.x,i=e.y,C=e.z,D=p*y,R=p*i;return this.set(D*y+r,D*i-c*C,D*C+c*i,0,D*i+c*C,R*i+r,R*C-c*y,0,D*C-c*i,R*C+c*y,p*C*C+r,0,0,0,0,1),this}makeScale(e,t,r){return this.set(e,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,t,r,c,p,y){return this.set(1,r,p,0,e,1,y,0,t,c,1,0,0,0,0,1),this}compose(e,t,r){const c=this.elements,p=t._x,y=t._y,i=t._z,C=t._w,D=p+p,R=y+y,Q=i+i,z=p*D,G=p*R,J=p*Q,Y=y*R,B=y*Q,ae=i*Q,ce=C*D,Ae=C*R,we=C*Q,me=r.x,De=r.y,Je=r.z;return c[0]=(1-(Y+ae))*me,c[1]=(G+we)*me,c[2]=(J-Ae)*me,c[3]=0,c[4]=(G-we)*De,c[5]=(1-(z+ae))*De,c[6]=(B+ce)*De,c[7]=0,c[8]=(J+Ae)*Je,c[9]=(B-ce)*Je,c[10]=(1-(z+Y))*Je,c[11]=0,c[12]=e.x,c[13]=e.y,c[14]=e.z,c[15]=1,this}decompose(e,t,r){const c=this.elements;let p=Am.set(c[0],c[1],c[2]).length();const y=Am.set(c[4],c[5],c[6]).length(),i=Am.set(c[8],c[9],c[10]).length();this.determinant()<0&&(p=-p),e.x=c[12],e.y=c[13],e.z=c[14],ou.copy(this);const D=1/p,R=1/y,Q=1/i;return ou.elements[0]*=D,ou.elements[1]*=D,ou.elements[2]*=D,ou.elements[4]*=R,ou.elements[5]*=R,ou.elements[6]*=R,ou.elements[8]*=Q,ou.elements[9]*=Q,ou.elements[10]*=Q,t.setFromRotationMatrix(ou),r.x=p,r.y=y,r.z=i,this}makePerspective(e,t,r,c,p,y){const i=this.elements,C=2*p/(t-e),D=2*p/(r-c),R=(t+e)/(t-e),Q=(r+c)/(r-c),z=-(y+p)/(y-p),G=-2*y*p/(y-p);return i[0]=C,i[4]=0,i[8]=R,i[12]=0,i[1]=0,i[5]=D,i[9]=Q,i[13]=0,i[2]=0,i[6]=0,i[10]=z,i[14]=G,i[3]=0,i[7]=0,i[11]=-1,i[15]=0,this}makeOrthographic(e,t,r,c,p,y){const i=this.elements,C=1/(t-e),D=1/(r-c),R=1/(y-p),Q=(t+e)*C,z=(r+c)*D,G=(y+p)*R;return i[0]=2*C,i[4]=0,i[8]=0,i[12]=-Q,i[1]=0,i[5]=2*D,i[9]=0,i[13]=-z,i[2]=0,i[6]=0,i[10]=-2*R,i[14]=-G,i[3]=0,i[7]=0,i[11]=0,i[15]=1,this}equals(e){const t=this.elements,r=e.elements;for(let c=0;c<16;c++)if(t[c]!==r[c])return!1;return!0}fromArray(e,t=0){for(let r=0;r<16;r++)this.elements[r]=e[r+t];return this}toArray(e=[],t=0){const r=this.elements;return e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],e}}const Am=new ft,ou=new ar,Fz=new ft(0,0,0),Lz=new ft(1,1,1),Od=new ft,ix=new ft,Sc=new ft,OE=new ar,NE=new sl;class hy{constructor(e=0,t=0,r=0,c=hy.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=r,this._order=c}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,r,c=this._order){return this._x=e,this._y=t,this._z=r,this._order=c,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,r=!0){const c=e.elements,p=c[0],y=c[4],i=c[8],C=c[1],D=c[5],R=c[9],Q=c[2],z=c[6],G=c[10];switch(t){case"XYZ":this._y=Math.asin(Eo(i,-1,1)),Math.abs(i)<.9999999?(this._x=Math.atan2(-R,G),this._z=Math.atan2(-y,p)):(this._x=Math.atan2(z,D),this._z=0);break;case"YXZ":this._x=Math.asin(-Eo(R,-1,1)),Math.abs(R)<.9999999?(this._y=Math.atan2(i,G),this._z=Math.atan2(C,D)):(this._y=Math.atan2(-Q,p),this._z=0);break;case"ZXY":this._x=Math.asin(Eo(z,-1,1)),Math.abs(z)<.9999999?(this._y=Math.atan2(-Q,G),this._z=Math.atan2(-y,D)):(this._y=0,this._z=Math.atan2(C,p));break;case"ZYX":this._y=Math.asin(-Eo(Q,-1,1)),Math.abs(Q)<.9999999?(this._x=Math.atan2(z,G),this._z=Math.atan2(C,p)):(this._x=0,this._z=Math.atan2(-y,D));break;case"YZX":this._z=Math.asin(Eo(C,-1,1)),Math.abs(C)<.9999999?(this._x=Math.atan2(-R,D),this._y=Math.atan2(-Q,p)):(this._x=0,this._y=Math.atan2(i,G));break;case"XZY":this._z=Math.asin(-Eo(y,-1,1)),Math.abs(y)<.9999999?(this._x=Math.atan2(z,D),this._y=Math.atan2(i,p)):(this._x=Math.atan2(-R,G),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,r){return OE.makeRotationFromQuaternion(e),this.setFromRotationMatrix(OE,t,r)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return NE.setFromEuler(this),this.setFromQuaternion(NE,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}hy.DEFAULT_ORDER="XYZ";class uy{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let r=0;r0&&(r=r.concat(y))}return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(n_,e,Pz),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(n_,Uz,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let r=0,c=t.length;r0&&(c.userData=this.userData),c.layers=this.layers.mask,c.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(c.matrixAutoUpdate=!1),this.isInstancedMesh&&(c.type="InstancedMesh",c.count=this.count,c.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(c.instanceColor=this.instanceColor.toJSON()));function p(i,C){return i[C.uuid]===void 0&&(i[C.uuid]=C.toJSON(e)),C.uuid}if(this.isScene)this.background&&(this.background.isColor?c.background=this.background.toJSON():this.background.isTexture&&(c.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(c.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){c.geometry=p(e.geometries,this.geometry);const i=this.geometry.parameters;if(i!==void 0&&i.shapes!==void 0){const C=i.shapes;if(Array.isArray(C))for(let D=0,R=C.length;D0){c.children=[];for(let i=0;i0){c.animations=[];for(let i=0;i0&&(r.geometries=i),C.length>0&&(r.materials=C),D.length>0&&(r.textures=D),R.length>0&&(r.images=R),Q.length>0&&(r.shapes=Q),z.length>0&&(r.skeletons=z),G.length>0&&(r.animations=G),J.length>0&&(r.nodes=J)}return r.object=c,r;function y(i){const C=[];for(const D in i){const R=i[D];delete R.metadata,C.push(R)}return C}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let r=0;r0?c.multiplyScalar(1/Math.sqrt(p)):c.set(0,0,0)}static getBarycoord(e,t,r,c,p){au.subVectors(c,t),OA.subVectors(r,t),Iw.subVectors(e,t);const y=au.dot(au),i=au.dot(OA),C=au.dot(Iw),D=OA.dot(OA),R=OA.dot(Iw),Q=y*D-i*i;if(Q===0)return p.set(-2,-1,-1);const z=1/Q,G=(D*C-i*R)*z,J=(y*R-i*C)*z;return p.set(1-G-J,J,G)}static containsPoint(e,t,r,c){return this.getBarycoord(e,t,r,c,NA),NA.x>=0&&NA.y>=0&&NA.x+NA.y<=1}static getUV(e,t,r,c,p,y,i,C){return this.getBarycoord(e,t,r,c,NA),C.set(0,0),C.addScaledVector(p,NA.x),C.addScaledVector(y,NA.y),C.addScaledVector(i,NA.z),C}static isFrontFacing(e,t,r,c){return au.subVectors(r,t),OA.subVectors(e,t),au.cross(OA).dot(c)<0}set(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this}setFromPointsAndIndices(e,t,r,c){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[c]),this}setFromAttributeAndIndices(e,t,r,c){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,r),this.c.fromBufferAttribute(e,c),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return au.subVectors(this.c,this.b),OA.subVectors(this.a,this.b),au.cross(OA).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return wh.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return wh.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,r,c,p){return wh.getUV(e,this.a,this.b,this.c,t,r,c,p)}containsPoint(e){return wh.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return wh.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const r=this.a,c=this.b,p=this.c;let y,i;pm.subVectors(c,r),fm.subVectors(p,r),Fw.subVectors(e,r);const C=pm.dot(Fw),D=fm.dot(Fw);if(C<=0&&D<=0)return t.copy(r);Lw.subVectors(e,c);const R=pm.dot(Lw),Q=fm.dot(Lw);if(R>=0&&Q<=R)return t.copy(c);const z=C*Q-R*D;if(z<=0&&C>=0&&R<=0)return y=C/(C-R),t.copy(r).addScaledVector(pm,y);Dw.subVectors(e,p);const G=pm.dot(Dw),J=fm.dot(Dw);if(J>=0&&G<=J)return t.copy(p);const Y=G*D-C*J;if(Y<=0&&D>=0&&J<=0)return i=D/(D-J),t.copy(r).addScaledVector(fm,i);const B=R*J-G*Q;if(B<=0&&Q-R>=0&&G-J>=0)return jE.subVectors(p,c),i=(Q-R)/(Q-R+(G-J)),t.copy(c).addScaledVector(jE,i);const ae=1/(B+Y+z);return y=Y*ae,i=z*ae,t.copy(r).addScaledVector(pm,y).addScaledVector(fm,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let zz=0;class ol extends Xu{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:zz++}),this.uuid=Pc(),this.name="",this.type="Material",this.blending=hf,this.side=uu,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=D2,this.blendDst=P2,this.blendEquation=qp,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=uv,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=LI,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Xx,this.stencilZFail=Xx,this.stencilZPass=Xx,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const r=e[t];if(r===void 0){console.warn("THREE.Material: '"+t+"' parameter is undefined.");continue}const c=this[t];if(c===void 0){console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.");continue}c&&c.isColor?c.set(r):c&&c.isVector3&&r&&r.isVector3?c.copy(r):this[t]=r}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const r={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.color&&this.color.isColor&&(r.color=this.color.getHex()),this.roughness!==void 0&&(r.roughness=this.roughness),this.metalness!==void 0&&(r.metalness=this.metalness),this.sheen!==void 0&&(r.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(r.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(r.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(r.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(r.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(r.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(r.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(r.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(r.shininess=this.shininess),this.clearcoat!==void 0&&(r.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(r.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(r.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(r.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,r.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(r.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(r.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(r.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(r.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(r.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(r.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(r.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(r.lightMap=this.lightMap.toJSON(e).uuid,r.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(r.aoMap=this.aoMap.toJSON(e).uuid,r.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(r.bumpMap=this.bumpMap.toJSON(e).uuid,r.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(r.normalMap=this.normalMap.toJSON(e).uuid,r.normalMapType=this.normalMapType,r.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(r.displacementMap=this.displacementMap.toJSON(e).uuid,r.displacementScale=this.displacementScale,r.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(r.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(r.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(r.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(r.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(r.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(r.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(r.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(r.combine=this.combine)),this.envMapIntensity!==void 0&&(r.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(r.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(r.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(r.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(r.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(r.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(r.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(r.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(r.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(r.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(r.size=this.size),this.shadowSide!==null&&(r.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(r.sizeAttenuation=this.sizeAttenuation),this.blending!==hf&&(r.blending=this.blending),this.side!==uu&&(r.side=this.side),this.vertexColors&&(r.vertexColors=!0),this.opacity<1&&(r.opacity=this.opacity),this.transparent===!0&&(r.transparent=this.transparent),r.depthFunc=this.depthFunc,r.depthTest=this.depthTest,r.depthWrite=this.depthWrite,r.colorWrite=this.colorWrite,r.stencilWrite=this.stencilWrite,r.stencilWriteMask=this.stencilWriteMask,r.stencilFunc=this.stencilFunc,r.stencilRef=this.stencilRef,r.stencilFuncMask=this.stencilFuncMask,r.stencilFail=this.stencilFail,r.stencilZFail=this.stencilZFail,r.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(r.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(r.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(r.wireframe=this.wireframe),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=this.flatShading),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function c(p){const y=[];for(const i in p){const C=p[i];delete C.metadata,y.push(C)}return y}if(t){const p=c(e.textures),y=c(e.images);p.length>0&&(r.textures=p),y.length>0&&(r.images=y)}return r}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let r=null;if(t!==null){const c=t.length;r=new Array(c);for(let p=0;p!==c;++p)r[p]=t[p].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class za extends ol{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Dn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ly,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ro=new ft,rx=new Di;class As{constructor(e,t,r=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=r,this.usage=W_,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,r){e*=this.itemSize,r*=t.itemSize;for(let c=0,p=this.itemSize;c0&&(e.userData=this.userData),this.parameters!==void 0){const C=this.parameters;for(const D in C)C[D]!==void 0&&(e[D]=C[D]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const r=this.attributes;for(const C in r){const D=r[C];e.data.attributes[C]=D.toJSON(e.data)}const c={};let p=!1;for(const C in this.morphAttributes){const D=this.morphAttributes[C],R=[];for(let Q=0,z=D.length;Q0&&(c[C]=R,p=!0)}p&&(e.data.morphAttributes=c,e.data.morphTargetsRelative=this.morphTargetsRelative);const y=this.groups;y.length>0&&(e.data.groups=JSON.parse(JSON.stringify(y)));const i=this.boundingSphere;return i!==null&&(e.data.boundingSphere={center:i.center.toArray(),radius:i.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const r=e.index;r!==null&&this.setIndex(r.clone(t));const c=e.attributes;for(const D in c){const R=c[D];this.setAttribute(D,R.clone(t))}const p=e.morphAttributes;for(const D in p){const R=[],Q=p[D];for(let z=0,G=Q.length;z0){const c=t[r[0]];if(c!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let p=0,y=c.length;pt.far?null:{distance:D,point:cx.clone(),object:u}}function hx(u,e,t,r,c,p,y,i,C){u.getVertexPosition(y,s_),u.getVertexPosition(i,o_),u.getVertexPosition(C,a_);const D=jz(u,e,t,r,s_,o_,a_,zw);if(D){c&&(ox.fromBufferAttribute(c,y),ax.fromBufferAttribute(c,i),lx.fromBufferAttribute(c,C),D.uv=wh.getUV(zw,s_,o_,a_,ox,ax,lx,new Di)),p&&(ox.fromBufferAttribute(p,y),ax.fromBufferAttribute(p,i),lx.fromBufferAttribute(p,C),D.uv2=wh.getUV(zw,s_,o_,a_,ox,ax,lx,new Di));const R={a:y,b:i,c:C,normal:new ft,materialIndex:0};wh.getNormal(s_,o_,a_,R.normal),D.face=R}return D}class qA extends br{constructor(e=1,t=1,r=1,c=1,p=1,y=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:r,widthSegments:c,heightSegments:p,depthSegments:y};const i=this;c=Math.floor(c),p=Math.floor(p),y=Math.floor(y);const C=[],D=[],R=[],Q=[];let z=0,G=0;J("z","y","x",-1,-1,r,t,e,y,p,0),J("z","y","x",1,-1,r,t,-e,y,p,1),J("x","z","y",1,1,e,r,t,c,y,2),J("x","z","y",1,-1,e,r,-t,c,y,3),J("x","y","z",1,-1,e,t,r,c,p,4),J("x","y","z",-1,-1,e,t,-r,c,p,5),this.setIndex(C),this.setAttribute("position",new jn(D,3)),this.setAttribute("normal",new jn(R,3)),this.setAttribute("uv",new jn(Q,2));function J(Y,B,ae,ce,Ae,we,me,De,Je,Fe,Ge){const Et=we/Je,li=me/Fe,xi=we/2,te=me/2,le=De/2,ye=Je+1,xe=Fe+1;let Re=0,Oe=0;const We=new ft;for(let Ve=0;Ve0?1:-1,R.push(We.x,We.y,We.z),Q.push(Se/Je),Q.push(1-Ve/Fe),Re+=1}}for(let Ve=0;Ve0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const r={};for(const c in this.extensions)this.extensions[c]===!0&&(r[c]=!0);return Object.keys(r).length>0&&(t.extensions=r),t}}class Qv extends ls{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ar,this.projectionMatrix=new ar,this.projectionMatrixInverse=new ar}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class _a extends Qv{constructor(e=50,t=1,r=.1,c=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=r,this.far=c,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=j_*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Af*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return j_*2*Math.atan(Math.tan(Af*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,r,c,p,y){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=c,this.view.width=p,this.view.height=y,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Af*.5*this.fov)/this.zoom,r=2*t,c=this.aspect*r,p=-.5*c;const y=this.view;if(this.view!==null&&this.view.enabled){const C=y.fullWidth,D=y.fullHeight;p+=y.offsetX*c/C,t-=y.offsetY*r/D,c*=y.width/C,r*=y.height/D}const i=this.filmOffset;i!==0&&(p+=e*i/this.getFilmWidth()),this.projectionMatrix.makePerspective(p,p+c,t,t-r,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const _m=-90,ym=1;class kI extends ls{constructor(e,t,r){super(),this.type="CubeCamera",this.renderTarget=r;const c=new _a(_m,ym,e,t);c.layers=this.layers,c.up.set(0,1,0),c.lookAt(1,0,0),this.add(c);const p=new _a(_m,ym,e,t);p.layers=this.layers,p.up.set(0,1,0),p.lookAt(-1,0,0),this.add(p);const y=new _a(_m,ym,e,t);y.layers=this.layers,y.up.set(0,0,-1),y.lookAt(0,1,0),this.add(y);const i=new _a(_m,ym,e,t);i.layers=this.layers,i.up.set(0,0,1),i.lookAt(0,-1,0),this.add(i);const C=new _a(_m,ym,e,t);C.layers=this.layers,C.up.set(0,1,0),C.lookAt(0,0,1),this.add(C);const D=new _a(_m,ym,e,t);D.layers=this.layers,D.up.set(0,1,0),D.lookAt(0,0,-1),this.add(D)}update(e,t){this.parent===null&&this.updateMatrixWorld();const r=this.renderTarget,[c,p,y,i,C,D]=this.children,R=e.getRenderTarget(),Q=e.toneMapping,z=e.xr.enabled;e.toneMapping=Hu,e.xr.enabled=!1;const G=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0),e.render(t,c),e.setRenderTarget(r,1),e.render(t,p),e.setRenderTarget(r,2),e.render(t,y),e.setRenderTarget(r,3),e.render(t,i),e.setRenderTarget(r,4),e.render(t,C),r.texture.generateMipmaps=G,e.setRenderTarget(r,5),e.render(t,D),e.setRenderTarget(R),e.toneMapping=Q,e.xr.enabled=z,r.texture.needsPMREMUpdate=!0}}class Ay extends To{constructor(e,t,r,c,p,y,i,C,D,R){e=e!==void 0?e:[],t=t!==void 0?t:rp,super(e,t,r,c,p,y,i,C,D,R),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class OI extends rl{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const r={width:e,height:e,depth:1},c=[r,r,r,r,r,r];this.texture=new Ay(c,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:Xs}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},c=new qA(5,5,5),p=new ko({name:"CubemapFromEquirect",uniforms:jm(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:rc,blending:KA});p.uniforms.tEquirect.value=t;const y=new us(c,p),i=t.minFilter;return t.minFilter===op&&(t.minFilter=Xs),new kI(1,10,this).update(e,y),t.minFilter=i,y.geometry.dispose(),y.material.dispose(),this}clear(e,t,r,c){const p=e.getRenderTarget();for(let y=0;y<6;y++)e.setRenderTarget(this,y),e.clear(t,r,c);e.setRenderTarget(p)}}const kw=new ft,Xz=new ft,qz=new Pl;class jd{constructor(e=new ft(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,r,c){return this.normal.set(e,t,r),this.constant=c,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,r){const c=kw.subVectors(r,t).cross(Xz.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(c,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){const r=e.delta(kw),c=this.normal.dot(r);if(c===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const p=-(e.start.dot(this.normal)+this.constant)/c;return p<0||p>1?null:t.copy(r).multiplyScalar(p).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const r=t||qz.getNormalMatrix(e),c=this.coplanarPoint(kw).applyMatrix4(e),p=this.normal.applyMatrix3(r).normalize();return this.constant=-c.dot(p),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const xm=new XA,ux=new ft;class Vv{constructor(e=new jd,t=new jd,r=new jd,c=new jd,p=new jd,y=new jd){this.planes=[e,t,r,c,p,y]}set(e,t,r,c,p,y){const i=this.planes;return i[0].copy(e),i[1].copy(t),i[2].copy(r),i[3].copy(c),i[4].copy(p),i[5].copy(y),this}copy(e){const t=this.planes;for(let r=0;r<6;r++)t[r].copy(e.planes[r]);return this}setFromProjectionMatrix(e){const t=this.planes,r=e.elements,c=r[0],p=r[1],y=r[2],i=r[3],C=r[4],D=r[5],R=r[6],Q=r[7],z=r[8],G=r[9],J=r[10],Y=r[11],B=r[12],ae=r[13],ce=r[14],Ae=r[15];return t[0].setComponents(i-c,Q-C,Y-z,Ae-B).normalize(),t[1].setComponents(i+c,Q+C,Y+z,Ae+B).normalize(),t[2].setComponents(i+p,Q+D,Y+G,Ae+ae).normalize(),t[3].setComponents(i-p,Q-D,Y-G,Ae-ae).normalize(),t[4].setComponents(i-y,Q-R,Y-J,Ae-ce).normalize(),t[5].setComponents(i+y,Q+R,Y+J,Ae+ce).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),xm.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(xm)}intersectsSprite(e){return xm.center.set(0,0,0),xm.radius=.7071067811865476,xm.applyMatrix4(e.matrixWorld),this.intersectsSphere(xm)}intersectsSphere(e){const t=this.planes,r=e.center,c=-e.radius;for(let p=0;p<6;p++)if(t[p].distanceToPoint(r)0?e.max.x:e.min.x,ux.y=c.normal.y>0?e.max.y:e.min.y,ux.z=c.normal.z>0?e.max.z:e.min.z,c.distanceToPoint(ux)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let r=0;r<6;r++)if(t[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function NI(){let u=null,e=!1,t=null,r=null;function c(p,y){t(p,y),r=u.requestAnimationFrame(c)}return{start:function(){e!==!0&&t!==null&&(r=u.requestAnimationFrame(c),e=!0)},stop:function(){u.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(p){t=p},setContext:function(p){u=p}}}function Yz(u,e){const t=e.isWebGL2,r=new WeakMap;function c(D,R){const Q=D.array,z=D.usage,G=u.createBuffer();u.bindBuffer(R,G),u.bufferData(R,Q,z),D.onUploadCallback();let J;if(Q instanceof Float32Array)J=5126;else if(Q instanceof Uint16Array)if(D.isFloat16BufferAttribute)if(t)J=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else J=5123;else if(Q instanceof Int16Array)J=5122;else if(Q instanceof Uint32Array)J=5125;else if(Q instanceof Int32Array)J=5124;else if(Q instanceof Int8Array)J=5120;else if(Q instanceof Uint8Array)J=5121;else if(Q instanceof Uint8ClampedArray)J=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+Q);return{buffer:G,type:J,bytesPerElement:Q.BYTES_PER_ELEMENT,version:D.version}}function p(D,R,Q){const z=R.array,G=R.updateRange;u.bindBuffer(Q,D),G.count===-1?u.bufferSubData(Q,0,z):(t?u.bufferSubData(Q,G.offset*z.BYTES_PER_ELEMENT,z,G.offset,G.count):u.bufferSubData(Q,G.offset*z.BYTES_PER_ELEMENT,z.subarray(G.offset,G.offset+G.count)),G.count=-1),R.onUploadCallback()}function y(D){return D.isInterleavedBufferAttribute&&(D=D.data),r.get(D)}function i(D){D.isInterleavedBufferAttribute&&(D=D.data);const R=r.get(D);R&&(u.deleteBuffer(R.buffer),r.delete(D))}function C(D,R){if(D.isGLBufferAttribute){const z=r.get(D);(!z||z.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); } vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( specularColor, 1.0, dotVH ); float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif`,lk=`#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.0415560, 1.0572252 ); vec3 Fresnel0ToIor( vec3 fresnel0 ) { vec3 sqrtF0 = sqrt( fresnel0 ); return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 ); } vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) ); } float IorToFresnel0( float transmittedIor, float incidentIor ) { return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor )); } vec3 evalSensitivity( float OPD, vec3 shift ) { float phase = 2.0 * PI * OPD * 1.0e-9; vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 ); vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 ); vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 ); vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var ); xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) ); xyz /= 1.0685e-7; vec3 rgb = XYZ_TO_REC709 * xyz; return rgb; } vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) { vec3 I; float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) ); float cosTheta2Sq = 1.0 - sinTheta2Sq; if ( cosTheta2Sq < 0.0 ) { return vec3( 1.0 ); } float cosTheta2 = sqrt( cosTheta2Sq ); float R0 = IorToFresnel0( iridescenceIOR, outsideIOR ); float R12 = F_Schlick( R0, 1.0, cosTheta1 ); float R21 = R12; float T121 = 1.0 - R12; float phi12 = 0.0; if ( iridescenceIOR < outsideIOR ) phi12 = PI; float phi21 = PI - phi12; vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR ); vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 ); vec3 phi23 = vec3( 0.0 ); if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI; if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI; if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI; float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2; vec3 phi = vec3( phi21 ) + phi23; vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 ); vec3 r123 = sqrt( R123 ); vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 ); vec3 C0 = R12 + Rs; I = C0; vec3 Cm = Rs - T121; for ( int m = 1; m <= 2; ++ m ) { Cm *= r123; vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi ); I += Cm * Sm; } return max( I, vec3( 0.0 ) ); } #endif`,ck=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float Hll = bumpScale * texture2D( bumpMap, vUv ).x; float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { vec3 vSigmaX = dFdx( surf_pos.xyz ); vec3 vSigmaY = dFdy( surf_pos.xyz ); vec3 vN = surf_norm; vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ) * faceDirection; vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif`,hk=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif`,uk=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,Ak=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,dk=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,pk=`#if defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #elif defined( USE_COLOR ) diffuseColor.rgb *= vColor; #endif`,fk=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) varying vec3 vColor; #endif`,mk=`#if defined( USE_COLOR_ALPHA ) varying vec4 vColor; #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) varying vec3 vColor; #endif`,gk=`#if defined( USE_COLOR_ALPHA ) vColor = vec4( 1.0 ); #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) vColor = vec3( 1.0 ); #endif #ifdef USE_COLOR vColor *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz *= instanceColor.xyz; #endif`,_k=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; struct GeometricContext { vec3 position; vec3 normal; vec3 viewDir; #ifdef USE_CLEARCOAT vec3 clearcoatNormal; #endif }; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } mat3 transposeMat3( const in mat3 m ) { mat3 tmp; tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); return tmp; } float luminance( const in vec3 rgb ) { const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); return dot( weights, rgb ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); }`,yk=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_v0 0.339 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_v1 0.276 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_v4 0.046 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_v5 0.016 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_v6 0.0038 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,xk=`vec3 transformedNormal = objectNormal; #ifdef USE_INSTANCING mat3 m = mat3( instanceMatrix ); transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); transformedNormal = m * transformedNormal; #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,vk=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,wk=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias ); #endif`,bk=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vUv ); totalEmissiveRadiance *= emissiveColor.rgb; #endif`,Bk=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,Ck="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ek=`vec4 LinearToLinear( in vec4 value ) { return value; } vec4 LinearTosRGB( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,Tk=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); #else vec4 envColor = vec4( 0.0 ); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif`,Sk=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,Mk=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,Ik=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,Fk=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,Lk=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,Dk=`#ifdef USE_FOG varying float vFogDepth; #endif`,Pk=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,Uk=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,Rk=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,zk=`#ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; reflectedLight.indirectDiffuse += lightMapIrradiance; #endif`,kk=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,Ok=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,Nk=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Qk=`uniform bool receiveShadow; uniform vec3 ambientLightColor; uniform vec3 lightProbe[ 9 ]; vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { #if defined ( PHYSICALLY_CORRECT_LIGHTS ) float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; #else if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) { return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent ); } return 1.0; #endif } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = pointLight.position - geometry.position; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) { vec3 lVector = spotLight.position - geometry.position; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif`,Vk=`#if defined( USE_ENVMAP ) vec3 getIBLIrradiance( const in vec3 normal ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #if defined( ENVMAP_TYPE_CUBE_UV ) vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #endif`,Hk=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,Gk=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Wk=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,jk=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Kk=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULARINTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a; #endif #ifdef USE_SPECULARCOLORMAP specularColorFactor *= texture2D( specularColorMap, vUv ).rgb; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEENCOLORMAP material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); #ifdef USE_SHEENROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a; #endif #endif`,$k=`struct PhysicalMaterial { vec3 diffuseColor; float roughness; vec3 specularColor; float specularF90; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif }; vec3 clearcoatSpecular = vec3( 0.0 ); vec3 sheenSpecular = vec3( 0.0 ); float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); return saturate( DG * RECIPROCAL_PI ); } vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); vec4 r = roughness * c0 + c1; float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; return fab; } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { vec2 fab = DFGApprox( normal, viewDir, roughness ); return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif vec2 fab = DFGApprox( normal, viewDir, roughness ); #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometry.normal; vec3 viewDir = geometry.viewDir; vec3 position = geometry.position; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness ); #endif #ifdef USE_IRIDESCENCE reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness ); #else reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness ); #endif reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness ); #endif vec3 singleScattering = vec3( 0.0 ); vec3 multiScattering = vec3( 0.0 ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); #else computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); #endif vec3 totalScattering = singleScattering + multiScattering; vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); reflectedLight.indirectSpecular += radiance * singleScattering; reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,Zk=` GeometricContext geometry; geometry.position = - vViewPosition; geometry.normal = normal; geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); #ifdef USE_CLEARCOAT geometry.clearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometry.viewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometry, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, geometry, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); irradiance += getLightProbeIrradiance( lightProbe, geometry.normal ); #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal ); } #pragma unroll_loop_end #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,Xk=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) iblIrradiance += getIBLIrradiance( geometry.normal ); #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); #endif #endif`,qk=`#if defined( RE_IndirectDiffuse ) RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); #endif`,Yk=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,Jk=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,e5=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT varying float vFragDepth; varying float vIsPerspective; #else uniform float logDepthBufFC; #endif #endif`,t5=`#ifdef USE_LOGDEPTHBUF #ifdef USE_LOGDEPTHBUF_EXT vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #else if ( isPerspectiveMatrix( projectionMatrix ) ) { gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; gl_Position.z *= gl_Position.w; } #endif #endif`,i5=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); #endif diffuseColor *= sampledDiffuseColor; #endif`,n5=`#ifdef USE_MAP uniform sampler2D map; #endif`,r5=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,s5=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,o5=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vUv ); metalnessFactor *= texelMetalness.b; #endif`,a5=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,l5=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,c5=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #else objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; #endif #endif`,h5=`#ifdef USE_MORPHTARGETS uniform float morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #else #ifndef USE_MORPHNORMALS uniform float morphTargetInfluences[ 8 ]; #else uniform float morphTargetInfluences[ 4 ]; #endif #endif #endif`,u5=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; #ifdef MORPHTARGETS_TEXTURE for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #else transformed += morphTarget0 * morphTargetInfluences[ 0 ]; transformed += morphTarget1 * morphTargetInfluences[ 1 ]; transformed += morphTarget2 * morphTargetInfluences[ 2 ]; transformed += morphTarget3 * morphTargetInfluences[ 3 ]; #ifndef USE_MORPHNORMALS transformed += morphTarget4 * morphTargetInfluences[ 4 ]; transformed += morphTarget5 * morphTargetInfluences[ 5 ]; transformed += morphTarget6 * morphTargetInfluences[ 6 ]; transformed += morphTarget7 * morphTargetInfluences[ 7 ]; #endif #endif #endif`,A5=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif #ifdef USE_TANGENT vec3 tangent = normalize( vTangent ); vec3 bitangent = normalize( vBitangent ); #ifdef DOUBLE_SIDED tangent = tangent * faceDirection; bitangent = bitangent * faceDirection; #endif #if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP ) mat3 vTBN = mat3( tangent, bitangent, normal ); #endif #endif #endif vec3 geometryNormal = normal;`,d5=`#ifdef OBJECTSPACE_NORMALMAP normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( TANGENTSPACE_NORMALMAP ) vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; mapN.xy *= normalScale; #ifdef USE_TANGENT normal = normalize( vTBN * mapN ); #else normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection ); #endif #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,p5=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,f5=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,m5=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,g5=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef OBJECTSPACE_NORMALMAP uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) ) vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( vUv.st ); vec2 st1 = dFdy( vUv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det ); return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z ); } #endif`,_5=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = geometryNormal; #endif`,y5=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; #ifdef USE_TANGENT clearcoatNormal = normalize( vTBN * clearcoatMapN ); #else clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection ); #endif #endif`,x5=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif`,v5=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,w5=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha + 0.1; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,b5=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); const float ShiftRight8 = 1. / 256.; vec4 packDepthToRGBA( const in float v ) { vec4 r = vec4( fract( v * PackFactors ), v ); r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors ); } vec2 packDepthToRG( in highp float v ) { return packDepthToRGBA( v ).yx; } float unpackRGToDepth( const in highp vec2 v ) { return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); } vec4 pack2HalfToRGBA( vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { return linearClipZ * ( near - far ) - near; } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { return ( near * far ) / ( ( far - near ) * invClipZ - far ); }`,B5=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,C5=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,E5=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,T5=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,S5=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vUv ); roughnessFactor *= texelRoughness.g; #endif`,M5=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,I5=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); } vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { return unpackRGBATo2Half( texture2D( shadow, uv ) ); } float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ float occlusion = 1.0; vec2 distribution = texture2DDistribution( shadow, uv ); float hard_shadow = step( compare , distribution.x ); if (hard_shadow != 1.0 ) { float distance = compare - distribution.x ; float variance = max( 0.00000, distribution.y * distribution.y ); float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); } return occlusion; } float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { #if defined( SHADOWMAP_TYPE_PCF ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx0 = - texelSize.x * shadowRadius; float dy0 = - texelSize.y * shadowRadius; float dx1 = + texelSize.x * shadowRadius; float dy1 = + texelSize.y * shadowRadius; float dx2 = dx0 / 2.0; float dy2 = dy0 / 2.0; float dx3 = dx1 / 2.0; float dy3 = dy1 / 2.0; shadow = ( texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) ) * ( 1.0 / 17.0 ); #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float dx = texelSize.x; float dy = texelSize.y; vec2 uv = shadowCoord.xy; vec2 f = fract( uv * shadowMapSize + 0.5 ); uv -= f * texelSize; shadow = ( texture2DCompare( shadowMap, uv, shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), f.x ) + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), f.y ) + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), f.x ), mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), f.x ), f.y ) ) * ( 1.0 / 9.0 ); #elif defined( SHADOWMAP_TYPE_VSM ) shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); #else shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); #endif } return shadow; } vec2 cubeToUV( vec3 v, float texelSizeY ) { vec3 absV = abs( v ); float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); absV *= scaleToCube; v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); vec2 planar = v.xy; float almostATexel = 1.5 * texelSizeY; float almostOne = 1.0 - almostATexel; if ( absV.z >= almostOne ) { if ( v.z > 0.0 ) planar.x = 4.0 - v.x; } else if ( absV.x >= almostOne ) { float signX = sign( v.x ); planar.x = v.z * signX + 2.0 * signX; } else if ( absV.y >= almostOne ) { float signY = sign( v.y ); planar.x = v.x + 2.0 * signY + 2.0; planar.y = v.z * signY - 2.0; } return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); } float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); vec3 lightToPosition = shadowCoord.xyz; float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; return ( texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) ) * ( 1.0 / 9.0 ); #else return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); #endif } #endif`,F5=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,L5=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,D5=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,P5=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,U5=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; uniform int boneTextureSize; mat4 getBoneMatrix( const in float i ) { float j = i * 4.0; float x = mod( j, float( boneTextureSize ) ); float y = floor( j / float( boneTextureSize ) ); float dx = 1.0 / float( boneTextureSize ); float dy = 1.0 / float( boneTextureSize ); y = dy * ( y + 0.5 ); vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); mat4 bone = mat4( v1, v2, v3, v4 ); return bone; } #endif`,R5=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,z5=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,k5=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,O5=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,N5=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,Q5=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return toneMappingExposure * color; } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 OptimizedCineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,V5=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmission = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission ); #endif`,H5=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); #ifdef texture2DLodEXT return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #else return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod ); #endif } vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return radiance; } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance * radiance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance ); vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a ); } #endif`,G5=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) ) varying vec2 vUv; #endif`,W5=`#ifdef USE_UV #ifdef UVS_VERTEX_ONLY vec2 vUv; #else varying vec2 vUv; #endif uniform mat3 uvTransform; #endif`,j5=`#ifdef USE_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif`,K5=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) varying vec2 vUv2; #endif`,$5=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) attribute vec2 uv2; varying vec2 vUv2; uniform mat3 uv2Transform; #endif`,Z5=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy; #endif`,X5=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`;const q5=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,Y5=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,J5=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,eO=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float flipEnvMap; uniform float backgroundBlurriness; uniform float backgroundIntensity; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,tO=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,iO=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,nO=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,rO=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include vec4 diffuseColor = vec4( 1.0 ); #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #endif }`,sO=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main() { #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,oO=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { #include vec4 diffuseColor = vec4( 1.0 ); #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = packDepthToRGBA( dist ); }`,aO=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,lO=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,cO=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include }`,hO=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include void main() { #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,uO=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,AO=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vUv2 ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,dO=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,pO=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,fO=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,mO=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,gO=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) vViewPosition = - mvPosition.xyz; #endif }`,_O=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main() { #include #include #include #include gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,yO=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,xO=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,vO=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,wO=`#define STANDARD #ifdef PHYSICAL #define IOR #define SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULARINTENSITYMAP uniform sampler2D specularIntensityMap; #endif #ifdef USE_SPECULARCOLORMAP uniform sampler2D specularColorMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEENCOLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEENROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat; #endif #include #include #include #include #include #include }`,bO=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,BO=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include vec4 diffuseColor = vec4( diffuse, opacity ); ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,CO=`uniform float size; uniform float scale; #include #include #include #include #include #include void main() { #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,EO=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,TO=`#include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include }`,SO=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include }`,MO=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); vec2 scale; scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,IO=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { #include vec3 outgoingLight = vec3( 0.0 ); vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,zr={alphamap_fragment:Jz,alphamap_pars_fragment:ek,alphatest_fragment:tk,alphatest_pars_fragment:ik,aomap_fragment:nk,aomap_pars_fragment:rk,begin_vertex:sk,beginnormal_vertex:ok,bsdfs:ak,iridescence_fragment:lk,bumpmap_pars_fragment:ck,clipping_planes_fragment:hk,clipping_planes_pars_fragment:uk,clipping_planes_pars_vertex:Ak,clipping_planes_vertex:dk,color_fragment:pk,color_pars_fragment:fk,color_pars_vertex:mk,color_vertex:gk,common:_k,cube_uv_reflection_fragment:yk,defaultnormal_vertex:xk,displacementmap_pars_vertex:vk,displacementmap_vertex:wk,emissivemap_fragment:bk,emissivemap_pars_fragment:Bk,encodings_fragment:Ck,encodings_pars_fragment:Ek,envmap_fragment:Tk,envmap_common_pars_fragment:Sk,envmap_pars_fragment:Mk,envmap_pars_vertex:Ik,envmap_physical_pars_fragment:Vk,envmap_vertex:Fk,fog_vertex:Lk,fog_pars_vertex:Dk,fog_fragment:Pk,fog_pars_fragment:Uk,gradientmap_pars_fragment:Rk,lightmap_fragment:zk,lightmap_pars_fragment:kk,lights_lambert_fragment:Ok,lights_lambert_pars_fragment:Nk,lights_pars_begin:Qk,lights_toon_fragment:Hk,lights_toon_pars_fragment:Gk,lights_phong_fragment:Wk,lights_phong_pars_fragment:jk,lights_physical_fragment:Kk,lights_physical_pars_fragment:$k,lights_fragment_begin:Zk,lights_fragment_maps:Xk,lights_fragment_end:qk,logdepthbuf_fragment:Yk,logdepthbuf_pars_fragment:Jk,logdepthbuf_pars_vertex:e5,logdepthbuf_vertex:t5,map_fragment:i5,map_pars_fragment:n5,map_particle_fragment:r5,map_particle_pars_fragment:s5,metalnessmap_fragment:o5,metalnessmap_pars_fragment:a5,morphcolor_vertex:l5,morphnormal_vertex:c5,morphtarget_pars_vertex:h5,morphtarget_vertex:u5,normal_fragment_begin:A5,normal_fragment_maps:d5,normal_pars_fragment:p5,normal_pars_vertex:f5,normal_vertex:m5,normalmap_pars_fragment:g5,clearcoat_normal_fragment_begin:_5,clearcoat_normal_fragment_maps:y5,clearcoat_pars_fragment:x5,iridescence_pars_fragment:v5,output_fragment:w5,packing:b5,premultiplied_alpha_fragment:B5,project_vertex:C5,dithering_fragment:E5,dithering_pars_fragment:T5,roughnessmap_fragment:S5,roughnessmap_pars_fragment:M5,shadowmap_pars_fragment:I5,shadowmap_pars_vertex:F5,shadowmap_vertex:L5,shadowmask_pars_fragment:D5,skinbase_vertex:P5,skinning_pars_vertex:U5,skinning_vertex:R5,skinnormal_vertex:z5,specularmap_fragment:k5,specularmap_pars_fragment:O5,tonemapping_fragment:N5,tonemapping_pars_fragment:Q5,transmission_fragment:V5,transmission_pars_fragment:H5,uv_pars_fragment:G5,uv_pars_vertex:W5,uv_vertex:j5,uv2_pars_fragment:K5,uv2_pars_vertex:$5,uv2_vertex:Z5,worldpos_vertex:X5,background_vert:q5,background_frag:Y5,backgroundCube_vert:J5,backgroundCube_frag:eO,cube_vert:tO,cube_frag:iO,depth_vert:nO,depth_frag:rO,distanceRGBA_vert:sO,distanceRGBA_frag:oO,equirect_vert:aO,equirect_frag:lO,linedashed_vert:cO,linedashed_frag:hO,meshbasic_vert:uO,meshbasic_frag:AO,meshlambert_vert:dO,meshlambert_frag:pO,meshmatcap_vert:fO,meshmatcap_frag:mO,meshnormal_vert:gO,meshnormal_frag:_O,meshphong_vert:yO,meshphong_frag:xO,meshphysical_vert:vO,meshphysical_frag:wO,meshtoon_vert:bO,meshtoon_frag:BO,points_vert:CO,points_frag:EO,shadow_vert:TO,shadow_frag:SO,sprite_vert:MO,sprite_frag:IO},En={common:{diffuse:{value:new Dn(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Pl},uv2Transform:{value:new Pl},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Di(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Dn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Dn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Pl}},sprite:{diffuse:{value:new Dn(16777215)},opacity:{value:1},center:{value:new Di(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Pl}}},Fl={basic:{uniforms:Sl([En.common,En.specularmap,En.envmap,En.aomap,En.lightmap,En.fog]),vertexShader:zr.meshbasic_vert,fragmentShader:zr.meshbasic_frag},lambert:{uniforms:Sl([En.common,En.specularmap,En.envmap,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.fog,En.lights,{emissive:{value:new Dn(0)}}]),vertexShader:zr.meshlambert_vert,fragmentShader:zr.meshlambert_frag},phong:{uniforms:Sl([En.common,En.specularmap,En.envmap,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.fog,En.lights,{emissive:{value:new Dn(0)},specular:{value:new Dn(1118481)},shininess:{value:30}}]),vertexShader:zr.meshphong_vert,fragmentShader:zr.meshphong_frag},standard:{uniforms:Sl([En.common,En.envmap,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.roughnessmap,En.metalnessmap,En.fog,En.lights,{emissive:{value:new Dn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:zr.meshphysical_vert,fragmentShader:zr.meshphysical_frag},toon:{uniforms:Sl([En.common,En.aomap,En.lightmap,En.emissivemap,En.bumpmap,En.normalmap,En.displacementmap,En.gradientmap,En.fog,En.lights,{emissive:{value:new Dn(0)}}]),vertexShader:zr.meshtoon_vert,fragmentShader:zr.meshtoon_frag},matcap:{uniforms:Sl([En.common,En.bumpmap,En.normalmap,En.displacementmap,En.fog,{matcap:{value:null}}]),vertexShader:zr.meshmatcap_vert,fragmentShader:zr.meshmatcap_frag},points:{uniforms:Sl([En.points,En.fog]),vertexShader:zr.points_vert,fragmentShader:zr.points_frag},dashed:{uniforms:Sl([En.common,En.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:zr.linedashed_vert,fragmentShader:zr.linedashed_frag},depth:{uniforms:Sl([En.common,En.displacementmap]),vertexShader:zr.depth_vert,fragmentShader:zr.depth_frag},normal:{uniforms:Sl([En.common,En.bumpmap,En.normalmap,En.displacementmap,{opacity:{value:1}}]),vertexShader:zr.meshnormal_vert,fragmentShader:zr.meshnormal_frag},sprite:{uniforms:Sl([En.sprite,En.fog]),vertexShader:zr.sprite_vert,fragmentShader:zr.sprite_frag},background:{uniforms:{uvTransform:{value:new Pl},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:zr.background_vert,fragmentShader:zr.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:zr.backgroundCube_vert,fragmentShader:zr.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:zr.cube_vert,fragmentShader:zr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:zr.equirect_vert,fragmentShader:zr.equirect_frag},distanceRGBA:{uniforms:Sl([En.common,En.displacementmap,{referencePosition:{value:new ft},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:zr.distanceRGBA_vert,fragmentShader:zr.distanceRGBA_frag},shadow:{uniforms:Sl([En.lights,En.fog,{color:{value:new Dn(0)},opacity:{value:1}}]),vertexShader:zr.shadow_vert,fragmentShader:zr.shadow_frag}};Fl.physical={uniforms:Sl([Fl.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Di(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Dn(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Di},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Dn(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Dn(1,1,1)},specularColorMap:{value:null}}]),vertexShader:zr.meshphysical_vert,fragmentShader:zr.meshphysical_frag};const Ax={r:0,b:0,g:0};function FO(u,e,t,r,c,p,y){const i=new Dn(0);let C=p===!0?0:1,D,R,Q=null,z=0,G=null;function J(B,ae){let ce=!1,Ae=ae.isScene===!0?ae.background:null;Ae&&Ae.isTexture&&(Ae=(ae.backgroundBlurriness>0?t:e).get(Ae));const we=u.xr,me=we.getSession&&we.getSession();me&&me.environmentBlendMode==="additive"&&(Ae=null),Ae===null?Y(i,C):Ae&&Ae.isColor&&(Y(Ae,1),ce=!0),(u.autoClear||ce)&&u.clear(u.autoClearColor,u.autoClearDepth,u.autoClearStencil),Ae&&(Ae.isCubeTexture||Ae.mapping===qm)?(R===void 0&&(R=new us(new qA(1,1,1),new ko({name:"BackgroundCubeMaterial",uniforms:jm(Fl.backgroundCube.uniforms),vertexShader:Fl.backgroundCube.vertexShader,fragmentShader:Fl.backgroundCube.fragmentShader,side:rc,depthTest:!1,depthWrite:!1,fog:!1})),R.geometry.deleteAttribute("normal"),R.geometry.deleteAttribute("uv"),R.onBeforeRender=function(De,Je,Fe){this.matrixWorld.copyPosition(Fe.matrixWorld)},Object.defineProperty(R.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),c.update(R)),R.material.uniforms.envMap.value=Ae,R.material.uniforms.flipEnvMap.value=Ae.isCubeTexture&&Ae.isRenderTargetTexture===!1?-1:1,R.material.uniforms.backgroundBlurriness.value=ae.backgroundBlurriness,R.material.uniforms.backgroundIntensity.value=ae.backgroundIntensity,R.material.toneMapped=Ae.encoding!==Ts,(Q!==Ae||z!==Ae.version||G!==u.toneMapping)&&(R.material.needsUpdate=!0,Q=Ae,z=Ae.version,G=u.toneMapping),R.layers.enableAll(),B.unshift(R,R.geometry,R.material,0,0,null)):Ae&&Ae.isTexture&&(D===void 0&&(D=new us(new xf(2,2),new ko({name:"BackgroundMaterial",uniforms:jm(Fl.background.uniforms),vertexShader:Fl.background.vertexShader,fragmentShader:Fl.background.fragmentShader,side:uu,depthTest:!1,depthWrite:!1,fog:!1})),D.geometry.deleteAttribute("normal"),Object.defineProperty(D.material,"map",{get:function(){return this.uniforms.t2D.value}}),c.update(D)),D.material.uniforms.t2D.value=Ae,D.material.uniforms.backgroundIntensity.value=ae.backgroundIntensity,D.material.toneMapped=Ae.encoding!==Ts,Ae.matrixAutoUpdate===!0&&Ae.updateMatrix(),D.material.uniforms.uvTransform.value.copy(Ae.matrix),(Q!==Ae||z!==Ae.version||G!==u.toneMapping)&&(D.material.needsUpdate=!0,Q=Ae,z=Ae.version,G=u.toneMapping),D.layers.enableAll(),B.unshift(D,D.geometry,D.material,0,0,null))}function Y(B,ae){B.getRGB(Ax,zI(u)),r.buffers.color.setClear(Ax.r,Ax.g,Ax.b,ae,y)}return{getClearColor:function(){return i},setClearColor:function(B,ae=1){i.set(B),C=ae,Y(i,C)},getClearAlpha:function(){return C},setClearAlpha:function(B){C=B,Y(i,C)},render:J}}function LO(u,e,t,r){const c=u.getParameter(34921),p=r.isWebGL2?null:e.get("OES_vertex_array_object"),y=r.isWebGL2||p!==null,i={},C=B(null);let D=C,R=!1;function Q(le,ye,xe,Re,Oe){let We=!1;if(y){const Ve=Y(Re,xe,ye);D!==Ve&&(D=Ve,G(D.object)),We=ae(le,Re,xe,Oe),We&&ce(le,Re,xe,Oe)}else{const Ve=ye.wireframe===!0;(D.geometry!==Re.id||D.program!==xe.id||D.wireframe!==Ve)&&(D.geometry=Re.id,D.program=xe.id,D.wireframe=Ve,We=!0)}Oe!==null&&t.update(Oe,34963),(We||R)&&(R=!1,Fe(le,ye,xe,Re),Oe!==null&&u.bindBuffer(34963,t.get(Oe).buffer))}function z(){return r.isWebGL2?u.createVertexArray():p.createVertexArrayOES()}function G(le){return r.isWebGL2?u.bindVertexArray(le):p.bindVertexArrayOES(le)}function J(le){return r.isWebGL2?u.deleteVertexArray(le):p.deleteVertexArrayOES(le)}function Y(le,ye,xe){const Re=xe.wireframe===!0;let Oe=i[le.id];Oe===void 0&&(Oe={},i[le.id]=Oe);let We=Oe[ye.id];We===void 0&&(We={},Oe[ye.id]=We);let Ve=We[Re];return Ve===void 0&&(Ve=B(z()),We[Re]=Ve),Ve}function B(le){const ye=[],xe=[],Re=[];for(let Oe=0;Oe=0){const nt=Oe[Se];let vt=We[Se];if(vt===void 0&&(Se==="instanceMatrix"&&le.instanceMatrix&&(vt=le.instanceMatrix),Se==="instanceColor"&&le.instanceColor&&(vt=le.instanceColor)),nt===void 0||nt.attribute!==vt||vt&&nt.data!==vt.data)return!0;Ve++}return D.attributesNum!==Ve||D.index!==Re}function ce(le,ye,xe,Re){const Oe={},We=ye.attributes;let Ve=0;const Qe=xe.getAttributes();for(const Se in Qe)if(Qe[Se].location>=0){let nt=We[Se];nt===void 0&&(Se==="instanceMatrix"&&le.instanceMatrix&&(nt=le.instanceMatrix),Se==="instanceColor"&&le.instanceColor&&(nt=le.instanceColor));const vt={};vt.attribute=nt,nt&&nt.data&&(vt.data=nt.data),Oe[Se]=vt,Ve++}D.attributes=Oe,D.attributesNum=Ve,D.index=Re}function Ae(){const le=D.newAttributes;for(let ye=0,xe=le.length;ye=0){let Ke=Oe[Qe];if(Ke===void 0&&(Qe==="instanceMatrix"&&le.instanceMatrix&&(Ke=le.instanceMatrix),Qe==="instanceColor"&&le.instanceColor&&(Ke=le.instanceColor)),Ke!==void 0){const nt=Ke.normalized,vt=Ke.itemSize,be=t.get(Ke);if(be===void 0)continue;const At=be.buffer,ut=be.type,Nt=be.bytesPerElement;if(Ke.isInterleavedBufferAttribute){const Gt=Ke.data,Qt=Gt.stride,Ct=Ke.offset;if(Gt.isInstancedInterleavedBuffer){for(let Ft=0;Ft0&&u.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";Je="mediump"}return Je==="mediump"&&u.getShaderPrecisionFormat(35633,36337).precision>0&&u.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const y=typeof WebGL2RenderingContext<"u"&&u instanceof WebGL2RenderingContext;let i=t.precision!==void 0?t.precision:"highp";const C=p(i);C!==i&&(console.warn("THREE.WebGLRenderer:",i,"not supported, using",C,"instead."),i=C);const D=y||e.has("WEBGL_draw_buffers"),R=t.logarithmicDepthBuffer===!0,Q=u.getParameter(34930),z=u.getParameter(35660),G=u.getParameter(3379),J=u.getParameter(34076),Y=u.getParameter(34921),B=u.getParameter(36347),ae=u.getParameter(36348),ce=u.getParameter(36349),Ae=z>0,we=y||e.has("OES_texture_float"),me=Ae&&we,De=y?u.getParameter(36183):0;return{isWebGL2:y,drawBuffers:D,getMaxAnisotropy:c,getMaxPrecision:p,precision:i,logarithmicDepthBuffer:R,maxTextures:Q,maxVertexTextures:z,maxTextureSize:G,maxCubemapSize:J,maxAttributes:Y,maxVertexUniforms:B,maxVaryings:ae,maxFragmentUniforms:ce,vertexTextures:Ae,floatFragmentTextures:we,floatVertexTextures:me,maxSamples:De}}function UO(u){const e=this;let t=null,r=0,c=!1,p=!1;const y=new jd,i=new Pl,C={value:null,needsUpdate:!1};this.uniform=C,this.numPlanes=0,this.numIntersection=0,this.init=function(Q,z){const G=Q.length!==0||z||r!==0||c;return c=z,r=Q.length,G},this.beginShadows=function(){p=!0,R(null)},this.endShadows=function(){p=!1},this.setGlobalState=function(Q,z){t=R(Q,z,0)},this.setState=function(Q,z,G){const J=Q.clippingPlanes,Y=Q.clipIntersection,B=Q.clipShadows,ae=u.get(Q);if(!c||J===null||J.length===0||p&&!B)p?R(null):D();else{const ce=p?0:r,Ae=ce*4;let we=ae.clippingState||null;C.value=we,we=R(J,z,Ae,G);for(let me=0;me!==Ae;++me)we[me]=t[me];ae.clippingState=we,this.numIntersection=Y?this.numPlanes:0,this.numPlanes+=ce}};function D(){C.value!==t&&(C.value=t,C.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function R(Q,z,G,J){const Y=Q!==null?Q.length:0;let B=null;if(Y!==0){if(B=C.value,J!==!0||B===null){const ae=G+Y*4,ce=z.matrixWorldInverse;i.getNormalMatrix(ce),(B===null||B.length0){const D=new OI(C.height/2);return D.fromEquirectangularTexture(u,y),e.set(y,D),y.addEventListener("dispose",c),t(D.texture,y.mapping)}else return null}}return y}function c(y){const i=y.target;i.removeEventListener("dispose",c);const C=e.get(i);C!==void 0&&(e.delete(i),C.dispose())}function p(){e=new WeakMap}return{get:r,dispose:p}}class dy extends Qv{constructor(e=-1,t=1,r=1,c=-1,p=.1,y=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=r,this.bottom=c,this.near=p,this.far=y,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,r,c,p,y){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=r,this.view.offsetY=c,this.view.width=p,this.view.height=y,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,c=(this.top+this.bottom)/2;let p=r-e,y=r+e,i=c+t,C=c-t;if(this.view!==null&&this.view.enabled){const D=(this.right-this.left)/this.view.fullWidth/this.zoom,R=(this.top-this.bottom)/this.view.fullHeight/this.zoom;p+=D*this.view.offsetX,y=p+D*this.view.width,i-=R*this.view.offsetY,C=i-R*this.view.height}this.projectionMatrix.makeOrthographic(p,y,i,C,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Um=4,$E=[.125,.215,.35,.446,.526,.582],Yp=20,Ow=new dy,ZE=new Dn;let Nw=null;const $p=(1+Math.sqrt(5))/2,vm=1/$p,XE=[new ft(1,1,1),new ft(-1,1,1),new ft(1,1,-1),new ft(-1,1,-1),new ft(0,$p,vm),new ft(0,$p,-vm),new ft(vm,0,$p),new ft(-vm,0,$p),new ft($p,vm,0),new ft(-$p,vm,0)];class a2{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,r=.1,c=100){Nw=this._renderer.getRenderTarget(),this._setSize(256);const p=this._allocateTargets();return p.depthBuffer=!0,this._sceneToCubeUV(e,r,c,p),t>0&&this._blur(p,0,0,t),this._applyPMREM(p),this._cleanup(p),p}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=JE(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=YE(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?Ae:0,Ae,Ae),R.setRenderTarget(c),Y&&R.render(J,i),R.render(e,i)}J.geometry.dispose(),J.material.dispose(),R.toneMapping=z,R.autoClear=Q,e.background=B}_textureToCubeUV(e,t){const r=this._renderer,c=e.mapping===rp||e.mapping===sp;c?(this._cubemapMaterial===null&&(this._cubemapMaterial=JE()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=YE());const p=c?this._cubemapMaterial:this._equirectMaterial,y=new us(this._lodPlanes[0],p),i=p.uniforms;i.envMap.value=e;const C=this._cubeSize;dx(t,0,0,3*C,2*C),r.setRenderTarget(t),r.render(y,Ow)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;for(let c=1;cYp&&console.warn(`sigmaRadians, ${p}, is too large and will clip, as it requested ${B} samples when the maximum is set to ${Yp}`);const ae=[];let ce=0;for(let Je=0;JeAe-Um?c-Ae+Um:0),De=4*(this._cubeSize-we);dx(t,me,De,3*we,2*we),C.setRenderTarget(t),C.render(Q,Ow)}}function zO(u){const e=[],t=[],r=[];let c=u;const p=u-Um+1+$E.length;for(let y=0;yu-Um?C=$E[y-u+Um-1]:y===0&&(C=0),r.push(C);const D=1/(i-2),R=-D,Q=1+D,z=[R,R,Q,R,Q,Q,R,R,Q,Q,R,Q],G=6,J=6,Y=3,B=2,ae=1,ce=new Float32Array(Y*J*G),Ae=new Float32Array(B*J*G),we=new Float32Array(ae*J*G);for(let De=0;De2?0:-1,Ge=[Je,Fe,0,Je+2/3,Fe,0,Je+2/3,Fe+1,0,Je,Fe,0,Je+2/3,Fe+1,0,Je,Fe+1,0];ce.set(Ge,Y*J*De),Ae.set(z,B*J*De);const Et=[De,De,De,De,De,De];we.set(Et,ae*J*De)}const me=new br;me.setAttribute("position",new As(ce,Y)),me.setAttribute("uv",new As(Ae,B)),me.setAttribute("faceIndex",new As(we,ae)),e.push(me),c>Um&&c--}return{lodPlanes:e,sizeLods:t,sigmas:r}}function qE(u,e,t){const r=new rl(u,e,t);return r.texture.mapping=qm,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function dx(u,e,t,r,c){u.viewport.set(e,t,r,c),u.scissor.set(e,t,r,c)}function kO(u,e,t){const r=new Float32Array(Yp),c=new ft(0,1,0);return new ko({name:"SphericalGaussianBlur",defines:{n:Yp,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${u}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:c}},vertexShader:G2(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:KA,depthTest:!1,depthWrite:!1})}function YE(){return new ko({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:G2(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:KA,depthTest:!1,depthWrite:!1})}function JE(){return new ko({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:G2(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:KA,depthTest:!1,depthWrite:!1})}function G2(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}function OO(u){let e=new WeakMap,t=null;function r(i){if(i&&i.isTexture){const C=i.mapping,D=C===O_||C===N_,R=C===rp||C===sp;if(D||R)if(i.isRenderTargetTexture&&i.needsPMREMUpdate===!0){i.needsPMREMUpdate=!1;let Q=e.get(i);return t===null&&(t=new a2(u)),Q=D?t.fromEquirectangular(i,Q):t.fromCubemap(i,Q),e.set(i,Q),Q.texture}else{if(e.has(i))return e.get(i).texture;{const Q=i.image;if(D&&Q&&Q.height>0||R&&Q&&c(Q)){t===null&&(t=new a2(u));const z=D?t.fromEquirectangular(i):t.fromCubemap(i);return e.set(i,z),i.addEventListener("dispose",p),z.texture}else return null}}}return i}function c(i){let C=0;const D=6;for(let R=0;Re.maxTextureSize&&(xi=Math.ceil(li/e.maxTextureSize),li=e.maxTextureSize);const te=new Float32Array(li*xi*4*B),le=new Nv(te,li,xi,B);le.type=GA,le.needsUpdate=!0;const ye=Et*4;for(let Re=0;Re0)return u;const c=e*t;let p=eT[c];if(p===void 0&&(p=new Float32Array(c),eT[c]=p),e!==0){r.toArray(p,0);for(let y=1,i=0;y!==e;++y)i+=t,u[y].toArray(p,i)}return p}function sa(u,e){if(u.length!==e.length)return!1;for(let t=0,r=u.length;t":" "} ${i}: ${t[y]}`)}return r.join(` `)}function N6(u){switch(u){case lp:return["Linear","( value )"];case Ts:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",u),["Linear","( value )"]}}function aT(u,e,t){const r=u.getShaderParameter(e,35713),c=u.getShaderInfoLog(e).trim();if(r&&c==="")return"";const p=/ERROR: 0:(\d+)/.exec(c);if(p){const y=parseInt(p[1]);return t.toUpperCase()+` `+c+` `+O6(u.getShaderSource(e),y)}else return c}function Q6(u,e){const t=N6(e);return"vec4 "+u+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function V6(u,e){let t;switch(e){case U2:t="Linear";break;case aI:t="Reinhard";break;case lI:t="OptimizedCineon";break;case cI:t="ACESFilmic";break;case hI:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+u+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function H6(u){return[u.extensionDerivatives||!!u.envMapCubeUVHeight||u.bumpMap||u.tangentSpaceNormalMap||u.clearcoatNormalMap||u.flatShading||u.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(u.extensionFragDepth||u.logarithmicDepthBuffer)&&u.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",u.extensionDrawBuffers&&u.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(u.extensionShaderTextureLOD||u.envMap||u.transmission)&&u.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(v_).join(` `)}function G6(u){const e=[];for(const t in u){const r=u[t];r!==!1&&e.push("#define "+t+" "+r)}return e.join(` `)}function W6(u,e){const t={},r=u.getProgramParameter(e,35721);for(let c=0;c/gm;function l2(u){return u.replace(j6,K6)}function K6(u,e){const t=zr[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return l2(t)}const $6=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function hT(u){return u.replace($6,Z6)}function Z6(u,e,t,r){let c="";for(let p=parseInt(e);p0&&(B+=` `),ae=[G,J].filter(v_).join(` `),ae.length>0&&(ae+=` `)):(B=[uT(t),"#define SHADER_NAME "+t.shaderName,J,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+R:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+C:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` `].filter(v_).join(` `),ae=[G,uT(t),"#define SHADER_NAME "+t.shaderName,J,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+D:"",t.envMap?"#define "+R:"",t.envMap?"#define "+Q:"",z?"#define CUBEUV_TEXEL_WIDTH "+z.texelWidth:"",z?"#define CUBEUV_TEXEL_HEIGHT "+z.texelHeight:"",z?"#define CUBEUV_MAX_MIP "+z.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+C:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Hu?"#define TONE_MAPPING":"",t.toneMapping!==Hu?zr.tonemapping_pars_fragment:"",t.toneMapping!==Hu?V6("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",zr.encodings_pars_fragment,Q6("linearToOutputTexel",t.outputEncoding),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` `].filter(v_).join(` `)),y=l2(y),y=lT(y,t),y=cT(y,t),i=l2(i),i=lT(i,t),i=cT(i,t),y=hT(y),i=hT(i),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(ce=`#version 300 es `,B=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+B,ae=["#define varying in",t.glslVersion===s2?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===s2?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` `+ae);const Ae=ce+B+y,we=ce+ae+i,me=oT(c,35633,Ae),De=oT(c,35632,we);if(c.attachShader(Y,me),c.attachShader(Y,De),t.index0AttributeName!==void 0?c.bindAttribLocation(Y,0,t.index0AttributeName):t.morphTargets===!0&&c.bindAttribLocation(Y,0,"position"),c.linkProgram(Y),u.debug.checkShaderErrors){const Ge=c.getProgramInfoLog(Y).trim(),Et=c.getShaderInfoLog(me).trim(),li=c.getShaderInfoLog(De).trim();let xi=!0,te=!0;if(c.getProgramParameter(Y,35714)===!1){xi=!1;const le=aT(c,me,"vertex"),ye=aT(c,De,"fragment");console.error("THREE.WebGLProgram: Shader Error "+c.getError()+" - VALIDATE_STATUS "+c.getProgramParameter(Y,35715)+` Program Info Log: `+Ge+` `+le+` `+ye)}else Ge!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Ge):(Et===""||li==="")&&(te=!1);te&&(this.diagnostics={runnable:xi,programLog:Ge,vertexShader:{log:Et,prefix:B},fragmentShader:{log:li,prefix:ae}})}c.deleteShader(me),c.deleteShader(De);let Je;this.getUniforms=function(){return Je===void 0&&(Je=new Yx(c,Y)),Je};let Fe;return this.getAttributes=function(){return Fe===void 0&&(Fe=W6(c,Y)),Fe},this.destroy=function(){r.releaseStatesOfProgram(this),c.deleteProgram(Y),this.program=void 0},this.name=t.shaderName,this.id=k6++,this.cacheKey=e,this.usedTimes=1,this.program=Y,this.vertexShader=me,this.fragmentShader=De,this}let iN=0;class nN{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,r=e.fragmentShader,c=this._getShaderStage(t),p=this._getShaderStage(r),y=this._getShaderCacheForMaterial(e);return y.has(c)===!1&&(y.add(c),c.usedTimes++),y.has(p)===!1&&(y.add(p),p.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const r of t)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let r=t.get(e);return r===void 0&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return r===void 0&&(r=new rN(e),t.set(e,r)),r}}class rN{constructor(e){this.id=iN++,this.code=e,this.usedTimes=0}}function sN(u,e,t,r,c,p,y){const i=new uy,C=new nN,D=[],R=c.isWebGL2,Q=c.logarithmicDepthBuffer,z=c.vertexTextures;let G=c.precision;const J={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function Y(Fe,Ge,Et,li,xi){const te=li.fog,le=xi.geometry,ye=Fe.isMeshStandardMaterial?li.environment:null,xe=(Fe.isMeshStandardMaterial?t:e).get(Fe.envMap||ye),Re=!!xe&&xe.mapping===qm?xe.image.height:null,Oe=J[Fe.type];Fe.precision!==null&&(G=c.getMaxPrecision(Fe.precision),G!==Fe.precision&&console.warn("THREE.WebGLProgram.getParameters:",Fe.precision,"not supported, using",G,"instead."));const We=le.morphAttributes.position||le.morphAttributes.normal||le.morphAttributes.color,Ve=We!==void 0?We.length:0;let Qe=0;le.morphAttributes.position!==void 0&&(Qe=1),le.morphAttributes.normal!==void 0&&(Qe=2),le.morphAttributes.color!==void 0&&(Qe=3);let Se,Ke,nt,vt;if(Oe){const Qt=Fl[Oe];Se=Qt.vertexShader,Ke=Qt.fragmentShader}else Se=Fe.vertexShader,Ke=Fe.fragmentShader,C.update(Fe),nt=C.getVertexShaderID(Fe),vt=C.getFragmentShaderID(Fe);const be=u.getRenderTarget(),At=Fe.alphaTest>0,ut=Fe.clearcoat>0,Nt=Fe.iridescence>0;return{isWebGL2:R,shaderID:Oe,shaderName:Fe.type,vertexShader:Se,fragmentShader:Ke,defines:Fe.defines,customVertexShaderID:nt,customFragmentShaderID:vt,isRawShaderMaterial:Fe.isRawShaderMaterial===!0,glslVersion:Fe.glslVersion,precision:G,instancing:xi.isInstancedMesh===!0,instancingColor:xi.isInstancedMesh===!0&&xi.instanceColor!==null,supportsVertexTextures:z,outputEncoding:be===null?u.outputEncoding:be.isXRRenderTarget===!0?be.texture.encoding:lp,map:!!Fe.map,matcap:!!Fe.matcap,envMap:!!xe,envMapMode:xe&&xe.mapping,envMapCubeUVHeight:Re,lightMap:!!Fe.lightMap,aoMap:!!Fe.aoMap,emissiveMap:!!Fe.emissiveMap,bumpMap:!!Fe.bumpMap,normalMap:!!Fe.normalMap,objectSpaceNormalMap:Fe.normalMapType===FI,tangentSpaceNormalMap:Fe.normalMapType===cp,decodeVideoTexture:!!Fe.map&&Fe.map.isVideoTexture===!0&&Fe.map.encoding===Ts,clearcoat:ut,clearcoatMap:ut&&!!Fe.clearcoatMap,clearcoatRoughnessMap:ut&&!!Fe.clearcoatRoughnessMap,clearcoatNormalMap:ut&&!!Fe.clearcoatNormalMap,iridescence:Nt,iridescenceMap:Nt&&!!Fe.iridescenceMap,iridescenceThicknessMap:Nt&&!!Fe.iridescenceThicknessMap,displacementMap:!!Fe.displacementMap,roughnessMap:!!Fe.roughnessMap,metalnessMap:!!Fe.metalnessMap,specularMap:!!Fe.specularMap,specularIntensityMap:!!Fe.specularIntensityMap,specularColorMap:!!Fe.specularColorMap,opaque:Fe.transparent===!1&&Fe.blending===hf,alphaMap:!!Fe.alphaMap,alphaTest:At,gradientMap:!!Fe.gradientMap,sheen:Fe.sheen>0,sheenColorMap:!!Fe.sheenColorMap,sheenRoughnessMap:!!Fe.sheenRoughnessMap,transmission:Fe.transmission>0,transmissionMap:!!Fe.transmissionMap,thicknessMap:!!Fe.thicknessMap,combine:Fe.combine,vertexTangents:!!Fe.normalMap&&!!le.attributes.tangent,vertexColors:Fe.vertexColors,vertexAlphas:Fe.vertexColors===!0&&!!le.attributes.color&&le.attributes.color.itemSize===4,vertexUvs:!!Fe.map||!!Fe.bumpMap||!!Fe.normalMap||!!Fe.specularMap||!!Fe.alphaMap||!!Fe.emissiveMap||!!Fe.roughnessMap||!!Fe.metalnessMap||!!Fe.clearcoatMap||!!Fe.clearcoatRoughnessMap||!!Fe.clearcoatNormalMap||!!Fe.iridescenceMap||!!Fe.iridescenceThicknessMap||!!Fe.displacementMap||!!Fe.transmissionMap||!!Fe.thicknessMap||!!Fe.specularIntensityMap||!!Fe.specularColorMap||!!Fe.sheenColorMap||!!Fe.sheenRoughnessMap,uvsVertexOnly:!(!!Fe.map||!!Fe.bumpMap||!!Fe.normalMap||!!Fe.specularMap||!!Fe.alphaMap||!!Fe.emissiveMap||!!Fe.roughnessMap||!!Fe.metalnessMap||!!Fe.clearcoatNormalMap||!!Fe.iridescenceMap||!!Fe.iridescenceThicknessMap||Fe.transmission>0||!!Fe.transmissionMap||!!Fe.thicknessMap||!!Fe.specularIntensityMap||!!Fe.specularColorMap||Fe.sheen>0||!!Fe.sheenColorMap||!!Fe.sheenRoughnessMap)&&!!Fe.displacementMap,fog:!!te,useFog:Fe.fog===!0,fogExp2:te&&te.isFogExp2,flatShading:!!Fe.flatShading,sizeAttenuation:Fe.sizeAttenuation,logarithmicDepthBuffer:Q,skinning:xi.isSkinnedMesh===!0,morphTargets:le.morphAttributes.position!==void 0,morphNormals:le.morphAttributes.normal!==void 0,morphColors:le.morphAttributes.color!==void 0,morphTargetsCount:Ve,morphTextureStride:Qe,numDirLights:Ge.directional.length,numPointLights:Ge.point.length,numSpotLights:Ge.spot.length,numSpotLightMaps:Ge.spotLightMap.length,numRectAreaLights:Ge.rectArea.length,numHemiLights:Ge.hemi.length,numDirLightShadows:Ge.directionalShadowMap.length,numPointLightShadows:Ge.pointShadowMap.length,numSpotLightShadows:Ge.spotShadowMap.length,numSpotLightShadowsWithMaps:Ge.numSpotLightShadowsWithMaps,numClippingPlanes:y.numPlanes,numClipIntersection:y.numIntersection,dithering:Fe.dithering,shadowMapEnabled:u.shadowMap.enabled&&Et.length>0,shadowMapType:u.shadowMap.type,toneMapping:Fe.toneMapped?u.toneMapping:Hu,physicallyCorrectLights:u.physicallyCorrectLights,premultipliedAlpha:Fe.premultipliedAlpha,doubleSided:Fe.side===ga,flipSided:Fe.side===rc,useDepthPacking:!!Fe.depthPacking,depthPacking:Fe.depthPacking||0,index0AttributeName:Fe.index0AttributeName,extensionDerivatives:Fe.extensions&&Fe.extensions.derivatives,extensionFragDepth:Fe.extensions&&Fe.extensions.fragDepth,extensionDrawBuffers:Fe.extensions&&Fe.extensions.drawBuffers,extensionShaderTextureLOD:Fe.extensions&&Fe.extensions.shaderTextureLOD,rendererExtensionFragDepth:R||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:R||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:R||r.has("EXT_shader_texture_lod"),customProgramCacheKey:Fe.customProgramCacheKey()}}function B(Fe){const Ge=[];if(Fe.shaderID?Ge.push(Fe.shaderID):(Ge.push(Fe.customVertexShaderID),Ge.push(Fe.customFragmentShaderID)),Fe.defines!==void 0)for(const Et in Fe.defines)Ge.push(Et),Ge.push(Fe.defines[Et]);return Fe.isRawShaderMaterial===!1&&(ae(Ge,Fe),ce(Ge,Fe),Ge.push(u.outputEncoding)),Ge.push(Fe.customProgramCacheKey),Ge.join()}function ae(Fe,Ge){Fe.push(Ge.precision),Fe.push(Ge.outputEncoding),Fe.push(Ge.envMapMode),Fe.push(Ge.envMapCubeUVHeight),Fe.push(Ge.combine),Fe.push(Ge.vertexUvs),Fe.push(Ge.fogExp2),Fe.push(Ge.sizeAttenuation),Fe.push(Ge.morphTargetsCount),Fe.push(Ge.morphAttributeCount),Fe.push(Ge.numDirLights),Fe.push(Ge.numPointLights),Fe.push(Ge.numSpotLights),Fe.push(Ge.numSpotLightMaps),Fe.push(Ge.numHemiLights),Fe.push(Ge.numRectAreaLights),Fe.push(Ge.numDirLightShadows),Fe.push(Ge.numPointLightShadows),Fe.push(Ge.numSpotLightShadows),Fe.push(Ge.numSpotLightShadowsWithMaps),Fe.push(Ge.shadowMapType),Fe.push(Ge.toneMapping),Fe.push(Ge.numClippingPlanes),Fe.push(Ge.numClipIntersection),Fe.push(Ge.depthPacking)}function ce(Fe,Ge){i.disableAll(),Ge.isWebGL2&&i.enable(0),Ge.supportsVertexTextures&&i.enable(1),Ge.instancing&&i.enable(2),Ge.instancingColor&&i.enable(3),Ge.map&&i.enable(4),Ge.matcap&&i.enable(5),Ge.envMap&&i.enable(6),Ge.lightMap&&i.enable(7),Ge.aoMap&&i.enable(8),Ge.emissiveMap&&i.enable(9),Ge.bumpMap&&i.enable(10),Ge.normalMap&&i.enable(11),Ge.objectSpaceNormalMap&&i.enable(12),Ge.tangentSpaceNormalMap&&i.enable(13),Ge.clearcoat&&i.enable(14),Ge.clearcoatMap&&i.enable(15),Ge.clearcoatRoughnessMap&&i.enable(16),Ge.clearcoatNormalMap&&i.enable(17),Ge.iridescence&&i.enable(18),Ge.iridescenceMap&&i.enable(19),Ge.iridescenceThicknessMap&&i.enable(20),Ge.displacementMap&&i.enable(21),Ge.specularMap&&i.enable(22),Ge.roughnessMap&&i.enable(23),Ge.metalnessMap&&i.enable(24),Ge.gradientMap&&i.enable(25),Ge.alphaMap&&i.enable(26),Ge.alphaTest&&i.enable(27),Ge.vertexColors&&i.enable(28),Ge.vertexAlphas&&i.enable(29),Ge.vertexUvs&&i.enable(30),Ge.vertexTangents&&i.enable(31),Ge.uvsVertexOnly&&i.enable(32),Fe.push(i.mask),i.disableAll(),Ge.fog&&i.enable(0),Ge.useFog&&i.enable(1),Ge.flatShading&&i.enable(2),Ge.logarithmicDepthBuffer&&i.enable(3),Ge.skinning&&i.enable(4),Ge.morphTargets&&i.enable(5),Ge.morphNormals&&i.enable(6),Ge.morphColors&&i.enable(7),Ge.premultipliedAlpha&&i.enable(8),Ge.shadowMapEnabled&&i.enable(9),Ge.physicallyCorrectLights&&i.enable(10),Ge.doubleSided&&i.enable(11),Ge.flipSided&&i.enable(12),Ge.useDepthPacking&&i.enable(13),Ge.dithering&&i.enable(14),Ge.specularIntensityMap&&i.enable(15),Ge.specularColorMap&&i.enable(16),Ge.transmission&&i.enable(17),Ge.transmissionMap&&i.enable(18),Ge.thicknessMap&&i.enable(19),Ge.sheen&&i.enable(20),Ge.sheenColorMap&&i.enable(21),Ge.sheenRoughnessMap&&i.enable(22),Ge.decodeVideoTexture&&i.enable(23),Ge.opaque&&i.enable(24),Fe.push(i.mask)}function Ae(Fe){const Ge=J[Fe.type];let Et;if(Ge){const li=Fl[Ge];Et=mf.clone(li.uniforms)}else Et=Fe.uniforms;return Et}function we(Fe,Ge){let Et;for(let li=0,xi=D.length;li0?r.push(ae):G.transparent===!0?c.push(ae):t.push(ae)}function C(Q,z,G,J,Y,B){const ae=y(Q,z,G,J,Y,B);G.transmission>0?r.unshift(ae):G.transparent===!0?c.unshift(ae):t.unshift(ae)}function D(Q,z){t.length>1&&t.sort(Q||aN),r.length>1&&r.sort(z||AT),c.length>1&&c.sort(z||AT)}function R(){for(let Q=e,z=u.length;Q=p.length?(y=new dT,p.push(y)):y=p[c],y}function t(){u=new WeakMap}return{get:e,dispose:t}}function cN(){const u={};return{get:function(e){if(u[e.id]!==void 0)return u[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new ft,color:new Dn};break;case"SpotLight":t={position:new ft,direction:new ft,color:new Dn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new ft,color:new Dn,distance:0,decay:0};break;case"HemisphereLight":t={direction:new ft,skyColor:new Dn,groundColor:new Dn};break;case"RectAreaLight":t={color:new Dn,position:new ft,halfWidth:new ft,halfHeight:new ft};break}return u[e.id]=t,t}}}function hN(){const u={};return{get:function(e){if(u[e.id]!==void 0)return u[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Di};break;case"SpotLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Di};break;case"PointLight":t={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Di,shadowCameraNear:1,shadowCameraFar:1e3};break}return u[e.id]=t,t}}}let uN=0;function AN(u,e){return(e.castShadow?2:0)-(u.castShadow?2:0)+(e.map?1:0)-(u.map?1:0)}function dN(u,e){const t=new cN,r=hN(),c={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let R=0;R<9;R++)c.probe.push(new ft);const p=new ft,y=new ar,i=new ar;function C(R,Q){let z=0,G=0,J=0;for(let li=0;li<9;li++)c.probe[li].set(0,0,0);let Y=0,B=0,ae=0,ce=0,Ae=0,we=0,me=0,De=0,Je=0,Fe=0;R.sort(AN);const Ge=Q!==!0?Math.PI:1;for(let li=0,xi=R.length;li0&&(e.isWebGL2||u.has("OES_texture_float_linear")===!0?(c.rectAreaLTC1=En.LTC_FLOAT_1,c.rectAreaLTC2=En.LTC_FLOAT_2):u.has("OES_texture_half_float_linear")===!0?(c.rectAreaLTC1=En.LTC_HALF_1,c.rectAreaLTC2=En.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),c.ambient[0]=z,c.ambient[1]=G,c.ambient[2]=J;const Et=c.hash;(Et.directionalLength!==Y||Et.pointLength!==B||Et.spotLength!==ae||Et.rectAreaLength!==ce||Et.hemiLength!==Ae||Et.numDirectionalShadows!==we||Et.numPointShadows!==me||Et.numSpotShadows!==De||Et.numSpotMaps!==Je)&&(c.directional.length=Y,c.spot.length=ae,c.rectArea.length=ce,c.point.length=B,c.hemi.length=Ae,c.directionalShadow.length=we,c.directionalShadowMap.length=we,c.pointShadow.length=me,c.pointShadowMap.length=me,c.spotShadow.length=De,c.spotShadowMap.length=De,c.directionalShadowMatrix.length=we,c.pointShadowMatrix.length=me,c.spotLightMatrix.length=De+Je-Fe,c.spotLightMap.length=Je,c.numSpotLightShadowsWithMaps=Fe,Et.directionalLength=Y,Et.pointLength=B,Et.spotLength=ae,Et.rectAreaLength=ce,Et.hemiLength=Ae,Et.numDirectionalShadows=we,Et.numPointShadows=me,Et.numSpotShadows=De,Et.numSpotMaps=Je,c.version=uN++)}function D(R,Q){let z=0,G=0,J=0,Y=0,B=0;const ae=Q.matrixWorldInverse;for(let ce=0,Ae=R.length;ce=i.length?(C=new pT(u,e),i.push(C)):C=i[y],C}function c(){t=new WeakMap}return{get:r,dispose:c}}class W2 extends ol{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=MI,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class j2 extends ol{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new ft,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const fN=`void main() { gl_Position = vec4( position, 1.0 ); }`,mN=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); }`;function gN(u,e,t){let r=new Vv;const c=new Di,p=new Di,y=new as,i=new W2({depthPacking:II}),C=new j2,D={},R=t.maxTextureSize,Q={[uu]:rc,[rc]:uu,[ga]:ga},z=new ko({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Di},radius:{value:4}},vertexShader:fN,fragmentShader:mN}),G=z.clone();G.defines.HORIZONTAL_PASS=1;const J=new br;J.setAttribute("position",new As(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const Y=new us(J,z),B=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=L2,this.render=function(we,me,De){if(B.enabled===!1||B.autoUpdate===!1&&B.needsUpdate===!1||we.length===0)return;const Je=u.getRenderTarget(),Fe=u.getActiveCubeFace(),Ge=u.getActiveMipmapLevel(),Et=u.state;Et.setBlending(KA),Et.buffers.color.setClear(1,1,1,1),Et.buffers.depth.setTest(!0),Et.setScissorTest(!1);for(let li=0,xi=we.length;liR||c.y>R)&&(c.x>R&&(p.x=Math.floor(R/ye.x),c.x=p.x*ye.x,le.mapSize.x=p.x),c.y>R&&(p.y=Math.floor(R/ye.y),c.y=p.y*ye.y,le.mapSize.y=p.y)),le.map===null){const Re=this.type!==Dm?{minFilter:Co,magFilter:Co}:{};le.map=new rl(c.x,c.y,Re),le.map.texture.name=te.name+".shadowMap",le.camera.updateProjectionMatrix()}u.setRenderTarget(le.map),u.clear();const xe=le.getViewportCount();for(let Re=0;Re0||me.map&&me.alphaTest>0){const xi=Et.uuid,te=me.uuid;let le=D[xi];le===void 0&&(le={},D[xi]=le);let ye=le[te];ye===void 0&&(ye=Et.clone(),le[te]=ye),Et=ye}return Et.visible=me.visible,Et.wireframe=me.wireframe,Ge===Dm?Et.side=me.shadowSide!==null?me.shadowSide:me.side:Et.side=me.shadowSide!==null?me.shadowSide:Q[me.side],Et.alphaMap=me.alphaMap,Et.alphaTest=me.alphaTest,Et.map=me.map,Et.clipShadows=me.clipShadows,Et.clippingPlanes=me.clippingPlanes,Et.clipIntersection=me.clipIntersection,Et.displacementMap=me.displacementMap,Et.displacementScale=me.displacementScale,Et.displacementBias=me.displacementBias,Et.wireframeLinewidth=me.wireframeLinewidth,Et.linewidth=me.linewidth,De.isPointLight===!0&&Et.isMeshDistanceMaterial===!0&&(Et.referencePosition.setFromMatrixPosition(De.matrixWorld),Et.nearDistance=Je,Et.farDistance=Fe),Et}function Ae(we,me,De,Je,Fe){if(we.visible===!1)return;if(we.layers.test(me.layers)&&(we.isMesh||we.isLine||we.isPoints)&&(we.castShadow||we.receiveShadow&&Fe===Dm)&&(!we.frustumCulled||r.intersectsObject(we))){we.modelViewMatrix.multiplyMatrices(De.matrixWorldInverse,we.matrixWorld);const li=e.update(we),xi=we.material;if(Array.isArray(xi)){const te=li.groups;for(let le=0,ye=te.length;le=1):Oe.indexOf("OpenGL ES")!==-1&&(Re=parseFloat(/^OpenGL ES (\d)/.exec(Oe)[1]),xe=Re>=2);let We=null,Ve={};const Qe=u.getParameter(3088),Se=u.getParameter(2978),Ke=new as().fromArray(Qe),nt=new as().fromArray(Se);function vt(Ot,wi,Wi){const Ui=new Uint8Array(4),Pn=u.createTexture();u.bindTexture(Ot,Pn),u.texParameteri(Ot,10241,9728),u.texParameteri(Ot,10240,9728);for(let qn=0;qn"u"?!1:/OculusBrowser/g.test(navigator.userAgent),J=new WeakMap;let Y;const B=new WeakMap;let ae=!1;try{ae=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function ce(yt,rt){return ae?new OffscreenCanvas(yt,rt):K_("canvas")}function Ae(yt,rt,ti,Ni){let qi=1;if((yt.width>Ni||yt.height>Ni)&&(qi=Ni/Math.max(yt.width,yt.height)),qi<1||rt===!0)if(typeof HTMLImageElement<"u"&&yt instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&yt instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&yt instanceof ImageBitmap){const en=rt?pv:Math.floor,$t=en(qi*yt.width),at=en(qi*yt.height);Y===void 0&&(Y=ce($t,at));const ii=ti?ce($t,at):Y;return ii.width=$t,ii.height=at,ii.getContext("2d").drawImage(yt,0,0,$t,at),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+yt.width+"x"+yt.height+") to ("+$t+"x"+at+")."),ii}else return"data"in yt&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+yt.width+"x"+yt.height+")."),yt;return yt}function we(yt){return o2(yt.width)&&o2(yt.height)}function me(yt){return i?!1:yt.wrapS!==nl||yt.wrapT!==nl||yt.minFilter!==Co&&yt.minFilter!==Xs}function De(yt,rt){return yt.generateMipmaps&&rt&&yt.minFilter!==Co&&yt.minFilter!==Xs}function Je(yt){u.generateMipmap(yt)}function Fe(yt,rt,ti,Ni,qi=!1){if(i===!1)return rt;if(yt!==null){if(u[yt]!==void 0)return u[yt];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+yt+"'")}let en=rt;return rt===6403&&(ti===5126&&(en=33326),ti===5131&&(en=33325),ti===5121&&(en=33321)),rt===33319&&(ti===5126&&(en=33328),ti===5131&&(en=33327),ti===5121&&(en=33323)),rt===6408&&(ti===5126&&(en=34836),ti===5131&&(en=34842),ti===5121&&(en=Ni===Ts&&qi===!1?35907:32856),ti===32819&&(en=32854),ti===32820&&(en=32855)),(en===33325||en===33326||en===33327||en===33328||en===34842||en===34836)&&e.get("EXT_color_buffer_float"),en}function Ge(yt,rt,ti){return De(yt,ti)===!0||yt.isFramebufferTexture&&yt.minFilter!==Co&&yt.minFilter!==Xs?Math.log2(Math.max(rt.width,rt.height))+1:yt.mipmaps!==void 0&&yt.mipmaps.length>0?yt.mipmaps.length:yt.isCompressedTexture&&Array.isArray(yt.image)?rt.mipmaps.length:1}function Et(yt){return yt===Co||yt===Av||yt===M_?9728:9729}function li(yt){const rt=yt.target;rt.removeEventListener("dispose",li),te(rt),rt.isVideoTexture&&J.delete(rt)}function xi(yt){const rt=yt.target;rt.removeEventListener("dispose",xi),ye(rt)}function te(yt){const rt=r.get(yt);if(rt.__webglInit===void 0)return;const ti=yt.source,Ni=B.get(ti);if(Ni){const qi=Ni[rt.__cacheKey];qi.usedTimes--,qi.usedTimes===0&&le(yt),Object.keys(Ni).length===0&&B.delete(ti)}r.remove(yt)}function le(yt){const rt=r.get(yt);u.deleteTexture(rt.__webglTexture);const ti=yt.source,Ni=B.get(ti);delete Ni[rt.__cacheKey],y.memory.textures--}function ye(yt){const rt=yt.texture,ti=r.get(yt),Ni=r.get(rt);if(Ni.__webglTexture!==void 0&&(u.deleteTexture(Ni.__webglTexture),y.memory.textures--),yt.depthTexture&&yt.depthTexture.dispose(),yt.isWebGLCubeRenderTarget)for(let qi=0;qi<6;qi++)u.deleteFramebuffer(ti.__webglFramebuffer[qi]),ti.__webglDepthbuffer&&u.deleteRenderbuffer(ti.__webglDepthbuffer[qi]);else{if(u.deleteFramebuffer(ti.__webglFramebuffer),ti.__webglDepthbuffer&&u.deleteRenderbuffer(ti.__webglDepthbuffer),ti.__webglMultisampledFramebuffer&&u.deleteFramebuffer(ti.__webglMultisampledFramebuffer),ti.__webglColorRenderbuffer)for(let qi=0;qi=C&&console.warn("THREE.WebGLTextures: Trying to use "+yt+" texture units while this GPU supports only "+C),xe+=1,yt}function We(yt){const rt=[];return rt.push(yt.wrapS),rt.push(yt.wrapT),rt.push(yt.wrapR||0),rt.push(yt.magFilter),rt.push(yt.minFilter),rt.push(yt.anisotropy),rt.push(yt.internalFormat),rt.push(yt.format),rt.push(yt.type),rt.push(yt.generateMipmaps),rt.push(yt.premultiplyAlpha),rt.push(yt.flipY),rt.push(yt.unpackAlignment),rt.push(yt.encoding),rt.join()}function Ve(yt,rt){const ti=r.get(yt);if(yt.isVideoTexture&&Gn(yt),yt.isRenderTargetTexture===!1&&yt.version>0&&ti.__version!==yt.version){const Ni=yt.image;if(Ni===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Ni.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ut(ti,yt,rt);return}}t.bindTexture(3553,ti.__webglTexture,33984+rt)}function Qe(yt,rt){const ti=r.get(yt);if(yt.version>0&&ti.__version!==yt.version){ut(ti,yt,rt);return}t.bindTexture(35866,ti.__webglTexture,33984+rt)}function Se(yt,rt){const ti=r.get(yt);if(yt.version>0&&ti.__version!==yt.version){ut(ti,yt,rt);return}t.bindTexture(32879,ti.__webglTexture,33984+rt)}function Ke(yt,rt){const ti=r.get(yt);if(yt.version>0&&ti.__version!==yt.version){Nt(ti,yt,rt);return}t.bindTexture(34067,ti.__webglTexture,33984+rt)}const nt={[HA]:10497,[nl]:33071,[Q_]:33648},vt={[Co]:9728,[Av]:9984,[M_]:9986,[Xs]:9729,[R2]:9985,[op]:9987};function be(yt,rt,ti){if(ti?(u.texParameteri(yt,10242,nt[rt.wrapS]),u.texParameteri(yt,10243,nt[rt.wrapT]),(yt===32879||yt===35866)&&u.texParameteri(yt,32882,nt[rt.wrapR]),u.texParameteri(yt,10240,vt[rt.magFilter]),u.texParameteri(yt,10241,vt[rt.minFilter])):(u.texParameteri(yt,10242,33071),u.texParameteri(yt,10243,33071),(yt===32879||yt===35866)&&u.texParameteri(yt,32882,33071),(rt.wrapS!==nl||rt.wrapT!==nl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),u.texParameteri(yt,10240,Et(rt.magFilter)),u.texParameteri(yt,10241,Et(rt.minFilter)),rt.minFilter!==Co&&rt.minFilter!==Xs&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const Ni=e.get("EXT_texture_filter_anisotropic");if(rt.magFilter===Co||rt.minFilter!==M_&&rt.minFilter!==op||rt.type===GA&&e.has("OES_texture_float_linear")===!1||i===!1&&rt.type===Gm&&e.has("OES_texture_half_float_linear")===!1)return;(rt.anisotropy>1||r.get(rt).__currentAnisotropy)&&(u.texParameterf(yt,Ni.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(rt.anisotropy,c.getMaxAnisotropy())),r.get(rt).__currentAnisotropy=rt.anisotropy)}}function At(yt,rt){let ti=!1;yt.__webglInit===void 0&&(yt.__webglInit=!0,rt.addEventListener("dispose",li));const Ni=rt.source;let qi=B.get(Ni);qi===void 0&&(qi={},B.set(Ni,qi));const en=We(rt);if(en!==yt.__cacheKey){qi[en]===void 0&&(qi[en]={texture:u.createTexture(),usedTimes:0},y.memory.textures++,ti=!0),qi[en].usedTimes++;const $t=qi[yt.__cacheKey];$t!==void 0&&(qi[yt.__cacheKey].usedTimes--,$t.usedTimes===0&&le(rt)),yt.__cacheKey=en,yt.__webglTexture=qi[en].texture}return ti}function ut(yt,rt,ti){let Ni=3553;(rt.isDataArrayTexture||rt.isCompressedArrayTexture)&&(Ni=35866),rt.isData3DTexture&&(Ni=32879);const qi=At(yt,rt),en=rt.source;t.bindTexture(Ni,yt.__webglTexture,33984+ti);const $t=r.get(en);if(en.version!==$t.__version||qi===!0){t.activeTexture(33984+ti),u.pixelStorei(37440,rt.flipY),u.pixelStorei(37441,rt.premultiplyAlpha),u.pixelStorei(3317,rt.unpackAlignment),u.pixelStorei(37443,0);const at=me(rt)&&we(rt.image)===!1;let ii=Ae(rt.image,at,!1,R);ii=kn(rt,ii);const hn=we(ii)||i,Xi=p.convert(rt.format,rt.encoding);let on=p.convert(rt.type),Cn=Fe(rt.internalFormat,Xi,on,rt.encoding,rt.isVideoTexture);be(Ni,rt,hn);let Tn;const nr=rt.mipmaps,Ii=i&&rt.isVideoTexture!==!0,bn=$t.__version===void 0||qi===!0,Ot=Ge(rt,ii,hn);if(rt.isDepthTexture)Cn=6402,i?rt.type===GA?Cn=36012:rt.type===Xd?Cn=33190:rt.type===uf?Cn=35056:Cn=33189:rt.type===GA&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),rt.format===ep&&Cn===6402&&rt.type!==z2&&rt.type!==Xd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),rt.type=Xd,on=p.convert(rt.type)),rt.format===ff&&Cn===6402&&(Cn=34041,rt.type!==uf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),rt.type=uf,on=p.convert(rt.type))),bn&&(Ii?t.texStorage2D(3553,1,Cn,ii.width,ii.height):t.texImage2D(3553,0,Cn,ii.width,ii.height,0,Xi,on,null));else if(rt.isDataTexture)if(nr.length>0&&hn){Ii&&bn&&t.texStorage2D(3553,Ot,Cn,nr[0].width,nr[0].height);for(let wi=0,Wi=nr.length;wi>=1,Wi>>=1}}else if(nr.length>0&&hn){Ii&&bn&&t.texStorage2D(3553,Ot,Cn,nr[0].width,nr[0].height);for(let wi=0,Wi=nr.length;wi0&&bn++,t.texStorage2D(34067,bn,Tn,ii[0].width,ii[0].height));for(let wi=0;wi<6;wi++)if(at){nr?t.texSubImage2D(34069+wi,0,0,0,ii[wi].width,ii[wi].height,on,Cn,ii[wi].data):t.texImage2D(34069+wi,0,Tn,ii[wi].width,ii[wi].height,0,on,Cn,ii[wi].data);for(let Wi=0;Wi=34069&&qi<=34074)&&u.framebufferTexture2D(36160,Ni,qi,r.get(ti).__webglTexture,0),t.bindFramebuffer(36160,null)}function Qt(yt,rt,ti){if(u.bindRenderbuffer(36161,yt),rt.depthBuffer&&!rt.stencilBuffer){let Ni=33189;if(ti||zi(rt)){const qi=rt.depthTexture;qi&&qi.isDepthTexture&&(qi.type===GA?Ni=36012:qi.type===Xd&&(Ni=33190));const en=wn(rt);zi(rt)?z.renderbufferStorageMultisampleEXT(36161,en,Ni,rt.width,rt.height):u.renderbufferStorageMultisample(36161,en,Ni,rt.width,rt.height)}else u.renderbufferStorage(36161,Ni,rt.width,rt.height);u.framebufferRenderbuffer(36160,36096,36161,yt)}else if(rt.depthBuffer&&rt.stencilBuffer){const Ni=wn(rt);ti&&zi(rt)===!1?u.renderbufferStorageMultisample(36161,Ni,35056,rt.width,rt.height):zi(rt)?z.renderbufferStorageMultisampleEXT(36161,Ni,35056,rt.width,rt.height):u.renderbufferStorage(36161,34041,rt.width,rt.height),u.framebufferRenderbuffer(36160,33306,36161,yt)}else{const Ni=rt.isWebGLMultipleRenderTargets===!0?rt.texture:[rt.texture];for(let qi=0;qi0&&zi(yt)===!1){const at=en?rt:[rt];ti.__webglMultisampledFramebuffer=u.createFramebuffer(),ti.__webglColorRenderbuffer=[],t.bindFramebuffer(36160,ti.__webglMultisampledFramebuffer);for(let ii=0;ii0&&zi(yt)===!1){const rt=yt.isWebGLMultipleRenderTargets?yt.texture:[yt.texture],ti=yt.width,Ni=yt.height;let qi=16384;const en=[],$t=yt.stencilBuffer?33306:36096,at=r.get(yt),ii=yt.isWebGLMultipleRenderTargets===!0;if(ii)for(let hn=0;hn0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&rt.__useRenderToTexture!==!1}function Gn(yt){const rt=y.render.frame;J.get(yt)!==rt&&(J.set(yt,rt),yt.update())}function kn(yt,rt){const ti=yt.encoding,Ni=yt.format,qi=yt.type;return yt.isCompressedTexture===!0||yt.isVideoTexture===!0||yt.format===dv||ti!==lp&&(ti===Ts?i===!1?e.has("EXT_sRGB")===!0&&Ni===Dl?(yt.format=dv,yt.minFilter=Xs,yt.generateMipmaps=!1):rt=N2.sRGBToLinear(rt):(Ni!==Dl||qi!==ap)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",ti)),rt}this.allocateTextureUnit=Oe,this.resetTextureUnits=Re,this.setTexture2D=Ve,this.setTexture2DArray=Qe,this.setTexture3D=Se,this.setTextureCube=Ke,this.rebindTextures=Xt,this.setupRenderTarget=_i,this.updateRenderTargetMipmap=fi,this.updateMultisampleRenderTarget=Gi,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=Gt,this.useMultisampledRTT=zi}function WI(u,e,t){const r=t.isWebGL2;function c(p,y=null){let i;if(p===ap)return 5121;if(p===pI)return 32819;if(p===fI)return 32820;if(p===uI)return 5120;if(p===AI)return 5122;if(p===z2)return 5123;if(p===dI)return 5124;if(p===Xd)return 5125;if(p===GA)return 5126;if(p===Gm)return r?5131:(i=e.get("OES_texture_half_float"),i!==null?i.HALF_FLOAT_OES:null);if(p===mI)return 6406;if(p===Dl)return 6408;if(p===gI)return 6409;if(p===_I)return 6410;if(p===ep)return 6402;if(p===ff)return 34041;if(p===dv)return i=e.get("EXT_sRGB"),i!==null?i.SRGB_ALPHA_EXT:null;if(p===yI)return 6403;if(p===xI)return 36244;if(p===vI)return 33319;if(p===wI)return 33320;if(p===bI)return 36249;if(p===Gx||p===Wx||p===jx||p===Kx)if(y===Ts)if(i=e.get("WEBGL_compressed_texture_s3tc_srgb"),i!==null){if(p===Gx)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(p===Wx)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(p===jx)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(p===Kx)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=e.get("WEBGL_compressed_texture_s3tc"),i!==null){if(p===Gx)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(p===Wx)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(p===jx)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(p===Kx)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(p===Rb||p===zb||p===kb||p===Ob)if(i=e.get("WEBGL_compressed_texture_pvrtc"),i!==null){if(p===Rb)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(p===zb)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(p===kb)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(p===Ob)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(p===BI)return i=e.get("WEBGL_compressed_texture_etc1"),i!==null?i.COMPRESSED_RGB_ETC1_WEBGL:null;if(p===Nb||p===Qb)if(i=e.get("WEBGL_compressed_texture_etc"),i!==null){if(p===Nb)return y===Ts?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(p===Qb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(p===Vb||p===Hb||p===Gb||p===Wb||p===jb||p===Kb||p===$b||p===Zb||p===Xb||p===qb||p===Yb||p===Jb||p===e2||p===t2)if(i=e.get("WEBGL_compressed_texture_astc"),i!==null){if(p===Vb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(p===Hb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(p===Gb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(p===Wb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(p===jb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(p===Kb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(p===$b)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(p===Zb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(p===Xb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(p===qb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(p===Yb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(p===Jb)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(p===e2)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(p===t2)return y===Ts?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(p===$x)if(i=e.get("EXT_texture_compression_bptc"),i!==null){if(p===$x)return y===Ts?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(p===CI||p===i2||p===n2||p===r2)if(i=e.get("EXT_texture_compression_rgtc"),i!==null){if(p===$x)return i.COMPRESSED_RED_RGTC1_EXT;if(p===i2)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(p===n2)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(p===r2)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return p===uf?r?34042:(i=e.get("WEBGL_depth_texture"),i!==null?i.UNSIGNED_INT_24_8_WEBGL:null):u[p]!==void 0?u[p]:null}return{convert:c}}class jI extends _a{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Hs extends ls{constructor(){super(),this.isGroup=!0,this.type="Group"}}const xN={type:"move"};class Vw{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Hs,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Hs,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ft,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ft),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Hs,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ft,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ft),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const r of e.hand.values())this._getHandJoint(t,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,r){let c=null,p=null,y=null;const i=this._targetRay,C=this._grip,D=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(D&&e.hand){y=!0;for(const Y of e.hand.values()){const B=t.getJointPose(Y,r),ae=this._getHandJoint(D,Y);B!==null&&(ae.matrix.fromArray(B.transform.matrix),ae.matrix.decompose(ae.position,ae.rotation,ae.scale),ae.jointRadius=B.radius),ae.visible=B!==null}const R=D.joints["index-finger-tip"],Q=D.joints["thumb-tip"],z=R.position.distanceTo(Q.position),G=.02,J=.005;D.inputState.pinching&&z>G+J?(D.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!D.inputState.pinching&&z<=G-J&&(D.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else C!==null&&e.gripSpace&&(p=t.getPose(e.gripSpace,r),p!==null&&(C.matrix.fromArray(p.transform.matrix),C.matrix.decompose(C.position,C.rotation,C.scale),p.linearVelocity?(C.hasLinearVelocity=!0,C.linearVelocity.copy(p.linearVelocity)):C.hasLinearVelocity=!1,p.angularVelocity?(C.hasAngularVelocity=!0,C.angularVelocity.copy(p.angularVelocity)):C.hasAngularVelocity=!1));i!==null&&(c=t.getPose(e.targetRaySpace,r),c===null&&p!==null&&(c=p),c!==null&&(i.matrix.fromArray(c.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),c.linearVelocity?(i.hasLinearVelocity=!0,i.linearVelocity.copy(c.linearVelocity)):i.hasLinearVelocity=!1,c.angularVelocity?(i.hasAngularVelocity=!0,i.angularVelocity.copy(c.angularVelocity)):i.hasAngularVelocity=!1,this.dispatchEvent(xN)))}return i!==null&&(i.visible=c!==null),C!==null&&(C.visible=p!==null),D!==null&&(D.visible=y!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const r=new Hs;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[t.jointName]=r,e.add(r)}return e.joints[t.jointName]}}class KI extends To{constructor(e,t,r,c,p,y,i,C,D,R){if(R=R!==void 0?R:ep,R!==ep&&R!==ff)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&R===ep&&(r=Xd),r===void 0&&R===ff&&(r=uf),super(null,c,p,y,i,C,R,r,D),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=i!==void 0?i:Co,this.minFilter=C!==void 0?C:Co,this.flipY=!1,this.generateMipmaps=!1}}class vN extends Xu{constructor(e,t){super();const r=this;let c=null,p=1,y=null,i="local-floor",C=1,D=null,R=null,Q=null,z=null,G=null,J=null;const Y=t.getContextAttributes();let B=null,ae=null;const ce=[],Ae=[],we=new Set,me=new Map,De=new _a;De.layers.enable(1),De.viewport=new as;const Je=new _a;Je.layers.enable(2),Je.viewport=new as;const Fe=[De,Je],Ge=new jI;Ge.layers.enable(1),Ge.layers.enable(2);let Et=null,li=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Se){let Ke=ce[Se];return Ke===void 0&&(Ke=new Vw,ce[Se]=Ke),Ke.getTargetRaySpace()},this.getControllerGrip=function(Se){let Ke=ce[Se];return Ke===void 0&&(Ke=new Vw,ce[Se]=Ke),Ke.getGripSpace()},this.getHand=function(Se){let Ke=ce[Se];return Ke===void 0&&(Ke=new Vw,ce[Se]=Ke),Ke.getHandSpace()};function xi(Se){const Ke=Ae.indexOf(Se.inputSource);if(Ke===-1)return;const nt=ce[Ke];nt!==void 0&&nt.dispatchEvent({type:Se.type,data:Se.inputSource})}function te(){c.removeEventListener("select",xi),c.removeEventListener("selectstart",xi),c.removeEventListener("selectend",xi),c.removeEventListener("squeeze",xi),c.removeEventListener("squeezestart",xi),c.removeEventListener("squeezeend",xi),c.removeEventListener("end",te),c.removeEventListener("inputsourceschange",le);for(let Se=0;Se=0&&(Ae[vt]=null,ce[vt].disconnect(nt))}for(let Ke=0;Ke=Ae.length){Ae.push(nt),vt=At;break}else if(Ae[At]===null){Ae[At]=nt,vt=At;break}if(vt===-1)break}const be=ce[vt];be&&be.connect(nt)}}const ye=new ft,xe=new ft;function Re(Se,Ke,nt){ye.setFromMatrixPosition(Ke.matrixWorld),xe.setFromMatrixPosition(nt.matrixWorld);const vt=ye.distanceTo(xe),be=Ke.projectionMatrix.elements,At=nt.projectionMatrix.elements,ut=be[14]/(be[10]-1),Nt=be[14]/(be[10]+1),Gt=(be[9]+1)/be[5],Qt=(be[9]-1)/be[5],Ct=(be[8]-1)/be[0],Ft=(At[8]+1)/At[0],Xt=ut*Ct,_i=ut*Ft,fi=vt/(-Ct+Ft),Gi=fi*-Ct;Ke.matrixWorld.decompose(Se.position,Se.quaternion,Se.scale),Se.translateX(Gi),Se.translateZ(fi),Se.matrixWorld.compose(Se.position,Se.quaternion,Se.scale),Se.matrixWorldInverse.copy(Se.matrixWorld).invert();const wn=ut+fi,zi=Nt+fi,Gn=Xt-Gi,kn=_i+(vt-Gi),yt=Gt*Nt/zi*wn,rt=Qt*Nt/zi*wn;Se.projectionMatrix.makePerspective(Gn,kn,yt,rt,wn,zi)}function Oe(Se,Ke){Ke===null?Se.matrixWorld.copy(Se.matrix):Se.matrixWorld.multiplyMatrices(Ke.matrixWorld,Se.matrix),Se.matrixWorldInverse.copy(Se.matrixWorld).invert()}this.updateCamera=function(Se){if(c===null)return;Ge.near=Je.near=De.near=Se.near,Ge.far=Je.far=De.far=Se.far,(Et!==Ge.near||li!==Ge.far)&&(c.updateRenderState({depthNear:Ge.near,depthFar:Ge.far}),Et=Ge.near,li=Ge.far);const Ke=Se.parent,nt=Ge.cameras;Oe(Ge,Ke);for(let be=0;bebe&&(me.set(vt,vt.lastChangedTime),r.dispatchEvent({type:"planechanged",data:vt}))}}J=null}const Qe=new NI;Qe.setAnimationLoop(Ve),this.setAnimationLoop=function(Se){We=Se},this.dispose=function(){}}}function wN(u,e){function t(Y,B){B.color.getRGB(Y.fogColor.value,zI(u)),B.isFog?(Y.fogNear.value=B.near,Y.fogFar.value=B.far):B.isFogExp2&&(Y.fogDensity.value=B.density)}function r(Y,B,ae,ce,Ae){B.isMeshBasicMaterial||B.isMeshLambertMaterial?c(Y,B):B.isMeshToonMaterial?(c(Y,B),R(Y,B)):B.isMeshPhongMaterial?(c(Y,B),D(Y,B)):B.isMeshStandardMaterial?(c(Y,B),Q(Y,B),B.isMeshPhysicalMaterial&&z(Y,B,Ae)):B.isMeshMatcapMaterial?(c(Y,B),G(Y,B)):B.isMeshDepthMaterial?c(Y,B):B.isMeshDistanceMaterial?(c(Y,B),J(Y,B)):B.isMeshNormalMaterial?c(Y,B):B.isLineBasicMaterial?(p(Y,B),B.isLineDashedMaterial&&y(Y,B)):B.isPointsMaterial?i(Y,B,ae,ce):B.isSpriteMaterial?C(Y,B):B.isShadowMaterial?(Y.color.value.copy(B.color),Y.opacity.value=B.opacity):B.isShaderMaterial&&(B.uniformsNeedUpdate=!1)}function c(Y,B){Y.opacity.value=B.opacity,B.color&&Y.diffuse.value.copy(B.color),B.emissive&&Y.emissive.value.copy(B.emissive).multiplyScalar(B.emissiveIntensity),B.map&&(Y.map.value=B.map),B.alphaMap&&(Y.alphaMap.value=B.alphaMap),B.bumpMap&&(Y.bumpMap.value=B.bumpMap,Y.bumpScale.value=B.bumpScale,B.side===rc&&(Y.bumpScale.value*=-1)),B.displacementMap&&(Y.displacementMap.value=B.displacementMap,Y.displacementScale.value=B.displacementScale,Y.displacementBias.value=B.displacementBias),B.emissiveMap&&(Y.emissiveMap.value=B.emissiveMap),B.normalMap&&(Y.normalMap.value=B.normalMap,Y.normalScale.value.copy(B.normalScale),B.side===rc&&Y.normalScale.value.negate()),B.specularMap&&(Y.specularMap.value=B.specularMap),B.alphaTest>0&&(Y.alphaTest.value=B.alphaTest);const ae=e.get(B).envMap;if(ae&&(Y.envMap.value=ae,Y.flipEnvMap.value=ae.isCubeTexture&&ae.isRenderTargetTexture===!1?-1:1,Y.reflectivity.value=B.reflectivity,Y.ior.value=B.ior,Y.refractionRatio.value=B.refractionRatio),B.lightMap){Y.lightMap.value=B.lightMap;const we=u.physicallyCorrectLights!==!0?Math.PI:1;Y.lightMapIntensity.value=B.lightMapIntensity*we}B.aoMap&&(Y.aoMap.value=B.aoMap,Y.aoMapIntensity.value=B.aoMapIntensity);let ce;B.map?ce=B.map:B.specularMap?ce=B.specularMap:B.displacementMap?ce=B.displacementMap:B.normalMap?ce=B.normalMap:B.bumpMap?ce=B.bumpMap:B.roughnessMap?ce=B.roughnessMap:B.metalnessMap?ce=B.metalnessMap:B.alphaMap?ce=B.alphaMap:B.emissiveMap?ce=B.emissiveMap:B.clearcoatMap?ce=B.clearcoatMap:B.clearcoatNormalMap?ce=B.clearcoatNormalMap:B.clearcoatRoughnessMap?ce=B.clearcoatRoughnessMap:B.iridescenceMap?ce=B.iridescenceMap:B.iridescenceThicknessMap?ce=B.iridescenceThicknessMap:B.specularIntensityMap?ce=B.specularIntensityMap:B.specularColorMap?ce=B.specularColorMap:B.transmissionMap?ce=B.transmissionMap:B.thicknessMap?ce=B.thicknessMap:B.sheenColorMap?ce=B.sheenColorMap:B.sheenRoughnessMap&&(ce=B.sheenRoughnessMap),ce!==void 0&&(ce.isWebGLRenderTarget&&(ce=ce.texture),ce.matrixAutoUpdate===!0&&ce.updateMatrix(),Y.uvTransform.value.copy(ce.matrix));let Ae;B.aoMap?Ae=B.aoMap:B.lightMap&&(Ae=B.lightMap),Ae!==void 0&&(Ae.isWebGLRenderTarget&&(Ae=Ae.texture),Ae.matrixAutoUpdate===!0&&Ae.updateMatrix(),Y.uv2Transform.value.copy(Ae.matrix))}function p(Y,B){Y.diffuse.value.copy(B.color),Y.opacity.value=B.opacity}function y(Y,B){Y.dashSize.value=B.dashSize,Y.totalSize.value=B.dashSize+B.gapSize,Y.scale.value=B.scale}function i(Y,B,ae,ce){Y.diffuse.value.copy(B.color),Y.opacity.value=B.opacity,Y.size.value=B.size*ae,Y.scale.value=ce*.5,B.map&&(Y.map.value=B.map),B.alphaMap&&(Y.alphaMap.value=B.alphaMap),B.alphaTest>0&&(Y.alphaTest.value=B.alphaTest);let Ae;B.map?Ae=B.map:B.alphaMap&&(Ae=B.alphaMap),Ae!==void 0&&(Ae.matrixAutoUpdate===!0&&Ae.updateMatrix(),Y.uvTransform.value.copy(Ae.matrix))}function C(Y,B){Y.diffuse.value.copy(B.color),Y.opacity.value=B.opacity,Y.rotation.value=B.rotation,B.map&&(Y.map.value=B.map),B.alphaMap&&(Y.alphaMap.value=B.alphaMap),B.alphaTest>0&&(Y.alphaTest.value=B.alphaTest);let ae;B.map?ae=B.map:B.alphaMap&&(ae=B.alphaMap),ae!==void 0&&(ae.matrixAutoUpdate===!0&&ae.updateMatrix(),Y.uvTransform.value.copy(ae.matrix))}function D(Y,B){Y.specular.value.copy(B.specular),Y.shininess.value=Math.max(B.shininess,1e-4)}function R(Y,B){B.gradientMap&&(Y.gradientMap.value=B.gradientMap)}function Q(Y,B){Y.roughness.value=B.roughness,Y.metalness.value=B.metalness,B.roughnessMap&&(Y.roughnessMap.value=B.roughnessMap),B.metalnessMap&&(Y.metalnessMap.value=B.metalnessMap),e.get(B).envMap&&(Y.envMapIntensity.value=B.envMapIntensity)}function z(Y,B,ae){Y.ior.value=B.ior,B.sheen>0&&(Y.sheenColor.value.copy(B.sheenColor).multiplyScalar(B.sheen),Y.sheenRoughness.value=B.sheenRoughness,B.sheenColorMap&&(Y.sheenColorMap.value=B.sheenColorMap),B.sheenRoughnessMap&&(Y.sheenRoughnessMap.value=B.sheenRoughnessMap)),B.clearcoat>0&&(Y.clearcoat.value=B.clearcoat,Y.clearcoatRoughness.value=B.clearcoatRoughness,B.clearcoatMap&&(Y.clearcoatMap.value=B.clearcoatMap),B.clearcoatRoughnessMap&&(Y.clearcoatRoughnessMap.value=B.clearcoatRoughnessMap),B.clearcoatNormalMap&&(Y.clearcoatNormalScale.value.copy(B.clearcoatNormalScale),Y.clearcoatNormalMap.value=B.clearcoatNormalMap,B.side===rc&&Y.clearcoatNormalScale.value.negate())),B.iridescence>0&&(Y.iridescence.value=B.iridescence,Y.iridescenceIOR.value=B.iridescenceIOR,Y.iridescenceThicknessMinimum.value=B.iridescenceThicknessRange[0],Y.iridescenceThicknessMaximum.value=B.iridescenceThicknessRange[1],B.iridescenceMap&&(Y.iridescenceMap.value=B.iridescenceMap),B.iridescenceThicknessMap&&(Y.iridescenceThicknessMap.value=B.iridescenceThicknessMap)),B.transmission>0&&(Y.transmission.value=B.transmission,Y.transmissionSamplerMap.value=ae.texture,Y.transmissionSamplerSize.value.set(ae.width,ae.height),B.transmissionMap&&(Y.transmissionMap.value=B.transmissionMap),Y.thickness.value=B.thickness,B.thicknessMap&&(Y.thicknessMap.value=B.thicknessMap),Y.attenuationDistance.value=B.attenuationDistance,Y.attenuationColor.value.copy(B.attenuationColor)),Y.specularIntensity.value=B.specularIntensity,Y.specularColor.value.copy(B.specularColor),B.specularIntensityMap&&(Y.specularIntensityMap.value=B.specularIntensityMap),B.specularColorMap&&(Y.specularColorMap.value=B.specularColorMap)}function G(Y,B){B.matcap&&(Y.matcap.value=B.matcap)}function J(Y,B){Y.referencePosition.value.copy(B.referencePosition),Y.nearDistance.value=B.nearDistance,Y.farDistance.value=B.farDistance}return{refreshFogUniforms:t,refreshMaterialUniforms:r}}function bN(u,e,t,r){let c={},p={},y=[];const i=t.isWebGL2?u.getParameter(35375):0;function C(ce,Ae){const we=Ae.program;r.uniformBlockBinding(ce,we)}function D(ce,Ae){let we=c[ce.id];we===void 0&&(J(ce),we=R(ce),c[ce.id]=we,ce.addEventListener("dispose",B));const me=Ae.program;r.updateUBOMapping(ce,me);const De=e.render.frame;p[ce.id]!==De&&(z(ce),p[ce.id]=De)}function R(ce){const Ae=Q();ce.__bindingPointIndex=Ae;const we=u.createBuffer(),me=ce.__size,De=ce.usage;return u.bindBuffer(35345,we),u.bufferData(35345,me,De),u.bindBuffer(35345,null),u.bindBufferBase(35345,Ae,we),we}function Q(){for(let ce=0;ce0){De=we%me;const xi=me-De;De!==0&&xi-Et.boundary<0&&(we+=me-De,Ge.__offset=we)}we+=Et.storage}return De=we%me,De>0&&(we+=me-De),ce.__size=we,ce.__cache={},this}function Y(ce){const Ae={boundary:0,storage:0};return typeof ce=="number"?(Ae.boundary=4,Ae.storage=4):ce.isVector2?(Ae.boundary=8,Ae.storage=8):ce.isVector3||ce.isColor?(Ae.boundary=16,Ae.storage=12):ce.isVector4?(Ae.boundary=16,Ae.storage=16):ce.isMatrix3?(Ae.boundary=48,Ae.storage=48):ce.isMatrix4?(Ae.boundary=64,Ae.storage=64):ce.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",ce),Ae}function B(ce){const Ae=ce.target;Ae.removeEventListener("dispose",B);const we=y.indexOf(Ae.__bindingPointIndex);y.splice(we,1),u.deleteBuffer(c[Ae.id]),delete c[Ae.id],delete p[Ae.id]}function ae(){for(const ce in c)u.deleteBuffer(c[ce]);y=[],c={},p={}}return{bind:C,update:D,dispose:ae}}function BN(){const u=K_("canvas");return u.style.display="block",u}function fv(u={}){this.isWebGLRenderer=!0;const e=u.canvas!==void 0?u.canvas:BN(),t=u.context!==void 0?u.context:null,r=u.depth!==void 0?u.depth:!0,c=u.stencil!==void 0?u.stencil:!0,p=u.antialias!==void 0?u.antialias:!1,y=u.premultipliedAlpha!==void 0?u.premultipliedAlpha:!0,i=u.preserveDrawingBuffer!==void 0?u.preserveDrawingBuffer:!1,C=u.powerPreference!==void 0?u.powerPreference:"default",D=u.failIfMajorPerformanceCaveat!==void 0?u.failIfMajorPerformanceCaveat:!1;let R;t!==null?R=t.getContextAttributes().alpha:R=u.alpha!==void 0?u.alpha:!1;let Q=null,z=null;const G=[],J=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=lp,this.physicallyCorrectLights=!1,this.toneMapping=Hu,this.toneMappingExposure=1;const Y=this;let B=!1,ae=0,ce=0,Ae=null,we=-1,me=null;const De=new as,Je=new as;let Fe=null,Ge=e.width,Et=e.height,li=1,xi=null,te=null;const le=new as(0,0,Ge,Et),ye=new as(0,0,Ge,Et);let xe=!1;const Re=new Vv;let Oe=!1,We=!1,Ve=null;const Qe=new ar,Se=new Di,Ke=new ft,nt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function vt(){return Ae===null?li:1}let be=t;function At(X,j){for(let ie=0;ie0?z=J[J.length-1]:z=null,G.pop(),G.length>0?Q=G[G.length-1]:Q=null};function Hr(X,j,ie,ne){if(X.visible===!1)return;if(X.layers.test(j.layers)){if(X.isGroup)ie=X.renderOrder;else if(X.isLOD)X.autoUpdate===!0&&X.update(j);else if(X.isLight)z.pushLight(X),X.castShadow&&z.pushShadow(X);else if(X.isSprite){if(!X.frustumCulled||Re.intersectsSprite(X)){ne&&Ke.setFromMatrixPosition(X.matrixWorld).applyMatrix4(Qe);const tt=wn.update(X),He=X.material;He.visible&&Q.push(X,tt,He,ie,Ke.z,null)}}else if((X.isMesh||X.isLine||X.isPoints)&&(X.isSkinnedMesh&&X.skeleton.frame!==Qt.render.frame&&(X.skeleton.update(),X.skeleton.frame=Qt.render.frame),!X.frustumCulled||Re.intersectsObject(X))){ne&&Ke.setFromMatrixPosition(X.matrixWorld).applyMatrix4(Qe);const tt=wn.update(X),He=X.material;if(Array.isArray(He)){const et=tt.groups;for(let pt=0,Lt=et.length;pt0&&kr(de,j,ie),ne&&Gt.viewport(De.copy(ne)),de.length>0&&Qn(de,j,ie),Ue.length>0&&Qn(Ue,j,ie),tt.length>0&&Qn(tt,j,ie),Gt.buffers.depth.setTest(!0),Gt.buffers.depth.setMask(!0),Gt.buffers.color.setMask(!0),Gt.setPolygonOffset(!1)}function kr(X,j,ie){const ne=Nt.isWebGL2;Ve===null&&(Ve=new rl(1,1,{generateMipmaps:!0,type:ut.has("EXT_color_buffer_half_float")?Gm:ap,minFilter:op,samples:ne&&p===!0?4:0})),Y.getDrawingBufferSize(Se),ne?Ve.setSize(Se.x,Se.y):Ve.setSize(pv(Se.x),pv(Se.y));const de=Y.getRenderTarget();Y.setRenderTarget(Ve),Y.clear();const Ue=Y.toneMapping;Y.toneMapping=Hu,Qn(X,j,ie),Y.toneMapping=Ue,Ft.updateMultisampleRenderTarget(Ve),Ft.updateRenderTargetMipmap(Ve),Y.setRenderTarget(de)}function Qn(X,j,ie){const ne=j.isScene===!0?j.overrideMaterial:null;for(let de=0,Ue=X.length;de0&&Ft.useMultisampledRTT(X)===!1?de=Ct.get(X).__webglMultisampledFramebuffer:de=Lt,De.copy(X.viewport),Je.copy(X.scissor),Fe=X.scissorTest}else De.copy(le).multiplyScalar(li).floor(),Je.copy(ye).multiplyScalar(li).floor(),Fe=xe;if(Gt.bindFramebuffer(36160,de)&&Nt.drawBuffers&&ne&&Gt.drawBuffers(X,de),Gt.viewport(De),Gt.scissor(Je),Gt.setScissorTest(Fe),Ue){const et=Ct.get(X.texture);be.framebufferTexture2D(36160,36064,34069+j,et.__webglTexture,ie)}else if(tt){const et=Ct.get(X.texture),pt=j||0;be.framebufferTextureLayer(36160,36064,et.__webglTexture,ie||0,pt)}we=-1},this.readRenderTargetPixels=function(X,j,ie,ne,de,Ue,tt){if(!(X&&X.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let He=Ct.get(X).__webglFramebuffer;if(X.isWebGLCubeRenderTarget&&tt!==void 0&&(He=He[tt]),He){Gt.bindFramebuffer(36160,He);try{const et=X.texture,pt=et.format,Lt=et.type;if(pt!==Dl&&at.convert(pt)!==be.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const jt=Lt===Gm&&(ut.has("EXT_color_buffer_half_float")||Nt.isWebGL2&&ut.has("EXT_color_buffer_float"));if(Lt!==ap&&at.convert(Lt)!==be.getParameter(35738)&&!(Lt===GA&&(Nt.isWebGL2||ut.has("OES_texture_float")||ut.has("WEBGL_color_buffer_float")))&&!jt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}j>=0&&j<=X.width-ne&&ie>=0&&ie<=X.height-de&&be.readPixels(j,ie,ne,de,at.convert(pt),at.convert(Lt),Ue)}finally{const et=Ae!==null?Ct.get(Ae).__webglFramebuffer:null;Gt.bindFramebuffer(36160,et)}}},this.copyFramebufferToTexture=function(X,j,ie=0){const ne=Math.pow(2,-ie),de=Math.floor(j.image.width*ne),Ue=Math.floor(j.image.height*ne);Ft.setTexture2D(j,0),be.copyTexSubImage2D(3553,ie,0,0,X.x,X.y,de,Ue),Gt.unbindTexture()},this.copyTextureToTexture=function(X,j,ie,ne=0){const de=j.image.width,Ue=j.image.height,tt=at.convert(ie.format),He=at.convert(ie.type);Ft.setTexture2D(ie,0),be.pixelStorei(37440,ie.flipY),be.pixelStorei(37441,ie.premultiplyAlpha),be.pixelStorei(3317,ie.unpackAlignment),j.isDataTexture?be.texSubImage2D(3553,ne,X.x,X.y,de,Ue,tt,He,j.image.data):j.isCompressedTexture?be.compressedTexSubImage2D(3553,ne,X.x,X.y,j.mipmaps[0].width,j.mipmaps[0].height,tt,j.mipmaps[0].data):be.texSubImage2D(3553,ne,X.x,X.y,tt,He,j.image),ne===0&&ie.generateMipmaps&&be.generateMipmap(3553),Gt.unbindTexture()},this.copyTextureToTexture3D=function(X,j,ie,ne,de=0){if(Y.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Ue=X.max.x-X.min.x+1,tt=X.max.y-X.min.y+1,He=X.max.z-X.min.z+1,et=at.convert(ne.format),pt=at.convert(ne.type);let Lt;if(ne.isData3DTexture)Ft.setTexture3D(ne,0),Lt=32879;else if(ne.isDataArrayTexture)Ft.setTexture2DArray(ne,0),Lt=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}be.pixelStorei(37440,ne.flipY),be.pixelStorei(37441,ne.premultiplyAlpha),be.pixelStorei(3317,ne.unpackAlignment);const jt=be.getParameter(3314),Wt=be.getParameter(32878),ki=be.getParameter(3316),bi=be.getParameter(3315),Oi=be.getParameter(32877),Yi=ie.isCompressedTexture?ie.mipmaps[0]:ie.image;be.pixelStorei(3314,Yi.width),be.pixelStorei(32878,Yi.height),be.pixelStorei(3316,X.min.x),be.pixelStorei(3315,X.min.y),be.pixelStorei(32877,X.min.z),ie.isDataTexture||ie.isData3DTexture?be.texSubImage3D(Lt,de,j.x,j.y,j.z,Ue,tt,He,et,pt,Yi.data):ie.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),be.compressedTexSubImage3D(Lt,de,j.x,j.y,j.z,Ue,tt,He,et,Yi.data)):be.texSubImage3D(Lt,de,j.x,j.y,j.z,Ue,tt,He,et,pt,Yi),be.pixelStorei(3314,jt),be.pixelStorei(32878,Wt),be.pixelStorei(3316,ki),be.pixelStorei(3315,bi),be.pixelStorei(32877,Oi),de===0&&ne.generateMipmaps&&be.generateMipmap(Lt),Gt.unbindTexture()},this.initTexture=function(X){X.isCubeTexture?Ft.setTextureCube(X,0):X.isData3DTexture?Ft.setTexture3D(X,0):X.isDataArrayTexture||X.isCompressedArrayTexture?Ft.setTexture2DArray(X,0):Ft.setTexture2D(X,0),Gt.unbindTexture()},this.resetState=function(){ae=0,ce=0,Ae=null,Gt.reset(),ii.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class $I extends fv{}$I.prototype.isWebGL1Renderer=!0;class Gv{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Dn(e),this.density=t}clone(){return new Gv(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Wv{constructor(e,t=1,r=1e3){this.isFog=!0,this.name="",this.color=new Dn(e),this.near=t,this.far=r}clone(){return new Wv(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class K2 extends ls{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class jv{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=W_,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Pc()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,r){e*=this.stride,r*=t.stride;for(let c=0,p=this.stride;ce.far||t.push({distance:C,point:l_.clone(),uv:wh.getUV(l_,px,h_,fx,fT,Hw,mT,new Di),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function mx(u,e,t,r,c,p){Cm.subVectors(u,t).addScalar(.5).multiply(r),c!==void 0?(c_.x=p*Cm.x-c*Cm.y,c_.y=c*Cm.x+p*Cm.y):c_.copy(Cm),u.copy(e),u.x+=c_.x,u.y+=c_.y,u.applyMatrix4(ZI)}const gx=new ft,gT=new ft;class XI extends ls{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let r=0,c=t.length;r0){let r,c;for(r=1,c=t.length;r0){gx.setFromMatrixPosition(this.matrixWorld);const c=e.ray.origin.distanceTo(gx);this.getObjectForDistance(c).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){gx.setFromMatrixPosition(e.matrixWorld),gT.setFromMatrixPosition(this.matrixWorld);const r=gx.distanceTo(gT)/e.zoom;t[0].object.visible=!0;let c,p;for(c=1,p=t.length;c=y)t[c-1].object.visible=!1,t[c].object.visible=!0;else break}for(this._currentLevel=c-1;cC)continue;z.applyMatrix4(this.matrixWorld);const Fe=e.ray.origin.distanceTo(z);Fee.far||t.push({distance:Fe,point:Q.clone().applyMatrix4(this.matrixWorld),index:Ae,face:null,faceIndex:null,object:this})}}else{const ae=Math.max(0,y.start),ce=Math.min(B.count,y.start+y.count);for(let Ae=ae,we=ce-1;AeC)continue;z.applyMatrix4(this.matrixWorld);const De=e.ray.origin.distanceTo(z);Dee.far||t.push({distance:De,point:Q.clone().applyMatrix4(this.matrixWorld),index:Ae,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,r=Object.keys(t);if(r.length>0){const c=t[r[0]];if(c!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let p=0,y=c.length;p0){const c=t[r[0]];if(c!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let p=0,y=c.length;pc.far)return;p.push({distance:D,distanceToRay:Math.sqrt(i),point:C,index:e,face:null,object:y})}}class SN extends To{constructor(e,t,r,c,p,y,i,C,D){super(e,t,r,c,p,y,i,C,D),this.isVideoTexture=!0,this.minFilter=y!==void 0?y:Xs,this.magFilter=p!==void 0?p:Xs,this.generateMipmaps=!1;const R=this;function Q(){R.needsUpdate=!0,e.requestVideoFrameCallback(Q)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(Q)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class MN extends To{constructor(e,t,r){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=r,this.magFilter=Co,this.minFilter=Co,this.generateMipmaps=!1,this.needsUpdate=!0}}class Y2 extends To{constructor(e,t,r,c,p,y,i,C,D,R,Q,z){super(null,y,i,C,D,R,c,p,Q,z),this.isCompressedTexture=!0,this.image={width:t,height:r},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class IN extends Y2{constructor(e,t,r,c,p,y){super(e,t,r,p,y),this.isCompressedArrayTexture=!0,this.image.depth=c,this.wrapR=nl}}class JI extends To{constructor(e,t,r,c,p,y,i,C,D){super(e,t,r,c,p,y,i,C,D),this.isCanvasTexture=!0,this.needsUpdate=!0}}class du{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const r=this.getUtoTmapping(e);return this.getPoint(r,t)}getPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPoint(r/e));return t}getSpacedPoints(e=5){const t=[];for(let r=0;r<=e;r++)t.push(this.getPointAt(r/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let r,c=this.getPoint(0),p=0;t.push(0);for(let y=1;y<=e;y++)r=this.getPoint(y/e),p+=r.distanceTo(c),t.push(p),c=r;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const r=this.getLengths();let c=0;const p=r.length;let y;t?y=t:y=e*r[p-1];let i=0,C=p-1,D;for(;i<=C;)if(c=Math.floor(i+(C-i)/2),D=r[c]-y,D<0)i=c+1;else if(D>0)C=c-1;else{C=c;break}if(c=C,r[c]===y)return c/(p-1);const R=r[c],z=r[c+1]-R,G=(y-R)/z;return(c+G)/(p-1)}getTangent(e,t){let c=e-1e-4,p=e+1e-4;c<0&&(c=0),p>1&&(p=1);const y=this.getPoint(c),i=this.getPoint(p),C=t||(y.isVector2?new Di:new ft);return C.copy(i).sub(y).normalize(),C}getTangentAt(e,t){const r=this.getUtoTmapping(e);return this.getTangent(r,t)}computeFrenetFrames(e,t){const r=new ft,c=[],p=[],y=[],i=new ft,C=new ar;for(let G=0;G<=e;G++){const J=G/e;c[G]=this.getTangentAt(J,new ft)}p[0]=new ft,y[0]=new ft;let D=Number.MAX_VALUE;const R=Math.abs(c[0].x),Q=Math.abs(c[0].y),z=Math.abs(c[0].z);R<=D&&(D=R,r.set(1,0,0)),Q<=D&&(D=Q,r.set(0,1,0)),z<=D&&r.set(0,0,1),i.crossVectors(c[0],r).normalize(),p[0].crossVectors(c[0],i),y[0].crossVectors(c[0],p[0]);for(let G=1;G<=e;G++){if(p[G]=p[G-1].clone(),y[G]=y[G-1].clone(),i.crossVectors(c[G-1],c[G]),i.length()>Number.EPSILON){i.normalize();const J=Math.acos(Eo(c[G-1].dot(c[G]),-1,1));p[G].applyMatrix4(C.makeRotationAxis(i,J))}y[G].crossVectors(c[G],p[G])}if(t===!0){let G=Math.acos(Eo(p[0].dot(p[e]),-1,1));G/=e,c[0].dot(i.crossVectors(p[0],p[e]))>0&&(G=-G);for(let J=1;J<=e;J++)p[J].applyMatrix4(C.makeRotationAxis(c[J],G*J)),y[J].crossVectors(c[J],p[J])}return{tangents:c,normals:p,binormals:y}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class $v extends du{constructor(e=0,t=0,r=1,c=1,p=0,y=Math.PI*2,i=!1,C=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=r,this.yRadius=c,this.aStartAngle=p,this.aEndAngle=y,this.aClockwise=i,this.aRotation=C}getPoint(e,t){const r=t||new Di,c=Math.PI*2;let p=this.aEndAngle-this.aStartAngle;const y=Math.abs(p)c;)p-=c;p0?0:(Math.floor(Math.abs(i)/p)+1)*p:C===0&&i===p-1&&(i=p-2,C=1);let D,R;this.closed||i>0?D=c[(i-1)%p]:(wx.subVectors(c[0],c[1]).add(c[0]),D=wx);const Q=c[i%p],z=c[(i+1)%p];if(this.closed||i+2c.length-2?c.length-1:y+1],Q=c[y>c.length-3?c.length-1:y+2];return r.set(LT(i,C.x,D.x,R.x,Q.x),LT(i,C.y,D.y,R.y,Q.y)),r}copy(e){super.copy(e),this.points=[];for(let t=0,r=e.points.length;t=r){const y=c[p]-r,i=this.curves[p],C=i.getLength(),D=C===0?0:1-y/C;return i.getPointAt(D,t)}p++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let r=0,c=this.curves.length;r1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,r=e.curves.length;t0){const Q=D.getPoint(0);Q.equals(this.currentPoint)||this.lineTo(Q.x,Q.y)}this.curves.push(D);const R=D.getPoint(1);return this.currentPoint.copy(R),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Jm extends br{constructor(e=[new Di(0,-.5),new Di(.5,0),new Di(0,.5)],t=12,r=0,c=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:r,phiLength:c},t=Math.floor(t),c=Eo(c,0,Math.PI*2);const p=[],y=[],i=[],C=[],D=[],R=1/t,Q=new ft,z=new Di,G=new ft,J=new ft,Y=new ft;let B=0,ae=0;for(let ce=0;ce<=e.length-1;ce++)switch(ce){case 0:B=e[ce+1].x-e[ce].x,ae=e[ce+1].y-e[ce].y,G.x=ae*1,G.y=-B,G.z=ae*0,Y.copy(G),G.normalize(),C.push(G.x,G.y,G.z);break;case e.length-1:C.push(Y.x,Y.y,Y.z);break;default:B=e[ce+1].x-e[ce].x,ae=e[ce+1].y-e[ce].y,G.x=ae*1,G.y=-B,G.z=ae*0,J.copy(G),G.x+=Y.x,G.y+=Y.y,G.z+=Y.z,G.normalize(),C.push(G.x,G.y,G.z),Y.copy(J)}for(let ce=0;ce<=t;ce++){const Ae=r+ce*R*c,we=Math.sin(Ae),me=Math.cos(Ae);for(let De=0;De<=e.length-1;De++){Q.x=e[De].x*we,Q.y=e[De].y,Q.z=e[De].x*me,y.push(Q.x,Q.y,Q.z),z.x=ce/t,z.y=De/(e.length-1),i.push(z.x,z.y);const Je=C[3*De+0]*we,Fe=C[3*De+1],Ge=C[3*De+0]*me;D.push(Je,Fe,Ge)}}for(let ce=0;ce0&&Ae(!0),t>0&&Ae(!1)),this.setIndex(R),this.setAttribute("position",new jn(Q,3)),this.setAttribute("normal",new jn(z,3)),this.setAttribute("uv",new jn(G,2));function ce(){const we=new ft,me=new ft;let De=0;const Je=(t-e)/r;for(let Fe=0;Fe<=p;Fe++){const Ge=[],Et=Fe/p,li=Et*(t-e)+e;for(let xi=0;xi<=c;xi++){const te=xi/c,le=te*C+i,ye=Math.sin(le),xe=Math.cos(le);me.x=li*ye,me.y=-Et*r+B,me.z=li*xe,Q.push(me.x,me.y,me.z),we.set(ye,Je,xe).normalize(),z.push(we.x,we.y,we.z),G.push(te,1-Et),Ge.push(J++)}Y.push(Ge)}for(let Fe=0;Fe.9&&Je<.1&&(Ae<.2&&(y[ce+0]+=1),we<.2&&(y[ce+2]+=1),me<.2&&(y[ce+4]+=1))}}function z(ce){p.push(ce.x,ce.y,ce.z)}function G(ce,Ae){const we=ce*3;Ae.x=e[we+0],Ae.y=e[we+1],Ae.z=e[we+2]}function J(){const ce=new ft,Ae=new ft,we=new ft,me=new ft,De=new Di,Je=new Di,Fe=new Di;for(let Ge=0,Et=0;Ge80*t){i=D=u[0],C=R=u[1];for(let J=t;JD&&(D=Q),z>R&&(R=z);G=Math.max(D-i,R-C),G=G!==0?32767/G:0}return X_(p,y,t,i,C,G,0),y}};function sF(u,e,t,r,c){let p,y;if(c===eQ(u,e,t,r)>0)for(p=e;p=e;p-=r)y=DT(p,u[p],u[p+1],y);return y&&Xv(y,y.next)&&(Y_(y),y=y.next),y}function _f(u,e){if(!u)return u;e||(e=u);let t=u,r;do if(r=!1,!t.steiner&&(Xv(t,t.next)||co(t.prev,t,t.next)===0)){if(Y_(t),t=e=t.prev,t===t.next)break;r=!0}else t=t.next;while(r||t!==e);return e}function X_(u,e,t,r,c,p,y){if(!u)return;!y&&p&&$N(u,r,c,p);let i=u,C,D;for(;u.prev!==u.next;){if(C=u.prev,D=u.next,p?NN(u,r,c,p):ON(u)){e.push(C.i/t|0),e.push(u.i/t|0),e.push(D.i/t|0),Y_(u),u=D.next,i=D.next;continue}if(u=D,u===i){y?y===1?(u=QN(_f(u),e,t),X_(u,e,t,r,c,p,2)):y===2&&VN(u,e,t,r,c,p):X_(_f(u),e,t,r,c,p,1);break}}}function ON(u){const e=u.prev,t=u,r=u.next;if(co(e,t,r)>=0)return!1;const c=e.x,p=t.x,y=r.x,i=e.y,C=t.y,D=r.y,R=cp?c>y?c:y:p>y?p:y,G=i>C?i>D?i:D:C>D?C:D;let J=r.next;for(;J!==e;){if(J.x>=R&&J.x<=z&&J.y>=Q&&J.y<=G&&Rm(c,i,p,C,y,D,J.x,J.y)&&co(J.prev,J,J.next)>=0)return!1;J=J.next}return!0}function NN(u,e,t,r){const c=u.prev,p=u,y=u.next;if(co(c,p,y)>=0)return!1;const i=c.x,C=p.x,D=y.x,R=c.y,Q=p.y,z=y.y,G=iC?i>D?i:D:C>D?C:D,B=R>Q?R>z?R:z:Q>z?Q:z,ae=h2(G,J,e,t,r),ce=h2(Y,B,e,t,r);let Ae=u.prevZ,we=u.nextZ;for(;Ae&&Ae.z>=ae&&we&&we.z<=ce;){if(Ae.x>=G&&Ae.x<=Y&&Ae.y>=J&&Ae.y<=B&&Ae!==c&&Ae!==y&&Rm(i,R,C,Q,D,z,Ae.x,Ae.y)&&co(Ae.prev,Ae,Ae.next)>=0||(Ae=Ae.prevZ,we.x>=G&&we.x<=Y&&we.y>=J&&we.y<=B&&we!==c&&we!==y&&Rm(i,R,C,Q,D,z,we.x,we.y)&&co(we.prev,we,we.next)>=0))return!1;we=we.nextZ}for(;Ae&&Ae.z>=ae;){if(Ae.x>=G&&Ae.x<=Y&&Ae.y>=J&&Ae.y<=B&&Ae!==c&&Ae!==y&&Rm(i,R,C,Q,D,z,Ae.x,Ae.y)&&co(Ae.prev,Ae,Ae.next)>=0)return!1;Ae=Ae.prevZ}for(;we&&we.z<=ce;){if(we.x>=G&&we.x<=Y&&we.y>=J&&we.y<=B&&we!==c&&we!==y&&Rm(i,R,C,Q,D,z,we.x,we.y)&&co(we.prev,we,we.next)>=0)return!1;we=we.nextZ}return!0}function QN(u,e,t){let r=u;do{const c=r.prev,p=r.next.next;!Xv(c,p)&&oF(c,r,r.next,p)&&q_(c,p)&&q_(p,c)&&(e.push(c.i/t|0),e.push(r.i/t|0),e.push(p.i/t|0),Y_(r),Y_(r.next),r=u=p),r=r.next}while(r!==u);return _f(r)}function VN(u,e,t,r,c,p){let y=u;do{let i=y.next.next;for(;i!==y.prev;){if(y.i!==i.i&&qN(y,i)){let C=aF(y,i);y=_f(y,y.next),C=_f(C,C.next),X_(y,e,t,r,c,p,0),X_(C,e,t,r,c,p,0);return}i=i.next}y=y.next}while(y!==u)}function HN(u,e,t,r){const c=[];let p,y,i,C,D;for(p=0,y=e.length;p=t.next.y&&t.next.y!==t.y){const z=t.x+(y-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(z<=p&&z>r&&(r=z,c=t.x=t.x&&t.x>=C&&p!==t.x&&Rm(yc.x||t.x===c.x&&KN(c,t)))&&(c=t,R=Q)),t=t.next;while(t!==i);return c}function KN(u,e){return co(u.prev,u,e.prev)<0&&co(e.next,u,u.next)<0}function $N(u,e,t,r){let c=u;do c.z===0&&(c.z=h2(c.x,c.y,e,t,r)),c.prevZ=c.prev,c.nextZ=c.next,c=c.next;while(c!==u);c.prevZ.nextZ=null,c.prevZ=null,ZN(c)}function ZN(u){let e,t,r,c,p,y,i,C,D=1;do{for(t=u,u=null,p=null,y=0;t;){for(y++,r=t,i=0,e=0;e0||C>0&&r;)i!==0&&(C===0||!r||t.z<=r.z)?(c=t,t=t.nextZ,i--):(c=r,r=r.nextZ,C--),p?p.nextZ=c:u=c,c.prevZ=p,p=c;t=r}p.nextZ=null,D*=2}while(y>1);return u}function h2(u,e,t,r,c){return u=(u-t)*c|0,e=(e-r)*c|0,u=(u|u<<8)&16711935,u=(u|u<<4)&252645135,u=(u|u<<2)&858993459,u=(u|u<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,u|e<<1}function XN(u){let e=u,t=u;do(e.x=(u-y)*(p-i)&&(u-y)*(r-i)>=(t-y)*(e-i)&&(t-y)*(p-i)>=(c-y)*(r-i)}function qN(u,e){return u.next.i!==e.i&&u.prev.i!==e.i&&!YN(u,e)&&(q_(u,e)&&q_(e,u)&&JN(u,e)&&(co(u.prev,u,e.prev)||co(u,e.prev,e))||Xv(u,e)&&co(u.prev,u,u.next)>0&&co(e.prev,e,e.next)>0)}function co(u,e,t){return(e.y-u.y)*(t.x-e.x)-(e.x-u.x)*(t.y-e.y)}function Xv(u,e){return u.x===e.x&&u.y===e.y}function oF(u,e,t,r){const c=Tx(co(u,e,t)),p=Tx(co(u,e,r)),y=Tx(co(t,r,u)),i=Tx(co(t,r,e));return!!(c!==p&&y!==i||c===0&&Ex(u,t,e)||p===0&&Ex(u,r,e)||y===0&&Ex(t,u,r)||i===0&&Ex(t,e,r))}function Ex(u,e,t){return e.x<=Math.max(u.x,t.x)&&e.x>=Math.min(u.x,t.x)&&e.y<=Math.max(u.y,t.y)&&e.y>=Math.min(u.y,t.y)}function Tx(u){return u>0?1:u<0?-1:0}function YN(u,e){let t=u;do{if(t.i!==u.i&&t.next.i!==u.i&&t.i!==e.i&&t.next.i!==e.i&&oF(t,t.next,u,e))return!0;t=t.next}while(t!==u);return!1}function q_(u,e){return co(u.prev,u,u.next)<0?co(u,e,u.next)>=0&&co(u,u.prev,e)>=0:co(u,e,u.prev)<0||co(u,u.next,e)<0}function JN(u,e){let t=u,r=!1;const c=(u.x+e.x)/2,p=(u.y+e.y)/2;do t.y>p!=t.next.y>p&&t.next.y!==t.y&&c<(t.next.x-t.x)*(p-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next;while(t!==u);return r}function aF(u,e){const t=new u2(u.i,u.x,u.y),r=new u2(e.i,e.x,e.y),c=u.next,p=e.prev;return u.next=e,e.prev=u,t.next=c,c.prev=t,r.next=t,t.prev=r,p.next=r,r.prev=p,r}function DT(u,e,t,r){const c=new u2(u,e,t);return r?(c.next=r.next,c.prev=r,r.next.prev=c,r.next=c):(c.prev=c,c.next=c),c}function Y_(u){u.next.prev=u.prev,u.prev.next=u.next,u.prevZ&&(u.prevZ.nextZ=u.nextZ),u.nextZ&&(u.nextZ.prevZ=u.prevZ)}function u2(u,e,t){this.i=u,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function eQ(u,e,t,r){let c=0;for(let p=e,y=t-r;p2&&u[e-1].equals(u[0])&&u.pop()}function UT(u,e){for(let t=0;tNumber.EPSILON){const ti=Math.sqrt(yt),Ni=Math.sqrt(Gn*Gn+kn*kn),qi=Ft.x-zi/ti,en=Ft.y+wn/ti,$t=Xt.x-kn/Ni,at=Xt.y+Gn/Ni,ii=(($t-qi)*kn-(at-en)*Gn)/(wn*kn-zi*Gn);_i=qi+wn*ii-Ct.x,fi=en+zi*ii-Ct.y;const hn=_i*_i+fi*fi;if(hn<=2)return new Di(_i,fi);Gi=Math.sqrt(hn/2)}else{let ti=!1;wn>Number.EPSILON?Gn>Number.EPSILON&&(ti=!0):wn<-Number.EPSILON?Gn<-Number.EPSILON&&(ti=!0):Math.sign(zi)===Math.sign(kn)&&(ti=!0),ti?(_i=-zi,fi=wn,Gi=Math.sqrt(yt)):(_i=wn,fi=zi,Gi=Math.sqrt(yt/2))}return new Di(_i/Gi,fi/Gi)}const We=[];for(let Ct=0,Ft=le.length,Xt=Ft-1,_i=Ct+1;Ct=0;Ct--){const Ft=Ct/B,Xt=G*Math.cos(Ft*Math.PI/2),_i=J*Math.sin(Ft*Math.PI/2)+Y;for(let fi=0,Gi=le.length;fi=0;){const _i=Xt;let fi=Xt-1;fi<0&&(fi=Ct.length-1);for(let Gi=0,wn=R+B*2;Gi0)&&G.push(Ae,we,De),(ae!==r-1||C0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class aB extends ol{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Dn(16777215),this.specular=new Dn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cp,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ly,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class hF extends ol{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Dn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cp,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class uF extends ol{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cp,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class gv extends ol{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Dn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Dn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cp,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ly,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class AF extends ol{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Dn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=cp,this.normalScale=new Di(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class dF extends ra{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function xh(u,e,t){return lB(u)?new u.constructor(u.subarray(e,t!==void 0?t:u.length)):u.slice(e,t)}function af(u,e,t){return!u||!t&&u.constructor===e?u:typeof e.BYTES_PER_ELEMENT=="number"?new e(u):Array.prototype.slice.call(u)}function lB(u){return ArrayBuffer.isView(u)&&!(u instanceof DataView)}function pF(u){function e(c,p){return u[c]-u[p]}const t=u.length,r=new Array(t);for(let c=0;c!==t;++c)r[c]=c;return r.sort(e),r}function A2(u,e,t){const r=u.length,c=new u.constructor(r);for(let p=0,y=0;y!==r;++p){const i=t[p]*e;for(let C=0;C!==e;++C)c[y++]=u[i+C]}return c}function cB(u,e,t,r){let c=1,p=u[0];for(;p!==void 0&&p[r]===void 0;)p=u[c++];if(p===void 0)return;let y=p[r];if(y!==void 0)if(Array.isArray(y))do y=p[r],y!==void 0&&(e.push(p.time),t.push.apply(t,y)),p=u[c++];while(p!==void 0);else if(y.toArray!==void 0)do y=p[r],y!==void 0&&(e.push(p.time),y.toArray(t,t.length)),p=u[c++];while(p!==void 0);else do y=p[r],y!==void 0&&(e.push(p.time),t.push(y)),p=u[c++];while(p!==void 0)}function rQ(u,e,t,r,c=30){const p=u.clone();p.name=e;const y=[];for(let C=0;C=r)){Q.push(D.times[G]);for(let Y=0;Yp.tracks[C].times[0]&&(i=p.tracks[C].times[0]);for(let C=0;C=i.times[J]){const ae=J*Q+R,ce=ae+Q-R;Y=xh(i.values,ae,ce)}else{const ae=i.createInterpolant(),ce=R,Ae=Q-R;ae.evaluate(p),Y=xh(ae.resultBuffer,ce,Ae)}C==="quaternion"&&new sl().fromArray(Y).normalize().conjugate().toArray(Y);const B=D.times.length;for(let ae=0;ae=p)){const i=t[1];e=p)break t}y=r,r=0;break i}break e}for(;r>>1;et;)--y;if(++y,p!==0||y!==c){p>=y&&(y=Math.max(y,1),p=y-1);const i=this.getValueSize();this.times=xh(r,p,y),this.values=xh(this.values,p*i,y*i)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const r=this.times,c=this.values,p=r.length;p===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let y=null;for(let i=0;i!==p;i++){const C=r[i];if(typeof C=="number"&&isNaN(C)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,i,C),e=!1;break}if(y!==null&&y>C){console.error("THREE.KeyframeTrack: Out of order keys.",this,i,C,y),e=!1;break}y=C}if(c!==void 0&&lB(c))for(let i=0,C=c.length;i!==C;++i){const D=c[i];if(isNaN(D)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,i,D),e=!1;break}}return e}optimize(){const e=xh(this.times),t=xh(this.values),r=this.getValueSize(),c=this.getInterpolation()===Zx,p=e.length-1;let y=1;for(let i=1;i0){e[y]=e[p];for(let i=p*r,C=y*r,D=0;D!==r;++D)t[C+D]=t[i+D];++y}return y!==e.length?(this.times=xh(e,0,y),this.values=xh(t,0,y*r)):(this.times=e,this.values=t),this}clone(){const e=xh(this.times,0),t=xh(this.values,0),r=this.constructor,c=new r(this.name,e,t);return c.createInterpolant=this.createInterpolant,c}}pu.prototype.TimeBufferType=Float32Array;pu.prototype.ValueBufferType=Float32Array;pu.prototype.DefaultInterpolation=H_;class wf extends pu{}wf.prototype.ValueTypeName="bool";wf.prototype.ValueBufferType=Array;wf.prototype.DefaultInterpolation=V_;wf.prototype.InterpolantFactoryMethodLinear=void 0;wf.prototype.InterpolantFactoryMethodSmooth=void 0;class uB extends pu{}uB.prototype.ValueTypeName="color";class ey extends pu{}ey.prototype.ValueTypeName="number";class gF extends By{constructor(e,t,r,c){super(e,t,r,c)}interpolate_(e,t,r,c){const p=this.resultBuffer,y=this.sampleValues,i=this.valueSize,C=(r-t)/(c-t);let D=e*i;for(let R=D+i;D!==R;D+=4)sl.slerpFlat(p,0,y,D-i,y,D,C);return p}}class ng extends pu{InterpolantFactoryMethodLinear(e){return new gF(this.times,this.values,this.getValueSize(),e)}}ng.prototype.ValueTypeName="quaternion";ng.prototype.DefaultInterpolation=H_;ng.prototype.InterpolantFactoryMethodSmooth=void 0;class bf extends pu{}bf.prototype.ValueTypeName="string";bf.prototype.ValueBufferType=Array;bf.prototype.DefaultInterpolation=V_;bf.prototype.InterpolantFactoryMethodLinear=void 0;bf.prototype.InterpolantFactoryMethodSmooth=void 0;class ty extends pu{}ty.prototype.ValueTypeName="vector";class iy{constructor(e,t=-1,r,c=Ov){this.name=e,this.tracks=r,this.duration=t,this.blendMode=c,this.uuid=Pc(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],r=e.tracks,c=1/(e.fps||1);for(let y=0,i=r.length;y!==i;++y)t.push(lQ(r[y]).scale(c));const p=new this(e.name,e.duration,t,e.blendMode);return p.uuid=e.uuid,p}static toJSON(e){const t=[],r=e.tracks,c={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let p=0,y=r.length;p!==y;++p)t.push(pu.toJSON(r[p]));return c}static CreateFromMorphTargetSequence(e,t,r,c){const p=t.length,y=[];for(let i=0;i1){const Q=R[1];let z=c[Q];z||(c[Q]=z=[]),z.push(D)}}const y=[];for(const i in c)y.push(this.CreateFromMorphTargetSequence(i,c[i],t,r));return y}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const r=function(Q,z,G,J,Y){if(G.length!==0){const B=[],ae=[];cB(G,B,ae,J),B.length!==0&&Y.push(new Q(z,B,ae))}},c=[],p=e.name||"default",y=e.fps||30,i=e.blendMode;let C=e.length||-1;const D=e.hierarchy||[];for(let Q=0;Q{t&&t(p),this.manager.itemEnd(e)},0),p;if(QA[e]!==void 0){QA[e].push({onLoad:t,onProgress:r,onError:c});return}QA[e]=[],QA[e].push({onLoad:t,onProgress:r,onError:c});const y=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),i=this.mimeType,C=this.responseType;fetch(y).then(D=>{if(D.status===200||D.status===0){if(D.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||D.body===void 0||D.body.getReader===void 0)return D;const R=QA[e],Q=D.body.getReader(),z=D.headers.get("Content-Length")||D.headers.get("X-File-Size"),G=z?parseInt(z):0,J=G!==0;let Y=0;const B=new ReadableStream({start(ae){ce();function ce(){Q.read().then(({done:Ae,value:we})=>{if(Ae)ae.close();else{Y+=we.byteLength;const me=new ProgressEvent("progress",{lengthComputable:J,loaded:Y,total:G});for(let De=0,Je=R.length;De{switch(C){case"arraybuffer":return D.arrayBuffer();case"blob":return D.blob();case"document":return D.text().then(R=>new DOMParser().parseFromString(R,i));case"json":return D.json();default:if(i===void 0)return D.text();{const Q=/charset="?([^;"\s]*)"?/i.exec(i),z=Q&&Q[1]?Q[1].toLowerCase():void 0,G=new TextDecoder(z);return D.arrayBuffer().then(J=>G.decode(J))}}}).then(D=>{yf.add(e,D);const R=QA[e];delete QA[e];for(let Q=0,z=R.length;Q{const R=QA[e];if(R===void 0)throw this.manager.itemError(e),D;delete QA[e];for(let Q=0,z=R.length;Q{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class hQ extends Uc{constructor(e){super(e)}load(e,t,r,c){const p=this,y=new ZA(this.manager);y.setPath(this.path),y.setRequestHeader(this.requestHeader),y.setWithCredentials(this.withCredentials),y.load(e,function(i){try{t(p.parse(JSON.parse(i)))}catch(C){c?c(C):console.error(C),p.manager.itemError(e)}},r,c)}parse(e){const t=[];for(let r=0;r0:c.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const p in e.uniforms){const y=e.uniforms[p];switch(c.uniforms[p]={},y.type){case"t":c.uniforms[p].value=r(y.value);break;case"c":c.uniforms[p].value=new Dn().setHex(y.value);break;case"v2":c.uniforms[p].value=new Di().fromArray(y.value);break;case"v3":c.uniforms[p].value=new ft().fromArray(y.value);break;case"v4":c.uniforms[p].value=new as().fromArray(y.value);break;case"m3":c.uniforms[p].value=new Pl().fromArray(y.value);break;case"m4":c.uniforms[p].value=new ar().fromArray(y.value);break;default:c.uniforms[p].value=y.value}}if(e.defines!==void 0&&(c.defines=e.defines),e.vertexShader!==void 0&&(c.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(c.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(c.glslVersion=e.glslVersion),e.extensions!==void 0)for(const p in e.extensions)c.extensions[p]=e.extensions[p];if(e.size!==void 0&&(c.size=e.size),e.sizeAttenuation!==void 0&&(c.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(c.map=r(e.map)),e.matcap!==void 0&&(c.matcap=r(e.matcap)),e.alphaMap!==void 0&&(c.alphaMap=r(e.alphaMap)),e.bumpMap!==void 0&&(c.bumpMap=r(e.bumpMap)),e.bumpScale!==void 0&&(c.bumpScale=e.bumpScale),e.normalMap!==void 0&&(c.normalMap=r(e.normalMap)),e.normalMapType!==void 0&&(c.normalMapType=e.normalMapType),e.normalScale!==void 0){let p=e.normalScale;Array.isArray(p)===!1&&(p=[p,p]),c.normalScale=new Di().fromArray(p)}return e.displacementMap!==void 0&&(c.displacementMap=r(e.displacementMap)),e.displacementScale!==void 0&&(c.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(c.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(c.roughnessMap=r(e.roughnessMap)),e.metalnessMap!==void 0&&(c.metalnessMap=r(e.metalnessMap)),e.emissiveMap!==void 0&&(c.emissiveMap=r(e.emissiveMap)),e.emissiveIntensity!==void 0&&(c.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(c.specularMap=r(e.specularMap)),e.specularIntensityMap!==void 0&&(c.specularIntensityMap=r(e.specularIntensityMap)),e.specularColorMap!==void 0&&(c.specularColorMap=r(e.specularColorMap)),e.envMap!==void 0&&(c.envMap=r(e.envMap)),e.envMapIntensity!==void 0&&(c.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(c.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(c.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(c.lightMap=r(e.lightMap)),e.lightMapIntensity!==void 0&&(c.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(c.aoMap=r(e.aoMap)),e.aoMapIntensity!==void 0&&(c.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(c.gradientMap=r(e.gradientMap)),e.clearcoatMap!==void 0&&(c.clearcoatMap=r(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(c.clearcoatRoughnessMap=r(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(c.clearcoatNormalMap=r(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(c.clearcoatNormalScale=new Di().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(c.iridescenceMap=r(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(c.iridescenceThicknessMap=r(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(c.transmissionMap=r(e.transmissionMap)),e.thicknessMap!==void 0&&(c.thicknessMap=r(e.thicknessMap)),e.sheenColorMap!==void 0&&(c.sheenColorMap=r(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(c.sheenRoughnessMap=r(e.sheenRoughnessMap)),c}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){const t={ShadowMaterial:lF,SpriteMaterial:py,RawShaderMaterial:cF,ShaderMaterial:ko,PointsMaterial:X2,MeshPhysicalMaterial:oB,MeshStandardMaterial:J_,MeshPhongMaterial:aB,MeshToonMaterial:hF,MeshNormalMaterial:uF,MeshLambertMaterial:gv,MeshDepthMaterial:W2,MeshDistanceMaterial:j2,MeshBasicMaterial:za,MeshMatcapMaterial:AF,LineDashedMaterial:dF,LineBasicMaterial:ra,Material:ol};return new t[e]}}class d2{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let r=0,c=e.length;r0){const C=new AB(t);p=new ny(C),p.setCrossOrigin(this.crossOrigin);for(let D=0,R=e.length;D0){c=new ny(this.manager),c.setCrossOrigin(this.crossOrigin);for(let y=0,i=e.length;y"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,r,c){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const p=this,y=yf.get(e);if(y!==void 0)return p.manager.itemStart(e),setTimeout(function(){t&&t(y),p.manager.itemEnd(e)},0),y;const i={};i.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",i.headers=this.requestHeader,fetch(e,i).then(function(C){return C.blob()}).then(function(C){return createImageBitmap(C,Object.assign(p.options,{colorSpaceConversion:"none"}))}).then(function(C){yf.add(e,C),t&&t(C),p.manager.itemEnd(e)}).catch(function(C){c&&c(C),p.manager.itemError(e),p.manager.itemEnd(e)}),p.manager.itemStart(e)}}let Sx;class yB{static getContext(){return Sx===void 0&&(Sx=new(window.AudioContext||window.webkitAudioContext)),Sx}static setContext(e){Sx=e}}class xQ extends Uc{constructor(e){super(e)}load(e,t,r,c){const p=this,y=new ZA(this.manager);y.setResponseType("arraybuffer"),y.setPath(this.path),y.setRequestHeader(this.requestHeader),y.setWithCredentials(this.withCredentials),y.load(e,function(i){try{const C=i.slice(0);yB.getContext().decodeAudioData(C,function(R){t(R)})}catch(C){c?c(C):console.error(C),p.manager.itemError(e)}},r,c)}}class vQ extends qv{constructor(e,t,r=1){super(void 0,r),this.isHemisphereLightProbe=!0;const c=new Dn().set(e),p=new Dn().set(t),y=new ft(c.r,c.g,c.b),i=new ft(p.r,p.g,p.b),C=Math.sqrt(Math.PI),D=C*Math.sqrt(.75);this.sh.coefficients[0].copy(y).add(i).multiplyScalar(C),this.sh.coefficients[1].copy(y).sub(i).multiplyScalar(D)}}class bF extends qv{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const r=new Dn().set(e);this.sh.coefficients[0].set(r.r,r.g,r.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const HT=new ar,GT=new ar,Qp=new ar;class wQ{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new _a,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new _a,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Qp.copy(e.projectionMatrix);const c=t.eyeSep/2,p=c*t.near/t.focus,y=t.near*Math.tan(Af*t.fov*.5)/t.zoom;let i,C;GT.elements[12]=-c,HT.elements[12]=c,i=-y*t.aspect+p,C=y*t.aspect+p,Qp.elements[0]=2*t.near/(C-i),Qp.elements[8]=(C+i)/(C-i),this.cameraL.projectionMatrix.copy(Qp),i=-y*t.aspect-p,C=y*t.aspect-p,Qp.elements[0]=2*t.near/(C-i),Qp.elements[8]=(C+i)/(C-i),this.cameraR.projectionMatrix.copy(Qp)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(GT),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(HT)}}class Jv{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=WT(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=WT();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function WT(){return(typeof performance>"u"?Date:performance).now()}const Vp=new ft,jT=new sl,bQ=new ft,Hp=new ft;class BQ extends ls{constructor(){super(),this.type="AudioListener",this.context=yB.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Jv}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,r=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Vp,jT,bQ),Hp.set(0,0,-1).applyQuaternion(jT),t.positionX){const c=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Vp.x,c),t.positionY.linearRampToValueAtTime(Vp.y,c),t.positionZ.linearRampToValueAtTime(Vp.z,c),t.forwardX.linearRampToValueAtTime(Hp.x,c),t.forwardY.linearRampToValueAtTime(Hp.y,c),t.forwardZ.linearRampToValueAtTime(Hp.z,c),t.upX.linearRampToValueAtTime(r.x,c),t.upY.linearRampToValueAtTime(r.y,c),t.upZ.linearRampToValueAtTime(r.z,c)}else t.setPosition(Vp.x,Vp.y,Vp.z),t.setOrientation(Hp.x,Hp.y,Hp.z,r.x,r.y,r.z)}}class BF extends ls{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(r,c,this._addIndex*t,1,t);for(let C=t,D=t+t;C!==D;++C)if(r[C]!==r[C+t]){i.setValue(r,c);break}}saveOriginalState(){const e=this.binding,t=this.buffer,r=this.valueSize,c=r*this._origIndex;e.getValue(t,c);for(let p=r,y=c;p!==y;++p)t[p]=t[c+p%r];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let r=e;r=.5)for(let y=0;y!==p;++y)e[t+y]=e[r+y]}_slerp(e,t,r,c){sl.slerpFlat(e,t,e,t,e,r,c)}_slerpAdditive(e,t,r,c,p){const y=this._workIndex*p;sl.multiplyQuaternionsFlat(e,y,e,t,e,r),sl.slerpFlat(e,t,e,t,e,y,c)}_lerp(e,t,r,c,p){const y=1-c;for(let i=0;i!==p;++i){const C=t+i;e[C]=e[C]*y+e[r+i]*c}}_lerpAdditive(e,t,r,c,p){for(let y=0;y!==p;++y){const i=t+y;e[i]=e[i]+e[r+y]*c}}}const xB="\\[\\]\\.:\\/",SQ=new RegExp("["+xB+"]","g"),vB="[^"+xB+"]",MQ="[^"+xB.replace("\\.","")+"]",IQ=/((?:WC+[\/:])*)/.source.replace("WC",vB),FQ=/(WCOD+)?/.source.replace("WCOD",MQ),LQ=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",vB),DQ=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",vB),PQ=new RegExp("^"+IQ+FQ+LQ+DQ+"$"),UQ=["material","materials","bones","map"];class RQ{constructor(e,t,r){const c=r||os.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,c)}getValue(e,t){this.bind();const r=this._targetGroup.nCachedObjects_,c=this._bindings[r];c!==void 0&&c.getValue(e,t)}setValue(e,t){const r=this._bindings;for(let c=this._targetGroup.nCachedObjects_,p=r.length;c!==p;++c)r[c].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,r=e.length;t!==r;++t)e[t].unbind()}}class os{constructor(e,t,r){this.path=t,this.parsedPath=r||os.parseTrackName(t),this.node=os.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,r){return e&&e.isAnimationObjectGroup?new os.Composite(e,t,r):new os(e,t,r)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(SQ,"")}static parseTrackName(e){const t=PQ.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const r={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},c=r.nodeName&&r.nodeName.lastIndexOf(".");if(c!==void 0&&c!==-1){const p=r.nodeName.substring(c+1);UQ.indexOf(p)!==-1&&(r.nodeName=r.nodeName.substring(0,c),r.objectName=p)}if(r.propertyName===null||r.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return r}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const r=e.skeleton.getBoneByName(t);if(r!==void 0)return r}if(e.children){const r=function(p){for(let y=0;y=p){const Q=p++,z=e[Q];t[z.uuid]=R,e[R]=z,t[D]=Q,e[Q]=C;for(let G=0,J=c;G!==J;++G){const Y=r[G],B=Y[Q],ae=Y[R];Y[R]=B,Y[Q]=ae}}}this.nCachedObjects_=p}uncache(){const e=this._objects,t=this._indicesByUUID,r=this._bindings,c=r.length;let p=this.nCachedObjects_,y=e.length;for(let i=0,C=arguments.length;i!==C;++i){const D=arguments[i],R=D.uuid,Q=t[R];if(Q!==void 0)if(delete t[R],Q0&&(t[G.uuid]=Q),e[Q]=G,e.pop();for(let J=0,Y=c;J!==Y;++J){const B=r[J];B[Q]=B[z],B.pop()}}}this.nCachedObjects_=p}subscribe_(e,t){const r=this._bindingsIndicesByPath;let c=r[e];const p=this._bindings;if(c!==void 0)return p[c];const y=this._paths,i=this._parsedPaths,C=this._objects,D=C.length,R=this.nCachedObjects_,Q=new Array(D);c=p.length,r[e]=c,y.push(e),i.push(t),p.push(Q);for(let z=R,G=C.length;z!==G;++z){const J=C[z];Q[z]=new os(J,e,t)}return Q}unsubscribe_(e){const t=this._bindingsIndicesByPath,r=t[e];if(r!==void 0){const c=this._paths,p=this._parsedPaths,y=this._bindings,i=y.length-1,C=y[i],D=e[i];t[D]=r,y[r]=C,y.pop(),p[r]=p[i],p.pop(),c[r]=c[i],c.pop()}}}class kQ{constructor(e,t,r=null,c=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=r,this.blendMode=c;const p=t.tracks,y=p.length,i=new Array(y),C={endingStart:rf,endingEnd:rf};for(let D=0;D!==y;++D){const R=p[D].createInterpolant(null);i[D]=R,R.settings=C}this._interpolantSettings=C,this._interpolants=i,this._propertyBindings=new Array(y),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=TI,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,r){if(e.fadeOut(t),this.fadeIn(t),r){const c=this._clip.duration,p=e._clip.duration,y=p/c,i=c/p;e.warp(1,y,t),this.warp(i,1,t)}return this}crossFadeTo(e,t,r){return e.crossFadeFrom(this,t,r)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,r){const c=this._mixer,p=c.time,y=this.timeScale;let i=this._timeScaleInterpolant;i===null&&(i=c._lendControlInterpolant(),this._timeScaleInterpolant=i);const C=i.parameterPositions,D=i.sampleValues;return C[0]=p,C[1]=p+r,D[0]=e/y,D[1]=t/y,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,r,c){if(!this.enabled){this._updateWeight(e);return}const p=this._startTime;if(p!==null){const C=(e-p)*r;C<0||r===0?t=0:(this._startTime=null,t=r*C)}t*=this._updateTimeScale(e);const y=this._updateTime(t),i=this._updateWeight(e);if(i>0){const C=this._interpolants,D=this._propertyBindings;switch(this.blendMode){case k2:for(let R=0,Q=C.length;R!==Q;++R)C[R].evaluate(y),D[R].accumulateAdditive(i);break;case Ov:default:for(let R=0,Q=C.length;R!==Q;++R)C[R].evaluate(y),D[R].accumulate(c,i)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const r=this._weightInterpolant;if(r!==null){const c=r.evaluate(e)[0];t*=c,e>r.parameterPositions[1]&&(this.stopFading(),c===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const r=this._timeScaleInterpolant;if(r!==null){const c=r.evaluate(e)[0];t*=c,e>r.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,r=this.loop;let c=this.time+e,p=this._loopCount;const y=r===SI;if(e===0)return p===-1?c:y&&(p&1)===1?t-c:c;if(r===EI){p===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(c>=t)c=t;else if(c<0)c=0;else{this.time=c;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=c,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(p===-1&&(e>=0?(p=0,this._setEndings(!0,this.repetitions===0,y)):this._setEndings(this.repetitions===0,!0,y)),c>=t||c<0){const i=Math.floor(c/t);c-=t*i,p+=Math.abs(i);const C=this.repetitions-p;if(C<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,c=e>0?t:0,this.time=c,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(C===1){const D=e<0;this._setEndings(D,!D,y)}else this._setEndings(!1,!1,y);this._loopCount=p,this.time=c,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=c;if(y&&(p&1)===1)return t-c}return c}_setEndings(e,t,r){const c=this._interpolantSettings;r?(c.endingStart=sf,c.endingEnd=sf):(e?c.endingStart=this.zeroSlopeAtStart?sf:rf:c.endingStart=G_,t?c.endingEnd=this.zeroSlopeAtEnd?sf:rf:c.endingEnd=G_)}_scheduleFading(e,t,r){const c=this._mixer,p=c.time;let y=this._weightInterpolant;y===null&&(y=c._lendControlInterpolant(),this._weightInterpolant=y);const i=y.parameterPositions,C=y.sampleValues;return i[0]=p,C[0]=t,i[1]=p+e,C[1]=r,this}}const OQ=new Float32Array(1);class NQ extends Xu{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const r=e._localRoot||this._root,c=e._clip.tracks,p=c.length,y=e._propertyBindings,i=e._interpolants,C=r.uuid,D=this._bindingsByRootAndName;let R=D[C];R===void 0&&(R={},D[C]=R);for(let Q=0;Q!==p;++Q){const z=c[Q],G=z.name;let J=R[G];if(J!==void 0)++J.referenceCount,y[Q]=J;else{if(J=y[Q],J!==void 0){J._cacheIndex===null&&(++J.referenceCount,this._addInactiveBinding(J,C,G));continue}const Y=t&&t._propertyBindings[Q].binding.parsedPath;J=new CF(os.create(r,G,Y),z.ValueTypeName,z.getValueSize()),++J.referenceCount,this._addInactiveBinding(J,C,G),y[Q]=J}i[Q].resultBuffer=J.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const r=(e._localRoot||this._root).uuid,c=e._clip.uuid,p=this._actionsByClip[c];this._bindAction(e,p&&p.knownActions[0]),this._addInactiveAction(e,c,r)}const t=e._propertyBindings;for(let r=0,c=t.length;r!==c;++r){const p=t[r];p.useCount++===0&&(this._lendBinding(p),p.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let r=0,c=t.length;r!==c;++r){const p=t[r];--p.useCount===0&&(p.restoreOriginalState(),this._takeBackBinding(p))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t=0;--r)e[r].stop();return this}update(e){e*=this.timeScale;const t=this._actions,r=this._nActiveActions,c=this.time+=e,p=Math.sign(e),y=this._accuIndex^=1;for(let D=0;D!==r;++D)t[D]._update(c,e,p,y);const i=this._bindings,C=this._nActiveBindings;for(let D=0;D!==C;++D)i[D].apply(y);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return ZT.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const XT=new ft,Mx=new ft;class EF{constructor(e=new ft,t=new ft){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){XT.subVectors(e,this.start),Mx.subVectors(this.end,this.start);const r=Mx.dot(Mx);let p=Mx.dot(XT)/r;return t&&(p=Eo(p,0,1)),p}closestPointToPoint(e,t,r){const c=this.closestPointToPointParameter(e,t);return this.delta(r).multiplyScalar(c).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const qT=new ft;class jQ extends ls{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const r=new br,c=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let y=0,i=1,C=32;y1)for(let Q=0;Q.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{iS.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(iS,t)}}setLength(e,t=e*.2,r=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(r,t,r),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class LF extends Yu{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],r=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],c=new br;c.setAttribute("position",new jn(t,3)),c.setAttribute("color",new jn(r,3));const p=new ra({vertexColors:!0,toneMapped:!1});super(c,p),this.type="AxesHelper"}setColors(e,t,r){const c=new Dn,p=this.geometry.attributes.color.array;return c.set(e),c.toArray(p,0),c.toArray(p,3),c.set(t),c.toArray(p,6),c.toArray(p,9),c.set(r),c.toArray(p,12),c.toArray(p,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class eV{constructor(){this.type="ShapePath",this.color=new Dn,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Z_,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,r,c){return this.currentPath.quadraticCurveTo(e,t,r,c),this}bezierCurveTo(e,t,r,c,p,y){return this.currentPath.bezierCurveTo(e,t,r,c,p,y),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(ae){const ce=[];for(let Ae=0,we=ae.length;AeNumber.EPSILON){if(Et<0&&(Je=ce[De],Ge=-Ge,Fe=ce[me],Et=-Et),ae.yFe.y)continue;if(ae.y===Je.y){if(ae.x===Je.x)return!0}else{const li=Et*(ae.x-Je.x)-Ge*(ae.y-Je.y);if(li===0)return!0;if(li<0)continue;we=!we}}else{if(ae.y!==Je.y)continue;if(Fe.x<=ae.x&&ae.x<=Je.x||Je.x<=ae.x&&ae.x<=Fe.x)return!0}}return we}const c=Gu.isClockWise,p=this.subPaths;if(p.length===0)return[];let y,i,C;const D=[];if(p.length===1)return i=p[0],C=new tp,C.curves=i.curves,D.push(C),D;let R=!c(p[0].getPoints());R=e?!R:R;const Q=[],z=[];let G=[],J=0,Y;z[J]=void 0,G[J]=[];for(let ae=0,ce=p.length;ae1){let ae=!1,ce=0;for(let Ae=0,we=z.length;Ae0&&ae===!1&&(G=Q)}let B;for(let ae=0,ce=z.length;ae>-D-14,r[C|256]=1024>>-D-14|32768,c[C]=-D-1,c[C|256]=-D-1):D<=15?(r[C]=D+15<<10,r[C|256]=D+15<<10|32768,c[C]=13,c[C|256]=13):D<128?(r[C]=31744,r[C|256]=64512,c[C]=24,c[C|256]=24):(r[C]=31744,r[C|256]=64512,c[C]=13,c[C|256]=13)}const p=new Uint32Array(2048),y=new Uint32Array(64),i=new Uint32Array(64);for(let C=1;C<1024;++C){let D=C<<13,R=0;for(;(D&8388608)===0;)D<<=1,R-=8388608;D&=-8388609,R+=947912704,p[C]=D|R}for(let C=1024;C<2048;++C)p[C]=939524096+(C-1024<<13);for(let C=1;C<31;++C)y[C]=C<<23;y[31]=1199570944,y[32]=2147483648;for(let C=33;C<63;++C)y[C]=2147483648+(C-32<<23);y[63]=3347054592;for(let C=1;C<64;++C)C!==32&&(i[C]=1024);return{floatView:e,uint32View:t,baseTable:r,shiftTable:c,mantissaTable:p,exponentTable:y,offsetTable:i}}function iV(u){Math.abs(u)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),u=Eo(u,-65504,65504),VA.floatView[0]=u;const e=VA.uint32View[0],t=e>>23&511;return VA.baseTable[t]+((e&8388607)>>VA.shiftTable[t])}function nV(u){const e=u>>10;return VA.uint32View[0]=VA.mantissaTable[VA.offsetTable[e]+(u&1023)]+VA.exponentTable[e],VA.floatView[0]}var rV=Object.freeze({__proto__:null,fromHalfFloat:nV,toHalfFloat:iV});class sV extends qA{constructor(e,t,r,c,p,y){console.warn("THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry."),super(e,t,r,c,p,y)}}class oV extends fy{constructor(e,t,r,c){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(e,t,r,c)}}class aV extends my{constructor(e,t,r,c){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(e,t,r,c)}}class lV extends gf{constructor(e,t,r,c,p,y,i){console.warn("THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry."),super(e,t,r,c,p,y,i)}}class cV extends vf{constructor(e,t,r,c,p,y,i,C){console.warn("THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry."),super(e,t,r,c,p,y,i,C)}}class hV extends gy{constructor(e,t){console.warn("THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry."),super(e,t)}}class uV extends _y{constructor(e,t){console.warn("THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry."),super(e,t)}}class AV extends yy{constructor(e,t){console.warn("THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry."),super(e,t)}}class dV extends Jm{constructor(e,t,r,c){console.warn("THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry."),super(e,t,r,c)}}class pV extends eg{constructor(e,t){console.warn("THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry."),super(e,t)}}class DF extends xf{constructor(e,t,r,c){console.warn("THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry."),super(e,t,r,c)}}class fV extends YA{constructor(e,t,r,c){console.warn("THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry."),super(e,t,r,c)}}class mV extends xy{constructor(e,t,r,c,p,y){console.warn("THREE.RingBufferGeometry has been renamed to THREE.RingGeometry."),super(e,t,r,c,p,y)}}class gV extends tg{constructor(e,t){console.warn("THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry."),super(e,t)}}class _V extends Vu{constructor(e,t,r,c,p,y,i){console.warn("THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry."),super(e,t,r,c,p,y,i)}}class yV extends vy{constructor(e,t){console.warn("THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry."),super(e,t)}}class xV extends wy{constructor(e,t,r,c,p){console.warn("THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry."),super(e,t,r,c,p)}}class vV extends by{constructor(e,t,r,c,p,y){console.warn("THREE.TorusKnotBufferGeometry has been renamed to THREE.TorusKnotGeometry."),super(e,t,r,c,p,y)}}class wV extends ig{constructor(e,t,r,c,p){console.warn("THREE.TubeBufferGeometry has been renamed to THREE.TubeGeometry."),super(e,t,r,c,p)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:zv}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=zv);const PF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:cI,AddEquation:qp,AddOperation:oI,AdditiveAnimationBlendMode:k2,AdditiveBlending:hv,AlphaFormat:mI,AlwaysDepth:JM,AlwaysStencilFunc:LI,AmbientLight:gB,AmbientLightProbe:bF,AnimationClip:iy,AnimationLoader:hQ,AnimationMixer:NQ,AnimationObjectGroup:zQ,AnimationUtils:oQ,ArcCurve:eF,ArrayCamera:jI,ArrowHelper:FF,Audio:BF,AudioAnalyser:TQ,AudioContext:yB,AudioListener:BQ,AudioLoader:xQ,AxesHelper:LF,BackSide:rc,BasicDepthPacking:MI,BasicShadowMap:DR,Bone:Z2,BooleanKeyframeTrack:wf,Box2:WQ,Box3:qu,Box3Helper:YQ,BoxBufferGeometry:sV,BoxGeometry:qA,BoxHelper:g2,BufferAttribute:As,BufferGeometry:br,BufferGeometryLoader:wF,ByteType:uI,Cache:yf,Camera:Qv,CameraHelper:IF,CanvasTexture:JI,CapsuleBufferGeometry:oV,CapsuleGeometry:fy,CatmullRomCurve3:$_,CineonToneMapping:lI,CircleBufferGeometry:aV,CircleGeometry:my,ClampToEdgeWrapping:nl,Clock:Jv,Color:Dn,ColorKeyframeTrack:uB,ColorManagement:el,CompressedArrayTexture:IN,CompressedTexture:Y2,CompressedTextureLoader:uQ,ConeBufferGeometry:lV,ConeGeometry:gf,CubeCamera:kI,CubeReflectionMapping:rp,CubeRefractionMapping:sp,CubeTexture:Ay,CubeTextureLoader:AQ,CubeUVReflectionMapping:qm,CubicBezierCurve:eB,CubicBezierCurve3:tF,CubicInterpolant:fF,CullFaceBack:Fb,CullFaceFront:kM,CullFaceFrontBack:LR,CullFaceNone:zM,Curve:du,CurvePath:nF,CustomBlending:NM,CustomToneMapping:hI,CylinderBufferGeometry:cV,CylinderGeometry:vf,Cylindrical:GQ,Data3DTexture:Q2,DataArrayTexture:Nv,DataTexture:Qm,DataTextureLoader:dQ,DataUtils:rV,DecrementStencilOp:jR,DecrementWrapStencilOp:$R,DefaultLoadingManager:_F,DepthFormat:ep,DepthStencilFormat:ff,DepthTexture:KI,DirectionalLight:mB,DirectionalLightHelper:MF,DiscreteInterpolant:mF,DodecahedronBufferGeometry:hV,DodecahedronGeometry:gy,DoubleSide:ga,DstAlphaFactor:KM,DstColorFactor:ZM,DynamicCopyUsage:cz,DynamicDrawUsage:nz,DynamicReadUsage:oz,EdgesGeometry:rF,EllipseCurve:$v,EqualDepth:tI,EqualStencilFunc:YR,EquirectangularReflectionMapping:O_,EquirectangularRefractionMapping:N_,Euler:hy,EventDispatcher:Xu,ExtrudeBufferGeometry:uV,ExtrudeGeometry:_y,FileLoader:ZA,Float16BufferAttribute:Hz,Float32BufferAttribute:jn,Float64BufferAttribute:Gz,FloatType:GA,Fog:Wv,FogExp2:Gv,FramebufferTexture:MN,FrontSide:uu,Frustum:Vv,GLBufferAttribute:HQ,GLSL1:uz,GLSL3:s2,GreaterDepth:nI,GreaterEqualDepth:iI,GreaterEqualStencilFunc:iz,GreaterStencilFunc:ez,GridHelper:XQ,Group:Hs,HalfFloatType:Gm,HemisphereLight:dB,HemisphereLightHelper:SF,HemisphereLightProbe:vQ,IcosahedronBufferGeometry:AV,IcosahedronGeometry:yy,ImageBitmapLoader:yQ,ImageLoader:ny,ImageUtils:N2,IncrementStencilOp:WR,IncrementWrapStencilOp:KR,InstancedBufferAttribute:Km,InstancedBufferGeometry:_B,InstancedInterleavedBuffer:_v,InstancedMesh:YI,Int16BufferAttribute:Qz,Int32BufferAttribute:Vz,Int8BufferAttribute:kz,IntType:dI,InterleavedBuffer:jv,InterleavedBufferAttribute:Dc,Interpolant:By,InterpolateDiscrete:V_,InterpolateLinear:H_,InterpolateSmooth:Zx,InvertStencilOp:ZR,KeepStencilOp:Xx,KeyframeTrack:pu,LOD:XI,LatheBufferGeometry:dV,LatheGeometry:Jm,Layers:uy,LessDepth:eI,LessEqualDepth:uv,LessEqualStencilFunc:JR,LessStencilFunc:qR,Light:hp,LightProbe:qv,Line:Ku,Line3:EF,LineBasicMaterial:ra,LineCurve:Zv,LineCurve3:iF,LineDashedMaterial:dF,LineLoop:mv,LineSegments:Yu,LinearEncoding:lp,LinearFilter:Xs,LinearInterpolant:hB,LinearMipMapLinearFilter:kR,LinearMipMapNearestFilter:zR,LinearMipmapLinearFilter:op,LinearMipmapNearestFilter:R2,LinearSRGBColorSpace:Wm,LinearToneMapping:U2,Loader:Uc,LoaderUtils:d2,LoadingManager:AB,LoopOnce:EI,LoopPingPong:SI,LoopRepeat:TI,LuminanceAlphaFormat:_I,LuminanceFormat:gI,MOUSE:jp,Material:ol,MaterialLoader:Yv,MathUtils:PI,Matrix3:Pl,Matrix4:ar,MaxEquation:Ub,Mesh:us,MeshBasicMaterial:za,MeshDepthMaterial:W2,MeshDistanceMaterial:j2,MeshLambertMaterial:gv,MeshMatcapMaterial:AF,MeshNormalMaterial:uF,MeshPhongMaterial:aB,MeshPhysicalMaterial:oB,MeshStandardMaterial:J_,MeshToonMaterial:hF,MinEquation:Pb,MirroredRepeatWrapping:Q_,MixOperation:sI,MultiplyBlending:Db,MultiplyOperation:ly,NearestFilter:Co,NearestMipMapLinearFilter:RR,NearestMipMapNearestFilter:UR,NearestMipmapLinearFilter:M_,NearestMipmapNearestFilter:Av,NeverDepth:YM,NeverStencilFunc:XR,NoBlending:KA,NoColorSpace:VR,NoToneMapping:Hu,NormalAnimationBlendMode:Ov,NormalBlending:hf,NotEqualDepth:rI,NotEqualStencilFunc:tz,NumberKeyframeTrack:ey,Object3D:ls,ObjectLoader:gQ,ObjectSpaceNormalMap:FI,OctahedronBufferGeometry:pV,OctahedronGeometry:eg,OneFactor:GM,OneMinusDstAlphaFactor:$M,OneMinusDstColorFactor:XM,OneMinusSrcAlphaFactor:P2,OneMinusSrcColorFactor:jM,OrthographicCamera:dy,PCFShadowMap:L2,PCFSoftShadowMap:OM,PMREMGenerator:a2,Path:Z_,PerspectiveCamera:_a,Plane:jd,PlaneBufferGeometry:DF,PlaneGeometry:xf,PlaneHelper:JQ,PointLight:fB,PointLightHelper:$Q,Points:q2,PointsMaterial:X2,PolarGridHelper:qQ,PolyhedronBufferGeometry:fV,PolyhedronGeometry:YA,PositionalAudio:EQ,PropertyBinding:os,PropertyMixer:CF,QuadraticBezierCurve:tB,QuadraticBezierCurve3:iB,Quaternion:sl,QuaternionKeyframeTrack:ng,QuaternionLinearInterpolant:gF,RED_GREEN_RGTC2_Format:n2,RED_RGTC1_Format:CI,REVISION:zv,RGBADepthPacking:II,RGBAFormat:Dl,RGBAIntegerFormat:bI,RGBA_ASTC_10x10_Format:Jb,RGBA_ASTC_10x5_Format:Xb,RGBA_ASTC_10x6_Format:qb,RGBA_ASTC_10x8_Format:Yb,RGBA_ASTC_12x10_Format:e2,RGBA_ASTC_12x12_Format:t2,RGBA_ASTC_4x4_Format:Vb,RGBA_ASTC_5x4_Format:Hb,RGBA_ASTC_5x5_Format:Gb,RGBA_ASTC_6x5_Format:Wb,RGBA_ASTC_6x6_Format:jb,RGBA_ASTC_8x5_Format:Kb,RGBA_ASTC_8x6_Format:$b,RGBA_ASTC_8x8_Format:Zb,RGBA_BPTC_Format:$x,RGBA_ETC2_EAC_Format:Qb,RGBA_PVRTC_2BPPV1_Format:Ob,RGBA_PVRTC_4BPPV1_Format:kb,RGBA_S3TC_DXT1_Format:Wx,RGBA_S3TC_DXT3_Format:jx,RGBA_S3TC_DXT5_Format:Kx,RGB_ETC1_Format:BI,RGB_ETC2_Format:Nb,RGB_PVRTC_2BPPV1_Format:zb,RGB_PVRTC_4BPPV1_Format:Rb,RGB_S3TC_DXT1_Format:Gx,RGFormat:vI,RGIntegerFormat:wI,RawShaderMaterial:cF,Ray:cy,Raycaster:p2,RectAreaLight:xF,RedFormat:yI,RedIntegerFormat:xI,ReinhardToneMapping:aI,RepeatWrapping:HA,ReplaceStencilOp:GR,ReverseSubtractEquation:VM,RingBufferGeometry:mV,RingGeometry:xy,SIGNED_RED_GREEN_RGTC2_Format:r2,SIGNED_RED_RGTC1_Format:i2,SRGBColorSpace:cu,Scene:K2,ShaderChunk:zr,ShaderLib:Fl,ShaderMaterial:ko,ShadowMaterial:lF,Shape:tp,ShapeBufferGeometry:gV,ShapeGeometry:tg,ShapePath:eV,ShapeUtils:Gu,ShortType:AI,Skeleton:Kv,SkeletonHelper:KQ,SkinnedMesh:qI,Source:of,Sphere:XA,SphereBufferGeometry:_V,SphereGeometry:Vu,Spherical:m2,SphericalHarmonics3:vF,SplineCurve:nB,SpotLight:yF,SpotLightHelper:jQ,Sprite:$2,SpriteMaterial:py,SrcAlphaFactor:D2,SrcAlphaSaturateFactor:qM,SrcColorFactor:WM,StaticCopyUsage:lz,StaticDrawUsage:W_,StaticReadUsage:sz,StereoCamera:wQ,StreamCopyUsage:hz,StreamDrawUsage:rz,StreamReadUsage:az,StringKeyframeTrack:bf,SubtractEquation:QM,SubtractiveBlending:Lb,TOUCH:Kp,TangentSpaceNormalMap:cp,TetrahedronBufferGeometry:yV,TetrahedronGeometry:vy,Texture:To,TextureLoader:Im,TorusBufferGeometry:xV,TorusGeometry:wy,TorusKnotBufferGeometry:vV,TorusKnotGeometry:by,Triangle:wh,TriangleFanDrawMode:QR,TriangleStripDrawMode:NR,TrianglesDrawMode:OR,TubeBufferGeometry:wV,TubeGeometry:ig,TwoPassDoubleSide:PR,UVMapping:kv,Uint16BufferAttribute:V2,Uint32BufferAttribute:H2,Uint8BufferAttribute:Oz,Uint8ClampedBufferAttribute:Nz,Uniform:wB,UniformsGroup:VQ,UniformsLib:En,UniformsUtils:mf,UnsignedByteType:ap,UnsignedInt248Type:uf,UnsignedIntType:Xd,UnsignedShort4444Type:pI,UnsignedShort5551Type:fI,UnsignedShortType:z2,VSMShadowMap:Dm,Vector2:Di,Vector3:ft,Vector4:as,VectorKeyframeTrack:ty,VideoTexture:SN,WebGL1Renderer:$I,WebGL3DRenderTarget:Sz,WebGLArrayRenderTarget:Tz,WebGLCubeRenderTarget:OI,WebGLMultipleRenderTargets:Mz,WebGLRenderTarget:rl,WebGLRenderer:fv,WebGLUtils:WI,WireframeGeometry:sB,WrapAroundEnding:G_,ZeroCurvatureEnding:rf,ZeroFactor:HM,ZeroSlopeEnding:sf,ZeroStencilOp:HR,_SRGBAFormat:dv,sRGBEncoding:Ts},Symbol.toStringTag,{value:"Module"}));var UF={exports:{}};(function(u,e){(function({},t){u.exports=t()})(MS,function(){var t,r,c;function p(i,C){if(!t)t=C;else if(!r)r=C;else{var D="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+t+")(sharedChunk); ("+r+")(sharedChunk); self.onerror = null;",R={};t(R),c=C(R),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(c.workerUrl=window.URL.createObjectURL(new Blob([D],{type:"text/javascript"})))}}p(["exports"],function(i){var C=typeof self<"u"?self:{},D="2.12.0";let R;const Q={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(R==null){const s=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{R={}.API_URL_REGEX!=null?new RegExp({}.API_URL_REGEX):s}catch{R=s}}return R},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){return this.API_URL?this.API_URL.indexOf("https://api.mapbox.cn")===0?"https://events.mapbox.cn/events/v2":this.API_URL.indexOf("https://api.mapbox.com")===0?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},z={supported:!1,testSupport:function(s){!Y&&J&&(B?ae(s):G=s)}};let G,J,Y=!1,B=!1;function ae(s){const n=s.createTexture();s.bindTexture(s.TEXTURE_2D,n);try{if(s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,J),s.isContextLost())return;z.supported=!0}catch{}s.deleteTexture(n),Y=!0}C.document&&(J=C.document.createElement("img"),J.onload=function(){G&&ae(G),G=null,B=!0},J.onerror=function(){Y=!0,G=null},J.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const ce="01";var Ae=we;function we(s,n,o,d){this.cx=3*s,this.bx=3*(o-s)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*n,this.by=3*(d-n)-this.cy,this.ay=1-this.cy-this.by,this.p1x=s,this.p1y=n,this.p2x=o,this.p2y=d}we.prototype={sampleCurveX:function(s){return((this.ax*s+this.bx)*s+this.cx)*s},sampleCurveY:function(s){return((this.ay*s+this.by)*s+this.cy)*s},sampleCurveDerivativeX:function(s){return(3*this.ax*s+2*this.bx)*s+this.cx},solveCurveX:function(s,n){if(n===void 0&&(n=1e-6),s<0)return 0;if(s>1)return 1;for(var o=s,d=0;d<8;d++){var g=this.sampleCurveX(o)-s;if(Math.abs(g)g?E=o:L=o,o=.5*(L-E)+E;return o},solve:function(s,n){return this.sampleCurveY(this.solveCurveX(s,n))}};var me=De;function De(s,n){this.x=s,this.y=n}De.prototype={clone:function(){return new De(this.x,this.y)},add:function(s){return this.clone()._add(s)},sub:function(s){return this.clone()._sub(s)},multByPoint:function(s){return this.clone()._multByPoint(s)},divByPoint:function(s){return this.clone()._divByPoint(s)},mult:function(s){return this.clone()._mult(s)},div:function(s){return this.clone()._div(s)},rotate:function(s){return this.clone()._rotate(s)},rotateAround:function(s,n){return this.clone()._rotateAround(s,n)},matMult:function(s){return this.clone()._matMult(s)},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(s){return this.x===s.x&&this.y===s.y},dist:function(s){return Math.sqrt(this.distSqr(s))},distSqr:function(s){var n=s.x-this.x,o=s.y-this.y;return n*n+o*o},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(s){return Math.atan2(this.y-s.y,this.x-s.x)},angleWith:function(s){return this.angleWithSep(s.x,s.y)},angleWithSep:function(s,n){return Math.atan2(this.x*n-this.y*s,this.x*s+this.y*n)},_matMult:function(s){var n=s[2]*this.x+s[3]*this.y;return this.x=s[0]*this.x+s[1]*this.y,this.y=n,this},_add:function(s){return this.x+=s.x,this.y+=s.y,this},_sub:function(s){return this.x-=s.x,this.y-=s.y,this},_mult:function(s){return this.x*=s,this.y*=s,this},_div:function(s){return this.x/=s,this.y/=s,this},_multByPoint:function(s){return this.x*=s.x,this.y*=s.y,this},_divByPoint:function(s){return this.x/=s.x,this.y/=s.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var s=this.y;return this.y=this.x,this.x=-s,this},_rotate:function(s){var n=Math.cos(s),o=Math.sin(s),d=o*this.x+n*this.y;return this.x=n*this.x-o*this.y,this.y=d,this},_rotateAround:function(s,n){var o=Math.cos(s),d=Math.sin(s),g=n.y+d*(this.x-n.x)+o*(this.y-n.y);return this.x=n.x+o*(this.x-n.x)-d*(this.y-n.y),this.y=g,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},De.convert=function(s){return s instanceof De?s:Array.isArray(s)?new De(s[0],s[1]):s};const Je=Math.PI/180,Fe=180/Math.PI;function Ge(s){return s*Je}function Et(s){return s*Fe}const li=[[0,0],[1,0],[1,1],[0,1]];function xi(s){if(s<=0)return 0;if(s>=1)return 1;const n=s*s,o=n*s;return 4*(s<.5?o:3*(s-n)+o-.75)}function te(s,n,o,d){const g=new Ae(s,n,o,d);return function(v){return g.solve(v)}}const le=te(.25,.1,.25,1);function ye(s,n,o){return Math.min(o,Math.max(n,s))}function xe(s,n,o){return(o=ye((o-s)/(n-s),0,1))*o*(3-2*o)}function Re(s,n,o){const d=o-n,g=((s-n)%d+d)%d+n;return g===n?o:g}function Oe(s,n,o){if(!s.length)return o(null,[]);let d=s.length;const g=new Array(s.length);let v=null;s.forEach((E,L)=>{n(E,(k,V)=>{k&&(v=k),g[L]=V,--d==0&&o(v,g)})})}function We(s){const n=[];for(const o in s)n.push(s[o]);return n}function Ve(s,...n){for(const o of n)for(const d in o)s[d]=o[d];return s}let Qe=1;function Se(){return Qe++}function Ke(){return function s(n){return n?(n^Math.random()*(16>>n/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,s)}()}function nt(s){return s<=1?1:Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function vt(s){return!!s&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(s)}function be(s,n){s.forEach(o=>{n[o]&&(n[o]=n[o].bind(n))})}function At(s,n){return s.indexOf(n,s.length-n.length)!==-1}function ut(s,n,o){const d={};for(const g in s)d[g]=n.call(o||this,s[g],g,s);return d}function Nt(s,n,o){const d={};for(const g in s)n.call(o||this,s[g],g,s)&&(d[g]=s[g]);return d}function Gt(s){return Array.isArray(s)?s.map(Gt):typeof s=="object"&&s?ut(s,Gt):s}const Qt={};function Ct(s){Qt[s]||(typeof console<"u"&&console.warn(s),Qt[s]=!0)}function Ft(s,n,o){return(o.y-s.y)*(n.x-s.x)>(n.y-s.y)*(o.x-s.x)}function Xt(s){let n=0;for(let o,d,g=0,v=s.length,E=v-1;g@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(o,d,g,v)=>{const E=g||v;return n[d]=!E||E.toLowerCase(),""}),n["max-age"]){const o=parseInt(n["max-age"],10);isNaN(o)?delete n["max-age"]:n["max-age"]=o}return n}let Gi=null;function wn(s){if(Gi==null){const n=s.navigator?s.navigator.userAgent:null;Gi=!!s.safari||!(!n||!(/\b(iPad|iPhone|iPod)\b/.test(n)||n.match("Safari")&&!n.match("Chrome")))}return Gi}function zi(s){try{const n=C[s];return n.setItem("_mapbox_test_",1),n.removeItem("_mapbox_test_"),!0}catch{return!1}}function Gn(s,n){return[s[4*n],s[4*n+1],s[4*n+2],s[4*n+3]]}const kn="mapbox-tiles";let yt,rt,ti=500,Ni=50;function qi(){try{return C.caches}catch{}}function en(){qi()&&!yt&&(yt=C.caches.open(kn))}function $t(s){const n=s.indexOf("?");if(n<0)return s;const o=function(g){const v=g.indexOf("?");return v>0?g.slice(v+1).split("&"):[]}(s),d=o.filter(g=>{const v=g.split("=");return v[0]==="language"||v[0]==="worldview"});return d.length?`${s.slice(0,n)}?${d.join("&")}`:s.slice(0,n)}let at=1/0;const ii={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(ii);class hn extends Error{constructor(n,o,d){o===401&&Ui(d)&&(n+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(n),this.status=o,this.url=d}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Xi=_i()?()=>self.worker&&self.worker.referrer:()=>(C.location.protocol==="blob:"?C.parent:C).location.href,on=function(s,n){if(!(/^file:/.test(o=s.url)||/^file:/.test(Xi())&&!/^\w+:/.test(o))){if(C.fetch&&C.Request&&C.AbortController&&C.Request.prototype.hasOwnProperty("signal"))return function(d,g){const v=new C.AbortController,E=new C.Request(d.url,{method:d.method||"GET",body:d.body,credentials:d.credentials,headers:d.headers,referrer:Xi(),signal:v.signal});let L=!1,k=!1;const V=(q=E.url).indexOf("sku=")>0&&Ui(q);var q;d.type==="json"&&E.headers.set("Accept","application/json");const se=(_e,Be,Le)=>{if(k)return;if(_e&&_e.message!=="SecurityError"&&Ct(_e),Be&&Le)return he(Be);const Xe=Date.now();C.fetch(E).then(xt=>{if(xt.ok){const Dt=V?xt.clone():null;return he(xt,Dt,Xe)}return g(new hn(xt.statusText,xt.status,d.url))}).catch(xt=>{xt.code!==20&&g(new Error(xt.message))})},he=(_e,Be,Le)=>{(d.type==="arrayBuffer"?_e.arrayBuffer():d.type==="json"?_e.json():_e.text()).then(Xe=>{k||(Be&&Le&&function(xt,Dt,_t){if(en(),!yt)return;const Tt={status:Dt.status,statusText:Dt.statusText,headers:new C.Headers};Dt.headers.forEach((ci,oi)=>Tt.headers.set(oi,ci));const kt=fi(Dt.headers.get("Cache-Control")||"");if(kt["no-store"])return;kt["max-age"]&&Tt.headers.set("Expires",new Date(_t+1e3*kt["max-age"]).toUTCString());const Ut=Tt.headers.get("Expires");Ut&&(new Date(Ut).getTime()-_t<42e4||function(ci,oi){if(rt===void 0)try{new Response(new ReadableStream),rt=!0}catch{rt=!1}rt?oi(ci.body):ci.blob().then(oi)}(Dt,ci=>{const oi=new C.Response(ci,Tt);en(),yt&&yt.then(Ti=>Ti.put($t(xt.url),oi)).catch(Ti=>Ct(Ti.message))}))}(E,Be,Le),L=!0,g(null,Xe,_e.headers.get("Cache-Control"),_e.headers.get("Expires")))}).catch(Xe=>{k||g(new Error(Xe.message))})};return V?function(_e,Be){if(en(),!yt)return Be(null);const Le=$t(_e.url);yt.then(Xe=>{Xe.match(Le).then(xt=>{const Dt=function(_t){if(!_t)return!1;const Tt=new Date(_t.headers.get("Expires")||0),kt=fi(_t.headers.get("Cache-Control")||"");return Tt>Date.now()&&!kt["no-cache"]}(xt);Xe.delete(Le),Dt&&Xe.put(Le,xt.clone()),Be(null,xt,Dt)}).catch(Be)}).catch(Be)}(E,se):se(null,null),{cancel:()=>{k=!0,L||v.abort()}}}(s,n);if(_i()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",s,n,void 0,!0)}var o;return function(d,g){const v=new C.XMLHttpRequest;v.open(d.method||"GET",d.url,!0),d.type==="arrayBuffer"&&(v.responseType="arraybuffer");for(const E in d.headers)v.setRequestHeader(E,d.headers[E]);return d.type==="json"&&(v.responseType="text",v.setRequestHeader("Accept","application/json")),v.withCredentials=d.credentials==="include",v.onerror=()=>{g(new Error(v.statusText))},v.onload=()=>{if((v.status>=200&&v.status<300||v.status===0)&&v.response!==null){let E=v.response;if(d.type==="json")try{E=JSON.parse(v.response)}catch(L){return g(L)}g(null,E,v.getResponseHeader("Cache-Control"),v.getResponseHeader("Expires"))}else g(new hn(v.statusText,v.status,d.url))},v.send(d.body),{cancel:()=>v.abort()}}(s,n)},Cn=function(s,n){return on(Ve(s,{type:"arrayBuffer"}),n)};function Tn(s){const n=C.document.createElement("a");return n.href=s,n.protocol===C.document.location.protocol&&n.host===C.document.location.host}const nr="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Ii,bn;Ii=[],bn=0;const Ot=function(s,n){if(z.supported&&(s.headers||(s.headers={}),s.headers.accept="image/webp,*/*"),bn>=Q.MAX_PARALLEL_IMAGE_REQUESTS){const v={requestParameters:s,callback:n,cancelled:!1,cancel(){this.cancelled=!0}};return Ii.push(v),v}bn++;let o=!1;const d=()=>{if(!o)for(o=!0,bn--;Ii.length&&bn{d(),v?n(v):E&&(C.createImageBitmap?function(V,q){const se=new C.Blob([new Uint8Array(V)],{type:"image/png"});C.createImageBitmap(se).then(he=>{q(null,he)}).catch(he=>{q(new Error(`Could not load image because of ${he.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(E,(V,q)=>n(V,q,L,k)):function(V,q){const se=new C.Image,he=C.URL;se.onload=()=>{q(null,se),he.revokeObjectURL(se.src),se.onload=null,C.requestAnimationFrame(()=>{se.src=nr})},se.onerror=()=>q(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 _e=new C.Blob([new Uint8Array(V)],{type:"image/png"});se.src=V.byteLength?he.createObjectURL(_e):nr}(E,(V,q)=>n(V,q,L,k)))});return{cancel:()=>{g.cancel(),d()}}},wi="NO_ACCESS_TOKEN";function Wi(s){return s.indexOf("mapbox:")===0}function Ui(s){return Q.API_URL_REGEX.test(s)}function Pn(s){return Q.API_CDN_URL_REGEX.test(s)}function qn(s){return Q.API_STYLE_REGEX.test(s)&&!Hr(s)}function Hr(s){return Q.API_SPRITE_REGEX.test(s)}const fr=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function kr(s){const n=s.match(fr);if(!n)throw new Error("Unable to parse URL object");return{protocol:n[1],authority:n[2],path:n[3]||"/",params:n[4]?n[4].split("&"):[]}}function Qn(s){const n=s.params.length?`?${s.params.join("&")}`:"";return`${s.protocol}://${s.authority}${s.path}${n}`}function Rs(s){if(!s)return null;const n=s.split(".");if(!n||n.length!==3)return null;try{return JSON.parse(decodeURIComponent(C.atob(n[1]).split("").map(o=>"%"+("00"+o.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class ot{constructor(n){this.type=n,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(n){const o=Rs(Q.ACCESS_TOKEN);let d="";return d=o&&o.u?C.btoa(encodeURIComponent(o.u).replace(/%([0-9A-F]{2})/g,(g,v)=>String.fromCharCode(Number("0x"+v)))):Q.ACCESS_TOKEN||"",n?`mapbox.eventData.${n}:${d}`:`mapbox.eventData:${d}`}fetchEventData(){const n=zi("localStorage"),o=this.getStorageKey(),d=this.getStorageKey("uuid");if(n)try{const g=C.localStorage.getItem(o);g&&(this.eventData=JSON.parse(g));const v=C.localStorage.getItem(d);v&&(this.anonId=v)}catch{Ct("Unable to read from LocalStorage")}}saveEventData(){const n=zi("localStorage"),o=this.getStorageKey(),d=this.getStorageKey("uuid");if(n)try{C.localStorage.setItem(d,this.anonId),Object.keys(this.eventData).length>=1&&C.localStorage.setItem(o,JSON.stringify(this.eventData))}catch{Ct("Unable to write to LocalStorage")}}processRequests(n){}postEvent(n,o,d,g){if(!Q.EVENTS_URL)return;const v=kr(Q.EVENTS_URL);v.params.push(`access_token=${g||Q.ACCESS_TOKEN||""}`);const E={event:this.type,created:new Date(n).toISOString()},L=o?Ve(E,o):E,k={url:Qn(v),headers:{"Content-Type":"text/plain"},body:JSON.stringify([L])};this.pendingRequest=function(V,q){return on(Ve(V,{method:"POST"}),q)}(k,V=>{this.pendingRequest=null,d(V),this.saveEventData(),this.processRequests(g)})}queueRequest(n,o){this.queue.push(n),this.processRequests(o)}}const Ee=new class extends ot{constructor(s){super("appUserTurnstile"),this._customAccessToken=s}postTurnstileEvent(s,n){Q.EVENTS_URL&&Q.ACCESS_TOKEN&&Array.isArray(s)&&s.some(o=>Wi(o)||Ui(o))&&this.queueRequest(Date.now(),n)}processRequests(s){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const n=Rs(Q.ACCESS_TOKEN),o=n?n.u:Q.ACCESS_TOKEN;let d=o!==this.eventData.tokenU;vt(this.anonId)||(this.anonId=Ke(),d=!0);const g=this.queue.shift();if(this.eventData.lastSuccess){const v=new Date(this.eventData.lastSuccess),E=new Date(g),L=(g-this.eventData.lastSuccess)/864e5;d=d||L>=1||L<-1||v.getDate()!==E.getDate()}else d=!0;d?this.postEvent(g,{sdkIdentifier:"mapbox-gl-js",sdkVersion:D,skuId:ce,"enabled.telemetry":!1,userId:this.anonId},v=>{v||(this.eventData.lastSuccess=g,this.eventData.tokenU=o)},s):this.processRequests()}},Pe=Ee.postTurnstileEvent.bind(Ee),ct=new class extends ot{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(s,n,o,d){this.skuToken=n,this.errorCb=d,Q.EVENTS_URL&&(o||Q.ACCESS_TOKEN?this.queueRequest({id:s,timestamp:Date.now()},o):this.errorCb(new Error(wi)))}processRequests(s){if(this.pendingRequest||this.queue.length===0)return;const{id:n,timestamp:o}=this.queue.shift();n&&this.success[n]||(this.anonId||this.fetchEventData(),vt(this.anonId)||(this.anonId=Ke()),this.postEvent(o,{sdkIdentifier:"mapbox-gl-js",sdkVersion:D,skuId:ce,skuToken:this.skuToken,userId:this.anonId},d=>{d?this.errorCb(d):n&&(this.success[n]=!0)},s))}},wt=ct.postMapLoadEvent.bind(ct),X=new class extends ot{constructor(){super("gljs.performance")}postPerformanceEvent(s,n){Q.EVENTS_URL&&(s||Q.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:n},s)}processRequests(s){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:n,performanceData:o}=this.queue.shift(),d=function(g){const v=C.performance.getEntriesByType("resource"),E=C.performance.getEntriesByType("mark"),L=function(he){const _e={};if(he){for(const Be in he)if(Be!=="other")for(const Le of he[Be]){const Xe=`${Be}ResolveRangeMin`,xt=`${Be}ResolveRangeMax`,Dt=`${Be}RequestCount`,_t=`${Be}RequestCachedCount`;_e[Xe]=Math.min(_e[Xe]||1/0,Le.startTime),_e[xt]=Math.max(_e[xt]||-1/0,Le.responseEnd);const Tt=kt=>{_e[kt]===void 0&&(_e[kt]=0),++_e[kt]};Le.transferSize!==void 0&&Le.transferSize===0&&Tt(_t),Tt(Dt)}}return _e}(function(he,_e){const Be={};if(he)for(const Le of he){const Xe=_e(Le);Be[Xe]===void 0&&(Be[Xe]=[]),Be[Xe].push(Le)}return Be}(v,He)),k=C.devicePixelRatio,V=C.navigator.connection||C.navigator.mozConnection||C.navigator.webkitConnection,q={counters:[],metadata:[],attributes:[]},se=(he,_e,Be)=>{Be!=null&&he.push({name:_e,value:Be.toString()})};for(const he in L)se(q.counters,he,L[he]);if(g.interactionRange[0]!==1/0&&g.interactionRange[1]!==-1/0&&(se(q.counters,"interactionRangeMin",g.interactionRange[0]),se(q.counters,"interactionRangeMax",g.interactionRange[1])),E)for(const he of Object.keys(Ue)){const _e=Ue[he],Be=E.find(Le=>Le.name===_e);Be&&se(q.counters,_e,Be.startTime)}return se(q.counters,"visibilityHidden",g.visibilityHidden),se(q.attributes,"style",function(he){if(he)for(const _e of he){const Be=_e.name.split("?")[0];if(qn(Be)){const Le=Be.split("/").slice(-2);if(Le.length===2)return`mapbox://styles/${Le[0]}/${Le[1]}`}}}(v)),se(q.attributes,"terrainEnabled",g.terrainEnabled?"true":"false"),se(q.attributes,"fogEnabled",g.fogEnabled?"true":"false"),se(q.attributes,"projection",g.projection),se(q.attributes,"zoom",g.zoom),se(q.metadata,"devicePixelRatio",k),se(q.metadata,"connectionEffectiveType",V?V.effectiveType:void 0),se(q.metadata,"navigatorUserAgent",C.navigator.userAgent),se(q.metadata,"screenWidth",C.screen.width),se(q.metadata,"screenHeight",C.screen.height),se(q.metadata,"windowWidth",C.innerWidth),se(q.metadata,"windowHeight",C.innerHeight),se(q.metadata,"mapWidth",g.width/k),se(q.metadata,"mapHeight",g.height/k),se(q.metadata,"webglRenderer",g.renderer),se(q.metadata,"webglVendor",g.vendor),se(q.metadata,"sdkVersion",D),se(q.metadata,"sdkIdentifier","mapbox-gl-js"),q}(o);for(const g of d.metadata);for(const g of d.counters);for(const g of d.attributes);this.postEvent(n,d,()=>{},s)}},j=X.postPerformanceEvent.bind(X),ie=new class extends ot{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(s,n,o,d){if(!Q.API_URL||!Q.SESSION_PATH)return;const g=kr(Q.API_URL+Q.SESSION_PATH);g.params.push(`sku=${n||""}`),g.params.push(`access_token=${d||Q.ACCESS_TOKEN||""}`);const v={url:Qn(g),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(E,L){return on(Ve(E,{method:"GET"}),L)}(v,E=>{this.pendingRequest=null,o(E),this.saveEventData(),this.processRequests(d)})}getSessionAPI(s,n,o,d){this.skuToken=n,this.errorCb=d,Q.SESSION_PATH&&Q.API_URL&&(o||Q.ACCESS_TOKEN?this.queueRequest({id:s,timestamp:Date.now()},o):this.errorCb(new Error(wi)))}processRequests(s){if(this.pendingRequest||this.queue.length===0)return;const{id:n,timestamp:o}=this.queue.shift();n&&this.success[n]||this.getSession(o,this.skuToken,d=>{d?this.errorCb(d):n&&(this.success[n]=!0)},s)}},ne=ie.getSessionAPI.bind(ie),de=new Set,Ue={create:"create",load:"load",fullLoad:"fullLoad"},tt={mark(s){C.performance.mark(s)},measure(s,n,o){C.performance.measure(s,n,o)}};function He(s){const n=s.name.split("?")[0];return Pn(n)&&n.includes("mapbox-gl.js")?"javascript":Pn(n)&&n.includes("mapbox-gl.css")?"css":function(o){return Q.API_FONTS_REGEX.test(o)}(n)?"fontRange":Hr(n)?"sprite":qn(n)?"style":function(o){return Q.API_TILEJSON_REGEX.test(o)}(n)?"tilejson":"other"}const et=C.performance;function pt(s){const n=s?s.url.toString():void 0;return et.getEntriesByName(n)}let Lt,jt,Wt,ki;const bi={now:()=>Wt!==void 0?Wt:C.performance.now(),setNow(s){Wt=s},restoreNow(){Wt=void 0},frame(s){const n=C.requestAnimationFrame(s);return{cancel:()=>C.cancelAnimationFrame(n)}},getImageData(s,n=0){const{width:o,height:d}=s;ki||(ki=C.document.createElement("canvas"));const g=ki.getContext("2d",{willReadFrequently:!0});if(!g)throw new Error("failed to create canvas 2d context");return(o>ki.width||d>ki.height)&&(ki.width=o,ki.height=d),g.clearRect(-n,-n,o+2*n,d+2*n),g.drawImage(s,0,0,o,d),g.getImageData(-n,-n,o+2*n,d+2*n)},resolveURL:s=>(Lt||(Lt=C.document.createElement("a")),Lt.href=s,Lt.href),get devicePixelRatio(){return C.devicePixelRatio},get prefersReducedMotion(){return!!C.matchMedia&&(jt==null&&(jt=C.matchMedia("(prefers-reduced-motion: reduce)")),jt.matches)}};function Oi(s,n,o){o[s]&&o[s].indexOf(n)!==-1||(o[s]=o[s]||[],o[s].push(n))}function Yi(s,n,o){if(o&&o[s]){const d=o[s].indexOf(n);d!==-1&&o[s].splice(d,1)}}class tn{constructor(n,o={}){Ve(this,o),this.type=n}}class rr extends tn{constructor(n,o={}){super("error",Ve({error:n},o))}}class yn{on(n,o){return this._listeners=this._listeners||{},Oi(n,o,this._listeners),this}off(n,o){return Yi(n,o,this._listeners),Yi(n,o,this._oneTimeListeners),this}once(n,o){return o?(this._oneTimeListeners=this._oneTimeListeners||{},Oi(n,o,this._oneTimeListeners),this):new Promise(d=>this.once(n,d))}fire(n,o){typeof n=="string"&&(n=new tn(n,o||{}));const d=n.type;if(this.listens(d)){n.target=this;const g=this._listeners&&this._listeners[d]?this._listeners[d].slice():[];for(const L of g)L.call(this,n);const v=this._oneTimeListeners&&this._oneTimeListeners[d]?this._oneTimeListeners[d].slice():[];for(const L of v)Yi(d,L,this._oneTimeListeners),L.call(this,n);const E=this._eventedParent;E&&(Ve(n,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),E.fire(n))}else n instanceof rr&&console.error(n.error);return this}listens(n){return!!(this._listeners&&this._listeners[n]&&this._listeners[n].length>0||this._oneTimeListeners&&this._oneTimeListeners[n]&&this._oneTimeListeners[n].length>0||this._eventedParent&&this._eventedParent.listens(n))}setEventedParent(n,o){return this._eventedParent=n,this._eventedParentData=o,this}}var Yt=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function sr(s,...n){for(const o of n)for(const d in o)s[d]=o[d];return s}function Yn(s){return s instanceof Number||s instanceof String||s instanceof Boolean?s.valueOf():s}function Wr(s){if(Array.isArray(s))return s.map(Wr);if(s instanceof Object&&!(s instanceof Number||s instanceof String||s instanceof Boolean)){const n={};for(const o in s)n[o]=Wr(s[o]);return n}return Yn(s)}class mr extends Error{constructor(n,o){super(o),this.message=o,this.key=n}}var Mr=mr;class Oo{constructor(n,o=[]){this.parent=n,this.bindings={};for(const[d,g]of o)this.bindings[d]=g}concat(n){return new Oo(this,n)}get(n){if(this.bindings[n])return this.bindings[n];if(this.parent)return this.parent.get(n);throw new Error(`${n} not found in scope.`)}has(n){return!!this.bindings[n]||!!this.parent&&this.parent.has(n)}}var zs=Oo;const or={kind:"null"},rn={kind:"number"},cr={kind:"string"},Ar={kind:"boolean"},aa={kind:"color"},al={kind:"object"},dr={kind:"value"},Ul={kind:"collator"},Rl={kind:"formatted"},ll={kind:"resolvedImage"};function qs(s,n){return{kind:"array",itemType:s,N:n}}function cs(s){if(s.kind==="array"){const n=cs(s.itemType);return typeof s.N=="number"?`array<${n}, ${s.N}>`:s.itemType.kind==="value"?"array":`array<${n}>`}return s.kind}const ho=[or,rn,cr,Ar,aa,Rl,al,qs(dr),ll];function cl(s,n){if(n.kind==="error")return null;if(s.kind==="array"){if(n.kind==="array"&&(n.N===0&&n.itemType.kind==="value"||!cl(s.itemType,n.itemType))&&(typeof s.N!="number"||s.N===n.N))return null}else{if(s.kind===n.kind)return null;if(s.kind==="value"){for(const o of ho)if(!cl(o,n))return null}}return`Expected ${cs(s)} but found ${cs(n)} instead.`}function Oa(s,n){return n.some(o=>o.kind===s.kind)}function zl(s,n){return n.some(o=>o==="null"?s===null:o==="array"?Array.isArray(s):o==="object"?s&&!Array.isArray(s)&&typeof s=="object":o===typeof s)}var kl,Ol={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Na(s){return(s=Math.round(s))<0?0:s>255?255:s}function Nl(s){return Na(s[s.length-1]==="%"?parseFloat(s)/100*255:parseInt(s))}function Ql(s){return(n=s[s.length-1]==="%"?parseFloat(s)/100:parseFloat(s))<0?0:n>1?1:n;var n}function is(s,n,o){return o<0?o+=1:o>1&&(o-=1),6*o<1?s+(n-s)*o*6:2*o<1?n:3*o<2?s+(n-s)*(2/3-o)*6:s}try{kl={}.parseCSSColor=function(s){var n,o=s.replace(/ /g,"").toLowerCase();if(o in Ol)return Ol[o].slice();if(o[0]==="#")return o.length===4?(n=parseInt(o.substr(1),16))>=0&&n<=4095?[(3840&n)>>4|(3840&n)>>8,240&n|(240&n)>>4,15&n|(15&n)<<4,1]:null:o.length===7&&(n=parseInt(o.substr(1),16))>=0&&n<=16777215?[(16711680&n)>>16,(65280&n)>>8,255&n,1]:null;var d=o.indexOf("("),g=o.indexOf(")");if(d!==-1&&g+1===o.length){var v=o.substr(0,d),E=o.substr(d+1,g-(d+1)).split(","),L=1;switch(v){case"rgba":if(E.length!==4)return null;L=Ql(E.pop());case"rgb":return E.length!==3?null:[Nl(E[0]),Nl(E[1]),Nl(E[2]),L];case"hsla":if(E.length!==4)return null;L=Ql(E.pop());case"hsl":if(E.length!==3)return null;var k=(parseFloat(E[0])%360+360)%360/360,V=Ql(E[1]),q=Ql(E[2]),se=q<=.5?q*(V+1):q+V-q*V,he=2*q-se;return[Na(255*is(he,se,k+1/3)),Na(255*is(he,se,k)),Na(255*is(he,se,k-1/3)),L];default:return null}}return null}}catch{}class Ys{constructor(n,o,d,g=1){this.r=n,this.g=o,this.b=d,this.a=g}static parse(n){if(!n)return;if(n instanceof Ys)return n;if(typeof n!="string")return;const o=kl(n);return o?new Ys(o[0]/255*o[3],o[1]/255*o[3],o[2]/255*o[3],o[3]):void 0}toString(){const[n,o,d,g]=this.toArray();return`rgba(${Math.round(n)},${Math.round(o)},${Math.round(d)},${g})`}toArray(){const{r:n,g:o,b:d,a:g}=this;return g===0?[0,0,0,0]:[255*n/g,255*o/g,255*d/g,g]}toArray01(){const{r:n,g:o,b:d,a:g}=this;return g===0?[0,0,0,0]:[n/g,o/g,d/g,g]}toArray01PremultipliedAlpha(){const{r:n,g:o,b:d,a:g}=this;return[n,o,d,g]}}Ys.black=new Ys(0,0,0,1),Ys.white=new Ys(1,1,1,1),Ys.transparent=new Ys(0,0,0,0),Ys.red=new Ys(1,0,0,1),Ys.blue=new Ys(0,0,1,1);var ps=Ys;class Rc{constructor(n,o,d){this.sensitivity=n?o?"variant":"case":o?"accent":"base",this.locale=d,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(n,o){return this.collator.compare(n,o)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Eh{constructor(n,o,d,g,v){this.text=n.normalize?n.normalize():n,this.image=o,this.scale=d,this.fontStack=g,this.textColor=v}}class ks{constructor(n){this.sections=n}static fromString(n){return new ks([new Eh(n,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(n=>n.text.length!==0||n.image&&n.image.name.length!==0)}static factory(n){return n instanceof ks?n:ks.fromString(n)}toString(){return this.sections.length===0?"":this.sections.map(n=>n.text).join("")}serialize(){const n=["format"];for(const o of this.sections){if(o.image){n.push(["image",o.image.name]);continue}n.push(o.text);const d={};o.fontStack&&(d["text-font"]=["literal",o.fontStack.split(",")]),o.scale&&(d["font-scale"]=o.scale),o.textColor&&(d["text-color"]=["rgba"].concat(o.textColor.toArray())),n.push(d)}return n}}class No{constructor(n){this.name=n.name,this.available=n.available}toString(){return this.name}static fromString(n){return n?new No({name:n,available:!1}):null}serialize(){return["image",this.name]}}function JA(s,n,o,d){return typeof s=="number"&&s>=0&&s<=255&&typeof n=="number"&&n>=0&&n<=255&&typeof o=="number"&&o>=0&&o<=255?d===void 0||typeof d=="number"&&d>=0&&d<=1?null:`Invalid rgba value [${[s,n,o,d].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof d=="number"?[s,n,o,d]:[s,n,o]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function fu(s){if(s===null||typeof s=="string"||typeof s=="boolean"||typeof s=="number"||s instanceof ps||s instanceof Rc||s instanceof ks||s instanceof No)return!0;if(Array.isArray(s)){for(const n of s)if(!fu(n))return!1;return!0}if(typeof s=="object"){for(const n in s)if(!fu(s[n]))return!1;return!0}return!1}function Bs(s){if(s===null)return or;if(typeof s=="string")return cr;if(typeof s=="boolean")return Ar;if(typeof s=="number")return rn;if(s instanceof ps)return aa;if(s instanceof Rc)return Ul;if(s instanceof ks)return Rl;if(s instanceof No)return ll;if(Array.isArray(s)){const n=s.length;let o;for(const d of s){const g=Bs(d);if(o){if(o===g)continue;o=dr;break}o=g}return qs(o||dr,n)}return al}function sc(s){const n=typeof s;return s===null?"":n==="string"||n==="number"||n==="boolean"?String(s):s instanceof ps||s instanceof ks||s instanceof No?s.toString():JSON.stringify(s)}class Th{constructor(n,o){this.type=n,this.value=o}static parse(n,o){if(n.length!==2)return o.error(`'literal' expression requires exactly one argument, but found ${n.length-1} instead.`);if(!fu(n[1]))return o.error("invalid value");const d=n[1];let g=Bs(d);const v=o.expectedType;return g.kind!=="array"||g.N!==0||!v||v.kind!=="array"||typeof v.N=="number"&&v.N!==0||(g=v),new Th(g,d)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof ps?["rgba"].concat(this.value.toArray()):this.value instanceof ks?this.value.serialize():this.value}}var oc=Th,er=class{constructor(s){this.name="ExpressionEvaluationError",this.message=s}toJSON(){return this.message}};const ac={string:cr,number:rn,boolean:Ar,object:al};class Ju{constructor(n,o){this.type=n,this.args=o}static parse(n,o){if(n.length<2)return o.error("Expected at least one argument.");let d,g=1;const v=n[0];if(v==="array"){let L,k;if(n.length>2){const V=n[1];if(typeof V!="string"||!(V in ac)||V==="object")return o.error('The item type argument of "array" must be one of string, number, boolean',1);L=ac[V],g++}else L=dr;if(n.length>3){if(n[2]!==null&&(typeof n[2]!="number"||n[2]<0||n[2]!==Math.floor(n[2])))return o.error('The length argument to "array" must be a positive integer literal',2);k=n[2],g++}d=qs(L,k)}else d=ac[v];const E=[];for(;gn.outputDefined())}serialize(){const n=this.type,o=[n.kind];if(n.kind==="array"){const d=n.itemType;if(d.kind==="string"||d.kind==="number"||d.kind==="boolean"){o.push(d.kind);const g=n.N;(typeof g=="number"||this.args.length>1)&&o.push(g)}}return o.concat(this.args.map(d=>d.serialize()))}}var Qo=Ju;class hl{constructor(n){this.type=Rl,this.sections=n}static parse(n,o){if(n.length<2)return o.error("Expected at least one argument.");const d=n[1];if(!Array.isArray(d)&&typeof d=="object")return o.error("First argument must be an image or text section.");const g=[];let v=!1;for(let E=1;E<=n.length-1;++E){const L=n[E];if(v&&typeof L=="object"&&!Array.isArray(L)){v=!1;let k=null;if(L["font-scale"]&&(k=o.parse(L["font-scale"],1,rn),!k))return null;let V=null;if(L["text-font"]&&(V=o.parse(L["text-font"],1,qs(cr)),!V))return null;let q=null;if(L["text-color"]&&(q=o.parse(L["text-color"],1,aa),!q))return null;const se=g[g.length-1];se.scale=k,se.font=V,se.textColor=q}else{const k=o.parse(n[E],1,dr);if(!k)return null;const V=k.type.kind;if(V!=="string"&&V!=="value"&&V!=="null"&&V!=="resolvedImage")return o.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");v=!0,g.push({content:k,scale:null,font:null,textColor:null})}}return new hl(g)}evaluate(n){return new ks(this.sections.map(o=>{const d=o.content.evaluate(n);return Bs(d)===ll?new Eh("",d,null,null,null):new Eh(sc(d),null,o.scale?o.scale.evaluate(n):null,o.font?o.font.evaluate(n).join(","):null,o.textColor?o.textColor.evaluate(n):null)}))}eachChild(n){for(const o of this.sections)n(o.content),o.scale&&n(o.scale),o.font&&n(o.font),o.textColor&&n(o.textColor)}outputDefined(){return!1}serialize(){const n=["format"];for(const o of this.sections){n.push(o.content.serialize());const d={};o.scale&&(d["font-scale"]=o.scale.serialize()),o.font&&(d["text-font"]=o.font.serialize()),o.textColor&&(d["text-color"]=o.textColor.serialize()),n.push(d)}return n}}class Sh{constructor(n){this.type=ll,this.input=n}static parse(n,o){if(n.length!==2)return o.error("Expected two arguments.");const d=o.parse(n[1],1,cr);return d?new Sh(d):o.error("No image name provided.")}evaluate(n){const o=this.input.evaluate(n),d=No.fromString(o);return d&&n.availableImages&&(d.available=n.availableImages.indexOf(o)>-1),d}eachChild(n){n(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Vo={"to-boolean":Ar,"to-color":aa,"to-number":rn,"to-string":cr};class Mh{constructor(n,o){this.type=n,this.args=o}static parse(n,o){if(n.length<2)return o.error("Expected at least one argument.");const d=n[0];if((d==="to-boolean"||d==="to-string")&&n.length!==2)return o.error("Expected one argument.");const g=Vo[d],v=[];for(let E=1;E4?`Invalid rbga value ${JSON.stringify(o)}: expected an array containing either three or four numeric values.`:JA(o[0],o[1],o[2],o[3]),!d))return new ps(o[0]/255,o[1]/255,o[2]/255,o[3])}throw new er(d||`Could not parse color from value '${typeof o=="string"?o:String(JSON.stringify(o))}'`)}if(this.type.kind==="number"){let o=null;for(const d of this.args){if(o=d.evaluate(n),o===null)return 0;const g=Number(o);if(!isNaN(g))return g}throw new er(`Could not convert ${JSON.stringify(o)} to number.`)}return this.type.kind==="formatted"?ks.fromString(sc(this.args[0].evaluate(n))):this.type.kind==="resolvedImage"?No.fromString(sc(this.args[0].evaluate(n))):sc(this.args[0].evaluate(n))}eachChild(n){this.args.forEach(n)}outputDefined(){return this.args.every(n=>n.outputDefined())}serialize(){if(this.type.kind==="formatted")return new hl([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new Sh(this.args[0]).serialize();const n=[`to-${this.type.kind}`];return this.eachChild(o=>{n.push(o.serialize())}),n}}var Qa=Mh;const lc=["Unknown","Point","LineString","Polygon"];var mu=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?lc[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const s=this.featureDistanceData.center,n=this.featureDistanceData.scale,{x:o,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(o*n-s[0])+this.featureDistanceData.bearing[1]*(d*n-s[1])}return 0}parseColor(s){let n=this._parseColorCache[s];return n||(n=this._parseColorCache[s]=ps.parse(s)),n}};class Vl{constructor(n,o,d,g){this.name=n,this.type=o,this._evaluate=d,this.args=g}evaluate(n){return this._evaluate(n,this.args)}eachChild(n){this.args.forEach(n)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(n=>n.serialize()))}static parse(n,o){const d=n[0],g=Vl.definitions[d];if(!g)return o.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0);const v=Array.isArray(g)?g[0]:g.type,E=Array.isArray(g)?[[g[1],g[2]]]:g.overloads,L=E.filter(([V])=>!Array.isArray(V)||V.length===n.length-1);let k=null;for(const[V,q]of L){k=new hr(o.registry,o.path,null,o.scope);const se=[];let he=!1;for(let _e=1;_e{return he=se,Array.isArray(he)?`(${he.map(cs).join(", ")})`:`(${cs(he.type)}...)`;var he}).join(" | "),q=[];for(let se=1;se=n[2]||s[1]<=n[1]||s[3]>=n[3])}function eA(s,n){const o=(180+s[0])/360,d=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+s[1]*Math.PI/360)))/360,g=Math.pow(2,n.z);return[Math.round(o*g*Ws),Math.round(d*g*Ws)]}function hc(s,n,o){const d=s[0]-n[0],g=s[1]-n[1],v=s[0]-o[0],E=s[1]-o[1];return d*E-v*g==0&&d*v<=0&&g*E<=0}function gu(s,n){let o=!1;for(let E=0,L=n.length;E(d=s)[1]!=(v=k[V+1])[1]>d[1]&&d[0]<(v[0]-g[0])*(d[1]-g[1])/(v[1]-g[1])+g[0]&&(o=!o)}}var d,g,v;return o}function ed(s,n){for(let o=0;o0&&L<0||E<0&&L>0}function Ih(s,n,o){for(const V of o)for(let q=0;qo[2]){const g=.5*d;let v=s[0]-o[0]>g?-d:o[0]-s[0]>g?d:0;v===0&&(v=s[0]-o[2]>g?-d:o[2]-s[0]>g?d:0),s[0]+=v}cc(n,s)}function Ir(s,n,o,d){const g=Math.pow(2,d.z)*Ws,v=[d.x*Ws,d.y*Ws],E=[];if(!s)return E;for(const L of s)for(const k of L){const V=[k.x+v[0],k.y+v[1]];ul(V,n,o,g),E.push(V)}return E}function Ac(s,n,o,d){const g=Math.pow(2,d.z)*Ws,v=[d.x*Ws,d.y*Ws],E=[];if(!s)return E;for(const k of s){const V=[];for(const q of k){const se=[q.x+v[0],q.y+v[1]];cc(n,se),V.push(se)}E.push(V)}if(n[2]-n[0]<=g/2){(L=n)[0]=L[1]=1/0,L[2]=L[3]=-1/0;for(const k of E)for(const V of k)ul(V,n,o,g)}var L;return E}class Nc{constructor(n,o){this.type=Ar,this.geojson=n,this.geometries=o}static parse(n,o){if(n.length!==2)return o.error(`'within' expression requires exactly one argument, but found ${n.length-1} instead.`);if(fu(n[1])){const d=n[1];if(d.type==="FeatureCollection")for(let g=0;g{n&&!Al(o)&&(n=!1)}),n}function Va(s){if(s instanceof ya&&s.name==="feature-state")return!1;let n=!0;return s.eachChild(o=>{n&&!Va(o)&&(n=!1)}),n}function Qc(s,n){if(s instanceof ya&&n.indexOf(s.name)>=0)return!1;let o=!0;return s.eachChild(d=>{o&&!Qc(d,n)&&(o=!1)}),o}class dl{constructor(n,o){this.type=o.type,this.name=n,this.boundExpression=o}static parse(n,o){if(n.length!==2||typeof n[1]!="string")return o.error("'var' expression requires exactly one string literal argument.");const d=n[1];return o.scope.has(d)?new dl(d,o.scope.get(d)):o.error(`Unknown variable "${d}". Make sure "${d}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(n){return this.boundExpression.evaluate(n)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var qr=dl;class Fh{constructor(n,o=[],d,g=new zs,v=[]){this.registry=n,this.path=o,this.key=o.map(E=>`[${E}]`).join(""),this.scope=g,this.errors=v,this.expectedType=d}parse(n,o,d,g,v={}){return o?this.concat(o,d,g)._parse(n,v):this._parse(n,v)}_parse(n,o){function d(g,v,E){return E==="assert"?new Qo(v,[g]):E==="coerce"?new Qa(v,[g]):g}if(n!==null&&typeof n!="string"&&typeof n!="boolean"&&typeof n!="number"||(n=["literal",n]),Array.isArray(n)){if(n.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const g=n[0];if(typeof g!="string")return this.error(`Expression name must be a string, but found ${typeof g} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const v=this.registry[g];if(v){let E=v.parse(n,this);if(!E)return null;if(this.expectedType){const L=this.expectedType,k=E.type;if(L.kind!=="string"&&L.kind!=="number"&&L.kind!=="boolean"&&L.kind!=="object"&&L.kind!=="array"||k.kind!=="value")if(L.kind!=="color"&&L.kind!=="formatted"&&L.kind!=="resolvedImage"||k.kind!=="value"&&k.kind!=="string"){if(this.checkSubtype(L,k))return null}else E=d(E,L,o.typeAnnotation||"coerce");else E=d(E,L,o.typeAnnotation||"assert")}if(!(E instanceof oc)&&E.type.kind!=="resolvedImage"&&Br(E)){const L=new mu;try{E=new oc(E.type,E.evaluate(L))}catch(k){return this.error(k.message),null}}return E}return this.error(`Unknown expression "${g}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(n===void 0?"'undefined' value invalid. Use null instead.":typeof n=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof n} instead.`)}concat(n,o,d){const g=typeof n=="number"?this.path.concat(n):this.path,v=d?this.scope.concat(d):this.scope;return new Fh(this.registry,g,o||null,v,this.errors)}error(n,...o){const d=`${this.key}${o.map(g=>`[${g}]`).join("")}`;this.errors.push(new Mr(d,n))}checkSubtype(n,o){const d=cl(n,o);return d&&this.error(d),d}}var hr=Fh;function Br(s){if(s instanceof qr)return Br(s.boundExpression);if(s instanceof ya&&s.name==="error"||s instanceof zc||s instanceof yu)return!1;const n=s instanceof Qa||s instanceof Qo;let o=!0;return s.eachChild(d=>{o=n?o&&Br(d):o&&d instanceof oc}),!!o&&Al(s)&&Qc(s,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function jr(s,n){const o=s.length-1;let d,g,v=0,E=o,L=0;for(;v<=E;)if(L=Math.floor((v+E)/2),d=s[L],g=s[L+1],d<=n){if(L===o||nn))throw new er("Input is not a number.");E=L-1}return 0}class $r{constructor(n,o,d){this.type=n,this.input=o,this.labels=[],this.outputs=[];for(const[g,v]of d)this.labels.push(g),this.outputs.push(v)}static parse(n,o){if(n.length-1<4)return o.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if((n.length-1)%2!=0)return o.error("Expected an even number of arguments.");const d=o.parse(n[1],1,rn);if(!d)return null;const g=[];let v=null;o.expectedType&&o.expectedType.kind!=="value"&&(v=o.expectedType);for(let E=1;E=L)return o.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',V);const se=o.parse(k,q,v);if(!se)return null;v=v||se.type,g.push([L,se])}return new $r(v,d,g)}evaluate(n){const o=this.labels,d=this.outputs;if(o.length===1)return d[0].evaluate(n);const g=this.input.evaluate(n);if(g<=o[0])return d[0].evaluate(n);const v=o.length;return g>=o[v-1]?d[v-1].evaluate(n):d[jr(o,g)].evaluate(n)}eachChild(n){n(this.input);for(const o of this.outputs)n(o)}outputDefined(){return this.outputs.every(n=>n.outputDefined())}serialize(){const n=["step",this.input.serialize()];for(let o=0;o0&&n.push(this.labels[o]),n.push(this.outputs[o].serialize());return n}}var Hl=$r;function gr(s,n,o){return s*(1-o)+n*o}var xu=Object.freeze({__proto__:null,number:gr,color:function(s,n,o){return new ps(gr(s.r,n.r,o),gr(s.g,n.g,o),gr(s.b,n.b,o),gr(s.a,n.a,o))},array:function(s,n,o){return s.map((d,g)=>gr(d,n[g],o))}});const iA=.95047,nA=1.08883,rA=4/29,dc=6/29,Vc=3*dc*dc,Hc=Math.PI/180,Lh=180/Math.PI;function Gc(s){return s>.008856451679035631?Math.pow(s,1/3):s/Vc+rA}function Dh(s){return s>dc?s*s*s:Vc*(s-rA)}function Wc(s){return 255*(s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055)}function jc(s){return(s/=255)<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function la(s){const n=jc(s.r),o=jc(s.g),d=jc(s.b),g=Gc((.4124564*n+.3575761*o+.1804375*d)/iA),v=Gc((.2126729*n+.7151522*o+.072175*d)/1);return{l:116*v-16,a:500*(g-v),b:200*(v-Gc((.0193339*n+.119192*o+.9503041*d)/nA)),alpha:s.a}}function sA(s){let n=(s.l+16)/116,o=isNaN(s.a)?n:n+s.a/500,d=isNaN(s.b)?n:n-s.b/200;return n=1*Dh(n),o=iA*Dh(o),d=nA*Dh(d),new ps(Wc(3.2404542*o-1.5371385*n-.4985314*d),Wc(-.969266*o+1.8760108*n+.041556*d),Wc(.0556434*o-.2040259*n+1.0572252*d),s.alpha)}function oA(s,n,o){const d=n-s;return s+o*(d>180||d<-180?d-360*Math.round(d/360):d)}const Kc={forward:la,reverse:sA,interpolate:function(s,n,o){return{l:gr(s.l,n.l,o),a:gr(s.a,n.a,o),b:gr(s.b,n.b,o),alpha:gr(s.alpha,n.alpha,o)}}},ca={forward:function(s){const{l:n,a:o,b:d}=la(s),g=Math.atan2(d,o)*Lh;return{h:g<0?g+360:g,c:Math.sqrt(o*o+d*d),l:n,alpha:s.a}},reverse:function(s){const n=s.h*Hc,o=s.c;return sA({l:s.l,a:Math.cos(n)*o,b:Math.sin(n)*o,alpha:s.alpha})},interpolate:function(s,n,o){return{h:oA(s.h,n.h,o),c:gr(s.c,n.c,o),l:gr(s.l,n.l,o),alpha:gr(s.alpha,n.alpha,o)}}};var $c=Object.freeze({__proto__:null,lab:Kc,hcl:ca});class pl{constructor(n,o,d,g,v){this.type=n,this.operator=o,this.interpolation=d,this.input=g,this.labels=[],this.outputs=[];for(const[E,L]of v)this.labels.push(E),this.outputs.push(L)}static interpolationFactor(n,o,d,g){let v=0;if(n.name==="exponential")v=aA(o,n.base,d,g);else if(n.name==="linear")v=aA(o,1,d,g);else if(n.name==="cubic-bezier"){const E=n.controlPoints;v=new Ae(E[0],E[1],E[2],E[3]).solve(aA(o,1,d,g))}return v}static parse(n,o){let[d,g,v,...E]=n;if(!Array.isArray(g)||g.length===0)return o.error("Expected an interpolation type expression.",1);if(g[0]==="linear")g={name:"linear"};else if(g[0]==="exponential"){const V=g[1];if(typeof V!="number")return o.error("Exponential interpolation requires a numeric base.",1,1);g={name:"exponential",base:V}}else{if(g[0]!=="cubic-bezier")return o.error(`Unknown interpolation type ${String(g[0])}`,1,0);{const V=g.slice(1);if(V.length!==4||V.some(q=>typeof q!="number"||q<0||q>1))return o.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);g={name:"cubic-bezier",controlPoints:V}}}if(n.length-1<4)return o.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if((n.length-1)%2!=0)return o.error("Expected an even number of arguments.");if(v=o.parse(v,2,rn),!v)return null;const L=[];let k=null;d==="interpolate-hcl"||d==="interpolate-lab"?k=aa:o.expectedType&&o.expectedType.kind!=="value"&&(k=o.expectedType);for(let V=0;V=q)return o.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',he);const Be=o.parse(se,_e,k);if(!Be)return null;k=k||Be.type,L.push([q,Be])}return k.kind==="number"||k.kind==="color"||k.kind==="array"&&k.itemType.kind==="number"&&typeof k.N=="number"?new pl(k,d,g,v,L):o.error(`Type ${cs(k)} is not interpolatable.`)}evaluate(n){const o=this.labels,d=this.outputs;if(o.length===1)return d[0].evaluate(n);const g=this.input.evaluate(n);if(g<=o[0])return d[0].evaluate(n);const v=o.length;if(g>=o[v-1])return d[v-1].evaluate(n);const E=jr(o,g),L=pl.interpolationFactor(this.interpolation,g,o[E],o[E+1]),k=d[E].evaluate(n),V=d[E+1].evaluate(n);return this.operator==="interpolate"?xu[this.type.kind.toLowerCase()](k,V,L):this.operator==="interpolate-hcl"?ca.reverse(ca.interpolate(ca.forward(k),ca.forward(V),L)):Kc.reverse(Kc.interpolate(Kc.forward(k),Kc.forward(V),L))}eachChild(n){n(this.input);for(const o of this.outputs)n(o)}outputDefined(){return this.outputs.every(n=>n.outputDefined())}serialize(){let n;n=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const o=[this.operator,n,this.input.serialize()];for(let d=0;dcl(g,L.type));return new Ph(E?dr:d,v)}evaluate(n){let o,d=null,g=0;for(const v of this.args){if(g++,d=v.evaluate(n),d&&d instanceof No&&!d.available&&(o||(o=d),d=null,g===this.args.length))return o;if(d!==null)break}return d}eachChild(n){this.args.forEach(n)}outputDefined(){return this.args.every(n=>n.outputDefined())}serialize(){const n=["coalesce"];return this.eachChild(o=>{n.push(o.serialize())}),n}}var vu=Ph;class Gl{constructor(n,o){this.type=o.type,this.bindings=[].concat(n),this.result=o}evaluate(n){return this.result.evaluate(n)}eachChild(n){for(const o of this.bindings)n(o[1]);n(this.result)}static parse(n,o){if(n.length<4)return o.error(`Expected at least 3 arguments, but found ${n.length-1} instead.`);const d=[];for(let v=1;v=d.length)throw new er(`Array index out of bounds: ${o} > ${d.length-1}.`);if(o!==Math.floor(o))throw new er(`Array index must be an integer, but found ${o} instead.`);return d[o]}eachChild(n){n(this.index),n(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Xc=Zc;class fl{constructor(n,o){this.type=Ar,this.needle=n,this.haystack=o}static parse(n,o){if(n.length!==3)return o.error(`Expected 2 arguments, but found ${n.length-1} instead.`);const d=o.parse(n[1],1,dr),g=o.parse(n[2],2,dr);return d&&g?Oa(d.type,[Ar,cr,rn,or,dr])?new fl(d,g):o.error(`Expected first argument to be of type boolean, string, number or null, but found ${cs(d.type)} instead`):null}evaluate(n){const o=this.needle.evaluate(n),d=this.haystack.evaluate(n);if(d==null)return!1;if(!zl(o,["boolean","string","number","null"]))throw new er(`Expected first argument to be of type boolean, string, number or null, but found ${cs(Bs(o))} instead.`);if(!zl(d,["string","array"]))throw new er(`Expected second argument to be of type array or string, but found ${cs(Bs(d))} instead.`);return d.indexOf(o)>=0}eachChild(n){n(this.needle),n(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var qc=fl;class Uh{constructor(n,o,d){this.type=rn,this.needle=n,this.haystack=o,this.fromIndex=d}static parse(n,o){if(n.length<=2||n.length>=5)return o.error(`Expected 3 or 4 arguments, but found ${n.length-1} instead.`);const d=o.parse(n[1],1,dr),g=o.parse(n[2],2,dr);if(!d||!g)return null;if(!Oa(d.type,[Ar,cr,rn,or,dr]))return o.error(`Expected first argument to be of type boolean, string, number or null, but found ${cs(d.type)} instead`);if(n.length===4){const v=o.parse(n[3],3,rn);return v?new Uh(d,g,v):null}return new Uh(d,g)}evaluate(n){const o=this.needle.evaluate(n),d=this.haystack.evaluate(n);if(!zl(o,["boolean","string","number","null"]))throw new er(`Expected first argument to be of type boolean, string, number or null, but found ${cs(Bs(o))} instead.`);if(!zl(d,["string","array"]))throw new er(`Expected second argument to be of type array or string, but found ${cs(Bs(d))} instead.`);if(this.fromIndex){const g=this.fromIndex.evaluate(n);return d.indexOf(o,g)}return d.indexOf(o)}eachChild(n){n(this.needle),n(this.haystack),this.fromIndex&&n(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const n=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),n]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Rh=Uh;class bu{constructor(n,o,d,g,v,E){this.inputType=n,this.type=o,this.input=d,this.cases=g,this.outputs=v,this.otherwise=E}static parse(n,o){if(n.length<5)return o.error(`Expected at least 4 arguments, but found only ${n.length-1}.`);if(n.length%2!=1)return o.error("Expected an even number of arguments.");let d,g;o.expectedType&&o.expectedType.kind!=="value"&&(g=o.expectedType);const v={},E=[];for(let V=2;VNumber.MAX_SAFE_INTEGER)return he.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof Be=="number"&&Math.floor(Be)!==Be)return he.error("Numeric branch labels must be integer values.");if(d){if(he.checkSubtype(d,Bs(Be)))return null}else d=Bs(Be);if(v[String(Be)]!==void 0)return he.error("Branch labels must be unique.");v[String(Be)]=E.length}const _e=o.parse(se,V,g);if(!_e)return null;g=g||_e.type,E.push(_e)}const L=o.parse(n[1],1,dr);if(!L)return null;const k=o.parse(n[n.length-1],n.length-1,g);return k?L.type.kind!=="value"&&o.concat(1).checkSubtype(d,L.type)?null:new bu(d,g,L,v,E,k):null}evaluate(n){const o=this.input.evaluate(n);return(Bs(o)===this.inputType&&this.outputs[this.cases[o]]||this.otherwise).evaluate(n)}eachChild(n){n(this.input),this.outputs.forEach(n),n(this.otherwise)}outputDefined(){return this.outputs.every(n=>n.outputDefined())&&this.otherwise.outputDefined()}serialize(){const n=["match",this.input.serialize()],o=Object.keys(this.cases).sort(),d=[],g={};for(const E of o){const L=g[this.cases[E]];L===void 0?(g[this.cases[E]]=d.length,d.push([this.cases[E],[E]])):d[L][1].push(E)}const v=E=>this.inputType.kind==="number"?Number(E):E;for(const[E,L]of d)n.push(L.length===1?v(L[0]):L.map(v)),n.push(this.outputs[E].serialize());return n.push(this.otherwise.serialize()),n}}var id=bu;class pc{constructor(n,o,d){this.type=n,this.branches=o,this.otherwise=d}static parse(n,o){if(n.length<4)return o.error(`Expected at least 3 arguments, but found only ${n.length-1}.`);if(n.length%2!=0)return o.error("Expected an odd number of arguments.");let d;o.expectedType&&o.expectedType.kind!=="value"&&(d=o.expectedType);const g=[];for(let E=1;Eo.outputDefined())&&this.otherwise.outputDefined()}serialize(){const n=["case"];return this.eachChild(o=>{n.push(o.serialize())}),n}}var fc=pc;class Yc{constructor(n,o,d,g){this.type=n,this.input=o,this.beginIndex=d,this.endIndex=g}static parse(n,o){if(n.length<=2||n.length>=5)return o.error(`Expected 3 or 4 arguments, but found ${n.length-1} instead.`);const d=o.parse(n[1],1,dr),g=o.parse(n[2],2,rn);if(!d||!g)return null;if(!Oa(d.type,[qs(dr),cr,dr]))return o.error(`Expected first argument to be of type array or string, but found ${cs(d.type)} instead`);if(n.length===4){const v=o.parse(n[3],3,rn);return v?new Yc(d.type,d,g,v):null}return new Yc(d.type,d,g)}evaluate(n){const o=this.input.evaluate(n),d=this.beginIndex.evaluate(n);if(!zl(o,["string","array"]))throw new er(`Expected first argument to be of type array or string, but found ${cs(Bs(o))} instead.`);if(this.endIndex){const g=this.endIndex.evaluate(n);return o.slice(d,g)}return o.slice(d)}eachChild(n){n(this.input),n(this.beginIndex),this.endIndex&&n(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const n=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),n]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var zh=Yc;function Jc(s,n){return s==="=="||s==="!="?n.kind==="boolean"||n.kind==="string"||n.kind==="number"||n.kind==="null"||n.kind==="value":n.kind==="string"||n.kind==="number"||n.kind==="value"}function So(s,n,o,d){return d.compare(n,o)===0}function xa(s,n,o){const d=s!=="=="&&s!=="!=";return class RF{constructor(v,E,L){this.type=Ar,this.lhs=v,this.rhs=E,this.collator=L,this.hasUntypedArgument=v.type.kind==="value"||E.type.kind==="value"}static parse(v,E){if(v.length!==3&&v.length!==4)return E.error("Expected two or three arguments.");const L=v[0];let k=E.parse(v[1],1,dr);if(!k)return null;if(!Jc(L,k.type))return E.concat(1).error(`"${L}" comparisons are not supported for type '${cs(k.type)}'.`);let V=E.parse(v[2],2,dr);if(!V)return null;if(!Jc(L,V.type))return E.concat(2).error(`"${L}" comparisons are not supported for type '${cs(V.type)}'.`);if(k.type.kind!==V.type.kind&&k.type.kind!=="value"&&V.type.kind!=="value")return E.error(`Cannot compare types '${cs(k.type)}' and '${cs(V.type)}'.`);d&&(k.type.kind==="value"&&V.type.kind!=="value"?k=new Qo(V.type,[k]):k.type.kind!=="value"&&V.type.kind==="value"&&(V=new Qo(k.type,[V])));let q=null;if(v.length===4){if(k.type.kind!=="string"&&V.type.kind!=="string"&&k.type.kind!=="value"&&V.type.kind!=="value")return E.error("Cannot use collator to compare non-string types.");if(q=E.parse(v[3],3,Ul),!q)return null}return new RF(k,V,q)}evaluate(v){const E=this.lhs.evaluate(v),L=this.rhs.evaluate(v);if(d&&this.hasUntypedArgument){const k=Bs(E),V=Bs(L);if(k.kind!==V.kind||k.kind!=="string"&&k.kind!=="number")throw new er(`Expected arguments for "${s}" to be (string, string) or (number, number), but found (${k.kind}, ${V.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const k=Bs(E),V=Bs(L);if(k.kind!=="string"||V.kind!=="string")return n(v,E,L)}return this.collator?o(v,E,L,this.collator.evaluate(v)):n(v,E,L)}eachChild(v){v(this.lhs),v(this.rhs),this.collator&&v(this.collator)}outputDefined(){return!0}serialize(){const v=[s];return this.eachChild(E=>{v.push(E.serialize())}),v}}}const Mo=xa("==",function(s,n,o){return n===o},So),nd=xa("!=",function(s,n,o){return n!==o},function(s,n,o,d){return!So(0,n,o,d)}),Ha=xa("<",function(s,n,o){return n",function(s,n,o){return n>o},function(s,n,o,d){return d.compare(n,o)>0}),ml=xa("<=",function(s,n,o){return n<=o},function(s,n,o,d){return d.compare(n,o)<=0}),kh=xa(">=",function(s,n,o){return n>=o},function(s,n,o,d){return d.compare(n,o)>=0});class Oh{constructor(n,o,d,g,v,E){this.type=cr,this.number=n,this.locale=o,this.currency=d,this.unit=g,this.minFractionDigits=v,this.maxFractionDigits=E}static parse(n,o){if(n.length!==3)return o.error("Expected two arguments.");const d=o.parse(n[1],1,rn);if(!d)return null;const g=n[2];if(typeof g!="object"||Array.isArray(g))return o.error("NumberFormat options argument must be an object.");let v=null;if(g.locale&&(v=o.parse(g.locale,1,cr),!v))return null;let E=null;if(g.currency&&(E=o.parse(g.currency,1,cr),!E))return null;let L=null;if(g.unit&&(L=o.parse(g.unit,1,cr),!L))return null;let k=null;if(g["min-fraction-digits"]&&(k=o.parse(g["min-fraction-digits"],1,rn),!k))return null;let V=null;return g["max-fraction-digits"]&&(V=o.parse(g["max-fraction-digits"],1,rn),!V)?null:new Oh(d,v,E,L,k,V)}evaluate(n){return new Intl.NumberFormat(this.locale?this.locale.evaluate(n):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(n):void 0,unit:this.unit?this.unit.evaluate(n):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(n):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(n):void 0}).format(this.number.evaluate(n))}eachChild(n){n(this.number),this.locale&&n(this.locale),this.currency&&n(this.currency),this.unit&&n(this.unit),this.minFractionDigits&&n(this.minFractionDigits),this.maxFractionDigits&&n(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const n={};return this.locale&&(n.locale=this.locale.serialize()),this.currency&&(n.currency=this.currency.serialize()),this.unit&&(n.unit=this.unit.serialize()),this.minFractionDigits&&(n["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(n["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),n]}}class lA{constructor(n){this.type=rn,this.input=n}static parse(n,o){if(n.length!==2)return o.error(`Expected 1 argument, but found ${n.length-1} instead.`);const d=o.parse(n[1],1);return d?d.type.kind!=="array"&&d.type.kind!=="string"&&d.type.kind!=="value"?o.error(`Expected argument of type string or array, but found ${cs(d.type)} instead.`):new lA(d):null}evaluate(n){const o=this.input.evaluate(n);if(typeof o=="string"||Array.isArray(o))return o.length;throw new er(`Expected value to be of type string or array, but found ${cs(Bs(o))} instead.`)}eachChild(n){n(this.input)}outputDefined(){return!1}serialize(){const n=["length"];return this.eachChild(o=>{n.push(o.serialize())}),n}}const sd={"==":Mo,"!=":nd,">":rd,"<":Ha,">=":kh,"<=":ml,array:Qo,at:Xc,boolean:Qo,case:fc,coalesce:vu,collator:zc,format:hl,image:Sh,in:qc,"index-of":Rh,interpolate:Ho,"interpolate-hcl":Ho,"interpolate-lab":Ho,length:lA,let:wu,literal:oc,match:id,number:Qo,"number-format":Oh,object:Qo,slice:zh,step:Hl,string:Qo,"to-boolean":Qa,"to-color":Qa,"to-number":Qa,"to-string":Qa,var:qr,within:yu};function Nh(s,[n,o,d,g]){n=n.evaluate(s),o=o.evaluate(s),d=d.evaluate(s);const v=g?g.evaluate(s):1,E=JA(n,o,d,v);if(E)throw new er(E);return new ps(n/255*v,o/255*v,d/255*v,v)}function mc(s,n){return s in n}function ha(s,n){const o=n[s];return o===void 0?null:o}function pn(s){return{type:s}}ya.register(sd,{error:[{kind:"error"},[cr],(s,[n])=>{throw new er(n.evaluate(s))}],typeof:[cr,[dr],(s,[n])=>cs(Bs(n.evaluate(s)))],"to-rgba":[qs(rn,4),[aa],(s,[n])=>n.evaluate(s).toArray()],rgb:[aa,[rn,rn,rn],Nh],rgba:[aa,[rn,rn,rn,rn],Nh],has:{type:Ar,overloads:[[[cr],(s,[n])=>mc(n.evaluate(s),s.properties())],[[cr,al],(s,[n,o])=>mc(n.evaluate(s),o.evaluate(s))]]},get:{type:dr,overloads:[[[cr],(s,[n])=>ha(n.evaluate(s),s.properties())],[[cr,al],(s,[n,o])=>ha(n.evaluate(s),o.evaluate(s))]]},"feature-state":[dr,[cr],(s,[n])=>ha(n.evaluate(s),s.featureState||{})],properties:[al,[],s=>s.properties()],"geometry-type":[cr,[],s=>s.geometryType()],id:[dr,[],s=>s.id()],zoom:[rn,[],s=>s.globals.zoom],pitch:[rn,[],s=>s.globals.pitch||0],"distance-from-center":[rn,[],s=>s.distanceFromCenter()],"heatmap-density":[rn,[],s=>s.globals.heatmapDensity||0],"line-progress":[rn,[],s=>s.globals.lineProgress||0],"sky-radial-progress":[rn,[],s=>s.globals.skyRadialProgress||0],accumulated:[dr,[],s=>s.globals.accumulated===void 0?null:s.globals.accumulated],"+":[rn,pn(rn),(s,n)=>{let o=0;for(const d of n)o+=d.evaluate(s);return o}],"*":[rn,pn(rn),(s,n)=>{let o=1;for(const d of n)o*=d.evaluate(s);return o}],"-":{type:rn,overloads:[[[rn,rn],(s,[n,o])=>n.evaluate(s)-o.evaluate(s)],[[rn],(s,[n])=>-n.evaluate(s)]]},"/":[rn,[rn,rn],(s,[n,o])=>n.evaluate(s)/o.evaluate(s)],"%":[rn,[rn,rn],(s,[n,o])=>n.evaluate(s)%o.evaluate(s)],ln2:[rn,[],()=>Math.LN2],pi:[rn,[],()=>Math.PI],e:[rn,[],()=>Math.E],"^":[rn,[rn,rn],(s,[n,o])=>Math.pow(n.evaluate(s),o.evaluate(s))],sqrt:[rn,[rn],(s,[n])=>Math.sqrt(n.evaluate(s))],log10:[rn,[rn],(s,[n])=>Math.log(n.evaluate(s))/Math.LN10],ln:[rn,[rn],(s,[n])=>Math.log(n.evaluate(s))],log2:[rn,[rn],(s,[n])=>Math.log(n.evaluate(s))/Math.LN2],sin:[rn,[rn],(s,[n])=>Math.sin(n.evaluate(s))],cos:[rn,[rn],(s,[n])=>Math.cos(n.evaluate(s))],tan:[rn,[rn],(s,[n])=>Math.tan(n.evaluate(s))],asin:[rn,[rn],(s,[n])=>Math.asin(n.evaluate(s))],acos:[rn,[rn],(s,[n])=>Math.acos(n.evaluate(s))],atan:[rn,[rn],(s,[n])=>Math.atan(n.evaluate(s))],min:[rn,pn(rn),(s,n)=>Math.min(...n.map(o=>o.evaluate(s)))],max:[rn,pn(rn),(s,n)=>Math.max(...n.map(o=>o.evaluate(s)))],abs:[rn,[rn],(s,[n])=>Math.abs(n.evaluate(s))],round:[rn,[rn],(s,[n])=>{const o=n.evaluate(s);return o<0?-Math.round(-o):Math.round(o)}],floor:[rn,[rn],(s,[n])=>Math.floor(n.evaluate(s))],ceil:[rn,[rn],(s,[n])=>Math.ceil(n.evaluate(s))],"filter-==":[Ar,[cr,dr],(s,[n,o])=>s.properties()[n.value]===o.value],"filter-id-==":[Ar,[dr],(s,[n])=>s.id()===n.value],"filter-type-==":[Ar,[cr],(s,[n])=>s.geometryType()===n.value],"filter-<":[Ar,[cr,dr],(s,[n,o])=>{const d=s.properties()[n.value],g=o.value;return typeof d==typeof g&&d{const o=s.id(),d=n.value;return typeof o==typeof d&&o":[Ar,[cr,dr],(s,[n,o])=>{const d=s.properties()[n.value],g=o.value;return typeof d==typeof g&&d>g}],"filter-id->":[Ar,[dr],(s,[n])=>{const o=s.id(),d=n.value;return typeof o==typeof d&&o>d}],"filter-<=":[Ar,[cr,dr],(s,[n,o])=>{const d=s.properties()[n.value],g=o.value;return typeof d==typeof g&&d<=g}],"filter-id-<=":[Ar,[dr],(s,[n])=>{const o=s.id(),d=n.value;return typeof o==typeof d&&o<=d}],"filter->=":[Ar,[cr,dr],(s,[n,o])=>{const d=s.properties()[n.value],g=o.value;return typeof d==typeof g&&d>=g}],"filter-id->=":[Ar,[dr],(s,[n])=>{const o=s.id(),d=n.value;return typeof o==typeof d&&o>=d}],"filter-has":[Ar,[dr],(s,[n])=>n.value in s.properties()],"filter-has-id":[Ar,[],s=>s.id()!==null&&s.id()!==void 0],"filter-type-in":[Ar,[qs(cr)],(s,[n])=>n.value.indexOf(s.geometryType())>=0],"filter-id-in":[Ar,[qs(dr)],(s,[n])=>n.value.indexOf(s.id())>=0],"filter-in-small":[Ar,[cr,qs(dr)],(s,[n,o])=>o.value.indexOf(s.properties()[n.value])>=0],"filter-in-large":[Ar,[cr,qs(dr)],(s,[n,o])=>function(d,g,v,E){for(;v<=E;){const L=v+E>>1;if(g[L]===d)return!0;g[L]>d?E=L-1:v=L+1}return!1}(s.properties()[n.value],o.value,0,o.value.length-1)],all:{type:Ar,overloads:[[[Ar,Ar],(s,[n,o])=>n.evaluate(s)&&o.evaluate(s)],[pn(Ar),(s,n)=>{for(const o of n)if(!o.evaluate(s))return!1;return!0}]]},any:{type:Ar,overloads:[[[Ar,Ar],(s,[n,o])=>n.evaluate(s)||o.evaluate(s)],[pn(Ar),(s,n)=>{for(const o of n)if(o.evaluate(s))return!0;return!1}]]},"!":[Ar,[Ar],(s,[n])=>!n.evaluate(s)],"is-supported-script":[Ar,[cr],(s,[n])=>{const o=s.globals&&s.globals.isSupportedScript;return!o||o(n.evaluate(s))}],upcase:[cr,[cr],(s,[n])=>n.evaluate(s).toUpperCase()],downcase:[cr,[cr],(s,[n])=>n.evaluate(s).toLowerCase()],concat:[cr,pn(dr),(s,n)=>n.map(o=>sc(o.evaluate(s))).join("")],"resolved-locale":[cr,[Ul],(s,[n])=>n.evaluate(s).resolvedLocale()]});var eh=sd;function Wl(s){return{result:"success",value:s}}function Os(s){return{result:"error",value:s}}function gl(s){return s["property-type"]==="data-driven"}function un(s){return!!s.expression&&s.expression.parameters.indexOf("zoom")>-1}function th(s){return!!s.expression&&s.expression.interpolated}function Ur(s){return s instanceof Number?"number":s instanceof String?"string":s instanceof Boolean?"boolean":Array.isArray(s)?"array":s===null?"null":typeof s}function gc(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function cA(s){return s}function Qh(s,n){const o=n.type==="color",d=s.stops&&typeof s.stops[0][0]=="object",g=d||!(d||s.property!==void 0),v=s.type||(th(n)?"exponential":"interval");if(o&&((s=sr({},s)).stops&&(s.stops=s.stops.map(V=>[V[0],ps.parse(V[1])])),s.default=ps.parse(s.default?s.default:n.default)),s.colorSpace&&s.colorSpace!=="rgb"&&!$c[s.colorSpace])throw new Error(`Unknown color space: ${s.colorSpace}`);let E,L,k;if(v==="exponential")E=Vh;else if(v==="interval")E=uA;else if(v==="categorical"){E=hA,L=Object.create(null);for(const V of s.stops)L[V[0]]=V[1];k=typeof s.stops[0][0]}else{if(v!=="identity")throw new Error(`Unknown function type "${v}"`);E=Hh}if(d){const V={},q=[];for(let _e=0;_e_e[0]),evaluate:({zoom:_e},Be)=>Vh({stops:se,base:s.base},n,_e).evaluate(_e,Be)}}if(g){const V=v==="exponential"?{name:"exponential",base:s.base!==void 0?s.base:1}:null;return{kind:"camera",interpolationType:V,interpolationFactor:Ho.interpolationFactor.bind(void 0,V),zoomStops:s.stops.map(q=>q[0]),evaluate:({zoom:q})=>E(s,n,q,L,k)}}return{kind:"source",evaluate(V,q){const se=q&&q.properties?q.properties[s.property]:void 0;return se===void 0?_c(s.default,n.default):E(s,n,se,L,k)}}}function _c(s,n,o){return s!==void 0?s:n!==void 0?n:o!==void 0?o:void 0}function hA(s,n,o,d,g){return _c(typeof o===g?d[o]:void 0,s.default,n.default)}function uA(s,n,o){if(Ur(o)!=="number")return _c(s.default,n.default);const d=s.stops.length;if(d===1||o<=s.stops[0][0])return s.stops[0][1];if(o>=s.stops[d-1][0])return s.stops[d-1][1];const g=jr(s.stops.map(v=>v[0]),o);return s.stops[g][1]}function Vh(s,n,o){const d=s.base!==void 0?s.base:1;if(Ur(o)!=="number")return _c(s.default,n.default);const g=s.stops.length;if(g===1||o<=s.stops[0][0])return s.stops[0][1];if(o>=s.stops[g-1][0])return s.stops[g-1][1];const v=jr(s.stops.map(q=>q[0]),o),E=function(q,se,he,_e){const Be=_e-he,Le=q-he;return Be===0?0:se===1?Le/Be:(Math.pow(se,Le)-1)/(Math.pow(se,Be)-1)}(o,d,s.stops[v][0],s.stops[v+1][0]),L=s.stops[v][1],k=s.stops[v+1][1];let V=xu[n.type]||cA;if(s.colorSpace&&s.colorSpace!=="rgb"){const q=$c[s.colorSpace];V=(se,he)=>q.reverse(q.interpolate(q.forward(se),q.forward(he),E))}return typeof L.evaluate=="function"?{evaluate(...q){const se=L.evaluate.apply(void 0,q),he=k.evaluate.apply(void 0,q);if(se!==void 0&&he!==void 0)return V(se,he,E)}}:V(L,k,E)}function Hh(s,n,o){return n.type==="color"?o=ps.parse(o):n.type==="formatted"?o=ks.fromString(o.toString()):n.type==="resolvedImage"?o=No.fromString(o.toString()):Ur(o)===n.type||n.type==="enum"&&n.values[o]||(o=void 0),_c(o,s.default,n.default)}class ih{constructor(n,o){this.expression=n,this._warningHistory={},this._evaluator=new mu,this._defaultValue=o?function(d){return d.type==="color"&&(gc(d.default)||Array.isArray(d.default))?new ps(0,0,0,0):d.type==="color"?ps.parse(d.default)||null:d.default===void 0?null:d.default}(o):null,this._enumValues=o&&o.type==="enum"?o.values:null}evaluateWithoutErrorHandling(n,o,d,g,v,E,L,k){return this._evaluator.globals=n,this._evaluator.feature=o,this._evaluator.featureState=d,this._evaluator.canonical=g||null,this._evaluator.availableImages=v||null,this._evaluator.formattedSection=E,this._evaluator.featureTileCoord=L||null,this._evaluator.featureDistanceData=k||null,this.expression.evaluate(this._evaluator)}evaluate(n,o,d,g,v,E,L,k){this._evaluator.globals=n,this._evaluator.feature=o||null,this._evaluator.featureState=d||null,this._evaluator.canonical=g||null,this._evaluator.availableImages=v||null,this._evaluator.formattedSection=E||null,this._evaluator.featureTileCoord=L||null,this._evaluator.featureDistanceData=k||null;try{const V=this.expression.evaluate(this._evaluator);if(V==null||typeof V=="number"&&V!=V)return this._defaultValue;if(this._enumValues&&!(V in this._enumValues))throw new er(`Expected value to be one of ${Object.keys(this._enumValues).map(q=>JSON.stringify(q)).join(", ")}, but found ${JSON.stringify(V)} instead.`);return V}catch(V){return this._warningHistory[V.message]||(this._warningHistory[V.message]=!0,typeof console<"u"&&console.warn(V.message)),this._defaultValue}}}function yc(s){return Array.isArray(s)&&s.length>0&&typeof s[0]=="string"&&s[0]in eh}function Ms(s,n){const o=new hr(eh,[],n?function(g){const v={color:aa,string:cr,number:rn,enum:cr,boolean:Ar,formatted:Rl,resolvedImage:ll};return g.type==="array"?qs(v[g.value]||dr,g.length):v[g.type]}(n):void 0),d=o.parse(s,void 0,void 0,void 0,n&&n.type==="string"?{typeAnnotation:"coerce"}:void 0);return d?Wl(new ih(d,n)):Os(o.errors)}class fo{constructor(n,o){this.kind=n,this._styleExpression=o,this.isStateDependent=n!=="constant"&&!Va(o.expression)}evaluateWithoutErrorHandling(n,o,d,g,v,E){return this._styleExpression.evaluateWithoutErrorHandling(n,o,d,g,v,E)}evaluate(n,o,d,g,v,E){return this._styleExpression.evaluate(n,o,d,g,v,E)}}class Gh{constructor(n,o,d,g){this.kind=n,this.zoomStops=d,this._styleExpression=o,this.isStateDependent=n!=="camera"&&!Va(o.expression),this.interpolationType=g}evaluateWithoutErrorHandling(n,o,d,g,v,E){return this._styleExpression.evaluateWithoutErrorHandling(n,o,d,g,v,E)}evaluate(n,o,d,g,v,E){return this._styleExpression.evaluate(n,o,d,g,v,E)}interpolationFactor(n,o,d){return this.interpolationType?Ho.interpolationFactor(this.interpolationType,n,o,d):0}}function jl(s,n){if((s=Ms(s,n)).result==="error")return s;const o=s.value.expression,d=Al(o);if(!d&&!gl(n))return Os([new Mr("","data expressions not supported")]);const g=Qc(o,["zoom","pitch","distance-from-center"]);if(!g&&!un(n))return Os([new Mr("","zoom expressions not supported")]);const v=_l(o);return v||g?v instanceof Mr?Os([v]):v instanceof Ho&&!th(n)?Os([new Mr("",'"interpolate" expressions cannot be used with this property')]):Wl(v?new Gh(d?"camera":"composite",s.value,v.labels,v instanceof Ho?v.interpolation:void 0):new fo(d?"constant":"source",s.value)):Os([new Mr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Kl{constructor(n,o){this._parameters=n,this._specification=o,sr(this,Qh(this._parameters,this._specification))}static deserialize(n){return new Kl(n._parameters,n._specification)}static serialize(n){return{_parameters:n._parameters,_specification:n._specification}}}function _l(s){let n=null;if(s instanceof wu)n=_l(s.result);else if(s instanceof vu){for(const o of s.args)if(n=_l(o),n)break}else(s instanceof Hl||s instanceof Ho)&&s.input instanceof ya&&s.input.name==="zoom"&&(n=s);return n instanceof Mr||s.eachChild(o=>{const d=_l(o);d instanceof Mr?n=d:!n&&d?n=new Mr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&d&&n!==d&&(n=new Mr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),n}class An{constructor(n,o,d,g){this.message=(n?`${n}: `:"")+d,g&&(this.identifier=g),o!=null&&o.__line__&&(this.line=o.__line__)}}function xs(s){const n=s.key,o=s.value,d=s.valueSpec||{},g=s.objectElementValidators||{},v=s.style,E=s.styleSpec;let L=[];const k=Ur(o);if(k!=="object")return[new An(n,o,`object expected, ${k} found`)];for(const V in o){const q=V.split(".")[0],se=d[q]||d["*"];let he;g[q]?he=g[q]:d[q]?he=Te:g["*"]?he=g["*"]:d["*"]&&(he=Te),he?L=L.concat(he({key:(n&&`${n}.`)+V,value:o[V],valueSpec:se,style:v,styleSpec:E,object:o,objectKey:V},o)):L.push(new An(n,o[V],`unknown property "${V}"`))}for(const V in d)g[V]||d[V].required&&d[V].default===void 0&&o[V]===void 0&&L.push(new An(n,o,`missing required property "${V}"`));return L}function Zr(s){const n=s.value,o=s.valueSpec,d=s.style,g=s.styleSpec,v=s.key,E=s.arrayElementValidator||Te;if(Ur(n)!=="array")return[new An(v,n,`array expected, ${Ur(n)} found`)];if(o.length&&n.length!==o.length)return[new An(v,n,`array length ${o.length} expected, length ${n.length} found`)];if(o["min-length"]&&n.lengthv)return[new An(n,o,`${o} is greater than the maximum value ${v}`)]}return[]}function Wh(s){const n=s.valueSpec,o=Yn(s.value.type);let d,g,v,E={};const L=o!=="categorical"&&s.value.property===void 0,k=!L,V=Ur(s.value.stops)==="array"&&Ur(s.value.stops[0])==="array"&&Ur(s.value.stops[0][0])==="object",q=xs({key:s.key,value:s.value,valueSpec:s.styleSpec.function,style:s.style,styleSpec:s.styleSpec,objectElementValidators:{stops:function(_e){if(o==="identity")return[new An(_e.key,_e.value,'identity function may not have a "stops" property')];let Be=[];const Le=_e.value;return Be=Be.concat(Zr({key:_e.key,value:Le,valueSpec:_e.valueSpec,style:_e.style,styleSpec:_e.styleSpec,arrayElementValidator:se})),Ur(Le)==="array"&&Le.length===0&&Be.push(new An(_e.key,Le,"array must have at least one stop")),Be},default:function(_e){return Te({key:_e.key,value:_e.value,valueSpec:n,style:_e.style,styleSpec:_e.styleSpec})}}});return o==="identity"&&L&&q.push(new An(s.key,s.value,'missing required property "property"')),o==="identity"||s.value.stops||q.push(new An(s.key,s.value,'missing required property "stops"')),o==="exponential"&&s.valueSpec.expression&&!th(s.valueSpec)&&q.push(new An(s.key,s.value,"exponential functions not supported")),s.styleSpec.$version>=8&&(k&&!gl(s.valueSpec)?q.push(new An(s.key,s.value,"property functions not supported")):L&&!un(s.valueSpec)&&q.push(new An(s.key,s.value,"zoom functions not supported"))),o!=="categorical"&&!V||s.value.property!==void 0||q.push(new An(s.key,s.value,'"property" property is required')),q;function se(_e){let Be=[];const Le=_e.value,Xe=_e.key;if(Ur(Le)!=="array")return[new An(Xe,Le,`array expected, ${Ur(Le)} found`)];if(Le.length!==2)return[new An(Xe,Le,`array length 2 expected, length ${Le.length} found`)];if(V){if(Ur(Le[0])!=="object")return[new An(Xe,Le,`object expected, ${Ur(Le[0])} found`)];if(Le[0].zoom===void 0)return[new An(Xe,Le,"object stop key must have zoom")];if(Le[0].value===void 0)return[new An(Xe,Le,"object stop key must have value")];const xt=Yn(Le[0].zoom);if(typeof xt!="number")return[new An(Xe,Le[0].zoom,"stop zoom values must be numbers")];if(v&&v>xt)return[new An(Xe,Le[0].zoom,"stop zoom values must appear in ascending order")];xt!==v&&(v=xt,g=void 0,E={}),Be=Be.concat(xs({key:`${Xe}[0]`,value:Le[0],valueSpec:{zoom:{}},style:_e.style,styleSpec:_e.styleSpec,objectElementValidators:{zoom:nh,value:he}}))}else Be=Be.concat(he({key:`${Xe}[0]`,value:Le[0],valueSpec:{},style:_e.style,styleSpec:_e.styleSpec},Le));return yc(Wr(Le[1]))?Be.concat([new An(`${Xe}[1]`,Le[1],"expressions are not allowed in function stops.")]):Be.concat(Te({key:`${Xe}[1]`,value:Le[1],valueSpec:n,style:_e.style,styleSpec:_e.styleSpec}))}function he(_e,Be){const Le=Ur(_e.value),Xe=Yn(_e.value),xt=_e.value!==null?_e.value:Be;if(d){if(Le!==d)return[new An(_e.key,xt,`${Le} stop domain type must match previous stop domain type ${d}`)]}else d=Le;if(Le!=="number"&&Le!=="string"&&Le!=="boolean"&&typeof Xe!="number"&&typeof Xe!="string"&&typeof Xe!="boolean")return[new An(_e.key,xt,"stop domain value must be a number, string, or boolean")];if(Le!=="number"&&o!=="categorical"){let Dt=`number expected, ${Le} found`;return gl(n)&&o===void 0&&(Dt+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new An(_e.key,xt,Dt)]}return o!=="categorical"||Le!=="number"||typeof Xe=="number"&&isFinite(Xe)&&Math.floor(Xe)===Xe?o!=="categorical"&&Le==="number"&&typeof Xe=="number"&&typeof g=="number"&&g!==void 0&&Xenew An(`${s.key}${d.key}`,s.value,d.message));const o=n.value.expression||n.value._styleExpression.expression;if(s.expressionContext==="property"&&s.propertyKey==="text-font"&&!o.outputDefined())return[new An(s.key,s.value,`Invalid data expression for "${s.propertyKey}". Output values must be contained as literals within the expression.`)];if(s.expressionContext==="property"&&s.propertyType==="layout"&&!Va(o))return[new An(s.key,s.value,'"feature-state" data expressions are not supported with layout properties.')];if(s.expressionContext==="filter")return AA(o,s);if(s.expressionContext&&s.expressionContext.indexOf("cluster")===0){if(!Qc(o,["zoom","feature-state"]))return[new An(s.key,s.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(s.expressionContext==="cluster-initial"&&!Al(o))return[new An(s.key,s.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function AA(s,n){const o=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(n.valueSpec&&n.valueSpec.expression)for(const g of n.valueSpec.expression.parameters)o.delete(g);if(o.size===0)return[];const d=[];return s instanceof ya&&o.has(s.name)?[new An(n.key,n.value,`["${s.name}"] expression is not supported in a filter for a ${n.object.type} layer with id: ${n.object.id}`)]:(s.eachChild(g=>{d.push(...AA(g,n))}),d)}function jh(s){const n=s.key,o=s.value,d=s.valueSpec,g=[];return Array.isArray(d.values)?d.values.indexOf(Yn(o))===-1&&g.push(new An(n,o,`expected one of [${d.values.join(", ")}], ${JSON.stringify(o)} found`)):Object.keys(d.values).indexOf(Yn(o))===-1&&g.push(new An(n,o,`expected one of [${Object.keys(d.values).join(", ")}], ${JSON.stringify(o)} found`)),g}function rh(s){if(s===!0||s===!1)return!0;if(!Array.isArray(s)||s.length===0)return!1;switch(s[0]){case"has":return s.length>=2&&s[1]!=="$id"&&s[1]!=="$type";case"in":return s.length>=3&&(typeof s[1]!="string"||Array.isArray(s[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return s.length!==3||Array.isArray(s[1])||Array.isArray(s[2]);case"any":case"all":for(const n of s.slice(1))if(!rh(n)&&typeof n!="boolean")return!1;return!0;default:return!0}}function uo(s,n="fill"){if(s==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};rh(s)||(s=Cs(s));const o=s;let d=!0;try{d=function(V){if(!Vn(V))return V;let q=Wr(V);return Fn(q),q=Js(q),q}(o)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md and paste the contents of this message in the report. Thank you! Filter Expression: ${JSON.stringify(o,null,2)} `)}const g=Yt[`filter_${n}`],v=Ms(d,g);let E=null;if(v.result==="error")throw new Error(v.value.map(V=>`${V.key}: ${V.message}`).join(", "));E=(V,q,se)=>v.value.evaluate(V,q,{},se);let L=null,k=null;if(d!==o){const V=Ms(o,g);if(V.result==="error")throw new Error(V.value.map(q=>`${q.key}: ${q.message}`).join(", "));L=(q,se,he,_e,Be)=>V.value.evaluate(q,se,{},he,void 0,void 0,_e,Be),k=!Al(V.value.expression)}return{filter:E,dynamicFilter:L||void 0,needGeometry:yl(d),needFeature:!!k}}function Js(s){if(!Array.isArray(s))return s;const n=function(o){if(sh.has(o[0])){for(let d=1;dJs(o))}function Fn(s){let n=!1;const o=[];if(s[0]==="case"){for(let d=1;d",">=","<","<=","to-boolean"]);function dA(s,n){return sn?1:0}function yl(s){if(!Array.isArray(s))return!1;if(s[0]==="within")return!0;for(let n=1;n"||n==="<="||n===">="?Ga(s[1],s[2],n):n==="any"?(o=s.slice(1),["any"].concat(o.map(Cs))):n==="all"?["all"].concat(s.slice(1).map(Cs)):n==="none"?["all"].concat(s.slice(1).map(Cs).map(va)):n==="in"?Go(s[1],s.slice(2)):n==="!in"?va(Go(s[1],s.slice(2))):n==="has"?pA(s[1]):n==="!has"?va(pA(s[1])):n!=="within"||s;var o}function Ga(s,n,o){switch(s){case"$type":return[`filter-type-${o}`,n];case"$id":return[`filter-id-${o}`,n];default:return[`filter-${o}`,s,n]}}function Go(s,n){if(n.length===0)return!1;switch(s){case"$type":return["filter-type-in",["literal",n]];case"$id":return["filter-id-in",["literal",n]];default:return n.length>200&&!n.some(o=>typeof o!=typeof n[0])?["filter-in-large",s,["literal",n.sort(dA)]]:["filter-in-small",s,["literal",n]]}}function pA(s){switch(s){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",s]}}function va(s){return["!",s]}function hs(s){return rh(Wr(s.value))?xc(sr({},s,{expressionContext:"filter",valueSpec:s.styleSpec[`filter_${s.layerType||"fill"}`]})):Is(s)}function Is(s){const n=s.value,o=s.key;if(Ur(n)!=="array")return[new An(o,n,`array expected, ${Ur(n)} found`)];const d=s.styleSpec;let g,v=[];if(n.length<1)return[new An(o,n,"filter array must have at least 1 element")];switch(v=v.concat(jh({key:`${o}[0]`,value:n[0],valueSpec:d.filter_operator,style:s.style,styleSpec:s.styleSpec})),Yn(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&Yn(n[1])==="$type"&&v.push(new An(o,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":n.length!==3&&v.push(new An(o,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&(g=Ur(n[1]),g!=="string"&&v.push(new An(`${o}[1]`,n[1],`string expected, ${g} found`)));for(let E=2;E{V in o&&n.push(new An(d,o[V],`"${V}" is prohibited for ref layers`))}),g.layers.forEach(V=>{Yn(V.id)===L&&(k=V)}),k?k.ref?n.push(new An(d,o.ref,"ref cannot reference another ref layer")):E=Yn(k.type):typeof L=="string"&&n.push(new An(d,o.ref,`ref layer "${L}" not found`))}else if(E!=="background"&&E!=="sky")if(o.source){const k=g.sources&&g.sources[o.source],V=k&&Yn(k.type);k?V==="vector"&&E==="raster"?n.push(new An(d,o.source,`layer "${o.id}" requires a raster source`)):V==="raster"&&E!=="raster"?n.push(new An(d,o.source,`layer "${o.id}" requires a vector source`)):V!=="vector"||o["source-layer"]?V==="raster-dem"&&E!=="hillshade"?n.push(new An(d,o.source,"raster-dem source can only be used with layer type 'hillshade'.")):E!=="line"||!o.paint||!o.paint["line-gradient"]&&!o.paint["line-trim-offset"]||V==="geojson"&&k.lineMetrics||n.push(new An(d,o,`layer "${o.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):n.push(new An(d,o,`layer "${o.id}" must specify a "source-layer"`)):n.push(new An(d,o.source,`source "${o.source}" not found`))}else n.push(new An(d,o,'missing required property "source"'));return n=n.concat(xs({key:d,value:o,valueSpec:v.layer,style:s.style,styleSpec:s.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Te({key:`${d}.type`,value:o.type,valueSpec:v.layer.type,style:s.style,styleSpec:s.styleSpec,object:o,objectKey:"type"}),filter:k=>hs(sr({layerType:E},k)),layout:k=>xs({layer:o,key:k.key,value:k.value,valueSpec:{},style:k.style,styleSpec:k.styleSpec,objectElementValidators:{"*":V=>M(sr({layerType:E},V))}}),paint:k=>xs({layer:o,key:k.key,value:k.value,valueSpec:{},style:k.style,styleSpec:k.styleSpec,objectElementValidators:{"*":V=>xl(sr({layerType:E},V))}})}})),n}function _(s){const n=s.value,o=s.key,d=Ur(n);return d!=="string"?[new An(o,n,`string expected, ${d} found`)]:[]}const T={promoteId:function({key:s,value:n}){if(Ur(n)==="string")return _({key:s,value:n});{const o=[];for(const d in n)o.push(..._({key:`${s}.${d}`,value:n[d]}));return o}}};function F(s){const n=s.value,o=s.key,d=s.styleSpec,g=s.style;if(!n.type)return[new An(o,n,'"type" is required')];const v=Yn(n.type);let E;switch(v){case"vector":case"raster":case"raster-dem":return E=xs({key:o,value:n,valueSpec:d[`source_${v.replace("-","_")}`],style:s.style,styleSpec:d,objectElementValidators:T}),E;case"geojson":if(E=xs({key:o,value:n,valueSpec:d.source_geojson,style:g,styleSpec:d,objectElementValidators:T}),n.cluster)for(const L in n.clusterProperties){const[k,V]=n.clusterProperties[L],q=typeof k=="string"?[k,["accumulated"],["get",L]]:k;E.push(...xc({key:`${o}.${L}.map`,value:V,expressionContext:"cluster-map"})),E.push(...xc({key:`${o}.${L}.reduce`,value:q,expressionContext:"cluster-reduce"}))}return E;case"video":return xs({key:o,value:n,valueSpec:d.source_video,style:g,styleSpec:d});case"image":return xs({key:o,value:n,valueSpec:d.source_image,style:g,styleSpec:d});case"canvas":return[new An(o,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return jh({key:`${o}.type`,value:n.type,valueSpec:{values:O(d)},style:g,styleSpec:d})}}function O(s){return s.source.reduce((n,o)=>{const d=s[o];return d.type.type==="enum"&&(n=n.concat(Object.keys(d.type.values))),n},[])}function K(s){const n=s.value,o=s.styleSpec,d=o.light,g=s.style;let v=[];const E=Ur(n);if(n===void 0)return v;if(E!=="object")return v=v.concat([new An("light",n,`object expected, ${E} found`)]),v;for(const L in n){const k=L.match(/^(.*)-transition$/);v=v.concat(k&&d[k[1]]&&d[k[1]].transition?Te({key:L,value:n[L],valueSpec:o.transition,style:g,styleSpec:o}):d[L]?Te({key:L,value:n[L],valueSpec:d[L],style:g,styleSpec:o}):[new An(L,n[L],`unknown property "${L}"`)])}return v}function oe(s){const n=s.value,o=s.key,d=s.style,g=s.styleSpec,v=g.terrain;let E=[];const L=Ur(n);if(n===void 0)return E;if(L!=="object")return E=E.concat([new An("terrain",n,`object expected, ${L} found`)]),E;for(const k in n){const V=k.match(/^(.*)-transition$/);E=E.concat(V&&v[V[1]]&&v[V[1]].transition?Te({key:k,value:n[k],valueSpec:g.transition,style:d,styleSpec:g}):v[k]?Te({key:k,value:n[k],valueSpec:v[k],style:d,styleSpec:g}):[new An(k,n[k],`unknown property "${k}"`)])}if(n.source){const k=d.sources&&d.sources[n.source],V=k&&Yn(k.type);k?V!=="raster-dem"&&E.push(new An(o,n.source,`terrain cannot be used with a source of type ${String(V)}, it only be used with a "raster-dem" source type`)):E.push(new An(o,n.source,`source "${n.source}" not found`))}else E.push(new An(o,n,'terrain is missing required property "source"'));return E}function ue(s){const n=s.value,o=s.style,d=s.styleSpec,g=d.fog;let v=[];const E=Ur(n);if(n===void 0)return v;if(E!=="object")return v=v.concat([new An("fog",n,`object expected, ${E} found`)]),v;for(const L in n){const k=L.match(/^(.*)-transition$/);v=v.concat(k&&g[k[1]]&&g[k[1]].transition?Te({key:L,value:n[L],valueSpec:d.transition,style:o,styleSpec:d}):g[L]?Te({key:L,value:n[L],valueSpec:g[L],style:o,styleSpec:d}):[new An(L,n[L],`unknown property "${L}"`)])}return v}const ve={"*":()=>[],array:Zr,boolean:function(s){const n=s.value,o=s.key,d=Ur(n);return d!=="boolean"?[new An(o,n,`boolean expected, ${d} found`)]:[]},number:nh,color:function(s){const n=s.key,o=s.value,d=Ur(o);return d!=="string"?[new An(n,o,`color expected, ${d} found`)]:kl(o)===null?[new An(n,o,`color expected, "${o}" found`)]:[]},enum:jh,filter:hs,function:Wh,layer:h,object:xs,source:F,light:K,terrain:oe,fog:ue,string:_,formatted:function(s){return _(s).length===0?[]:xc(s)},resolvedImage:function(s){return _(s).length===0?[]:xc(s)},projection:function(s){const n=s.value,o=s.styleSpec,d=o.projection,g=s.style;let v=[];const E=Ur(n);if(E==="object")for(const L in n)v=v.concat(Te({key:L,value:n[L],valueSpec:d[L],style:g,styleSpec:o}));else E!=="string"&&(v=v.concat([new An("projection",n,`object or string expected, ${E} found`)]));return v}};function Te(s){const n=s.value,o=s.valueSpec,d=s.styleSpec;return o.expression&&gc(Yn(n))?Wh(s):o.expression&&yc(Wr(n))?xc(s):o.type&&ve[o.type]?ve[o.type](s):xs(sr({},s,{valueSpec:o.type?d[o.type]:o}))}function ze(s){const n=s.value,o=s.key,d=_(s);return d.length||(n.indexOf("{fontstack}")===-1&&d.push(new An(o,n,'"glyphs" url must include a "{fontstack}" token')),n.indexOf("{range}")===-1&&d.push(new An(o,n,'"glyphs" url must include a "{range}" token'))),d}function je(s,n=Yt){return gt(Te({key:"",value:s,valueSpec:n.$root,styleSpec:n,style:s,objectElementValidators:{glyphs:ze,"*":()=>[]}}))}const bt=s=>gt(xl(s)),mt=s=>gt(M(s));function gt(s){return s.slice().sort((n,o)=>n.line&&o.line?n.line-o.line:0)}function Vt(s,n){let o=!1;if(n&&n.length)for(const d of n)s.fire(new rr(new Error(d.message))),o=!0;return o}var Zt=ni;function ni(s,n,o){var d=this.cells=[];if(s instanceof ArrayBuffer){this.arrayBuffer=s;var g=new Int32Array(this.arrayBuffer);s=g[0],this.d=(n=g[1])+2*(o=g[2]);for(var v=0;v=q[_e+0]&&d>=q[_e+1])?(E[he]=!0,v.push(V[he])):E[he]=!1}}},ni.prototype._forEachCell=function(s,n,o,d,g,v,E,L){for(var k=this._convertToCellCoord(s),V=this._convertToCellCoord(n),q=this._convertToCellCoord(o),se=this._convertToCellCoord(d),he=k;he<=q;he++)for(var _e=V;_e<=se;_e++){var Be=this.d*_e+he;if((!L||L(this._convertFromCellCoord(he),this._convertFromCellCoord(_e),this._convertFromCellCoord(he+1),this._convertFromCellCoord(_e+1)))&&g.call(this,s,n,o,d,Be,v,E,L))return}},ni.prototype._convertFromCellCoord=function(s){return(s-this.padding)/this.scale},ni.prototype._convertToCellCoord=function(s){return Math.max(0,Math.min(this.d-1,Math.floor(s*this.scale)+this.padding))},ni.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var s=this.cells,n=3+this.cells.length+1+1,o=0,d=0;d=0||(g[v]=Bi(s[v],n)));s instanceof Error&&(g.message=s.message)}if(g.$name)throw new Error("$name property is reserved for worker serialization logic.");return d!=="Object"&&(g.$name=d),g}throw new Error("can't serialize object of type "+typeof s)}function Hi(s){if(s==null||typeof s=="boolean"||typeof s=="number"||typeof s=="string"||s instanceof Boolean||s instanceof Number||s instanceof String||s instanceof Date||s instanceof RegExp||ai(s)||Ei(s)||ArrayBuffer.isView(s)||s instanceof C.ImageData)return s;if(Array.isArray(s))return s.map(Hi);if(typeof s=="object"){const n=s.$name||"Object",{klass:o}=St[n];if(!o)throw new Error(`can't deserialize unregistered class ${n}`);if(o.deserialize)return o.deserialize(s);const d=Object.create(o.prototype);for(const g of Object.keys(s))g!=="$name"&&(d[g]=Hi(s[g]));return d}throw new Error("can't deserialize object of type "+typeof s)}const vi=s=>s>=1536&&s<=1791,xn=s=>s>=1872&&s<=1919,cn=s=>s>=2208&&s<=2303,Bn=s=>s>=11904&&s<=12031,tr=s=>s>=12032&&s<=12255,ur=s=>s>=12272&&s<=12287,Un=s=>s>=12288&&s<=12351,Lr=s=>s>=12352&&s<=12447,Rr=s=>s>=12448&&s<=12543,Cr=s=>s>=12544&&s<=12591,Er=s=>s>=12704&&s<=12735,Gr=s=>s>=12736&&s<=12783,js=s=>s>=12784&&s<=12799,wa=s=>s>=12800&&s<=13055,ua=s=>s>=13056&&s<=13311,ba=s=>s>=13312&&s<=19903,Wa=s=>s>=19968&&s<=40959,Wo=s=>s>=40960&&s<=42127,mo=s=>s>=42128&&s<=42191,Ba=s=>s>=44032&&s<=55215,$l=s=>s>=63744&&s<=64255,x=s=>s>=64336&&s<=65023,a=s=>s>=65040&&s<=65055,m=s=>s>=65072&&s<=65103,b=s=>s>=65104&&s<=65135,S=s=>s>=65136&&s<=65279,P=s=>s>=65280&&s<=65519;function H(s){for(const n of s)if(pe(n.charCodeAt(0)))return!0;return!1}function W(s){for(const n of s)if(!ee(n.charCodeAt(0)))return!1;return!0}function ee(s){return!(vi(s)||xn(s)||cn(s)||x(s)||S(s))}function pe(s){return!(s!==746&&s!==747&&(s<4352||!(Er(s)||Cr(s)||m(s)&&!(s>=65097&&s<=65103)||$l(s)||ua(s)||Bn(s)||Gr(s)||!(!Un(s)||s>=12296&&s<=12305||s>=12308&&s<=12319||s===12336)||ba(s)||Wa(s)||wa(s)||(n=>n>=12592&&n<=12687)(s)||(n=>n>=43360&&n<=43391)(s)||(n=>n>=55216&&n<=55295)(s)||(n=>n>=4352&&n<=4607)(s)||Ba(s)||Lr(s)||ur(s)||(n=>n>=12688&&n<=12703)(s)||tr(s)||js(s)||Rr(s)&&s!==12540||!(!P(s)||s===65288||s===65289||s===65293||s>=65306&&s<=65310||s===65339||s===65341||s===65343||s>=65371&&s<=65503||s===65507||s>=65512&&s<=65519)||!(!b(s)||s>=65112&&s<=65118||s>=65123&&s<=65126)||(n=>n>=5120&&n<=5759)(s)||(n=>n>=6320&&n<=6399)(s)||a(s)||(n=>n>=19904&&n<=19967)(s)||Wo(s)||mo(s))))}function fe(s){return!(pe(s)||function(n){return!!((o=>o>=128&&o<=255)(n)&&(n===167||n===169||n===174||n===177||n===188||n===189||n===190||n===215||n===247)||(o=>o>=8192&&o<=8303)(n)&&(n===8214||n===8224||n===8225||n===8240||n===8241||n===8251||n===8252||n===8258||n===8263||n===8264||n===8265||n===8273)||(o=>o>=8448&&o<=8527)(n)||(o=>o>=8528&&o<=8591)(n)||(o=>o>=8960&&o<=9215)(n)&&(n>=8960&&n<=8967||n>=8972&&n<=8991||n>=8996&&n<=9e3||n===9003||n>=9085&&n<=9114||n>=9150&&n<=9165||n===9167||n>=9169&&n<=9179||n>=9186&&n<=9215)||(o=>o>=9216&&o<=9279)(n)&&n!==9251||(o=>o>=9280&&o<=9311)(n)||(o=>o>=9312&&o<=9471)(n)||(o=>o>=9632&&o<=9727)(n)||(o=>o>=9728&&o<=9983)(n)&&!(n>=9754&&n<=9759)||(o=>o>=11008&&o<=11263)(n)&&(n>=11026&&n<=11055||n>=11088&&n<=11097||n>=11192&&n<=11243)||Un(n)||Rr(n)||(o=>o>=57344&&o<=63743)(n)||m(n)||b(n)||P(n)||n===8734||n===8756||n===8757||n>=9984&&n<=10087||n>=10102&&n<=10131||n===65532||n===65533)}(s))}function Me(s){return s>=1424&&s<=2303||x(s)||S(s)}function Ne(s,n){return!(!n&&Me(s)||s>=2304&&s<=3583||s>=3840&&s<=4255||(o=>o>=6016&&o<=6143)(s))}function st(s){for(const n of s)if(Me(n.charCodeAt(0)))return!0;return!1}const it="deferred",lt="loading",qe="loaded";let Ye=null,dt="unavailable",ht=null;const Bt=function(s){s&&typeof s=="string"&&s.indexOf("NetworkError")>-1&&(dt="error"),Ye&&Ye(s)};function Pt(){It.fire(new tn("pluginStateChange",{pluginStatus:dt,pluginURL:ht}))}const It=new yn,Ht=function(){return dt},hi=function(){if(dt!==it||!ht)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");dt=lt,Pt(),ht&&Cn({url:ht},s=>{s?Bt(s):(dt=qe,Pt())})},si={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>dt===qe||si.applyArabicShaping!=null,isLoading:()=>dt===lt,setState(s){dt=s.pluginStatus,ht=s.pluginURL},isParsed:()=>si.applyArabicShaping!=null&&si.processBidirectionalText!=null&&si.processStyledBidirectionalText!=null,getPluginURL:()=>ht};class qt{constructor(n,o){this.zoom=n,o?(this.now=o.now,this.fadeDuration=o.fadeDuration,this.transition=o.transition,this.pitch=o.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(n){return function(o,d){for(const g of o)if(!Ne(g.charCodeAt(0),d))return!1;return!0}(n,si.isLoaded())}}class ji{constructor(n,o){this.property=n,this.value=o,this.expression=function(d,g){if(gc(d))return new Kl(d,g);if(yc(d)){const v=jl(d,g);if(v.result==="error")throw new Error(v.value.map(E=>`${E.key}: ${E.message}`).join(", "));return v.value}{let v=d;return typeof d=="string"&&g.type==="color"&&(v=ps.parse(d)),{kind:"constant",evaluate:()=>v}}}(o===void 0?n.specification.default:o,n.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(n,o,d){return this.property.possiblyEvaluate(this,n,o,d)}}class Kt{constructor(n){this.property=n,this.value=new ji(n,void 0)}transitioned(n,o){return new di(this.property,this.value,o,Ve({},n.transition,this.transition),n.now)}untransitioned(){return new di(this.property,this.value,null,{},0)}}class Ci{constructor(n){this._properties=n,this._values=Object.create(n.defaultTransitionablePropertyValues)}getValue(n){return Gt(this._values[n].value.value)}setValue(n,o){this._values.hasOwnProperty(n)||(this._values[n]=new Kt(this._values[n].property)),this._values[n].value=new ji(this._values[n].property,o===null?void 0:Gt(o))}getTransition(n){return Gt(this._values[n].transition)}setTransition(n,o){this._values.hasOwnProperty(n)||(this._values[n]=new Kt(this._values[n].property)),this._values[n].transition=Gt(o)||void 0}serialize(){const n={};for(const o of Object.keys(this._values)){const d=this.getValue(o);d!==void 0&&(n[o]=d);const g=this.getTransition(o);g!==void 0&&(n[`${o}-transition`]=g)}return n}transitioned(n,o){const d=new Ri(this._properties);for(const g of Object.keys(this._values))d._values[g]=this._values[g].transitioned(n,o._values[g]);return d}untransitioned(){const n=new Ri(this._properties);for(const o of Object.keys(this._values))n._values[o]=this._values[o].untransitioned();return n}}class di{constructor(n,o,d,g,v){const E=g.delay||0,L=g.duration||0;v=v||0,this.property=n,this.value=o,this.begin=v+E,this.end=this.begin+L,n.specification.transition&&(g.delay||g.duration)&&(this.prior=d)}possiblyEvaluate(n,o,d){const g=n.now||0,v=this.value.possiblyEvaluate(n,o,d),E=this.prior;if(E){if(g>this.end)return this.prior=null,v;if(this.value.isDataDriven())return this.prior=null,v;if(gthis.capacity){this.capacity=Math.max(n,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const o=this.uint8;this._refreshViews(),o&&this.uint8.set(o)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function _n(s,n=1){let o=0,d=0;return{members:s.map(g=>{const v=$n[g.type].BYTES_PER_ELEMENT,E=o=Dr(o,Math.max(n,v)),L=g.components||1;return d=Math.max(d,v),o+=v*L,{name:g.name,type:g.type,components:L,offset:E}}),size:Dr(o,Math.max(d,n)),alignment:n}}function Dr(s,n){return Math.ceil(s/n)*n}class Or extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o){const d=this.length;return this.resize(d+1),this.emplace(d,n,o)}emplace(n,o,d){const g=2*n;return this.int16[g+0]=o,this.int16[g+1]=d,n}}Or.prototype.bytesPerElement=4,zt(Or,"StructArrayLayout2i4");class Nr extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d){const g=this.length;return this.resize(g+1),this.emplace(g,n,o,d)}emplace(n,o,d,g){const v=3*n;return this.int16[v+0]=o,this.int16[v+1]=d,this.int16[v+2]=g,n}}Nr.prototype.bytesPerElement=6,zt(Nr,"StructArrayLayout3i6");class Qr extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=4*n;return this.int16[E+0]=o,this.int16[E+1]=d,this.int16[E+2]=g,this.int16[E+3]=v,n}}Qr.prototype.bytesPerElement=8,zt(Qr,"StructArrayLayout4i8");class go extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E,L){const k=this.length;return this.resize(k+1),this.emplace(k,n,o,d,g,v,E,L)}emplace(n,o,d,g,v,E,L,k){const V=6*n,q=12*n,se=3*n;return this.int16[V+0]=o,this.int16[V+1]=d,this.uint8[q+4]=g,this.uint8[q+5]=v,this.uint8[q+6]=E,this.uint8[q+7]=L,this.float32[se+2]=k,n}}go.prototype.bytesPerElement=12,zt(go,"StructArrayLayout2i4ub1f12");class Ca extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=4*n;return this.float32[E+0]=o,this.float32[E+1]=d,this.float32[E+2]=g,this.float32[E+3]=v,n}}Ca.prototype.bytesPerElement=16,zt(Ca,"StructArrayLayout4f16");class jo extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v){const E=this.length;return this.resize(E+1),this.emplace(E,n,o,d,g,v)}emplace(n,o,d,g,v,E){const L=6*n,k=3*n;return this.uint16[L+0]=o,this.uint16[L+1]=d,this.uint16[L+2]=g,this.uint16[L+3]=v,this.float32[k+2]=E,n}}jo.prototype.bytesPerElement=12,zt(jo,"StructArrayLayout4ui1f12");class vs extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=4*n;return this.uint16[E+0]=o,this.uint16[E+1]=d,this.uint16[E+2]=g,this.uint16[E+3]=v,n}}vs.prototype.bytesPerElement=8,zt(vs,"StructArrayLayout4ui8");class _r extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E){const L=this.length;return this.resize(L+1),this.emplace(L,n,o,d,g,v,E)}emplace(n,o,d,g,v,E,L){const k=6*n;return this.int16[k+0]=o,this.int16[k+1]=d,this.int16[k+2]=g,this.int16[k+3]=v,this.int16[k+4]=E,this.int16[k+5]=L,n}}_r.prototype.bytesPerElement=12,zt(_r,"StructArrayLayout6i12");class Xr extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E,L,k,V,q,se,he){const _e=this.length;return this.resize(_e+1),this.emplace(_e,n,o,d,g,v,E,L,k,V,q,se,he)}emplace(n,o,d,g,v,E,L,k,V,q,se,he,_e){const Be=12*n;return this.int16[Be+0]=o,this.int16[Be+1]=d,this.int16[Be+2]=g,this.int16[Be+3]=v,this.uint16[Be+4]=E,this.uint16[Be+5]=L,this.uint16[Be+6]=k,this.uint16[Be+7]=V,this.int16[Be+8]=q,this.int16[Be+9]=se,this.int16[Be+10]=he,this.int16[Be+11]=_e,n}}Xr.prototype.bytesPerElement=24,zt(Xr,"StructArrayLayout4i4ui4i24");class Fr extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E){const L=this.length;return this.resize(L+1),this.emplace(L,n,o,d,g,v,E)}emplace(n,o,d,g,v,E,L){const k=10*n,V=5*n;return this.int16[k+0]=o,this.int16[k+1]=d,this.int16[k+2]=g,this.float32[V+2]=v,this.float32[V+3]=E,this.float32[V+4]=L,n}}Fr.prototype.bytesPerElement=20,zt(Fr,"StructArrayLayout3i3f20");class Fs extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(n){const o=this.length;return this.resize(o+1),this.emplace(o,n)}emplace(n,o){return this.uint32[1*n+0]=o,n}}Fs.prototype.bytesPerElement=4,zt(Fs,"StructArrayLayout1ul4");class eo extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E,L,k,V,q,se,he,_e){const Be=this.length;return this.resize(Be+1),this.emplace(Be,n,o,d,g,v,E,L,k,V,q,se,he,_e)}emplace(n,o,d,g,v,E,L,k,V,q,se,he,_e,Be){const Le=20*n,Xe=10*n;return this.int16[Le+0]=o,this.int16[Le+1]=d,this.int16[Le+2]=g,this.int16[Le+3]=v,this.int16[Le+4]=E,this.float32[Xe+3]=L,this.float32[Xe+4]=k,this.float32[Xe+5]=V,this.float32[Xe+6]=q,this.int16[Le+14]=se,this.uint32[Xe+8]=he,this.uint16[Le+18]=_e,this.uint16[Le+19]=Be,n}}eo.prototype.bytesPerElement=40,zt(eo,"StructArrayLayout5i4f1i1ul2ui40");class ns extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E,L){const k=this.length;return this.resize(k+1),this.emplace(k,n,o,d,g,v,E,L)}emplace(n,o,d,g,v,E,L,k){const V=8*n;return this.int16[V+0]=o,this.int16[V+1]=d,this.int16[V+2]=g,this.int16[V+4]=v,this.int16[V+5]=E,this.int16[V+6]=L,this.int16[V+7]=k,n}}ns.prototype.bytesPerElement=16,zt(ns,"StructArrayLayout3i2i2i16");class Io extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v){const E=this.length;return this.resize(E+1),this.emplace(E,n,o,d,g,v)}emplace(n,o,d,g,v,E){const L=4*n,k=8*n;return this.float32[L+0]=o,this.float32[L+1]=d,this.float32[L+2]=g,this.int16[k+6]=v,this.int16[k+7]=E,n}}Io.prototype.bytesPerElement=16,zt(Io,"StructArrayLayout2f1f2i16");class Bu extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=12*n,L=3*n;return this.uint8[E+0]=o,this.uint8[E+1]=d,this.float32[L+1]=g,this.float32[L+2]=v,n}}Bu.prototype.bytesPerElement=12,zt(Bu,"StructArrayLayout2ub2f12");class ja extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d){const g=this.length;return this.resize(g+1),this.emplace(g,n,o,d)}emplace(n,o,d,g){const v=3*n;return this.float32[v+0]=o,this.float32[v+1]=d,this.float32[v+2]=g,n}}ja.prototype.bytesPerElement=12,zt(ja,"StructArrayLayout3f12");class _o extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o,d){const g=this.length;return this.resize(g+1),this.emplace(g,n,o,d)}emplace(n,o,d,g){const v=3*n;return this.uint16[v+0]=o,this.uint16[v+1]=d,this.uint16[v+2]=g,n}}_o.prototype.bytesPerElement=6,zt(_o,"StructArrayLayout3ui6");class Ea extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E,L,k,V,q,se,he,_e,Be,Le,Xe,xt,Dt,_t,Tt,kt){const Ut=this.length;return this.resize(Ut+1),this.emplace(Ut,n,o,d,g,v,E,L,k,V,q,se,he,_e,Be,Le,Xe,xt,Dt,_t,Tt,kt)}emplace(n,o,d,g,v,E,L,k,V,q,se,he,_e,Be,Le,Xe,xt,Dt,_t,Tt,kt,Ut){const ci=30*n,oi=15*n,Ti=60*n;return this.int16[ci+0]=o,this.int16[ci+1]=d,this.int16[ci+2]=g,this.float32[oi+2]=v,this.float32[oi+3]=E,this.uint16[ci+8]=L,this.uint16[ci+9]=k,this.uint32[oi+5]=V,this.uint32[oi+6]=q,this.uint32[oi+7]=se,this.uint16[ci+16]=he,this.uint16[ci+17]=_e,this.uint16[ci+18]=Be,this.float32[oi+10]=Le,this.float32[oi+11]=Xe,this.uint8[Ti+48]=xt,this.uint8[Ti+49]=Dt,this.uint8[Ti+50]=_t,this.uint32[oi+13]=Tt,this.int16[ci+28]=kt,this.uint8[Ti+58]=Ut,n}}Ea.prototype.bytesPerElement=60,zt(Ea,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class vl extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v,E,L,k,V,q,se,he,_e,Be,Le,Xe,xt,Dt,_t,Tt,kt,Ut,ci,oi,Ti,Ki,gi,Si,Li,Vi){const Zi=this.length;return this.resize(Zi+1),this.emplace(Zi,n,o,d,g,v,E,L,k,V,q,se,he,_e,Be,Le,Xe,xt,Dt,_t,Tt,kt,Ut,ci,oi,Ti,Ki,gi,Si,Li,Vi)}emplace(n,o,d,g,v,E,L,k,V,q,se,he,_e,Be,Le,Xe,xt,Dt,_t,Tt,kt,Ut,ci,oi,Ti,Ki,gi,Si,Li,Vi,Zi){const yi=38*n,sn=19*n;return this.int16[yi+0]=o,this.int16[yi+1]=d,this.int16[yi+2]=g,this.float32[sn+2]=v,this.float32[sn+3]=E,this.int16[yi+8]=L,this.int16[yi+9]=k,this.int16[yi+10]=V,this.int16[yi+11]=q,this.int16[yi+12]=se,this.int16[yi+13]=he,this.uint16[yi+14]=_e,this.uint16[yi+15]=Be,this.uint16[yi+16]=Le,this.uint16[yi+17]=Xe,this.uint16[yi+18]=xt,this.uint16[yi+19]=Dt,this.uint16[yi+20]=_t,this.uint16[yi+21]=Tt,this.uint16[yi+22]=kt,this.uint16[yi+23]=Ut,this.uint16[yi+24]=ci,this.uint16[yi+25]=oi,this.uint16[yi+26]=Ti,this.uint16[yi+27]=Ki,this.uint16[yi+28]=gi,this.uint32[sn+15]=Si,this.float32[sn+16]=Li,this.float32[sn+17]=Vi,this.float32[sn+18]=Zi,n}}vl.prototype.bytesPerElement=76,zt(vl,"StructArrayLayout3i2f6i15ui1ul3f76");class Zl extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n){const o=this.length;return this.resize(o+1),this.emplace(o,n)}emplace(n,o){return this.float32[1*n+0]=o,n}}Zl.prototype.bytesPerElement=4,zt(Zl,"StructArrayLayout1f4");class $h extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o,d,g,v){const E=this.length;return this.resize(E+1),this.emplace(E,n,o,d,g,v)}emplace(n,o,d,g,v,E){const L=5*n;return this.float32[L+0]=o,this.float32[L+1]=d,this.float32[L+2]=g,this.float32[L+3]=v,this.float32[L+4]=E,n}}$h.prototype.bytesPerElement=20,zt($h,"StructArrayLayout5f20");class Zh extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o,d,g){const v=this.length;return this.resize(v+1),this.emplace(v,n,o,d,g)}emplace(n,o,d,g,v){const E=6*n;return this.uint32[3*n+0]=o,this.uint16[E+2]=d,this.uint16[E+3]=g,this.uint16[E+4]=v,n}}Zh.prototype.bytesPerElement=12,zt(Zh,"StructArrayLayout1ul3ui12");class Ka extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n,o){const d=this.length;return this.resize(d+1),this.emplace(d,n,o)}emplace(n,o,d){const g=2*n;return this.uint16[g+0]=o,this.uint16[g+1]=d,n}}Ka.prototype.bytesPerElement=4,zt(Ka,"StructArrayLayout2ui4");class Xh extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(n){const o=this.length;return this.resize(o+1),this.emplace(o,n)}emplace(n,o){return this.uint16[1*n+0]=o,n}}Xh.prototype.bytesPerElement=2,zt(Xh,"StructArrayLayout1ui2");class Aa extends On{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(n,o){const d=this.length;return this.resize(d+1),this.emplace(d,n,o)}emplace(n,o,d){const g=2*n;return this.float32[g+0]=o,this.float32[g+1]=d,n}}Aa.prototype.bytesPerElement=8,zt(Aa,"StructArrayLayout2f8");class rg extends lr{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}rg.prototype.size=40;class sg extends eo{get(n){return new rg(this,n)}}zt(sg,"CollisionBoxArray");class Ey extends lr{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(n){this._structArray.uint8[this._pos1+49]=n}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(n){this._structArray.uint8[this._pos1+50]=n}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(n){this._structArray.uint32[this._pos4+13]=n}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(n){this._structArray.uint8[this._pos1+58]=n}}Ey.prototype.size=60;class Ty extends Ea{get(n){return new Ey(this,n)}}zt(Ty,"PlacedSymbolArray");class up extends lr{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(n){this._structArray.uint32[this._pos4+15]=n}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}up.prototype.size=76;class Ap extends vl{get(n){return new up(this,n)}}zt(Ap,"SymbolInstanceArray");class og extends Zl{getoffsetX(n){return this.float32[1*n+0]}}zt(og,"GlyphOffsetArray");class Cu extends Or{getx(n){return this.int16[2*n+0]}gety(n){return this.int16[2*n+1]}}zt(Cu,"SymbolLineVertexArray");class od extends lr{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}od.prototype.size=12;class Sy extends Zh{get(n){return new od(this,n)}}zt(Sy,"FeatureIndexArray");class My extends Ka{geta_centroid_pos0(n){return this.uint16[2*n+0]}geta_centroid_pos1(n){return this.uint16[2*n+1]}}zt(My,"FillExtrusionCentroidArray");const i1=_n([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),n1=_n([{name:"a_dash",components:4,type:"Uint16"}]);var ad={exports:{}},Iy={exports:{}};Iy.exports=function(s,n){var o,d,g,v,E,L,k,V;for(d=s.length-(o=3&s.length),g=n,E=3432918353,L=461845907,V=0;V>>16)*E&65535)<<16)&4294967295)<<15|k>>>17))*L+(((k>>>16)*L&65535)<<16)&4294967295)<<13|g>>>19))+((5*(g>>>16)&65535)<<16)&4294967295))+((58964+(v>>>16)&65535)<<16);switch(k=0,o){case 3:k^=(255&s.charCodeAt(V+2))<<16;case 2:k^=(255&s.charCodeAt(V+1))<<8;case 1:g^=k=(65535&(k=(k=(65535&(k^=255&s.charCodeAt(V)))*E+(((k>>>16)*E&65535)<<16)&4294967295)<<15|k>>>17))*L+(((k>>>16)*L&65535)<<16)&4294967295}return g^=s.length,g=2246822507*(65535&(g^=g>>>16))+((2246822507*(g>>>16)&65535)<<16)&4294967295,g=3266489909*(65535&(g^=g>>>13))+((3266489909*(g>>>16)&65535)<<16)&4294967295,(g^=g>>>16)>>>0};var Fy={exports:{}};Fy.exports=function(s,n){for(var o,d=s.length,g=n^d,v=0;d>=4;)o=1540483477*(65535&(o=255&s.charCodeAt(v)|(255&s.charCodeAt(++v))<<8|(255&s.charCodeAt(++v))<<16|(255&s.charCodeAt(++v))<<24))+((1540483477*(o>>>16)&65535)<<16),g=1540483477*(65535&g)+((1540483477*(g>>>16)&65535)<<16)^(o=1540483477*(65535&(o^=o>>>24))+((1540483477*(o>>>16)&65535)<<16)),d-=4,++v;switch(d){case 3:g^=(255&s.charCodeAt(v+2))<<16;case 2:g^=(255&s.charCodeAt(v+1))<<8;case 1:g=1540483477*(65535&(g^=255&s.charCodeAt(v)))+((1540483477*(g>>>16)&65535)<<16)}return g=1540483477*(65535&(g^=g>>>13))+((1540483477*(g>>>16)&65535)<<16),(g^=g>>>15)>>>0};var Bf=Iy.exports,r1=Fy.exports;ad.exports=Bf,ad.exports.murmur3=Bf,ad.exports.murmur2=r1;class qh{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(n,o,d,g){this.ids.push(Ly(n)),this.positions.push(o,d,g)}getPositions(n){const o=Ly(n);let d=0,g=this.ids.length-1;for(;d>1;this.ids[E]>=o?g=E:d=E+1}const v=[];for(;this.ids[d]===o;)v.push({index:this.positions[3*d],start:this.positions[3*d+1],end:this.positions[3*d+2]}),d++;return v}static serialize(n,o){const d=new Float64Array(n.ids),g=new Uint32Array(n.positions);return Ls(d,g,0,d.length-1),o&&o.push(d.buffer,g.buffer),{ids:d,positions:g}}static deserialize(n){const o=new qh;return o.ids=n.ids,o.positions=n.positions,o.indexed=!0,o}}function Ly(s){const n=+s;return!isNaN(n)&&Number.MIN_SAFE_INTEGER<=n&&n<=Number.MAX_SAFE_INTEGER?n:ad.exports(String(s))}function Ls(s,n,o,d){for(;o>1];let v=o-1,E=d+1;for(;;){do v++;while(s[v]g);if(v>=E)break;fA(s,v,E),fA(n,3*v,3*E),fA(n,3*v+1,3*E+1),fA(n,3*v+2,3*E+2)}E-o`u_${g}`),this.type=d}setUniform(n,o,d,g,v){o.set(n,v,g.constantOr(this.value))}getBinding(n,o){return this.type==="color"?new ld(n):new mA(n)}}class cd{constructor(n,o){this.uniformNames=o.map(d=>`u_${d}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(n){this.pixelRatio=n.pixelRatio||1,this.pattern=n.tl.concat(n.br)}setUniform(n,o,d,g,v){const E=v==="u_pattern"||v==="u_dash"?this.pattern:v==="u_pixel_ratio"?this.pixelRatio:null;E&&o.set(n,v,E)}getBinding(n,o){return o==="u_pattern"||o==="u_dash"?new dp(n):new mA(n)}}class ah{constructor(n,o,d,g){this.expression=n,this.type=d,this.maxValue=0,this.paintVertexAttributes=o.map(v=>({name:`a_${v}`,type:"Float32",components:d==="color"?2:1,offset:0})),this.paintVertexArray=new g}populatePaintArray(n,o,d,g,v,E){const L=this.paintVertexArray.length,k=this.expression.evaluate(new qt(0),o,{},v,g,E);this.paintVertexArray.resize(n),this._setPaintValue(L,n,k)}updatePaintArray(n,o,d,g,v){const E=this.expression.evaluate({zoom:0},d,g,void 0,v);this._setPaintValue(n,o,E)}_setPaintValue(n,o,d){if(this.type==="color"){const g=fp(d);for(let v=n;v`u_${L}_t`),this.type=d,this.useIntegerZoom=g,this.zoom=v,this.maxValue=0,this.paintVertexAttributes=o.map(L=>({name:`a_${L}`,type:"Float32",components:d==="color"?4:2,offset:0})),this.paintVertexArray=new E}populatePaintArray(n,o,d,g,v,E){const L=this.expression.evaluate(new qt(this.zoom),o,{},v,g,E),k=this.expression.evaluate(new qt(this.zoom+1),o,{},v,g,E),V=this.paintVertexArray.length;this.paintVertexArray.resize(n),this._setPaintValue(V,n,L,k)}updatePaintArray(n,o,d,g,v){const E=this.expression.evaluate({zoom:this.zoom},d,g,void 0,v),L=this.expression.evaluate({zoom:this.zoom+1},d,g,void 0,v);this._setPaintValue(n,o,E,L)}_setPaintValue(n,o,d,g){if(this.type==="color"){const v=fp(d),E=fp(g);for(let L=n;L!0){this.binders={},this._buffers=[];const g=[];for(const v in n.paint._values){if(!d(v))continue;const E=n.paint.get(v);if(!(E instanceof Mi&&gl(E.property.specification)))continue;const L=lg(v,n.type),k=E.value,V=E.property.specification.type,q=E.property.useIntegerZoom,se=v==="line-dasharray"||v.endsWith("pattern"),he=v==="line-dasharray"&&n.layout.get("line-cap").value.kind!=="constant";if(k.kind!=="constant"||he)if(k.kind==="source"||he||se){const _e=Uy(v,V,"source");this.binders[v]=se?new Eu(k,L,V,_e,n.id):new ah(k,L,V,_e),g.push(`/a_${v}`)}else{const _e=Uy(v,V,"composite");this.binders[v]=new Ta(k,L,V,q,o,_e),g.push(`/z_${v}`)}else this.binders[v]=se?new cd(k.value,L):new gA(k.value,L,V),g.push(`/u_${v}`)}this.cacheKey=g.sort().join("")}getMaxValue(n){const o=this.binders[n];return o instanceof ah||o instanceof Ta?o.maxValue:0}populatePaintArrays(n,o,d,g,v,E){for(const L in this.binders){const k=this.binders[L];(k instanceof ah||k instanceof Ta||k instanceof Eu)&&k.populatePaintArray(n,o,d,g,v,E)}}setConstantPatternPositions(n){for(const o in this.binders){const d=this.binders[o];d instanceof cd&&d.setConstantPatternPositions(n)}}updatePaintArrays(n,o,d,g,v,E){let L=!1;for(const k in n){const V=o.getPositions(k);for(const q of V){const se=d.feature(q.index);for(const he in this.binders){const _e=this.binders[he];if((_e instanceof ah||_e instanceof Ta||_e instanceof Eu)&&_e.expression.isStateDependent===!0){const Be=g.paint.get(he);_e.expression=Be.value,_e.updatePaintArray(q.start,q.end,se,n[k],v,E),L=!0}}}}return L}defines(){const n=[];for(const o in this.binders){const d=this.binders[o];(d instanceof gA||d instanceof cd)&&n.push(...d.uniformNames.map(g=>`#define HAS_UNIFORM_${g}`))}return n}getBinderAttributes(){const n=[];for(const o in this.binders){const d=this.binders[o];if(d instanceof ah||d instanceof Ta||d instanceof Eu)for(let g=0;g!0){this.programConfigurations={};for(const g of n)this.programConfigurations[g.id]=new lh(g,o,d);this.needsUpload=!1,this._featureMap=new qh,this._bufferOffset=0}populatePaintArrays(n,o,d,g,v,E,L){for(const k in this.programConfigurations)this.programConfigurations[k].populatePaintArrays(n,o,g,v,E,L);o.id!==void 0&&this._featureMap.add(o.id,d,this._bufferOffset,n),this._bufferOffset=n,this.needsUpload=!0}updatePaintArrays(n,o,d,g,v){for(const E of d)this.needsUpload=this.programConfigurations[E.id].updatePaintArrays(n,this._featureMap,o,E,g,v)||this.needsUpload}get(n){return this.programConfigurations[n]}upload(n){if(this.needsUpload){for(const o in this.programConfigurations)this.programConfigurations[o].upload(n);this.needsUpload=!1}}destroy(){for(const n in this.programConfigurations)this.programConfigurations[n].destroy()}}const ag={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function lg(s,n){return ag[s]||[s.replace(`${n}-`,"").replace(/-/g,"_")]}const cg={"line-pattern":{source:jo,composite:jo},"fill-pattern":{source:jo,composite:jo},"fill-extrusion-pattern":{source:jo,composite:jo},"line-dasharray":{source:vs,composite:vs}},s1={color:{source:Aa,composite:Ca},number:{source:Zl,composite:Aa}};function Uy(s,n,o){const d=cg[s];return d&&d[o]||s1[n][o]}zt(gA,"ConstantBinder"),zt(cd,"PatternConstantBinder"),zt(ah,"SourceExpressionBinder"),zt(Eu,"PatternCompositeBinder"),zt(Ta,"CompositeExpressionBinder"),zt(lh,"ProgramConfiguration",{omit:["_buffers"]}),zt(_A,"ProgramConfigurationSet");const Cf="-transition";class vc extends yn{constructor(n,o){if(super(),this.id=n.id,this.type=n.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,n.type!=="custom"&&(this.metadata=n.metadata,this.minzoom=n.minzoom,this.maxzoom=n.maxzoom,n.type!=="background"&&n.type!=="sky"&&(this.source=n.source,this.sourceLayer=n["source-layer"],this.filter=n.filter),o.layout&&(this._unevaluatedLayout=new Ai(o.layout)),o.paint)){this._transitionablePaint=new Ci(o.paint);for(const d in n.paint)this.setPaintProperty(d,n.paint[d],{validate:!1});for(const d in n.layout)this.setLayoutProperty(d,n.layout[d],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new $i(o.paint)}}getLayoutProperty(n){return n==="visibility"?this.visibility:this._unevaluatedLayout.getValue(n)}setLayoutProperty(n,o,d={}){o!=null&&this._validate(mt,`layers.${this.id}.layout.${n}`,n,o,d)||(n!=="visibility"?this._unevaluatedLayout.setValue(n,o):this.visibility=o)}getPaintProperty(n){return At(n,Cf)?this._transitionablePaint.getTransition(n.slice(0,-Cf.length)):this._transitionablePaint.getValue(n)}setPaintProperty(n,o,d={}){if(o!=null&&this._validate(bt,`layers.${this.id}.paint.${n}`,n,o,d))return!1;if(At(n,Cf))return this._transitionablePaint.setTransition(n.slice(0,-Cf.length),o||void 0),!1;{const g=this._transitionablePaint._values[n],v=g.value.isDataDriven(),E=g.value;this._transitionablePaint.setValue(n,o),this._handleSpecialPaintPropertyUpdate(n);const L=this._transitionablePaint._values[n].value,k=L.isDataDriven(),V=At(n,"pattern")||n==="line-dasharray";return k||v||V||this._handleOverridablePaintPropertyUpdate(n,E,L)}}_handleSpecialPaintPropertyUpdate(n){}getProgramIds(){return null}getProgramConfiguration(n){return null}_handleOverridablePaintPropertyUpdate(n,o,d){return!1}isHidden(n){return!!(this.minzoom&&n=this.maxzoom)||this.visibility==="none"}updateTransitions(n){this._transitioningPaint=this._transitionablePaint.transitioned(n,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(n,o){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(n,void 0,o)),this.paint=this._transitioningPaint.possiblyEvaluate(n,void 0,o)}serialize(){const n={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&&(n.layout=n.layout||{},n.layout.visibility=this.visibility),Nt(n,(o,d)=>!(o===void 0||d==="layout"&&!Object.keys(o).length||d==="paint"&&!Object.keys(o).length))}_validate(n,o,d,g,v={}){return(!v||v.validate!==!1)&&Vt(this,n.call(je,{key:o,layerType:this.type,objectKey:d,value:g,styleSpec:Yt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const n in this.paint._values){const o=this.paint.get(n);if(o instanceof Mi&&gl(o.property.specification)&&(o.value.kind==="source"||o.value.kind==="composite")&&o.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=uo(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const o1=_n([{name:"a_pos",components:2,type:"Int16"}],4),Tu=_n([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class to{constructor(n=[]){this.segments=n}prepareSegment(n,o,d,g){let v=this.segments[this.segments.length-1];return n>to.MAX_VERTEX_ARRAY_LENGTH&&Ct(`Max vertices per segment is ${to.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${n}`),(!v||v.vertexLength+n>to.MAX_VERTEX_ARRAY_LENGTH||v.sortKey!==g)&&(v={vertexOffset:o.length,primitiveOffset:d.length,vertexLength:0,primitiveLength:0},g!==void 0&&(v.sortKey=g),this.segments.push(v)),v}get(){return this.segments}destroy(){for(const n of this.segments)for(const o in n.vaos)n.vaos[o].destroy()}static simpleSegment(n,o,d,g){return new to([{vertexOffset:n,primitiveOffset:o,vertexLength:d,primitiveLength:g,vaos:{},sortKey:0}])}}to.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,zt(to,"SegmentVector");var Zn=8192;class wl{constructor(n,o){n&&(o?this.setSouthWest(n).setNorthEast(o):n.length===4?this.setSouthWest([n[0],n[1]]).setNorthEast([n[2],n[3]]):this.setSouthWest(n[0]).setNorthEast(n[1]))}setNorthEast(n){return this._ne=n instanceof Pr?new Pr(n.lng,n.lat):Pr.convert(n),this}setSouthWest(n){return this._sw=n instanceof Pr?new Pr(n.lng,n.lat):Pr.convert(n),this}extend(n){const o=this._sw,d=this._ne;let g,v;if(n instanceof Pr)g=n,v=n;else{if(!(n instanceof wl))return Array.isArray(n)?n.length===4||n.every(Array.isArray)?this.extend(wl.convert(n)):this.extend(Pr.convert(n)):typeof n=="object"&&n!==null&&n.hasOwnProperty("lat")&&n.hasOwnProperty("lon")?this.extend(Pr.convert(n)):this;if(g=n._sw,v=n._ne,!g||!v)return this}return o||d?(o.lng=Math.min(g.lng,o.lng),o.lat=Math.min(g.lat,o.lat),d.lng=Math.max(v.lng,d.lng),d.lat=Math.max(v.lat,d.lat)):(this._sw=new Pr(g.lng,g.lat),this._ne=new Pr(v.lng,v.lat)),this}getCenter(){return new Pr((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 Pr(this.getWest(),this.getNorth())}getSouthEast(){return new Pr(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(n){const{lng:o,lat:d}=Pr.convert(n);let g=this._sw.lng<=o&&o<=this._ne.lng;return this._sw.lng>this._ne.lng&&(g=this._sw.lng>=o&&o>=this._ne.lng),this._sw.lat<=d&&d<=this._ne.lat&&g}static convert(n){return!n||n instanceof wl?n:new wl(n)}}const Ef=63710088e-1;class Pr{constructor(n,o){if(isNaN(n)||isNaN(o))throw new Error(`Invalid LngLat object: (${n}, ${o})`);if(this.lng=+n,this.lat=+o,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Pr(Re(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(n){const o=Math.PI/180,d=this.lat*o,g=n.lat*o,v=Math.sin(d)*Math.sin(g)+Math.cos(d)*Math.cos(g)*Math.cos((n.lng-this.lng)*o);return Ef*Math.acos(Math.min(v,1))}toBounds(n=0){const o=360*n/40075017,d=o/Math.cos(Math.PI/180*this.lat);return new wl(new Pr(this.lng-d,this.lat-o),new Pr(this.lng+d,this.lat+o))}static convert(n){if(n instanceof Pr)return n;if(Array.isArray(n)&&(n.length===2||n.length===3))return new Pr(Number(n[0]),Number(n[1]));if(!Array.isArray(n)&&typeof n=="object"&&n!==null)return new Pr(Number("lng"in n?n.lng:n.lon),Number(n.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 Ry=2*Math.PI*Ef;function Tf(s){return Ry*Math.cos(s*Math.PI/180)}function wc(s){return(180+s)/360}function ch(s){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+s*Math.PI/360)))/360}function Xl(s,n){return s/Tf(n)}function bl(s){return 360*s-180}function Fo(s){return 360/Math.PI*Math.atan(Math.exp((180-360*s)*Math.PI/180))-90}function Sf(s,n){return s*Tf(Fo(n))}const $a=85.051129;function Mf(s){return 1/Math.cos(s*Math.PI/180)}class hd{constructor(n,o,d=0){this.x=+n,this.y=+o,this.z=+d}static fromLngLat(n,o=0){const d=Pr.convert(n);return new hd(wc(d.lng),ch(d.lat),Xl(o,d.lat))}toLngLat(){return new Pr(bl(this.x),Fo(this.y))}toAltitude(){return Sf(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ry*Mf(Fo(this.y))}}function hg(s,n,o,d,g,v,E,L,k){const V=(n+d)/2,q=(o+g)/2,se=new me(V,q);L(se),function(he,_e,Be,Le,Xe,xt){const Dt=Be-Xe,_t=Le-xt;return Math.abs((Le-_e)*Dt-(Be-he)*_t)/Math.hypot(Dt,_t)}(se.x,se.y,v.x,v.y,E.x,E.y)>=k?(hg(s,n,o,V,q,v,se,L,k),hg(s,V,q,d,g,se,E,L,k)):s.push(E)}function zy(s,n,o){let d=s[0],g=d.x,v=d.y;n(d);const E=[d];for(let L=1;Ls.x+1||ds.y+1)&&Ct("Geometry exceeds allowed extent, reduce your vector tile buffer size"),s}function Yh(s,n,o){const d=s.loadGeometry(),g=s.extent,v=Zn/g;if(n&&o&&o.projection.isReprojectedInTileSpace){const E=1<{const _e=bl((n.x+he.x/g)/E),Be=Fo((n.y+he.y/g)/E),Le=q.project(_e,Be);he.x=(Le.x*L-k)*g,he.y=(Le.y*L-V)*g};for(let he=0;he=g||Be.y<0||Be.y>=g||(se(Be),_e.push(Be));d[he]=_e}}for(const E of d)for(const L of E)a1(L,v);return d}function xA(s,n){return{type:s.type,id:s.id,properties:s.properties,geometry:n?Yh(s):[]}}function If(s,n,o,d,g){s.emplaceBack(2*n+(d+1)/2,2*o+(g+1)/2)}function mp(s,n,o){s.emplaceBack(n.x,n.y,n.z,o[0]*16384,o[1]*16384,o[2]*16384)}class gp{constructor(n){this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(o=>o.id),this.index=n.index,this.hasPattern=!1,this.projection=n.projection,this.layoutVertexArray=new Or,this.indexArray=new _o,this.segments=new to,this.programConfigurations=new _A(n.layers,n.zoom),this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id)}populate(n,o,d,g){const v=this.layers[0],E=[];let L=null;v.type==="circle"&&(L=v.layout.get("circle-sort-key"));for(const{feature:V,id:q,index:se,sourceLayerIndex:he}of n){const _e=this.layers[0]._featureFilter.needGeometry,Be=xA(V,_e);if(!this.layers[0]._featureFilter.filter(new qt(this.zoom),Be,d))continue;const Le=L?L.evaluate(Be,{},d):void 0,Xe={id:q,properties:V.properties,type:V.type,sourceLayerIndex:he,index:se,geometry:_e?Be.geometry:Yh(V,d,g),patterns:{},sortKey:Le};E.push(Xe)}L&&E.sort((V,q)=>V.sortKey-q.sortKey);let k=null;g.projection.name==="globe"&&(this.globeExtVertexArray=new _r,k=g.projection);for(const V of E){const{geometry:q,index:se,sourceLayerIndex:he}=V,_e=n[se].feature;this.addFeature(V,q,se,o.availableImages,d,k),o.featureIndex.insert(_e,q,se,he,this.index)}}update(n,o,d,g){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,o,this.stateDependentLayers,d,g)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,o1.members),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=n.createVertexBuffer(this.globeExtVertexArray,Tu.members))),this.programConfigurations.upload(n),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(n,o,d,g,v,E){for(const L of o)for(const k of L){const V=k.x,q=k.y;if(V<0||V>=Zn||q<0||q>=Zn)continue;if(E){const _e=E.projectTilePoint(V,q,v),Be=E.upVector(v,V,q),Le=this.globeExtVertexArray;mp(Le,_e,Be),mp(Le,_e,Be),mp(Le,_e,Be),mp(Le,_e,Be)}const se=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,n.sortKey),he=se.vertexLength;If(this.layoutVertexArray,V,q,-1,-1),If(this.layoutVertexArray,V,q,1,-1),If(this.layoutVertexArray,V,q,1,1),If(this.layoutVertexArray,V,q,-1,1),this.indexArray.emplaceBack(he,he+1,he+2),this.indexArray.emplaceBack(he,he+2,he+3),se.vertexLength+=4,se.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,d,{},g,v)}}function Ny(s,n){for(let o=0;o1){if(dg(s,n))return!0;for(let d=0;d1?o:o.sub(n)._mult(g)._add(n))}function Hy(s,n){let o,d,g,v=!1;for(let E=0;En.y!=g.y>n.y&&n.x<(g.x-d.x)*(n.y-d.y)/(g.y-d.y)+d.x&&(v=!v)}return v}function vA(s,n){let o=!1;for(let d=0,g=s.length-1;dn.y!=E.y>n.y&&n.x<(E.x-v.x)*(n.y-v.y)/(E.y-v.y)+v.x&&(o=!o)}return o}function ud(s,n,o,d,g){for(const E of s)if(n<=E.x&&o<=E.y&&d>=E.x&&g>=E.y)return!0;const v=[new me(n,o),new me(n,g),new me(d,g),new me(d,o)];if(s.length>2){for(const E of v)if(vA(s,E))return!0}for(let E=0;Eg.x&&n.x>g.x||s.yg.y&&n.y>g.y)return!1;const v=Ft(s,n,o[0]);return v!==Ft(s,n,o[1])||v!==Ft(s,n,o[2])||v!==Ft(s,n,o[3])}function Su(s,n,o){const d=n.paint.get(s).value;return d.kind==="constant"?d.value:o.programConfigurations.get(n.id).getMaxValue(s)}function _p(s){return Math.sqrt(s[0]*s[0]+s[1]*s[1])}function mg(s,n,o,d,g){if(!n[0]&&!n[1])return s;const v=me.convert(n)._mult(g);o==="viewport"&&v._rotate(-d);const E=[];for(let L=0;L0&&(v=1/Math.sqrt(v)),s[0]=n[0]*v,s[1]=n[1]*v,s[2]=n[2]*v,s}function Ma(s,n){return s[0]*n[0]+s[1]*n[1]+s[2]*n[2]}function md(s,n,o){var d=n[0],g=n[1],v=n[2],E=o[0],L=o[1],k=o[2];return s[0]=g*k-v*L,s[1]=v*E-d*k,s[2]=d*L-g*E,s}function Ns(s,n,o){var d=n[0],g=n[1],v=n[2],E=o[3]*d+o[7]*g+o[11]*v+o[15];return s[0]=(o[0]*d+o[4]*g+o[8]*v+o[12])/(E=E||1),s[1]=(o[1]*d+o[5]*g+o[9]*v+o[13])/E,s[2]=(o[2]*d+o[6]*g+o[10]*v+o[14])/E,s}function wg(s,n,o){var d=o[0],g=o[1],v=o[2],E=n[0],L=n[1],k=n[2],V=g*k-v*L,q=v*E-d*k,se=d*L-g*E,he=g*se-v*q,_e=v*V-d*se,Be=d*q-g*V,Le=2*o[3];return q*=Le,se*=Le,_e*=2,Be*=2,s[0]=E+(V*=Le)+(he*=2),s[1]=L+q+_e,s[2]=k+se+Be,s}var gd,bc=xg,jy=vg,Ky=dd;function Lf(s,n,o){return s[0]=n[0]*o,s[1]=n[1]*o,s[2]=n[2]*o,s[3]=n[3]*o,s}function Df(s,n){var o=n[0],d=n[1],g=n[2],v=n[3],E=o*o+d*d+g*g+v*v;return E>0&&(E=1/Math.sqrt(E)),s[0]=o*E,s[1]=d*E,s[2]=g*E,s[3]=v*E,s}function TA(s,n,o){var d=n[0],g=n[1],v=n[2],E=n[3];return s[0]=o[0]*d+o[4]*g+o[8]*v+o[12]*E,s[1]=o[1]*d+o[5]*g+o[9]*v+o[13]*E,s[2]=o[2]*d+o[6]*g+o[10]*v+o[14]*E,s[3]=o[3]*d+o[7]*g+o[11]*v+o[15]*E,s}function $y(){var s=new Sa(4);return Sa!=Float32Array&&(s[0]=0,s[1]=0,s[2]=0),s[3]=1,s}function bg(s){return s[0]=0,s[1]=0,s[2]=0,s[3]=1,s}function uh(s,n,o){o*=.5;var d=n[0],g=n[1],v=n[2],E=n[3],L=Math.sin(o),k=Math.cos(o);return s[0]=d*k+E*L,s[1]=g*k+v*L,s[2]=v*k-g*L,s[3]=E*k-d*L,s}function Bg(s,n,o){o*=.5;var d=n[0],g=n[1],v=n[2],E=n[3],L=Math.sin(o),k=Math.cos(o);return s[0]=d*k-v*L,s[1]=g*k+E*L,s[2]=v*k+d*L,s[3]=E*k-g*L,s}Ad(),gd=new Sa(4),Sa!=Float32Array&&(gd[0]=0,gd[1]=0,gd[2]=0,gd[3]=0);var Iu=Df;Ad(),pd(1,0,0),pd(0,1,0),$y(),$y(),hh();class Pf{constructor(n,o){this.pos=n,this.dir=o}intersectsPlane(n,o,d){const g=Ma(o,this.dir);if(Math.abs(g)<1e-6)return!1;const v=((n[0]-this.pos[0])*o[0]+(n[1]-this.pos[1])*o[1]+(n[2]-this.pos[2])*o[2])/g;return d[0]=this.pos[0]+this.dir[0]*v,d[1]=this.pos[1]+this.dir[1]*v,d[2]=this.pos[2]+this.dir[2]*v,!0}closestPointOnSphere(n,o,d){if(function(_e,Be){var Le=_e[0],Xe=_e[1],xt=_e[2],Dt=Be[0],_t=Be[1],Tt=Be[2];return Math.abs(Le-Dt)<=yp*Math.max(1,Math.abs(Le),Math.abs(Dt))&&Math.abs(Xe-_t)<=yp*Math.max(1,Math.abs(Xe),Math.abs(_t))&&Math.abs(xt-Tt)<=yp*Math.max(1,Math.abs(xt),Math.abs(Tt))}(this.pos,n)||o===0)return d[0]=d[1]=d[2]=0,!1;const[g,v,E]=this.dir,L=this.pos[0]-n[0],k=this.pos[1]-n[1],V=this.pos[2]-n[2],q=g*g+v*v+E*E,se=2*(L*g+k*v+V*E),he=se*se-4*q*(L*L+k*k+V*V-o*o);if(he<0){const _e=Math.max(-se/2,0),Be=L+g*_e,Le=k+v*_e,Xe=V+E*_e,xt=Math.hypot(Be,Le,Xe);return d[0]=Be*o/xt,d[1]=Le*o/xt,d[2]=Xe*o/xt,!1}{const _e=(-se-Math.sqrt(he))/(2*q);if(_e<0){const Be=Math.hypot(L,k,V);return d[0]=L*o/Be,d[1]=k*o/Be,d[2]=V*o/Be,!1}return d[0]=L+g*_e,d[1]=k+v*_e,d[2]=V+E*_e,!0}}}class Uf{constructor(n,o,d,g,v){this.TL=n,this.TR=o,this.BR=d,this.BL=g,this.horizon=v}static fromInvProjectionMatrix(n,o,d){const g=[-1,1,1],v=[1,1,1],E=[1,-1,1],L=[-1,-1,1],k=Ns(g,g,n),V=Ns(v,v,n),q=Ns(E,E,n),se=Ns(L,L,n);return new Uf(k,V,q,se,o/d)}}class Rf{constructor(n,o){this.points=n,this.planes=o}static fromInvProjectionMatrix(n,o,d,g){const v=Math.pow(2,d),E=[[-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(k=>{const V=TA([],k,n),q=1/V[3]/o*v;return function(se,he,_e){return se[0]=he[0]*_e[0],se[1]=he[1]*_e[1],se[2]=he[2]*_e[2],se[3]=he[3]*_e[3],se}(V,V,[q,q,g?1/V[3]:q,q])}),L=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(k=>{const V=so([],md([],bc([],E[k[0]],E[k[1]]),bc([],E[k[2]],E[k[1]]))),q=-Ma(V,E[k[1]]);return V.concat(q)});return new Rf(E,L)}}class Ko{static fromPoints(n){const o=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(const g of n)EA(o,o,g),fd(d,d,g);return new Ko(o,d)}static applyTransform(n,o){const d=n.getCorners();for(let g=0;g=0;if(E===0)return 0;E!==o.length&&(d=!1)}if(d)return 2;for(let g=0;g<3;g++){let v=Number.MAX_VALUE,E=-Number.MAX_VALUE;for(let L=0;Lthis.max[g]-this.min[g])return 0}return 1}}function Zy(s,n,o,d,g,v,E,L,k){if(v&&s.queryGeometry.isAboveHorizon)return!1;v&&(k*=s.pixelToTileUnitsFactor);const V=s.tileID.canonical,q=o.projection.upVectorScale(V,o.center.lat,o.worldSize).metersToTile;for(const se of n)for(const he of se){const _e=he.add(L),Be=g&&o.elevation?o.elevation.exaggeration()*g.getElevationAt(_e.x,_e.y,!0):0,Le=o.projection.projectTilePoint(_e.x,_e.y,V);if(Be>0){const _t=o.projection.upVector(V,_e.x,_e.y);Le.x+=_t[0]*q*Be,Le.y+=_t[1]*q*Be,Le.z+=_t[2]*q*Be}const Xe=v?_e:h1(Le.x,Le.y,Le.z,d),xt=v?s.tilespaceRays.map(_t=>qy(_t,Be)):s.queryGeometry.screenGeometry,Dt=TA([],[Le.x,Le.y,Le.z,1],d);if(!E&&v?k*=Dt[3]/o.cameraToCenterDistance:E&&!v&&(k*=o.cameraToCenterDistance/Dt[3]),v){const _t=Fo((he.y/Zn+V.y)/(1<s.width||g.height>s.height||o.x>s.width-g.width||o.y>s.height-g.height)throw new RangeError("out of range source coordinates for image copy");if(g.width>n.width||g.height>n.height||d.x>n.width-g.width||d.y>n.height-g.height)throw new RangeError("out of range destination coordinates for image copy");const E=s.data,L=n.data;for(let k=0;k{n[s.evaluationKey]=k;const V=s.expression.evaluate(n);g.data[E+L+0]=Math.floor(255*V.r/V.a),g.data[E+L+1]=Math.floor(255*V.g/V.a),g.data[E+L+2]=Math.floor(255*V.b/V.a),g.data[E+L+3]=Math.floor(255*V.a)};if(s.clips)for(let E=0,L=0;E80*o){d=v=s[0],g=E=s[1];for(var Be=o;Bev&&(v=L),k>E&&(E=k);V=(V=Math.max(v-d,E-g))!==0?32767/V:0}return wd(he,_e,o,d,g,V,0),_e}function Yy(s,n,o,d,g){var v,E;if(g===Es(s,n,o,d)>0)for(v=n;v=n;v-=d)E=t0(v,s[v],s[v+1],E);return E&&Bp(E,E.next)&&(Tp(E),E=E.next),E}function Xa(s,n){if(!s)return s;n||(n=s);var o,d=s;do if(o=!1,d.steiner||!Bp(d,d.next)&&Ds(d.prev,d,d.next)!==0)d=d.next;else{if(Tp(d),(d=n=d.prev)===d.next)break;o=!0}while(o||d!==n);return n}function wd(s,n,o,d,g,v,E){if(s){!E&&v&&function(q,se,he,_e){var Be=q;do Be.z===0&&(Be.z=bp(Be.x,Be.y,se,he,_e)),Be.prevZ=Be.prev,Be.nextZ=Be.next,Be=Be.next;while(Be!==q);Be.prevZ.nextZ=null,Be.prevZ=null,function(Le){var Xe,xt,Dt,_t,Tt,kt,Ut,ci,oi=1;do{for(xt=Le,Le=null,Tt=null,kt=0;xt;){for(kt++,Dt=xt,Ut=0,Xe=0;Xe0||ci>0&&Dt;)Ut!==0&&(ci===0||!Dt||xt.z<=Dt.z)?(_t=xt,xt=xt.nextZ,Ut--):(_t=Dt,Dt=Dt.nextZ,ci--),Tt?Tt.nextZ=_t:Le=_t,_t.prevZ=Tt,Tt=_t;xt=Dt}Tt.nextZ=null,oi*=2}while(kt>1)}(Be)}(s,d,g,v);for(var L,k,V=s;s.prev!==s.next;)if(L=s.prev,k=s.next,v?d1(s,d,g,v):Jy(s))n.push(L.i/o|0),n.push(s.i/o|0),n.push(k.i/o|0),Tp(s),s=k.next,V=k.next;else if((s=k)===V){E?E===1?wd(s=p1(Xa(s),n,o),n,o,d,g,v,2):E===2&&f1(s,n,o,d,g,v):wd(Xa(s),n,o,d,g,v,1);break}}}function Jy(s){var n=s.prev,o=s,d=s.next;if(Ds(n,o,d)>=0)return!1;for(var g=n.x,v=o.x,E=d.x,L=n.y,k=o.y,V=d.y,q=gv?g>E?g:E:v>E?v:E,_e=L>k?L>V?L:V:k>V?k:V,Be=d.next;Be!==n;){if(Be.x>=q&&Be.x<=he&&Be.y>=se&&Be.y<=_e&&Bc(g,L,v,k,E,V,Be.x,Be.y)&&Ds(Be.prev,Be,Be.next)>=0)return!1;Be=Be.next}return!0}function d1(s,n,o,d){var g=s.prev,v=s,E=s.next;if(Ds(g,v,E)>=0)return!1;for(var L=g.x,k=v.x,V=E.x,q=g.y,se=v.y,he=E.y,_e=Lk?L>V?L:V:k>V?k:V,Xe=q>se?q>he?q:he:se>he?se:he,xt=bp(_e,Be,n,o,d),Dt=bp(Le,Xe,n,o,d),_t=s.prevZ,Tt=s.nextZ;_t&&_t.z>=xt&&Tt&&Tt.z<=Dt;){if(_t.x>=_e&&_t.x<=Le&&_t.y>=Be&&_t.y<=Xe&&_t!==g&&_t!==E&&Bc(L,q,k,se,V,he,_t.x,_t.y)&&Ds(_t.prev,_t,_t.next)>=0||(_t=_t.prevZ,Tt.x>=_e&&Tt.x<=Le&&Tt.y>=Be&&Tt.y<=Xe&&Tt!==g&&Tt!==E&&Bc(L,q,k,se,V,he,Tt.x,Tt.y)&&Ds(Tt.prev,Tt,Tt.next)>=0))return!1;Tt=Tt.nextZ}for(;_t&&_t.z>=xt;){if(_t.x>=_e&&_t.x<=Le&&_t.y>=Be&&_t.y<=Xe&&_t!==g&&_t!==E&&Bc(L,q,k,se,V,he,_t.x,_t.y)&&Ds(_t.prev,_t,_t.next)>=0)return!1;_t=_t.prevZ}for(;Tt&&Tt.z<=Dt;){if(Tt.x>=_e&&Tt.x<=Le&&Tt.y>=Be&&Tt.y<=Xe&&Tt!==g&&Tt!==E&&Bc(L,q,k,se,V,he,Tt.x,Tt.y)&&Ds(Tt.prev,Tt,Tt.next)>=0)return!1;Tt=Tt.nextZ}return!0}function p1(s,n,o){var d=s;do{var g=d.prev,v=d.next.next;!Bp(g,v)&&Cp(g,d,d.next,v)&&Ep(g,v)&&Ep(v,g)&&(n.push(g.i/o|0),n.push(d.i/o|0),n.push(v.i/o|0),Tp(d),Tp(d.next),d=s=v),d=d.next}while(d!==s);return Xa(d)}function f1(s,n,o,d,g,v){var E=s;do{for(var L=E.next.next;L!==E.prev;){if(E.i!==L.i&&g1(E,L)){var k=e0(E,L);return E=Xa(E,E.next),k=Xa(k,k.next),wd(E,n,o,d,g,v,0),void wd(k,n,o,d,g,v,0)}L=L.next}E=E.next}while(E!==s)}function zf(s,n){return s.x-n.x}function Mg(s,n){var o=function(g,v){var E,L=v,k=g.x,V=g.y,q=-1/0;do{if(V<=L.y&&V>=L.next.y&&L.next.y!==L.y){var se=L.x+(V-L.y)*(L.next.x-L.x)/(L.next.y-L.y);if(se<=k&&se>q&&(q=se,E=L.x=L.x&&L.x>=Be&&k!==L.x&&Bc(VE.x||L.x===E.x&&m1(E,L)))&&(E=L,Xe=he)),L=L.next;while(L!==_e);return E}(s,n);if(!o)return n;var d=e0(o,s);return Xa(d,d.next),Xa(o,o.next)}function m1(s,n){return Ds(s.prev,s,n.prev)<0&&Ds(n.next,s,s.next)<0}function bp(s,n,o,d,g){return(s=1431655765&((s=858993459&((s=252645135&((s=16711935&((s=(s-o)*g|0)|s<<8))|s<<4))|s<<2))|s<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-d)*g|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function Ig(s){var n=s,o=s;do(n.x=(s-E)*(v-L)&&(s-E)*(d-L)>=(o-E)*(n-L)&&(o-E)*(v-L)>=(g-E)*(d-L)}function g1(s,n){return s.next.i!==n.i&&s.prev.i!==n.i&&!function(o,d){var g=o;do{if(g.i!==o.i&&g.next.i!==o.i&&g.i!==d.i&&g.next.i!==d.i&&Cp(g,g.next,o,d))return!0;g=g.next}while(g!==o);return!1}(s,n)&&(Ep(s,n)&&Ep(n,s)&&function(o,d){var g=o,v=!1,E=(o.x+d.x)/2,L=(o.y+d.y)/2;do g.y>L!=g.next.y>L&&g.next.y!==g.y&&E<(g.next.x-g.x)*(L-g.y)/(g.next.y-g.y)+g.x&&(v=!v),g=g.next;while(g!==o);return v}(s,n)&&(Ds(s.prev,s,n.prev)||Ds(s,n.prev,n))||Bp(s,n)&&Ds(s.prev,s,s.next)>0&&Ds(n.prev,n,n.next)>0)}function Ds(s,n,o){return(n.y-s.y)*(o.x-n.x)-(n.x-s.x)*(o.y-n.y)}function Bp(s,n){return s.x===n.x&&s.y===n.y}function Cp(s,n,o,d){var g=kf(Ds(s,n,o)),v=kf(Ds(s,n,d)),E=kf(Ds(o,d,s)),L=kf(Ds(o,d,n));return g!==v&&E!==L||!(g!==0||!bd(s,o,n))||!(v!==0||!bd(s,d,n))||!(E!==0||!bd(o,s,d))||!(L!==0||!bd(o,n,d))}function bd(s,n,o){return n.x<=Math.max(s.x,o.x)&&n.x>=Math.min(s.x,o.x)&&n.y<=Math.max(s.y,o.y)&&n.y>=Math.min(s.y,o.y)}function kf(s){return s>0?1:s<0?-1:0}function Ep(s,n){return Ds(s.prev,s,s.next)<0?Ds(s,n,s.next)>=0&&Ds(s,s.prev,n)>=0:Ds(s,n,s.prev)<0||Ds(s,s.next,n)<0}function e0(s,n){var o=new Of(s.i,s.x,s.y),d=new Of(n.i,n.x,n.y),g=s.next,v=n.prev;return s.next=n,n.prev=s,o.next=g,g.prev=o,d.next=o,o.prev=d,v.next=d,d.prev=v,d}function t0(s,n,o,d){var g=new Of(s,n,o);return d?(g.next=d.next,g.prev=d,d.next.prev=g,d.next=g):(g.prev=g,g.next=g),g}function Tp(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function Of(s,n,o){this.i=s,this.x=n,this.y=o,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Es(s,n,o,d){for(var g=0,v=n,E=o-d;vo;){if(d-o>600){var v=d-o+1,E=n-o+1,L=Math.log(v),k=.5*Math.exp(2*L/3),V=.5*Math.sqrt(L*k*(v-k)/v)*(E-v/2<0?-1:1);Fg(s,n,Math.max(o,Math.floor(n-E*k/v+V)),Math.min(d,Math.floor(n+(v-E)*k/v+V)),g)}var q=s[n],se=o,he=d;for(Bd(s,o,n),g(s[d],q)>0&&Bd(s,o,d);se0;)he--}g(s[o],q)===0?Bd(s,o,he):Bd(s,++he,d),he<=n&&(o=he+1),n<=he&&(d=he-1)}}function Bd(s,n,o){var d=s[n];s[n]=s[o],s[o]=d}function i0(s,n){return sn?1:0}function Nf(s,n){const o=s.length;if(o<=1)return[s];const d=[];let g,v;for(let E=0;E1)for(let E=0;E0&&o.holes.push(d+=s[g-1].length)}return o};class Mp{constructor(n){this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(o=>o.id),this.index=n.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Or,this.indexArray=new _o,this.indexArray2=new Ka,this.programConfigurations=new _A(n.layers,n.zoom),this.segments=new to,this.segments2=new to,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.projection=n.projection}populate(n,o,d,g){this.hasPattern=Sp("fill",this.layers,o);const v=this.layers[0].layout.get("fill-sort-key"),E=[];for(const{feature:L,id:k,index:V,sourceLayerIndex:q}of n){const se=this.layers[0]._featureFilter.needGeometry,he=xA(L,se);if(!this.layers[0]._featureFilter.filter(new qt(this.zoom),he,d))continue;const _e=v?v.evaluate(he,{},d,o.availableImages):void 0,Be={id:k,properties:L.properties,type:L.type,sourceLayerIndex:q,index:V,geometry:se?he.geometry:Yh(L,d,g),patterns:{},sortKey:_e};E.push(Be)}v&&E.sort((L,k)=>L.sortKey-k.sortKey);for(const L of E){const{geometry:k,index:V,sourceLayerIndex:q}=L;if(this.hasPattern){const se=Cd("fill",this.layers,L,this.zoom,o);this.patternFeatures.push(se)}else this.addFeature(L,k,V,d,{},o.availableImages);o.featureIndex.insert(n[V].feature,k,V,q,this.index)}}update(n,o,d,g){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,o,this.stateDependentLayers,d,g)}addFeatures(n,o,d,g,v){for(const E of this.patternFeatures)this.addFeature(E,E.geometry,E.index,o,d,g)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Sg),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.indexBuffer2=n.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(n),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(n,o,d,g,v,E=[]){for(const L of Nf(o,500)){let k=0;for(const Be of L)k+=Be.length;const V=this.segments.prepareSegment(k,this.layoutVertexArray,this.indexArray),q=V.vertexLength,se=[],he=[];for(const Be of L){if(Be.length===0)continue;Be!==L[0]&&he.push(se.length/2);const Le=this.segments2.prepareSegment(Be.length,this.layoutVertexArray,this.indexArray2),Xe=Le.vertexLength;this.layoutVertexArray.emplaceBack(Be[0].x,Be[0].y),this.indexArray2.emplaceBack(Xe+Be.length-1,Xe),se.push(Be[0].x),se.push(Be[0].y);for(let xt=1;xt>3}if(g--,d===1||d===2)v+=s.readSVarint(),E+=s.readSVarint(),d===1&&(n&&L.push(n),n=[]),n.push(new a0(v,E));else{if(d!==7)throw new Error("unknown command "+d);n&&n.push(n[0].clone())}}return n&&L.push(n),L},MA.prototype.bbox=function(){var s=this._pbf;s.pos=this._geometry;for(var n=s.readVarint()+s.pos,o=1,d=0,g=0,v=0,E=1/0,L=-1/0,k=1/0,V=-1/0;s.pos>3}if(d--,o===1||o===2)(g+=s.readSVarint())L&&(L=g),(v+=s.readSVarint())V&&(V=v);else if(o!==7)throw new Error("unknown command "+o)}return[E,k,L,V]},MA.prototype.toGeoJSON=function(s,n,o){var d,g,v=this.extent*Math.pow(2,o),E=this.extent*s,L=this.extent*n,k=this.loadGeometry(),V=MA.types[this.type];function q(_e){for(var Be=0;Be<_e.length;Be++){var Le=_e[Be];_e[Be]=[360*(Le.x+E)/v-180,360/Math.PI*Math.atan(Math.exp((180-360*(Le.y+L)/v)*Math.PI/180))-90]}}switch(this.type){case 1:var se=[];for(d=0;d>3;g=E===1?d.readString():E===2?d.readFloat():E===3?d.readDouble():E===4?d.readVarint64():E===5?d.readVarint():E===6?d.readSVarint():E===7?d.readBoolean():null}return g}(o))}Vf.prototype.feature=function(s){if(s<0||s>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[s];var n=this._pbf.readVarint()+this._pbf.pos;return new Qf(this._pbf,n,this.extent,this._keys,this._values)};var A=Ed;function l(s,n,o){if(s===3){var d=new A(o,o.readVarint()+o.pos);d.length&&(n[d.name]=d)}}var f=Fp.VectorTile=function(s,n){this.layers=s.readFields(l,{},n)},w=Fp.VectorTileFeature=Dg;function I(s,n,o,d){const g=[],v=d===0?(E,L,k,V,q,se)=>{E.push(new me(se,k+(se-L)/(V-L)*(q-k)))}:(E,L,k,V,q,se)=>{E.push(new me(L+(se-k)/(q-k)*(V-L),se))};for(const E of s){const L=[];for(const k of E){if(k.length<=2)continue;const V=[];for(let he=0;hen&&v(V,_e,Be,Le,Xe,n):xt>o?Dt=n&&v(V,_e,Be,Le,Xe,n),Dt>o&&xt<=o&&v(V,_e,Be,Le,Xe,o)}let q=k[k.length-1];const se=d===0?q.x:q.y;se>=n&&se<=o&&V.push(q),V.length&&(q=V[V.length-1],V[0].x===q.x&&V[0].y===q.y||V.push(V[0]),L.push(V))}L.length&&g.push(L)}return g}Fp.VectorTileLayer=Ed;const U=w.types,N=Math.pow(2,13);function Z(s,n,o,d,g,v,E,L){s.emplaceBack((n<<1)+E,(o<<1)+v,(Math.floor(d*N)<<1)+g,Math.round(L))}function re(s,n,o){s.emplaceBack(n.x,n.y,n.z,o[0]*16384,o[1]*16384,o[2]*16384)}class ge{constructor(){this.acc=new me(0,0),this.polyCount=[]}startRing(n){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new me(n.x,n.y),this.max=new me(n.x,n.y))}append(n,o){this.currentPolyCount.edges++,this.acc._add(n);const d=this.min,g=this.max;n.xg.x&&(g.x=n.x),n.yg.y&&(g.y=n.y),((n.x===0||n.x===Zn)&&n.x===o.x)!=((n.y===0||n.y===Zn)&&n.y===o.y)&&this.processBorderOverlap(n,o),o.x<0!=n.x<0&&this.addBorderIntersection(0,gr(o.y,n.y,(0-o.x)/(n.x-o.x))),o.x>Zn!=n.x>Zn&&this.addBorderIntersection(1,gr(o.y,n.y,(Zn-o.x)/(n.x-o.x))),o.y<0!=n.y<0&&this.addBorderIntersection(2,gr(o.x,n.x,(0-o.y)/(n.y-o.y))),o.y>Zn!=n.y>Zn&&this.addBorderIntersection(3,gr(o.x,n.x,(Zn-o.y)/(n.y-o.y)))}addBorderIntersection(n,o){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const d=this.borders[n];od[1]&&(d[1]=o)}processBorderOverlap(n,o){if(n.x===o.x){if(n.y===o.y)return;const d=n.x===0?0:1;this.addBorderIntersection(d,o.y),this.addBorderIntersection(d,n.y)}else{const d=n.y===0?2:3;this.addBorderIntersection(d,o.x),this.addBorderIntersection(d,n.x)}}centroid(){const n=this.polyCount.reduce((o,d)=>o+d.edges,0);return n!==0?this.acc.div(n)._round():new me(0,0)}span(){return new me(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((n,o)=>n+ +(o[0]!==Number.MAX_VALUE),0)}}class Ce{constructor(n){this.zoom=n.zoom,this.canonical=n.canonical,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(o=>o.id),this.index=n.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=n.projection,this.layoutVertexArray=new Qr,this.centroidVertexArray=new My,this.indexArray=new _o,this.programConfigurations=new _A(n.layers,n.zoom),this.segments=new to,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id),this.enableTerrain=n.enableTerrain}populate(n,o,d,g){this.features=[],this.hasPattern=Sp("fill-extrusion",this.layers,o),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(v){const E=Math.exp(Math.PI*(1-v.y/(1<=0;xt--){const Dt=_e[xt];(Dt.length===0||(Be=Dt[0]).every(_t=>_t.x<=0)||Be.every(_t=>_t.x>=Zn)||Be.every(_t=>_t.y<=0)||Be.every(_t=>_t.y>=Zn))&&_e.splice(xt,1)}var Be;let Le;if(q)Le=mi(_e,k,g);else{Le=[];for(const xt of _e)Le.push({polygon:xt,bounds:k})}const Xe=he?this.edgeRadius:0;for(const{polygon:xt,bounds:Dt}of Le){let _t=0,Tt=0;for(const Ut of xt)he&&!Ut[0].equals(Ut[Ut.length-1])&&Ut.push(Ut[0]),Tt+=he?Ut.length-1:Ut.length;const kt=this.segments.prepareSegment((he?5:4)*Tt,this.layoutVertexArray,this.indexArray);if(he){const Ut=[],ci=[];_t=kt.vertexLength;for(const Ti of xt){let Ki,gi;Ti.length&&Ti!==xt[0]&&ci.push(Ut.length/2),Ki=Ti[1].sub(Ti[0])._perp()._unit();for(let Si=1;Si4&&Rt(Ut[Ut.length-2],Ut[0],Ut[1]),gi=Xe?ke(Ut[Ut.length-2],Ut[0],Ut[1],Xe):0;oi=Ut[1].sub(Ut[0])._perp()._unit();let Si=!0;for(let Li=1,Vi=0;Li0?1:0,ln=Zi.dist(yi);if(Vi+ln>32768&&(Vi=0),Xe){Ti=sn.sub(yi)._perp()._unit();let xr=$e(Zi,yi,sn,Ie(oi,Ti),Xe);isNaN(xr)&&(xr=0);const Jn=yi.sub(Zi)._unit();Zi=Zi.add(Jn.mult(gi))._round(),yi=yi.add(Jn.mult(-xr))._round(),gi=xr,oi=Ti}const Xn=kt.vertexLength,Tr=Ut.length>4&&Rt(Zi,yi,sn);let wr=Mt(Vi,Ki,Si);if(Z(this.layoutVertexArray,Zi.x,Zi.y,dn,Ln,0,0,wr),Z(this.layoutVertexArray,Zi.x,Zi.y,dn,Ln,0,1,wr),Vi+=ln,wr=Mt(Vi,Tr,!Si),Ki=Tr,Z(this.layoutVertexArray,yi.x,yi.y,dn,Ln,0,0,wr),Z(this.layoutVertexArray,yi.x,yi.y,dn,Ln,0,1,wr),kt.vertexLength+=4,this.indexArray.emplaceBack(Xn+0,Xn+1,Xn+2),this.indexArray.emplaceBack(Xn+1,Xn+3,Xn+2),kt.primitiveLength+=2,Xe){const xr=_t+(Li===1?Ut.length-2:Li-2),Jn=Li===1?_t:xr+1;if(this.indexArray.emplaceBack(Xn+1,xr,Xn+3),this.indexArray.emplaceBack(xr,Jn,Xn+3),kt.primitiveLength+=2,ci===void 0&&(ci=Xn),!Ze(sn,Ut[Li],Dt)){const es=Li===Ut.length-1?ci:kt.vertexLength;this.indexArray.emplaceBack(Xn+2,Xn+3,es),this.indexArray.emplaceBack(Xn+3,es+1,es),this.indexArray.emplaceBack(Xn+3,Jn,es+1),kt.primitiveLength+=3}Si=!Si}if(q){const xr=this.layoutVertexExtArray,Jn=V.projectTilePoint(Zi.x,Zi.y,g),es=V.projectTilePoint(yi.x,yi.y,g),ir=V.upVector(g,Zi.x,Zi.y),Sr=V.upVector(g,yi.x,yi.y);re(xr,Jn,ir),re(xr,Jn,ir),re(xr,es,Sr),re(xr,es,Sr)}}he&&(_t+=Ut.length-1)}}if(se&&se.polyCount.length>0){if(se.borders){se.vertexArrayOffset=this.centroidVertexArray.length;const xt=se.borders,Dt=this.featuresOnBorder.push(se)-1;for(let _t=0;_t<4;_t++)xt[_t][0]!==Number.MAX_VALUE&&this.borders[_t].push(Dt)}this.encodeCentroid(se.borders?void 0:se.centroid(),se)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,d,v,E,g)}sortBorders(){for(let n=0;n<4;n++)this.borders[n].sort((o,d)=>this.featuresOnBorder[o].borders[n][0]-this.featuresOnBorder[d].borders[n][0])}encodeCentroid(n,o,d=!0){let g,v;if(n)if(n.y!==0){const L=o.span()._mult(this.tileToMeter);g=(Math.max(n.x,1)<<3)+Math.min(7,Math.round(L.x/10)),v=(Math.max(n.y,1)<<3)+Math.min(7,Math.round(L.y/10))}else g=Math.ceil(7*(n.x+450)),v=0;else g=0,v=+d;let E=d?this.centroidVertexArray.length:o.vertexArrayOffset;for(const L of o.polyCount){d&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*L.edges+L.top);for(let k=0;ko[1].x&&n.x>o[1].x||s.yo[1].y&&n.y>o[1].y}function Rt(s,n,o){if(s.x<0||s.x>=Zn||n.x<0||n.x>=Zn||o.x<0||o.x>=Zn)return!1;const d=o.sub(n),g=d.perp(),v=s.sub(n);return(d.x*v.x+d.y*v.y)/Math.sqrt((d.x*d.x+d.y*d.y)*(v.x*v.x+v.y*v.y))>-.866&&g.x*v.x+g.y*v.y<0}function Mt(s,n,o){const d=n?2|s:-3&s;return o?1|d:-2&d}function ri(){const s=Math.PI/32,n=Math.tan(s),o=Ef;return o*Math.sqrt(1+2*n*n)-o}function mi(s,n,o){const d=1<{for(const oi of Ut)Be.push({polygon:oi,bounds:ci})},Xe=Math.ceil(Math.log2(q)),xt=Math.ceil(Math.log2(se)),Dt=Xe-xt,_t=[];for(let Ut=0;Ut0?0:1);for(let Ut=0;Utci+1?kt.push({polygons:Vi,bounds:yi,depth:ci+1}):Le(Vi,yi)}if(Zi.length){const yi=[new me(oi===0?Li:Ti.x,oi===1?Li:Ti.y),Ki];_t.length>ci+1?kt.push({polygons:Zi,bounds:yi,depth:ci+1}):Le(Zi,yi)}}return Be}(s,n,Math.ceil((v-g)/11.25),Math.ceil((E-L)/11.25),1,(k,V,q)=>{if(k===0)return .5*(V+q);{const se=Fo((o.y+V/Zn)/d);return(ch(.5*(Fo((o.y+q/Zn)/d)+se))*d-o.y)*Zn}})}zt(Ce,"FillExtrusionBucket",{omit:["layers","features"]}),zt(ge,"PartMetadata");const ei=new Hn({"fill-extrusion-edge-radius":new Jt(Yt["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var ui={paint:new Hn({"fill-extrusion-opacity":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new pi(Yt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new pi(Yt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new pi(Yt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new pi(Yt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new Jt(Yt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"])}),layout:ei};function Pi(s,n,o){var d=2*Math.PI*6378137/256/Math.pow(2,o);return[s*d-2*Math.PI*6378137/2,n*d-2*Math.PI*6378137/2]}class Fi{constructor(n,o,d){this.z=n,this.x=o,this.y=d,this.key=mn(0,n,n,o,d)}equals(n){return this.z===n.z&&this.x===n.x&&this.y===n.y}url(n,o){const d=function(v,E,L){var k=Pi(256*v,256*(E=Math.pow(2,L)-E-1),L),V=Pi(256*(v+1),256*(E+1),L);return k[0]+","+k[1]+","+V[0]+","+V[1]}(this.x,this.y,this.z),g=function(v,E,L){let k,V="";for(let q=v;q>0;q--)k=1<this.canonical.z?new fn(n,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fn(n,this.wrap,n,this.canonical.x>>o,this.canonical.y>>o)}calculateScaledKey(n,o=!0){if(this.overscaledZ===n&&o)return this.key;if(n>this.canonical.z)return mn(this.wrap*+o,n,this.canonical.z,this.canonical.x,this.canonical.y);{const d=this.canonical.z-n;return mn(this.wrap*+o,n,n,this.canonical.x>>d,this.canonical.y>>d)}}isChildOf(n){if(n.wrap!==this.wrap)return!1;const o=this.canonical.z-n.canonical.z;return n.overscaledZ===0||n.overscaledZ>o&&n.canonical.y===this.canonical.y>>o}children(n){if(this.overscaledZ>=n)return[new fn(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const o=this.canonical.z+1,d=2*this.canonical.x,g=2*this.canonical.y;return[new fn(o,this.wrap,o,d,g),new fn(o,this.wrap,o,d+1,g),new fn(o,this.wrap,o,d,g+1),new fn(o,this.wrap,o,d+1,g+1)]}isLessThan(n){return this.wrapn.wrap)&&(this.overscaledZn.overscaledZ)&&(this.canonical.xn.canonical.x)&&this.canonical.yo.id),this.index=n.index,this.projection=n.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(o=>{this.gradients[o.id]={}}),this.layoutVertexArray=new go,this.layoutVertexArray2=new Ca,this.indexArray=new _o,this.programConfigurations=new _A(n.layers,n.zoom),this.segments=new to,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(o=>o.isStateDependent()).map(o=>o.id)}populate(n,o,d,g){this.hasPattern=Sp("line",this.layers,o);const v=this.layers[0].layout.get("line-sort-key"),E=[];for(const{feature:q,id:se,index:he,sourceLayerIndex:_e}of n){const Be=this.layers[0]._featureFilter.needGeometry,Le=xA(q,Be);if(!this.layers[0]._featureFilter.filter(new qt(this.zoom),Le,d))continue;const Xe=v?v.evaluate(Le,{},d):void 0,xt={id:se,properties:q.properties,type:q.type,sourceLayerIndex:_e,index:he,geometry:Be?Le.geometry:Yh(q,d,g),patterns:{},sortKey:Xe};E.push(xt)}v&&E.sort((q,se)=>q.sortKey-se.sortKey);const{lineAtlas:L,featureIndex:k}=o,V=this.addConstantDashes(L);for(const q of E){const{geometry:se,index:he,sourceLayerIndex:_e}=q;if(V&&this.addFeatureDashes(q,L),this.hasPattern){const Be=Cd("line",this.layers,q,this.zoom,o);this.patternFeatures.push(Be)}else this.addFeature(q,se,he,d,L.positions,o.availableImages);k.insert(n[he].feature,se,he,_e,this.index)}}addConstantDashes(n){let o=!1;for(const d of this.layers){const g=d.paint.get("line-dasharray").value,v=d.layout.get("line-cap").value;if(g.kind!=="constant"||v.kind!=="constant")o=!0;else{const E=v.value,L=g.value;if(!L)continue;n.addDash(L,E)}}return o}addFeatureDashes(n,o){const d=this.zoom;for(const g of this.layers){const v=g.paint.get("line-dasharray").value,E=g.layout.get("line-cap").value;if(v.kind==="constant"&&E.kind==="constant")continue;let L,k;if(v.kind==="constant"){if(L=v.value,!L)continue}else L=v.evaluate({zoom:d},n);k=E.kind==="constant"?E.value:E.evaluate({zoom:d},n),o.addDash(L,k),n.patterns[g.id]=o.getKey(L,k)}}update(n,o,d,g){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(n,o,this.stateDependentLayers,d,g)}addFeatures(n,o,d,g,v){for(const E of this.patternFeatures)this.addFeature(E,E.geometry,E.index,o,d,g)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(n){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=n.createVertexBuffer(this.layoutVertexArray2,yr)),this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Wn),this.indexBuffer=n.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(n),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(n){if(n.properties&&n.properties.hasOwnProperty("mapbox_clip_start")&&n.properties.hasOwnProperty("mapbox_clip_end"))return{start:+n.properties.mapbox_clip_start,end:+n.properties.mapbox_clip_end}}addFeature(n,o,d,g,v,E){const L=this.layers[0].layout,k=L.get("line-join").evaluate(n,{}),V=L.get("line-cap").evaluate(n,{}),q=L.get("line-miter-limit"),se=L.get("line-round-limit");this.lineClips=this.lineFeatureClips(n);for(const he of o)this.addLine(he,n,k,V,q,se);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,n,d,v,E,g)}addLine(n,o,d,g,v,E){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let xt=0;xt=2&&n[k-1].equals(n[k-2]);)k--;let V=0;for(;V0;if(ci&&xt>V){const gi=he.dist(_e);if(gi>2*q){const Si=he.sub(he.sub(_e)._mult(q/gi)._round());this.updateDistance(_e,Si),this.addCurrentVertex(Si,Le,0,0,se),_e=Si}}const Ti=_e&&Be;let Ki=Ti?d:L?"butt":g;if(Ti&&Ki==="round"&&(ktv&&(Ki="bevel"),Ki==="bevel"&&(kt>2&&(Ki="flipbevel"),kt100)Dt=Xe.mult(-1);else{const gi=kt*Le.add(Xe).mag()/Le.sub(Xe).mag();Dt._perp()._mult(gi*(oi?-1:1))}this.addCurrentVertex(he,Dt,0,0,se),this.addCurrentVertex(he,Dt.mult(-1),0,0,se)}else if(Ki==="bevel"||Ki==="fakeround"){const gi=-Math.sqrt(kt*kt-1),Si=oi?gi:0,Li=oi?0:gi;if(_e&&this.addCurrentVertex(he,Le,Si,Li,se),Ki==="fakeround"){const Vi=Math.round(180*Ut/Math.PI/20);for(let Zi=1;Zi2*q){const Si=he.add(Be.sub(he)._mult(q/gi)._round());this.updateDistance(he,Si),this.addCurrentVertex(Si,Xe,0,0,se),he=Si}}}}addCurrentVertex(n,o,d,g,v,E=!1){const L=o.y*g-o.x,k=-o.y-o.x*g;this.addHalfVertex(n,o.x+o.y*d,o.y-o.x*d,E,!1,d,v),this.addHalfVertex(n,L,k,E,!0,-g,v)}addHalfVertex({x:n,y:o},d,g,v,E,L,k){this.layoutVertexArray.emplaceBack((n<<1)+(v?1:0),(o<<1)+(E?1:0),Math.round(63*d)+128,Math.round(63*g)+128,1+(L===0?0:L<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const V=k.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,V),k.primitiveLength++),E?this.e2=V:this.e1=V}updateScaledDistance(){if(this.lineClips){const n=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=n*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(n,o){this.distance+=n.dist(o),this.updateScaledDistance()}}zt(Qs,"LineBucket",{omit:["layers","patternFeatures"]});const Cl=new Hn({"line-cap":new pi(Yt.layout_line["line-cap"]),"line-join":new pi(Yt.layout_line["line-join"]),"line-miter-limit":new Jt(Yt.layout_line["line-miter-limit"]),"line-round-limit":new Jt(Yt.layout_line["line-round-limit"]),"line-sort-key":new pi(Yt.layout_line["line-sort-key"])});var xo={paint:new Hn({"line-opacity":new pi(Yt.paint_line["line-opacity"]),"line-color":new pi(Yt.paint_line["line-color"]),"line-translate":new Jt(Yt.paint_line["line-translate"]),"line-translate-anchor":new Jt(Yt.paint_line["line-translate-anchor"]),"line-width":new pi(Yt.paint_line["line-width"]),"line-gap-width":new pi(Yt.paint_line["line-gap-width"]),"line-offset":new pi(Yt.paint_line["line-offset"]),"line-blur":new pi(Yt.paint_line["line-blur"]),"line-dasharray":new pi(Yt.paint_line["line-dasharray"]),"line-pattern":new pi(Yt.paint_line["line-pattern"]),"line-gradient":new In(Yt.paint_line["line-gradient"]),"line-trim-offset":new Jt(Yt.paint_line["line-trim-offset"])}),layout:Cl};const Ks=new class extends pi{possiblyEvaluate(s,n){return n=new qt(Math.floor(n.zoom),{now:n.now,fadeDuration:n.fadeDuration,transition:n.transition}),super.possiblyEvaluate(s,n)}evaluate(s,n,o,d){return n=Ve({},n,{zoom:Math.floor(n.zoom)}),super.evaluate(s,n,o,d)}}(xo.paint.properties["line-width"].specification);function oo(s,n){return n>0?n+2*s:s}Ks.useIntegerZoom=!0;const Lo=_n([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),$o=_n([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Ia=_n([{name:"a_projected_pos",components:4,type:"Float32"}],4);_n([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const io=_n([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),Do=_n([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);_n([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Po=_n([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),pa=_n([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);_n([{name:"triangle",components:3,type:"Uint16"}]),_n([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),_n([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),_n([{type:"Float32",name:"offsetX"}]),_n([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Jr=24;const Vs=128;function ms(s,n){const{expression:o}=n;if(o.kind==="constant")return{kind:"constant",layoutSize:o.evaluate(new qt(s+1))};if(o.kind==="source")return{kind:"source"};{const{zoomStops:d,interpolationType:g}=o;let v=0;for(;v{d.text=function(g,v,E){const L=v.layout.get("text-transform").evaluate(E,{});return L==="uppercase"?g=g.toLocaleUpperCase():L==="lowercase"&&(g=g.toLocaleLowerCase()),si.applyArabicShaping&&(g=si.applyArabicShaping(g)),g}(d.text,n,o)}),s}const ao={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};function Jl(s){return s==="\uFE36"||s==="\uFE48"||s==="\uFE38"||s==="\uFE44"||s==="\uFE42"||s==="\uFE3E"||s==="\uFE3C"||s==="\uFE3A"||s==="\uFE18"||s==="\uFE40"||s==="\uFE10"||s==="\uFE13"||s==="\uFE14"||s==="\uFF40"||s==="\uFFE3"||s==="\uFE11"||s==="\uFE12"}function Cc(s){return s==="\uFE35"||s==="\uFE47"||s==="\uFE37"||s==="\uFE43"||s==="\uFE41"||s==="\uFE3D"||s==="\uFE3B"||s==="\uFE39"||s==="\uFE17"||s==="\uFE3F"}var Fa=vr,Ah=function(s,n,o,d,g){var v,E,L=8*g-d-1,k=(1<>1,q=-7,se=o?g-1:0,he=o?-1:1,_e=s[n+se];for(se+=he,v=_e&(1<<-q)-1,_e>>=-q,q+=L;q>0;v=256*v+s[n+se],se+=he,q-=8);for(E=v&(1<<-q)-1,v>>=-q,q+=d;q>0;E=256*E+s[n+se],se+=he,q-=8);if(v===0)v=1-V;else{if(v===k)return E?NaN:1/0*(_e?-1:1);E+=Math.pow(2,d),v-=V}return(_e?-1:1)*E*Math.pow(2,v-d)},El=function(s,n,o,d,g,v){var E,L,k,V=8*v-g-1,q=(1<>1,he=g===23?Math.pow(2,-24)-Math.pow(2,-77):0,_e=d?0:v-1,Be=d?1:-1,Le=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(L=isNaN(n)?1:0,E=q):(E=Math.floor(Math.log(n)/Math.LN2),n*(k=Math.pow(2,-E))<1&&(E--,k*=2),(n+=E+se>=1?he/k:he*Math.pow(2,1-se))*k>=2&&(E++,k/=2),E+se>=q?(L=0,E=q):E+se>=1?(L=(n*k-1)*Math.pow(2,g),E+=se):(L=n*Math.pow(2,se-1)*Math.pow(2,g),E=0));g>=8;s[o+_e]=255&L,_e+=Be,L/=256,g-=8);for(E=E<0;s[o+_e]=255&E,_e+=Be,E/=256,V-=8);s[o+_e-Be]|=128*Le};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function vr(s){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(s)?s:new Uint8Array(s||0),this.pos=0,this.type=0,this.length=this.buf.length}vr.Varint=0,vr.Fixed64=1,vr.Bytes=2,vr.Fixed32=5;var Zo=4294967296,dh=1/Zo,Td=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function ph(s){return s.type===vr.Bytes?s.readVarint()+s.pos:s.pos+1}function Fu(s,n,o){return o?4294967296*n+(s>>>0):4294967296*(n>>>0)+(s>>>0)}function Hf(s,n,o){var d=n<=16383?1:n<=2097151?2:n<=268435455?3:Math.floor(Math.log(n)/(7*Math.LN2));o.realloc(d);for(var g=o.pos-1;g>=s;g--)o.buf[g+d]=o.buf[g]}function tu(s,n){for(var o=0;o>>8,s[o+2]=n>>>16,s[o+3]=n>>>24}function h0(s,n){return(s[n]|s[n+1]<<8|s[n+2]<<16)+(s[n+3]<<24)}function B1(s,n,o){n.glyphs=[],s===1&&o.readMessage(Ec,n)}function Ec(s,n,o){if(s===3){const{id:d,bitmap:g,width:v,height:E,left:L,top:k,advance:V}=o.readMessage(Wf,{});n.glyphs.push({id:d,bitmap:new Yl({width:v+6,height:E+6},g),metrics:{width:v,height:E,left:L,top:k,advance:V}})}else s===4?n.ascender=o.readSVarint():s===5&&(n.descender=o.readSVarint())}function Wf(s,n,o){s===1?n.id=o.readVarint():s===2?n.bitmap=o.readBytes():s===3?n.width=o.readVarint():s===4?n.height=o.readVarint():s===5?n.left=o.readSVarint():s===6?n.top=o.readSVarint():s===7&&(n.advance=o.readVarint())}function jf(s){let n=0,o=0;for(const E of s)n+=E.w*E.h,o=Math.max(o,E.w);s.sort((E,L)=>L.h-E.h);const d=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(n/.95)),o),h:1/0}];let g=0,v=0;for(const E of s)for(let L=d.length-1;L>=0;L--){const k=d[L];if(!(E.w>k.w||E.h>k.h)){if(E.x=k.x,E.y=k.y,v=Math.max(v,E.y+E.h),g=Math.max(g,E.x+E.w),E.w===k.w&&E.h===k.h){const V=d.pop();L>3,v=this.pos;this.type=7&d,s(g,n,this),this.pos===v&&this.skip(d)}return n},readMessage:function(s,n){return this.readFields(s,n,this.readVarint()+this.pos)},readFixed32:function(){var s=Gf(this.buf,this.pos);return this.pos+=4,s},readSFixed32:function(){var s=h0(this.buf,this.pos);return this.pos+=4,s},readFixed64:function(){var s=Gf(this.buf,this.pos)+Gf(this.buf,this.pos+4)*Zo;return this.pos+=8,s},readSFixed64:function(){var s=Gf(this.buf,this.pos)+h0(this.buf,this.pos+4)*Zo;return this.pos+=8,s},readFloat:function(){var s=Ah(this.buf,this.pos,!0,23,4);return this.pos+=4,s},readDouble:function(){var s=Ah(this.buf,this.pos,!0,52,8);return this.pos+=8,s},readVarint:function(s){var n,o,d=this.buf;return n=127&(o=d[this.pos++]),o<128?n:(n|=(127&(o=d[this.pos++]))<<7,o<128?n:(n|=(127&(o=d[this.pos++]))<<14,o<128?n:(n|=(127&(o=d[this.pos++]))<<21,o<128?n:function(g,v,E){var L,k,V=E.buf;if(L=(112&(k=V[E.pos++]))>>4,k<128||(L|=(127&(k=V[E.pos++]))<<3,k<128)||(L|=(127&(k=V[E.pos++]))<<10,k<128)||(L|=(127&(k=V[E.pos++]))<<17,k<128)||(L|=(127&(k=V[E.pos++]))<<24,k<128)||(L|=(1&(k=V[E.pos++]))<<31,k<128))return Fu(g,L,v);throw new Error("Expected varint not more than 10 bytes")}(n|=(15&(o=d[this.pos]))<<28,s,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var s=this.readVarint();return s%2==1?(s+1)/-2:s/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var s=this.readVarint()+this.pos,n=this.pos;return this.pos=s,s-n>=12&&Td?function(o,d,g){return Td.decode(o.subarray(d,g))}(this.buf,n,s):function(o,d,g){for(var v="",E=d;E239?4:q>223?3:q>191?2:1;if(E+he>g)break;he===1?q<128&&(se=q):he===2?(192&(L=o[E+1]))==128&&(se=(31&q)<<6|63&L)<=127&&(se=null):he===3?(k=o[E+2],(192&(L=o[E+1]))==128&&(192&k)==128&&((se=(15&q)<<12|(63&L)<<6|63&k)<=2047||se>=55296&&se<=57343)&&(se=null)):he===4&&(k=o[E+2],V=o[E+3],(192&(L=o[E+1]))==128&&(192&k)==128&&(192&V)==128&&((se=(15&q)<<18|(63&L)<<12|(63&k)<<6|63&V)<=65535||se>=1114112)&&(se=null)),se===null?(se=65533,he=1):se>65535&&(se-=65536,v+=String.fromCharCode(se>>>10&1023|55296),se=56320|1023&se),v+=String.fromCharCode(se),E+=he}return v}(this.buf,n,s)},readBytes:function(){var s=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,s);return this.pos=s,n},readPackedVarint:function(s,n){if(this.type!==vr.Bytes)return s.push(this.readVarint(n));var o=ph(this);for(s=s||[];this.pos127;);else if(n===vr.Bytes)this.pos=this.readVarint()+this.pos;else if(n===vr.Fixed32)this.pos+=4;else{if(n!==vr.Fixed64)throw new Error("Unimplemented type: "+n);this.pos+=8}},writeTag:function(s,n){this.writeVarint(s<<3|n)},realloc:function(s){for(var n=this.length||16;n268435455||s<0?function(n,o){var d,g;if(n>=0?(d=n%4294967296|0,g=n/4294967296|0):(g=~(-n/4294967296),4294967295^(d=~(-n%4294967296))?d=d+1|0:(d=0,g=g+1|0)),n>=18446744073709552e3||n<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");o.realloc(10),function(v,E,L){L.buf[L.pos++]=127&v|128,v>>>=7,L.buf[L.pos++]=127&v|128,v>>>=7,L.buf[L.pos++]=127&v|128,v>>>=7,L.buf[L.pos++]=127&v|128,L.buf[L.pos]=127&(v>>>=7)}(d,0,o),function(v,E){var L=(7&v)<<4;E.buf[E.pos++]|=L|((v>>>=3)?128:0),v&&(E.buf[E.pos++]=127&v|((v>>>=7)?128:0),v&&(E.buf[E.pos++]=127&v|((v>>>=7)?128:0),v&&(E.buf[E.pos++]=127&v|((v>>>=7)?128:0),v&&(E.buf[E.pos++]=127&v|((v>>>=7)?128:0),v&&(E.buf[E.pos++]=127&v)))))}(g,o)}(s,this):(this.realloc(4),this.buf[this.pos++]=127&s|(s>127?128:0),s<=127||(this.buf[this.pos++]=127&(s>>>=7)|(s>127?128:0),s<=127||(this.buf[this.pos++]=127&(s>>>=7)|(s>127?128:0),s<=127||(this.buf[this.pos++]=s>>>7&127))))},writeSVarint:function(s){this.writeVarint(s<0?2*-s-1:2*s)},writeBoolean:function(s){this.writeVarint(Boolean(s))},writeString:function(s){s=String(s),this.realloc(4*s.length),this.pos++;var n=this.pos;this.pos=function(d,g,v){for(var E,L,k=0;k55295&&E<57344){if(!L){E>56319||k+1===g.length?(d[v++]=239,d[v++]=191,d[v++]=189):L=E;continue}if(E<56320){d[v++]=239,d[v++]=191,d[v++]=189,L=E;continue}E=L-55296<<10|E-56320|65536,L=null}else L&&(d[v++]=239,d[v++]=191,d[v++]=189,L=null);E<128?d[v++]=E:(E<2048?d[v++]=E>>6|192:(E<65536?d[v++]=E>>12|224:(d[v++]=E>>18|240,d[v++]=E>>12&63|128),d[v++]=E>>6&63|128),d[v++]=63&E|128)}return v}(this.buf,s,this.pos);var o=this.pos-n;o>=128&&Hf(n,o,this),this.pos=n-1,this.writeVarint(o),this.pos+=o},writeFloat:function(s){this.realloc(4),El(this.buf,s,this.pos,!0,23,4),this.pos+=4},writeDouble:function(s){this.realloc(8),El(this.buf,s,this.pos,!0,52,8),this.pos+=8},writeBytes:function(s){var n=s.length;this.writeVarint(n),this.realloc(n);for(var o=0;o=128&&Hf(o,d,this),this.pos=o-1,this.writeVarint(d),this.pos+=d},writeMessage:function(s,n,o){this.writeTag(s,vr.Bytes),this.writeRawMessage(n,o)},writePackedVarint:function(s,n){n.length&&this.writeMessage(s,tu,n)},writePackedSVarint:function(s,n){n.length&&this.writeMessage(s,l0,n)},writePackedBoolean:function(s,n){n.length&&this.writeMessage(s,c0,n)},writePackedFloat:function(s,n){n.length&&this.writeMessage(s,Ug,n)},writePackedDouble:function(s,n){n.length&&this.writeMessage(s,Rg,n)},writePackedFixed32:function(s,n){n.length&&this.writeMessage(s,x1,n)},writePackedSFixed32:function(s,n){n.length&&this.writeMessage(s,v1,n)},writePackedFixed64:function(s,n){n.length&&this.writeMessage(s,w1,n)},writePackedSFixed64:function(s,n){n.length&&this.writeMessage(s,b1,n)},writeBytesField:function(s,n){this.writeTag(s,vr.Bytes),this.writeBytes(n)},writeFixed32Field:function(s,n){this.writeTag(s,vr.Fixed32),this.writeFixed32(n)},writeSFixed32Field:function(s,n){this.writeTag(s,vr.Fixed32),this.writeSFixed32(n)},writeFixed64Field:function(s,n){this.writeTag(s,vr.Fixed64),this.writeFixed64(n)},writeSFixed64Field:function(s,n){this.writeTag(s,vr.Fixed64),this.writeSFixed64(n)},writeVarintField:function(s,n){this.writeTag(s,vr.Varint),this.writeVarint(n)},writeSVarintField:function(s,n){this.writeTag(s,vr.Varint),this.writeSVarint(n)},writeStringField:function(s,n){this.writeTag(s,vr.Bytes),this.writeString(n)},writeFloatField:function(s,n){this.writeTag(s,vr.Fixed32),this.writeFloat(n)},writeDoubleField:function(s,n){this.writeTag(s,vr.Fixed64),this.writeDouble(n)},writeBooleanField:function(s,n){this.writeVarintField(s,Boolean(n))}};class Xo{constructor(n,{pixelRatio:o,version:d,stretchX:g,stretchY:v,content:E}){this.paddedRect=n,this.pixelRatio=o,this.stretchX=g,this.stretchY=v,this.content=E,this.version=d}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Tc{constructor(n,o){const d={},g={};this.haveRenderCallbacks=[];const v=[];this.addImages(n,d,v),this.addImages(o,g,v);const{w:E,h:L}=jf(v),k=new Za({width:E||1,height:L||1});for(const V in n){const q=n[V],se=d[V].paddedRect;Za.copy(q.data,k,{x:0,y:0},{x:se.x+1,y:se.y+1},q.data)}for(const V in o){const q=o[V],se=g[V].paddedRect,he=se.x+1,_e=se.y+1,Be=q.data.width,Le=q.data.height;Za.copy(q.data,k,{x:0,y:0},{x:he,y:_e},q.data),Za.copy(q.data,k,{x:0,y:Le-1},{x:he,y:_e-1},{width:Be,height:1}),Za.copy(q.data,k,{x:0,y:0},{x:he,y:_e+Le},{width:Be,height:1}),Za.copy(q.data,k,{x:Be-1,y:0},{x:he-1,y:_e},{width:1,height:Le}),Za.copy(q.data,k,{x:0,y:0},{x:he+Be,y:_e},{width:1,height:Le})}this.image=k,this.iconPositions=d,this.patternPositions=g}addImages(n,o,d){for(const g in n){const v=n[g],E={x:0,y:0,w:v.data.width+2,h:v.data.height+2};d.push(E),o[g]=new Xo(E,v),v.hasRenderCallback&&this.haveRenderCallbacks.push(g)}}patchUpdatedImages(n,o){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(d=>n.hasImage(d)),n.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const d in n.updatedImages)this.patchUpdatedImage(this.iconPositions[d],n.getImage(d),o),this.patchUpdatedImage(this.patternPositions[d],n.getImage(d),o)}patchUpdatedImage(n,o,d){if(!n||!o||n.version===o.version)return;n.version=o.version;const[g,v]=n.tl;d.update(o.data,void 0,{x:g,y:v})}}zt(Xo,"ImagePosition"),zt(Tc,"ImageAtlas");const qo={horizontal:1,vertical:2,horizontalOnly:3};class iu{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(n,o){const d=new iu;return d.scale=n||1,d.fontStack=o,d}static forImage(n){const o=new iu;return o.imageName=n,o}}class IA{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(n,o){const d=new IA;for(let g=0;g=0&&d>=n&&u0[this.text.charCodeAt(d)];d--)o--;this.text=this.text.substring(n,o),this.sectionIndex=this.sectionIndex.slice(n,o)}substring(n,o){const d=new IA;return d.text=this.text.substring(n,o),d.sectionIndex=this.sectionIndex.slice(n,o),d.sections=this.sections,d}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((n,o)=>Math.max(n,this.sections[o].scale),0)}addTextSection(n,o){this.text+=n.text,this.sections.push(iu.forText(n.scale,n.fontStack||o));const d=this.sections.length-1;for(let g=0;g=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function nu(s,n,o,d,g,v,E,L,k,V,q,se,he,_e,Be){const Le=IA.fromFeature(s,g);se===qo.vertical&&Le.verticalizePunctuation(he);let Xe=[];const xt=function(Ut,ci,oi,Ti,Ki,gi){if(!Ut)return[];const Si=[],Li=function(sn,Kn,dn,Ln,ln,Xn){let Tr=0;for(let wr=0;wr=0;let Zi=0;for(let sn=0;sn0&&DA>_s&&(_s=DA)}else{const Ya=oi[Ao.fontStack];if(!Ya)continue;Ya[Vr]&&(ss=Ya[Vr]);const ta=ci[Ao.fontStack];if(!ta)continue;const DA=ta.glyphs[Vr];if(!DA)continue;if(vo=DA.metrics,La=Vr!==8203?Jr:0,Xn){const tm=ta.ascender!==void 0?Math.abs(ta.ascender):0,$g=ta.descender!==void 0?Math.abs(ta.descender):0,Zg=(tm+$g)*Ps;bs-o/2;){if(E--,E<0)return!1;L-=s[E].dist(v),v=s[E]}L+=s[E].dist(s[E+1]),E++;const k=[];let V=0;for(;Ld;)V-=k.shift().angleDelta;if(V>g)return!1;E++,L+=q.dist(se)}return!0}function UB(s){let n=0;for(let o=0;oV){const Be=(V-k)/_e,Le=gr(se.x,he.x,Be),Xe=gr(se.y,he.y,Be),xt=new FA(Le,Xe,0,he.angleTo(se),q);return!E||PB(s,xt,L,E,n)?xt:void 0}k+=_e}}function YF(s,n,o,d,g,v,E,L,k){const V=RB(d,v,E),q=zB(d,g),se=q*E,he=s[0].x===0||s[0].x===k||s[0].y===0||s[0].y===k;return n-se=0&&Tt=0&&kt=0&&he+V<=q){const Ut=new FA(Tt,kt,0,Dt,Be);Ut._round(),d&&!PB(s,Ut,v,d,g)||_e.push(Ut)}}se+=xt}return L||_e.length||E||(_e=kB(s,se/2,o,d,g,v,E,!0,k)),_e}function OB(s,n,o,d,g){const v=[];for(let E=0;E=d&&se.x>=d||(q.x>=d?q=new me(d,q.y+(d-q.x)/(se.x-q.x)*(se.y-q.y))._round():se.x>=d&&(se=new me(d,q.y+(d-q.x)/(se.x-q.x)*(se.y-q.y))._round()),q.y>=g&&se.y>=g||(q.y>=g?q=new me(q.x+(g-q.y)/(se.y-q.y)*(se.x-q.x),g)._round():se.y>=g&&(se=new me(q.x+(g-q.y)/(se.y-q.y)*(se.x-q.x),g)._round()),k&&q.equals(k[k.length-1])||(k=[q],v.push(k)),k.push(se)))))}}return v}zt(FA,"Anchor");const zg=1e20;function NB(s,n,o,d,g,v,E,L,k){for(let V=n;V-1);k++,v[k]=L,E[k]=V,E[k+1]=zg}for(let L=0,k=0;L{let L=this.entries[g];L||(L=this.entries[g]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let k=L.glyphs[v];if(k!==void 0)return void E(null,{stack:g,id:v,glyph:k});if(k=this._tinySDF(L,g,v),k)return L.glyphs[v]=k,void E(null,{stack:g,id:v,glyph:k});const V=Math.floor(v/256);if(256*V>65535)return void E(new Error("glyphs > 65535 not supported"));if(L.ranges[V])return void E(null,{stack:g,id:v,glyph:k});let q=L.requests[V];q||(q=L.requests[V]=[],Kf.loadGlyphRange(g,V,this.url,this.requestManager,(se,he)=>{if(he){L.ascender=he.ascender,L.descender=he.descender;for(const _e in he.glyphs)this._doesCharSupportLocalGlyph(+_e)||(L.glyphs[+_e]=he.glyphs[+_e]);L.ranges[V]=!0}for(const _e of q)_e(se,he);delete L.requests[V]})),q.push((se,he)=>{se?E(se):he&&E(null,{stack:g,id:v,glyph:he.glyphs[v]||null})})},(g,v)=>{if(g)o(g);else if(v){const E={};for(const{stack:L,id:k,glyph:V}of v)E[L]===void 0&&(E[L]={}),E[L].glyphs===void 0&&(E[L].glyphs={}),E[L].glyphs[k]=V&&{id:V.id,bitmap:V.bitmap.clone(),metrics:V.metrics},E[L].ascender=this.entries[L].ascender,E[L].descender=this.entries[L].descender;o(null,E)}})}_doesCharSupportLocalGlyph(n){return this.localGlyphMode!==E1.none&&(this.localGlyphMode===E1.all?!!this.localFontFamily:!!this.localFontFamily&&(Wa(n)||Ba(n)||Lr(n)||Rr(n)||Un(n)))}_tinySDF(n,o,d){const g=this.localFontFamily;if(!g||!this._doesCharSupportLocalGlyph(d))return;let v=n.tinySDF;if(!v){let Le="400";/bold/i.test(o)?Le="900":/medium/i.test(o)?Le="500":/light/i.test(o)&&(Le="200"),v=n.tinySDF=new Kf.TinySDF({fontFamily:g,fontWeight:Le,fontSize:48,buffer:6,radius:16}),v.fontWeight=Le}if(this.localGlyphs[v.fontWeight][d])return this.localGlyphs[v.fontWeight][d];const E=String.fromCharCode(d),{data:L,width:k,height:V,glyphWidth:q,glyphHeight:se,glyphLeft:he,glyphTop:_e,glyphAdvance:Be}=v.draw(E);return this.localGlyphs[v.fontWeight][d]={id:d,bitmap:new Yl({width:k,height:V},L),metrics:{width:q/2,height:se/2,left:he/2,top:_e/2-27,advance:Be/2,localGlyph:!0}}}}function VB(s,n,o,d){const g=[],v=s.image,E=v.pixelRatio,L=v.paddedRect.w-2,k=v.paddedRect.h-2,V=s.right-s.left,q=s.bottom-s.top,se=v.stretchX||[[0,L]],he=v.stretchY||[[0,k]],_e=(gi,Si)=>gi+Si[1]-Si[0],Be=se.reduce(_e,0),Le=he.reduce(_e,0),Xe=L-Be,xt=k-Le;let Dt=0,_t=Be,Tt=0,kt=Le,Ut=0,ci=Xe,oi=0,Ti=xt;if(v.content&&d){const gi=v.content;Dt=A0(se,0,gi[0]),Tt=A0(he,0,gi[1]),_t=A0(se,gi[0],gi[2]),kt=A0(he,gi[1],gi[3]),Ut=gi[0]-Dt,oi=gi[1]-Tt,ci=gi[2]-gi[0]-_t,Ti=gi[3]-gi[1]-kt}const Ki=(gi,Si,Li,Vi)=>{const Zi=d0(gi.stretch-Dt,_t,V,s.left),yi=p0(gi.fixed-Ut,ci,gi.stretch,Be),sn=d0(Si.stretch-Tt,kt,q,s.top),Kn=p0(Si.fixed-oi,Ti,Si.stretch,Le),dn=d0(Li.stretch-Dt,_t,V,s.left),Ln=p0(Li.fixed-Ut,ci,Li.stretch,Be),ln=d0(Vi.stretch-Tt,kt,q,s.top),Xn=p0(Vi.fixed-oi,Ti,Vi.stretch,Le),Tr=new me(Zi,sn),wr=new me(dn,sn),xr=new me(dn,ln),Jn=new me(Zi,ln),es=new me(yi/E,Kn/E),ir=new me(Ln/E,Xn/E),Sr=n*Math.PI/180;if(Sr){const ds=Math.sin(Sr),_s=Math.cos(Sr),bs=[_s,-ds,ds,_s];Tr._matMult(bs),wr._matMult(bs),Jn._matMult(bs),xr._matMult(bs)}const rs=gi.stretch+gi.fixed,gs=Si.stretch+Si.fixed;return{tl:Tr,tr:wr,bl:Jn,br:xr,tex:{x:v.paddedRect.x+1+rs,y:v.paddedRect.y+1+gs,w:Li.stretch+Li.fixed-rs,h:Vi.stretch+Vi.fixed-gs},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:es,pixelOffsetBR:ir,minFontScaleX:ci/E/V,minFontScaleY:Ti/E/q,isSDF:o}};if(d&&(v.stretchX||v.stretchY)){const gi=HB(se,Xe,Be),Si=HB(he,xt,Le);for(let Li=0;Li{if(k)g(k);else if(V){const q={},se=function(he){return new Fa(he).readFields(B1,{})}(V);for(const he of se.glyphs)q[he.id]=he;g(null,{glyphs:q,ascender:se.ascender,descender:se.descender})}})},Kf.TinySDF=class{constructor({fontSize:s=24,buffer:n=3,radius:o=8,cutoff:d=.25,fontFamily:g="sans-serif",fontWeight:v="normal",fontStyle:E="normal"}={}){this.buffer=n,this.cutoff=d,this.radius=o;const L=this.size=s+4*n,k=this._createCanvas(L),V=this.ctx=k.getContext("2d",{willReadFrequently:!0});V.font=`${E} ${v} ${s}px ${g}`,V.textBaseline="alphabetic",V.textAlign="left",V.fillStyle="black",this.gridOuter=new Float64Array(L*L),this.gridInner=new Float64Array(L*L),this.f=new Float64Array(L),this.z=new Float64Array(L+1),this.v=new Uint16Array(L)}_createCanvas(s){const n=document.createElement("canvas");return n.width=n.height=s,n}draw(s){const{width:n,actualBoundingBoxAscent:o,actualBoundingBoxDescent:d,actualBoundingBoxLeft:g,actualBoundingBoxRight:v}=this.ctx.measureText(s),E=Math.ceil(o),L=Math.min(this.size-this.buffer,Math.ceil(v-g)),k=Math.min(this.size-this.buffer,E+Math.ceil(d)),V=L+2*this.buffer,q=k+2*this.buffer,se=Math.max(V*q,0),he=new Uint8ClampedArray(se),_e={data:he,width:V,height:q,glyphWidth:L,glyphHeight:k,glyphTop:E,glyphLeft:0,glyphAdvance:n};if(L===0||k===0)return _e;const{ctx:Be,buffer:Le,gridInner:Xe,gridOuter:xt}=this;Be.clearRect(Le,Le,L,k),Be.fillText(s,Le,Le+E);const Dt=Be.getImageData(Le,Le,L,k);xt.fill(zg,0,se),Xe.fill(0,0,se);for(let _t=0;_t0?ci*ci:0,Xe[Ut]=ci<0?ci*ci:0}}NB(xt,0,0,V,q,V,this.f,this.v,this.z),NB(Xe,Le,Le,L,k,V,this.f,this.v,this.z);for(let _t=0;_t0)for(let d=(this.length>>1)-1;d>=0;d--)this._down(d)}push(n){this.data.push(n),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const n=this.data[0],o=this.data.pop();return this.length--,this.length>0&&(this.data[0]=o,this._down(0)),n}peek(){return this.data[0]}_up(n){const{data:o,compare:d}=this,g=o[n];for(;n>0;){const v=n-1>>1,E=o[v];if(d(g,E)>=0)break;o[n]=E,n=v}o[n]=g}_down(n){const{data:o,compare:d}=this,g=this.length>>1,v=o[n];for(;n=0)break;o[n]=L,n=E}o[n]=v}}function t3(s,n){return sn?1:0}function i3(s,n=1,o=!1){let d=1/0,g=1/0,v=-1/0,E=-1/0;const L=s[0];for(let _e=0;_ev)&&(v=Be.x),(!_e||Be.y>E)&&(E=Be.y)}const k=Math.min(v-d,E-g);let V=k/2;const q=new e3([],n3);if(k===0)return new me(d,g);for(let _e=d;_ese.d||!se.d)&&(se=_e,o&&console.log("found best %d after %d probes",Math.round(1e4*_e.d)/1e4,he)),_e.max-se.d<=n||(V=_e.h/2,q.push(new $f(_e.p.x-V,_e.p.y-V,V,s)),q.push(new $f(_e.p.x+V,_e.p.y-V,V,s)),q.push(new $f(_e.p.x-V,_e.p.y+V,V,s)),q.push(new $f(_e.p.x+V,_e.p.y+V,V,s)),he+=4)}return o&&(console.log(`num probes: ${he}`),console.log(`best distance: ${se.d}`)),se.p}function n3(s,n){return n.max-s.max}function $f(s,n,o,d){this.p=new me(s,n),this.h=o,this.d=function(g,v){let E=!1,L=1/0;for(let k=0;kg.y!=Be.y>g.y&&g.x<(Be.x-_e.x)*(g.y-_e.y)/(Be.y-_e.y)+_e.x&&(E=!E),L=Math.min(L,fg(g,_e,Be))}}return(E?1:-1)*Math.sqrt(L)}(this.p,d),this.max=this.d+this.h*Math.SQRT2}const T1=Number.POSITIVE_INFINITY,r3=Math.sqrt(2);function GB(s,[n,o]){let d=0,g=0;if(o===T1){n<0&&(n=0);const v=n/r3;switch(s){case"top-right":case"top-left":g=v-7;break;case"bottom-right":case"bottom-left":g=7-v;break;case"bottom":g=7-n;break;case"top":g=n-7}switch(s){case"top-right":case"bottom-right":d=-v;break;case"top-left":case"bottom-left":d=v;break;case"left":d=n;break;case"right":d=-n}}else{switch(n=Math.abs(n),o=Math.abs(o),s){case"top-right":case"top-left":case"top":g=o-7;break;case"bottom-right":case"bottom-left":case"bottom":g=7-o}switch(s){case"top-right":case"bottom-right":case"right":d=-n;break;case"top-left":case"bottom-left":case"left":d=n}}return[d,g]}function s3(s,n,o,d,g,v,E,L,k,V){s.createArrays(),s.tilePixelRatio=Zn/(512*s.overscaling),s.compareText={},s.iconsNeedLinear=!1;const q=s.layers[0].layout,se=s.layers[0]._unevaluatedLayout._values,he={};if(s.textSizeData.kind==="composite"){const{minZoom:Le,maxZoom:Xe}=s.textSizeData;he.compositeTextSizes=[se["text-size"].possiblyEvaluate(new qt(Le),L),se["text-size"].possiblyEvaluate(new qt(Xe),L)]}if(s.iconSizeData.kind==="composite"){const{minZoom:Le,maxZoom:Xe}=s.iconSizeData;he.compositeIconSizes=[se["icon-size"].possiblyEvaluate(new qt(Le),L),se["icon-size"].possiblyEvaluate(new qt(Xe),L)]}he.layoutTextSize=se["text-size"].possiblyEvaluate(new qt(k+1),L),he.layoutIconSize=se["icon-size"].possiblyEvaluate(new qt(k+1),L),he.textMaxSize=se["text-size"].possiblyEvaluate(new qt(18),L);const _e=q.get("text-rotation-alignment")==="map"&&q.get("symbol-placement")!=="point",Be=q.get("text-size");for(const Le of s.features){const Xe=q.get("text-font").evaluate(Le,{},L).join(","),xt=Be.evaluate(Le,{},L),Dt=he.layoutTextSize.evaluate(Le,{},L),_t=(he.layoutIconSize.evaluate(Le,{},L),{horizontal:{},vertical:void 0}),Tt=Le.text;let kt,Ut=[0,0];if(Tt){const Ti=Tt.toString(),Ki=q.get("text-letter-spacing").evaluate(Le,{},L)*Jr,gi=q.get("text-line-height").evaluate(Le,{},L)*Jr,Si=W(Ti)?Ki:0,Li=q.get("text-anchor").evaluate(Le,{},L),Vi=q.get("text-variable-anchor");if(!Vi){const dn=q.get("text-radial-offset").evaluate(Le,{},L);Ut=dn?GB(Li,[dn*Jr,T1]):q.get("text-offset").evaluate(Le,{},L).map(Ln=>Ln*Jr)}let Zi=_e?"center":q.get("text-justify").evaluate(Le,{},L);const yi=q.get("symbol-placement")==="point",sn=yi?q.get("text-max-width").evaluate(Le,{},L)*Jr:1/0,Kn=dn=>{s.allowVerticalPlacement&&H(Ti)&&(_t.vertical=nu(Tt,n,o,g,Xe,sn,gi,Li,dn,Si,Ut,qo.vertical,!0,Dt,xt))};if(!_e&&Vi){const dn=Zi==="auto"?Vi.map(ln=>S1(ln)):[Zi];let Ln=!1;for(let ln=0;ln=0||!H(Ti)){const dn=nu(Tt,n,o,g,Xe,sn,gi,Li,Zi,Si,Ut,qo.horizontal,!1,Dt,xt);dn&&(_t.horizontal[Zi]=dn)}Kn(yi?"left":Zi)}}let ci=!1;if(Le.icon&&Le.icon.name){const Ti=d[Le.icon.name];Ti&&(kt=XF(g[Le.icon.name],q.get("icon-offset").evaluate(Le,{},L),q.get("icon-anchor").evaluate(Le,{},L)),ci=Ti.sdf,s.sdfIcons===void 0?s.sdfIcons=Ti.sdf:s.sdfIcons!==Ti.sdf&&Ct("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Ti.pixelRatio!==s.pixelRatio||q.get("icon-rotate").constantOr(1)!==0)&&(s.iconsNeedLinear=!0))}const oi=jB(_t.horizontal)||_t.vertical;s.iconsInText||(s.iconsInText=!!oi&&oi.iconsInText),(oi||kt)&&o3(s,Le,_t,kt,d,he,Dt,0,Ut,ci,E,L,V)}v&&s.generateCollisionDebugBuffers(k,s.collisionBoxArray)}function S1(s){switch(s){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function o3(s,n,o,d,g,v,E,L,k,V,q,se,he){let _e=v.textMaxSize.evaluate(n,{},se);_e===void 0&&(_e=E);const Be=s.layers[0].layout,Le=Be.get("icon-offset").evaluate(n,{},se),Xe=jB(o.horizontal)||o.vertical,xt=he.name==="globe",Dt=E/24,_t=s.tilePixelRatio*_e/24,Tt=(Si=s.overscaling,s.zoom>18&&Si>2&&(Si>>=1),Math.max(Zn/(512*Si),1)*Be.get("symbol-spacing")),kt=Be.get("text-padding")*s.tilePixelRatio,Ut=Be.get("icon-padding")*s.tilePixelRatio,ci=Ge(Be.get("text-max-angle")),oi=Be.get("text-rotation-alignment")==="map"&&Be.get("symbol-placement")!=="point",Ti=Be.get("icon-rotation-alignment")==="map"&&Be.get("symbol-placement")!=="point",Ki=Be.get("symbol-placement"),gi=Tt/2;var Si;const Li=Be.get("icon-text-fit");let Vi;d&&Li!=="none"&&(s.allowVerticalPlacement&&o.vertical&&(Vi=DB(d,o.vertical,Li,Be.get("icon-text-fit-padding"),Le,Dt)),Xe&&(d=DB(d,Xe,Li,Be.get("icon-text-fit-padding"),Le,Dt)));const Zi=(yi,sn,Kn)=>{if(sn.x<0||sn.x>=Zn||sn.y<0||sn.y>=Zn)return;let dn=null;if(xt){const{x:Ln,y:ln,z:Xn}=he.projectTilePoint(sn.x,sn.y,Kn);dn={anchor:new FA(Ln,ln,Xn,0,void 0),up:he.upVector(Kn,sn.x,sn.y)}}(function(Ln,ln,Xn,Tr,wr,xr,Jn,es,ir,Sr,rs,gs,ds,_s,bs,Zs,Yo,ts,Ao,lo,Vr,Ps,vo,ss,no){const La=Ln.addToLineVertexArray(ln,Tr);let Jo,ea,Ya,ta,DA,tm,$g,Zg=0,IC=0,FC=0,LC=0,W1=-1,j1=-1;const Ru={};let DC=ad.exports("");const Up=Xn?Xn.anchor:ln;let K1=0,$1=0;if(ir._unevaluatedLayout.getValue("text-radial-offset")===void 0?[K1,$1]=ir.layout.get("text-offset").evaluate(Vr,{},no).map(ec=>ec*Jr):(K1=ir.layout.get("text-radial-offset").evaluate(Vr,{},no)*Jr,$1=T1),Ln.allowVerticalPlacement&&wr.vertical){const ec=wr.vertical;if(bs)tm=M1(ec),es&&($g=M1(es));else{const tc=ir.layout.get("text-rotate").evaluate(Vr,{},no)+90;Ya=f0(Sr,Up,ln,rs,gs,ds,ec,_s,tc,Zs),es&&(ta=f0(Sr,Up,ln,rs,gs,ds,es,ts,tc))}}if(xr){const ec=ir.layout.get("icon-rotate").evaluate(Vr,{},no),tc=ir.layout.get("icon-text-fit")!=="none",Xg=VB(xr,ec,vo,tc),X1=es?VB(es,ec,vo,tc):void 0;ea=f0(Sr,Up,ln,rs,gs,ds,xr,ts,ec),Zg=4*Xg.length;const PC=Ln.iconSizeData;let Rp=null;PC.kind==="source"?(Rp=[Vs*ir.layout.get("icon-size").evaluate(Vr,{},no)],Rp[0]>Md&&Ct(`${Ln.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):PC.kind==="composite"&&(Rp=[Vs*Ps.compositeIconSizes[0].evaluate(Vr,{},no),Vs*Ps.compositeIconSizes[1].evaluate(Vr,{},no)],(Rp[0]>Md||Rp[1]>Md)&&Ct(`${Ln.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),Ln.addSymbols(Ln.icon,Xg,Rp,lo,Ao,Vr,!1,Xn,ln,La.lineStartIndex,La.lineLength,-1,ss,no),W1=Ln.icon.placedSymbolArray.length-1,X1&&(IC=4*X1.length,Ln.addSymbols(Ln.icon,X1,Rp,lo,Ao,Vr,qo.vertical,Xn,ln,La.lineStartIndex,La.lineLength,-1,ss,no),j1=Ln.icon.placedSymbolArray.length-1)}for(const ec in wr.horizontal){const tc=wr.horizontal[ec];Jo||(DC=ad.exports(tc.text),bs?DA=M1(tc):Jo=f0(Sr,Up,ln,rs,gs,ds,tc,_s,ir.layout.get("text-rotate").evaluate(Vr,{},no),Zs));const Xg=tc.positionedLines.length===1;if(FC+=WB(Ln,Xn,ln,tc,Jn,ir,bs,Vr,Zs,La,wr.vertical?qo.horizontal:qo.horizontalOnly,Xg?Object.keys(wr.horizontal):[ec],Ru,W1,Ps,ss,no),Xg)break}wr.vertical&&(LC+=WB(Ln,Xn,ln,wr.vertical,Jn,ir,bs,Vr,Zs,La,qo.vertical,["vertical"],Ru,j1,Ps,ss,no));let Ud=-1;const Z1=(ec,tc)=>ec?Math.max(ec,tc):tc;Ud=Z1(DA,Ud),Ud=Z1(tm,Ud),Ud=Z1($g,Ud);const k3=Ud>-1?1:0;Ln.glyphOffsetArray.length>=Fd.MAX_GLYPHS&&Ct("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Vr.sortKey!==void 0&&Ln.addToSortKeyRanges(Ln.symbolInstances.length,Vr.sortKey),Ln.symbolInstances.emplaceBack(Up.x,Up.y,Up.z,ln.x,ln.y,Ru.right>=0?Ru.right:-1,Ru.center>=0?Ru.center:-1,Ru.left>=0?Ru.left:-1,Ru.vertical>=0?Ru.vertical:-1,W1,j1,DC,Jo!==void 0?Jo:Ln.collisionBoxArray.length,Jo!==void 0?Jo+1:Ln.collisionBoxArray.length,Ya!==void 0?Ya:Ln.collisionBoxArray.length,Ya!==void 0?Ya+1:Ln.collisionBoxArray.length,ea!==void 0?ea:Ln.collisionBoxArray.length,ea!==void 0?ea+1:Ln.collisionBoxArray.length,ta||Ln.collisionBoxArray.length,ta?ta+1:Ln.collisionBoxArray.length,rs,FC,LC,Zg,IC,k3,0,K1,$1,Ud)})(s,sn,dn,yi,o,d,g,Vi,s.layers[0],s.collisionBoxArray,n.index,n.sourceLayerIndex,s.index,kt,oi,k,0,Ut,Ti,Le,n,v,V,q,se)};if(Ki==="line")for(const yi of OB(n.geometry,0,0,Zn,Zn)){const sn=YF(yi,Tt,ci,o.vertical||Xe,d,24,_t,s.overscaling,Zn);for(const Kn of sn){const dn=Xe;dn&&a3(s,dn.text,gi,Kn)||Zi(yi,Kn,se)}}else if(Ki==="line-center"){for(const yi of n.geometry)if(yi.length>1){const sn=qF(yi,ci,o.vertical||Xe,d,24,_t);sn&&Zi(yi,sn,se)}}else if(n.type==="Polygon")for(const yi of Nf(n.geometry,0)){const sn=i3(yi,16);Zi(yi[0],new FA(sn.x,sn.y,0,0,void 0),se)}else if(n.type==="LineString")for(const yi of n.geometry)Zi(yi,new FA(yi[0].x,yi[0].y,0,0,void 0),se);else if(n.type==="Point")for(const yi of n.geometry)for(const sn of yi)Zi([sn],new FA(sn.x,sn.y,0,0,void 0),se)}const Md=32640;function WB(s,n,o,d,g,v,E,L,k,V,q,se,he,_e,Be,Le,Xe){const xt=function(Tt,kt,Ut,ci,oi,Ti,Ki,gi){const Si=[];if(kt.positionedLines.length===0)return Si;const Li=ci.layout.get("text-rotate").evaluate(Ti,{})*Math.PI/180,Vi=function(dn){const Ln=dn[0],ln=dn[1],Xn=Ln*ln;return Xn>0?[Ln,-ln]:Xn<0?[-Ln,ln]:Ln===0?[ln,Ln]:[ln,-Ln]}(Ut);let Zi=Math.abs(kt.top-kt.bottom);for(const dn of kt.positionedLines)Zi-=dn.lineOffset;const yi=kt.positionedLines.length,sn=Zi/yi;let Kn=kt.top-Ut[1];for(let dn=0;dnMd&&Ct(`${s.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):Dt.kind==="composite"&&(_t=[Vs*Be.compositeTextSizes[0].evaluate(L,{},Xe),Vs*Be.compositeTextSizes[1].evaluate(L,{},Xe)],(_t[0]>Md||_t[1]>Md)&&Ct(`${s.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),s.addSymbols(s.text,xt,_t,k,E,L,q,n,o,V.lineStartIndex,V.lineLength,_e,Le,Xe);for(const Tt of se)he[Tt]=s.text.placedSymbolArray.length-1;return 4*xt.length}function jB(s){for(const n in s)return s[n];return null}function f0(s,n,o,d,g,v,E,L,k,V){let q=E.top,se=E.bottom,he=E.left,_e=E.right;const Be=E.collisionPadding;if(Be&&(he-=Be[0],q-=Be[1],_e+=Be[2],se+=Be[3]),k){const Le=new me(he,q),Xe=new me(_e,q),xt=new me(he,se),Dt=new me(_e,se),_t=Ge(k);let Tt=new me(0,0);V&&(Tt=new me(V[0],V[1])),Le._rotateAround(_t,Tt),Xe._rotateAround(_t,Tt),xt._rotateAround(_t,Tt),Dt._rotateAround(_t,Tt),he=Math.min(Le.x,Xe.x,xt.x,Dt.x),_e=Math.max(Le.x,Xe.x,xt.x,Dt.x),q=Math.min(Le.y,Xe.y,xt.y,Dt.y),se=Math.max(Le.y,Xe.y,xt.y,Dt.y)}return s.emplaceBack(n.x,n.y,n.z,o.x,o.y,he,q,_e,se,L,d,g,v),s.length-1}function M1(s){s.collisionPadding&&(s.top-=s.collisionPadding[1],s.bottom+=s.collisionPadding[3]);const n=s.bottom-s.top;return n>0?Math.max(10,n):null}function a3(s,n,o,d){const g=s.compareText;if(n in g){const v=g[n];for(let E=v.length-1;E>=0;E--)if(d.dist(v[E])1?null:function(d,g,v,E){const L=Math.sin(v);return d*(Math.sin((1-E)*v)/L)+g*(Math.sin(E*v)/L)}(s.a[n],s.b[n],s.angle,ye(o,0,1))+s.center[n]}function Lu(s){if(s.z<=1)return c3[s.z+2*s.y+s.x];const n=L1(m0(s));return Ko.fromPoints(n)}function Lp(s,n,o){return da(s,s,1-o),eu(s,s,n,o)}function XB(s,n){const o=Yf(n.zoom);if(o===0)return Lu(s);const d=m0(s),g=L1(d),v=wc(d.getWest())*n.worldSize,E=wc(d.getEast())*n.worldSize,L=ch(d.getNorth())*n.worldSize,k=ch(d.getSouth())*n.worldSize,V=[v,L,0],q=[E,L,0],se=[v,k,0],he=[E,k,0],_e=_g([],n.globeMatrix);return Ns(V,V,_e),Ns(q,q,_e),Ns(se,se,_e),Ns(he,he,_e),g[0]=Lp(g[0],se,o),g[1]=Lp(g[1],he,o),g[2]=Lp(g[2],q,o),g[3]=Lp(g[3],V,o),Ko.fromPoints(g)}function qB(s,n,o){for(const d of s)Ns(d,d,n),da(d,d,o)}function u3(s,n,o){const d=n/s.worldSize,g=s.globeMatrix;if(o.z<=1){const oi=Lu(o).getCorners();return qB(oi,g,d),Ko.fromPoints(oi)}const v=m0(o),E=L1(v);qB(E,g,d);const L=Number.MAX_VALUE,k=[-L,-L,-L],V=[L,L,L];if(v.contains(s.center)){for(const Ki of E)EA(V,V,Ki),fd(k,k,Ki);k[2]=0;const oi=s.point,Ti=[oi.x*d,oi.y*d,0];return EA(V,V,Ti),fd(k,k,Ti),new Ko(V,k)}const q=[g[12]*d,g[13]*d,g[14]*d],se=v.getCenter(),he=ye(s.center.lat,-85.051129,$a),_e=ye(se.lat,-85.051129,$a),Be=wc(s.center.lng),Le=ch(he);let Xe=Be-wc(se.lng);const xt=Le-ch(_e);Xe>.5?Xe-=1:Xe<-.5&&(Xe+=1);let Dt=0;Math.abs(Xe)>Math.abs(xt)?Dt=Xe>=0?1:3:(Dt=xt>=0?0:2,eu(q,q,[g[4]*d,g[5]*d,g[6]*d],-Math.sin(Ge(xt>=0?v.getSouth():v.getNorth()))*LA));const _t=E[Dt],Tt=E[(Dt+1)%4],kt=new h3(_t,Tt,q),Ut=[F1(kt,0)||_t[0],F1(kt,1)||_t[1],F1(kt,2)||_t[2]],ci=Yf(s.zoom);if(ci>0){const oi=function({x:Ki,y:gi,z:Si},Li,Vi,Zi,yi){const sn=1/(1<.5?Xn=-1:Tr<-.5&&(Xn=1),Kn=((Kn+Xn)*Li-(Zi*=Li))*Vi+Zi,dn=((dn+Xn)*Li-Zi)*Vi+Zi,Ln=(Ln*Li-(yi*=Li))*Vi+yi,ln=(ln*Li-yi)*Vi+yi,[[Kn,ln,0],[dn,ln,0],[dn,Ln,0],[Kn,Ln,0]]}(o,n,s._pixelsPerMercatorPixel,Be,Le);for(let Ki=0;KiMath.PI/2*1.01}const tC=Ge(85),A3=Math.cos(tC),d3=Math.sin(tC);function iC(s,n){const o=s.fovAboveCenter,d=s.elevation?s.elevation.getMinElevationBelowMSL()*n:0,g=(s._camera.position[2]*s.worldSize-d)/Math.cos(s._pitch),v=Math.sin(o)*g/Math.sin(Math.max(Math.PI/2-s._pitch-o,.01)),E=Math.sin(s._pitch)*v+g;return Math.min(1.01*E,g*(1/s._horizonShift))}function Dp(s,n){if(!n.isReprojectedInTileSpace)return{scale:1<_t&&(Tt(Ut,Vi,oi,Ti,Si,Li),Tt(Vi,ci,Si,Li,Ki,gi))}Tt(se,he,d,v,g,v),Tt(he,_e,g,v,g,E),Tt(_e,Be,g,E,d,E),Tt(Be,se,d,E,d,v),Le-=_t,Xe-=_t,xt+=_t,Dt+=_t;const kt=1/Math.max(xt-Le,Dt-Xe);return{scale:kt,x:Le*kt,y:Xe*kt,x2:xt*kt,y2:Dt*kt,projection:n}}const p3=ql(new Float32Array(16));class Id{constructor(n){this.spec=n,this.name=n.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(n,o){return{x:0,y:0,z:0}}unproject(n,o){return new Pr(0,0)}projectTilePoint(n,o,d){return{x:n,y:o,z:0}}locationPoint(n,o,d=!0){return n._coordinatePoint(n.locationCoordinate(o),d)}pixelsPerMeter(n,o){return Xl(1,n)*o}pixelSpaceConversion(n,o,d){return 1}farthestPixelDistance(n){return iC(n,n.pixelsPerMeter)}pointCoordinate(n,o,d,g){const v=n.horizonLineFromTop(!1),E=new me(o,Math.max(v,d));return n.rayIntersectionCoordinate(n.pointRayIntersection(E,g))}pointCoordinate3D(n,o,d){const g=new me(o,d);if(n.elevation)return n.elevation.pointCoordinate(g);{const v=this.pointCoordinate(n,g.x,g.y,0);return[v.x,v.y,v.z]}}isPointAboveHorizon(n,o){if(n.elevation)return!this.pointCoordinate3D(n,o.x,o.y);const d=n.horizonLineFromTop();return o.y0?o<-Jf+d&&(o=-Jf+d):o>Jf-d&&(o=Jf-d);const E=v/Math.pow(y0(o),g);let L=E*Math.sin(g*n),k=v-E*Math.cos(g*n);return L=.5*(L/Math.PI+.5),k=.5*(k/Math.PI+.5),{x:L,y:this.southernCenter?k:1-k,z:0}}unproject(n,o){n=(2*n-.5)*Math.PI,this.southernCenter&&(o=1-o),o=(2*(1-o)-.5)*Math.PI;const{n:d,f:g}=this,v=g-o,E=Math.sign(v),L=Math.sign(d)*Math.sqrt(n*n+v*v);let k=Math.atan2(n,Math.abs(v))*E;v*d<0&&(k-=Math.PI*Math.sign(n)*E);const V=ye(Et(k/d)+this.center[0],-180,180),q=ye(Et(2*Math.atan(Math.pow(g/L,1/d))-Jf),-85.051129,$a);return new Pr(V,this.southernCenter?-q:q)}}class nC extends Id{constructor(n){super(n),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(n,o){return{x:wc(n),y:ch(o),z:0}}unproject(n,o){const d=bl(n),g=Fo(o);return new Pr(d,g)}}const rC=Ge($a);class y3 extends Id{project(n,o){const d=(o=Ge(o))*o,g=d*d;return{x:.5*((n=Ge(n))*(.8707-.131979*d+g*(g*(.003971*d-.001529*g)-.013791))/Math.PI+.5),y:1-.5*(o*(1.007226+d*(.015085+g*(.028874*d-.044475-.005916*g)))/Math.PI+1),z:0}}unproject(n,o){n=(2*n-.5)*Math.PI;let d=o=(2*(1-o)-1)*Math.PI,g=25,v=0,E=d*d;do{E=d*d;const V=E*E;v=(d*(1.007226+E*(.015085+V*(.028874*E-.044475-.005916*V)))-o)/(1.007226+E*(.045255+V*(.259866*E-.311325-.005916*11*V))),d=ye(d-v,-rC,rC)}while(Math.abs(v)>1e-6&&--g>0);E=d*d;const L=ye(Et(n/(.8707+E*(E*(E*E*E*(.003971-.001529*E)-.013791)-.131979))),-180,180),k=Et(d);return new Pr(L,k)}}const sC=Ge($a);class x3 extends Id{project(n,o){o=Ge(o),n=Ge(n);const d=Math.cos(o),g=2/Math.PI,v=Math.acos(d*Math.cos(n/2)),E=Math.sin(v)/v,L=.5*(n*g+2*d*Math.sin(n/2)/E)||0,k=.5*(o+Math.sin(o)/E)||0;return{x:.5*(L/Math.PI+.5),y:1-.5*(k/Math.PI+1),z:0}}unproject(n,o){let d=n=(2*n-.5)*Math.PI,g=o=(2*(1-o)-1)*Math.PI,v=25;const E=1e-6;let L=0,k=0;do{const V=Math.cos(g),q=Math.sin(g),se=2*q*V,he=q*q,_e=V*V,Be=Math.cos(d/2),Le=Math.sin(d/2),Xe=2*Be*Le,xt=Le*Le,Dt=1-_e*Be*Be,_t=Dt?1/Dt:0,Tt=Dt?Math.acos(V*Be)*Math.sqrt(1/Dt):0,kt=.5*(2*Tt*V*Le+2*d/Math.PI)-n,Ut=.5*(Tt*q+g)-o,ci=.5*_t*(_e*xt+Tt*V*Be*he)+1/Math.PI,oi=_t*(Xe*se/4-Tt*q*Le),Ti=.125*_t*(se*Le-Tt*q*_e*Xe),Ki=.5*_t*(he*Be+Tt*xt*V)+.5,gi=oi*Ti-Ki*ci;L=(Ut*oi-kt*Ki)/gi,k=(kt*Ti-Ut*ci)/gi,d=ye(d-L,-Math.PI,Math.PI),g=ye(g-k,-sC,sC)}while((Math.abs(L)>E||Math.abs(k)>E)&&--v>0);return new Pr(Et(d),Et(g))}}class oC extends Id{constructor(n){super(n),this.center=n.center||[0,0],this.parallels=n.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Ge(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(n,o){const{scale:d,cosPhi:g}=this;return{x:Ge(n)*g*d+.5,y:-Math.sin(Ge(o))/g*d+.5,z:0}}unproject(n,o){const{scale:d,cosPhi:g}=this,v=-(o-.5)/d,E=ye(Et((n-.5)/d)/g,-180,180),L=Math.asin(ye(v*g,-1,1)),k=ye(Et(L),-85.051129,$a);return new Pr(E,k)}}class v3 extends nC{constructor(n){super(n),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(n,o,d){const g=Ng(n,o,d);return Ns(g,g,Qg(Lu(d))),{x:g[0],y:g[1],z:g[2]}}locationPoint(n,o){const d=Og(o.lat,o.lng),g=so([],d),v=n.elevation?n.elevation.getAtPointOrZero(n.locationCoordinate(o),n._centerAltitude):n._centerAltitude;eu(d,d,g,Xl(1,0)*Zn*v);const E=ql(new Float64Array(16));return bA(E,n.pixelMatrix,n.globeMatrix),Ns(d,d,E),new me(d[0],d[1])}pixelsPerMeter(n,o){return Xl(1,0)*o}pixelSpaceConversion(n,o,d){const g=Xl(1,n)*o,v=gr(Xl(1,45)*o,g,d);return this.pixelsPerMeter(n,o)/v}createTileMatrix(n,o,d){const g=D1(Lu(d.canonical));return bA(new Float64Array(16),n.globeMatrix,g)}createInversionMatrix(n,o){const{center:d}=n,g=Qg(Lu(o));return Ff(g,g,Ge(d.lng)),yg(g,g,Ge(d.lat)),BA(g,g,[n._pixelsPerMercatorPixel,n._pixelsPerMercatorPixel,1]),Float32Array.from(g)}pointCoordinate(n,o,d,g){return ZB(n,o,d,!0)||new hd(0,0)}pointCoordinate3D(n,o,d){const g=this.pointCoordinate(n,o,d,0);return[g.x,g.y,g.z]}isPointAboveHorizon(n,o){return!ZB(n,o.x,o.y,!1)}farthestPixelDistance(n){const o=function(g,v){const E=g.cameraToCenterDistance,L=g._centerAltitude*v,k=g._camera,V=g._camera.forward(),q=Jh([],da([],V,-E),[0,0,L]),se=g.worldSize/(2*Math.PI),he=[0,0,-se],_e=g.width/g.height,Be=Math.tan(g.fovAboveCenter),Le=da([],k.up(),Be),Xe=da([],k.right(),Be*_e),xt=so([],Jh([],Jh([],V,Le),Xe)),Dt=[];let _t;if(new Pf(q,xt).closestPointOnSphere(he,se,Dt)){const Tt=Jh([],Dt,he),kt=bc([],Tt,q);_t=Math.cos(g.fovAboveCenter)*dd(kt)}else{const Tt=bc([],q,he),kt=bc([],he,q);so(kt,kt);const Ut=dd(Tt)-se;_t=Math.sqrt(Ut*(Ut+2*se));const ci=Math.acos(_t/(se+Ut))-Math.acos(Ma(V,kt));_t*=Math.cos(ci)}return 1.01*_t}(n,this.pixelsPerMeter(n.center.lat,n.worldSize)),d=Yf(n.zoom);if(d>0){const g=iC(n,Xl(1,n.center.lat)*n.worldSize),v=n.worldSize/(2*Math.PI),E=Math.max(n.width,n.height)/n.worldSize*Math.PI;return gr(o,g+v*(1-Math.cos(E)),Math.pow(d,10))}return o}upVector(n,o,d){return Ng(o,d,n,1)}upVectorScale(n){return{metersToTile:I1*g0(Lu(n))}}}function aC(s){const n=s.parallels,o=!!n&&Math.abs(n[0]+n[1])<.01;switch(s.name){case"mercator":return new nC(s);case"equirectangular":return new g3(s);case"naturalEarth":return new y3(s);case"equalEarth":return new m3(s);case"winkelTripel":return new x3(s);case"albers":return o?new oC(s):new f3(s);case"lambertConformalConic":return o?new oC(s):new _3(s);case"globe":return new v3(s)}throw new Error(`Invalid projection name: ${s.name}`)}const w3=w.types,b3=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function x0(s,n,o,d,g,v,E,L,k,V,q,se,he){const _e=L?Math.min(Md,Math.round(L[0])):0,Be=L?Math.min(Md,Math.round(L[1])):0;s.emplaceBack(n,o,Math.round(32*d),Math.round(32*g),v,E,(_e<<1)+(k?1:0),Be,16*V,16*q,256*se,256*he)}function v0(s,n,o,d,g,v,E){s.emplaceBack(n,o,d,g,v,E)}function w0(s,n,o,d,g){s.emplaceBack(n,o,d,g),s.emplaceBack(n,o,d,g),s.emplaceBack(n,o,d,g),s.emplaceBack(n,o,d,g)}function B3(s){for(const n of s.sections)if(st(n.text))return!0;return!1}class U1{constructor(n){this.layoutVertexArray=new Xr,this.indexArray=new _o,this.programConfigurations=n,this.segments=new to,this.dynamicLayoutVertexArray=new Ca,this.opacityVertexArray=new Fs,this.placedSymbolArray=new Ty,this.globeExtVertexArray=new Fr}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(n,o,d,g){this.isEmpty()||(d&&(this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,Lo.members),this.indexBuffer=n.createIndexBuffer(this.indexArray,o),this.dynamicLayoutVertexBuffer=n.createVertexBuffer(this.dynamicLayoutVertexArray,Ia.members,!0),this.opacityVertexBuffer=n.createVertexBuffer(this.opacityVertexArray,b3,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=n.createVertexBuffer(this.globeExtVertexArray,$o.members,!0)),this.opacityVertexBuffer.itemSize=1),(d||g)&&this.programConfigurations.upload(n))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}zt(U1,"SymbolBuffers");class R1{constructor(n,o,d){this.layoutVertexArray=new n,this.layoutAttributes=o,this.indexArray=new d,this.segments=new to,this.collisionVertexArray=new Bu,this.collisionVertexArrayExt=new ja}upload(n){this.layoutVertexBuffer=n.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=n.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=n.createVertexBuffer(this.collisionVertexArray,io.members,!0),this.collisionVertexBufferExt=n.createVertexBuffer(this.collisionVertexArrayExt,Do.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}zt(R1,"CollisionBuffers");class Fd{constructor(n){this.collisionBoxArray=n.collisionBoxArray,this.zoom=n.zoom,this.overscaling=n.overscaling,this.layers=n.layers,this.layerIds=this.layers.map(E=>E.id),this.index=n.index,this.pixelRatio=n.pixelRatio,this.sourceLayerIndex=n.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ql([]),this.placementViewportMatrix=ql([]);const o=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ms(this.zoom,o["text-size"]),this.iconSizeData=ms(this.zoom,o["icon-size"]);const d=this.layers[0].layout,g=d.get("symbol-sort-key"),v=d.get("symbol-z-order");this.canOverlap=d.get("text-allow-overlap")||d.get("icon-allow-overlap")||d.get("text-ignore-placement")||d.get("icon-ignore-placement"),this.sortFeaturesByKey=v!=="viewport-y"&&g.constantOr(1)!==void 0,this.sortFeaturesByY=(v==="viewport-y"||v==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=d.get("text-writing-mode").map(E=>qo[E]),this.stateDependentLayerIds=this.layers.filter(E=>E.isStateDependent()).map(E=>E.id),this.sourceID=n.sourceID,this.projection=n.projection}createArrays(){this.text=new U1(new _A(this.layers,this.zoom,n=>/^text/.test(n))),this.icon=new U1(new _A(this.layers,this.zoom,n=>/^icon/.test(n))),this.glyphOffsetArray=new og,this.lineVertexArray=new Cu,this.symbolInstances=new Ap}calculateGlyphDependencies(n,o,d,g,v){for(let E=0;E0)&&(k.value.kind!=="constant"||k.value.value.length>0),he=q.value.kind!=="constant"||!!q.value.value||Object.keys(q.parameters).length>0,_e=E.get("symbol-sort-key");if(this.features=[],!se&&!he)return;const Be=o.iconDependencies,Le=o.glyphDependencies,Xe=o.availableImages,xt=new qt(this.zoom);for(const{feature:Dt,id:_t,index:Tt,sourceLayerIndex:kt}of n){const Ut=v._featureFilter.needGeometry,ci=xA(Dt,Ut);if(!v._featureFilter.filter(xt,ci,d))continue;if(Ut||(ci.geometry=Yh(Dt,d,g)),L&&Dt.type!==1&&d.z<=5){const gi=ci.geometry,Si=.98078528056,Li=(Vi,Zi)=>Ma(Ng(Vi.x,Vi.y,d,1),Ng(Zi.x,Zi.y,d,1))=0;for(const Li of oi.sections)if(Li.image)Be[Li.image.name]=!0;else{const Vi=H(oi.toString()),Zi=Li.fontStack||gi,yi=Le[Zi]=Le[Zi]||{};this.calculateGlyphDependencies(Li.text,yi,Si,this.allowVerticalPlacement,Vi)}}}E.get("symbol-placement")==="line"&&(this.features=function(Dt){const _t={},Tt={},kt=[];let Ut=0;function ci(gi){kt.push(Dt[gi]),Ut++}function oi(gi,Si,Li){const Vi=Tt[gi];return delete Tt[gi],Tt[Si]=Vi,kt[Vi].geometry[0].pop(),kt[Vi].geometry[0]=kt[Vi].geometry[0].concat(Li[0]),Vi}function Ti(gi,Si,Li){const Vi=_t[Si];return delete _t[Si],_t[gi]=Vi,kt[Vi].geometry[0].shift(),kt[Vi].geometry[0]=Li[0].concat(kt[Vi].geometry[0]),Vi}function Ki(gi,Si,Li){const Vi=Li?Si[0][Si[0].length-1]:Si[0][0];return`${gi}:${Vi.x}:${Vi.y}`}for(let gi=0;gigi.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((Dt,_t)=>Dt.sortKey-_t.sortKey)}update(n,o,d,g){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(n,o,this.layers,d,g),this.icon.programConfigurations.updatePaintArrays(n,o,this.layers,d,g))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(n){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(n),this.iconCollisionBox.upload(n)),this.text.upload(n,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(n,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=aC(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(n,o){const d=this.lineVertexArray.length;if(n.segment!==void 0)for(const{x:g,y:v}of o)this.lineVertexArray.emplaceBack(g,v);return{lineStartIndex:d,lineLength:this.lineVertexArray.length-d}}addSymbols(n,o,d,g,v,E,L,k,V,q,se,he,_e,Be){const Le=n.indexArray,Xe=n.layoutVertexArray,xt=n.globeExtVertexArray,Dt=n.segments.prepareSegment(4*o.length,Xe,Le,this.canOverlap?E.sortKey:void 0),_t=this.glyphOffsetArray.length,Tt=Dt.vertexLength,kt=this.allowVerticalPlacement&&L===qo.vertical?Math.PI/2:0,Ut=E.text&&E.text.sections;for(let oi=0;oi=0?o.rightJustifiedTextSymbolIndex:o.centerJustifiedTextSymbolIndex>=0?o.centerJustifiedTextSymbolIndex:o.leftJustifiedTextSymbolIndex>=0?o.leftJustifiedTextSymbolIndex:o.verticalPlacedTextSymbolIndex>=0?o.verticalPlacedTextSymbolIndex:g),E=$s(this.textSizeData,n,v)/Jr;return this.tilePixelRatio*E}getSymbolInstanceIconSize(n,o,d){const g=this.icon.placedSymbolArray.get(d),v=$s(this.iconSizeData,n,g);return this.tilePixelRatio*v}_commitDebugCollisionVertexUpdate(n,o,d){n.emplaceBack(o,-d,-d),n.emplaceBack(o,d,-d),n.emplaceBack(o,d,d),n.emplaceBack(o,-d,d)}_updateTextDebugCollisionBoxes(n,o,d,g,v,E){for(let L=g;L0}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(n,o){const d=n.placedSymbolArray.get(o),g=d.vertexStartIndex+4*d.numGlyphs;for(let v=d.vertexStartIndex;vg[L]-g[k]||v[k]-v[L]),E}addToSortKeyRanges(n,o){const d=this.sortKeyRanges[this.sortKeyRanges.length-1];d&&d.sortKey===o?d.symbolInstanceEnd=n+1:this.sortKeyRanges.push({sortKey:o,symbolInstanceStart:n,symbolInstanceEnd:n+1})}sortFeatures(n){if(this.sortFeaturesByY&&this.sortedAngle!==n&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(n),this.sortedAngle=n,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const o of this.symbolInstanceIndexes){const d=this.symbolInstances.get(o);this.featureSortOrder.push(d.featureIndex);const{rightJustifiedTextSymbolIndex:g,centerJustifiedTextSymbolIndex:v,leftJustifiedTextSymbolIndex:E,verticalPlacedTextSymbolIndex:L,placedIconSymbolIndex:k,verticalPlacedIconSymbolIndex:V}=d;g>=0&&this.addIndicesForPlacedSymbol(this.text,g),v>=0&&v!==g&&this.addIndicesForPlacedSymbol(this.text,v),E>=0&&E!==v&&E!==g&&this.addIndicesForPlacedSymbol(this.text,E),L>=0&&this.addIndicesForPlacedSymbol(this.text,L),k>=0&&this.addIndicesForPlacedSymbol(this.icon,k),V>=0&&this.addIndicesForPlacedSymbol(this.icon,V)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}zt(Fd,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Fd.MAX_GLYPHS=65535,Fd.addDynamicAttributes=w0;const C3=new Hn({"symbol-placement":new Jt(Yt.layout_symbol["symbol-placement"]),"symbol-spacing":new Jt(Yt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Jt(Yt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new pi(Yt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Jt(Yt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Jt(Yt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Jt(Yt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Jt(Yt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Jt(Yt.layout_symbol["icon-rotation-alignment"]),"icon-size":new pi(Yt.layout_symbol["icon-size"]),"icon-text-fit":new Jt(Yt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Jt(Yt.layout_symbol["icon-text-fit-padding"]),"icon-image":new pi(Yt.layout_symbol["icon-image"]),"icon-rotate":new pi(Yt.layout_symbol["icon-rotate"]),"icon-padding":new Jt(Yt.layout_symbol["icon-padding"]),"icon-keep-upright":new Jt(Yt.layout_symbol["icon-keep-upright"]),"icon-offset":new pi(Yt.layout_symbol["icon-offset"]),"icon-anchor":new pi(Yt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Jt(Yt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Jt(Yt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Jt(Yt.layout_symbol["text-rotation-alignment"]),"text-field":new pi(Yt.layout_symbol["text-field"]),"text-font":new pi(Yt.layout_symbol["text-font"]),"text-size":new pi(Yt.layout_symbol["text-size"]),"text-max-width":new pi(Yt.layout_symbol["text-max-width"]),"text-line-height":new pi(Yt.layout_symbol["text-line-height"]),"text-letter-spacing":new pi(Yt.layout_symbol["text-letter-spacing"]),"text-justify":new pi(Yt.layout_symbol["text-justify"]),"text-radial-offset":new pi(Yt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Jt(Yt.layout_symbol["text-variable-anchor"]),"text-anchor":new pi(Yt.layout_symbol["text-anchor"]),"text-max-angle":new Jt(Yt.layout_symbol["text-max-angle"]),"text-writing-mode":new Jt(Yt.layout_symbol["text-writing-mode"]),"text-rotate":new pi(Yt.layout_symbol["text-rotate"]),"text-padding":new Jt(Yt.layout_symbol["text-padding"]),"text-keep-upright":new Jt(Yt.layout_symbol["text-keep-upright"]),"text-transform":new pi(Yt.layout_symbol["text-transform"]),"text-offset":new pi(Yt.layout_symbol["text-offset"]),"text-allow-overlap":new Jt(Yt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Jt(Yt.layout_symbol["text-ignore-placement"]),"text-optional":new Jt(Yt.layout_symbol["text-optional"])});var z1={paint:new Hn({"icon-opacity":new pi(Yt.paint_symbol["icon-opacity"]),"icon-color":new pi(Yt.paint_symbol["icon-color"]),"icon-halo-color":new pi(Yt.paint_symbol["icon-halo-color"]),"icon-halo-width":new pi(Yt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new pi(Yt.paint_symbol["icon-halo-blur"]),"icon-translate":new Jt(Yt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Jt(Yt.paint_symbol["icon-translate-anchor"]),"text-opacity":new pi(Yt.paint_symbol["text-opacity"]),"text-color":new pi(Yt.paint_symbol["text-color"],{runtimeType:aa,getOverride:s=>s.textColor,hasOverride:s=>!!s.textColor}),"text-halo-color":new pi(Yt.paint_symbol["text-halo-color"]),"text-halo-width":new pi(Yt.paint_symbol["text-halo-width"]),"text-halo-blur":new pi(Yt.paint_symbol["text-halo-blur"]),"text-translate":new Jt(Yt.paint_symbol["text-translate"]),"text-translate-anchor":new Jt(Yt.paint_symbol["text-translate-anchor"])}),layout:C3};class lC{constructor(n){this.type=n.property.overrides?n.property.overrides.runtimeType:or,this.defaultValue=n}evaluate(n){if(n.formattedSection){const o=this.defaultValue.property.overrides;if(o&&o.hasOverride(n.formattedSection))return o.getOverride(n.formattedSection)}return n.feature&&n.featureState?this.defaultValue.evaluate(n.feature,n.featureState):this.defaultValue.property.specification.default}eachChild(n){this.defaultValue.isConstant()||n(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}zt(lC,"FormatSectionOverride",{omit:["defaultValue"]});class b0 extends vc{constructor(n){super(n,z1)}recalculate(n,o){super.recalculate(n,o),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")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const d=this.layout.get("text-writing-mode");if(d){const g=[];for(const v of d)g.indexOf(v)<0&&g.push(v);this.layout._values["text-writing-mode"]=g}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(n,o,d,g){const v=this.layout.get(n).evaluate(o,{},d,g),E=this._unevaluatedLayout._values[n];return E.isDataDriven()||yc(E.value)||!v?v:function(L,k){return k.replace(/{([^{}]+)}/g,(V,q)=>q in L?String(L[q]):"")}(o.properties,v)}createBucket(n){return new Fd(n)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const n of z1.paint.overridableProperties){if(!b0.hasPaintOverride(this.layout,n))continue;const o=this.paint.get(n),d=new lC(o),g=new ih(d,o.property.specification);let v=null;v=o.value.kind==="constant"||o.value.kind==="source"?new fo("source",g):new Gh("composite",g,o.value.zoomStops,o.value._interpolationType),this.paint._values[n]=new Mi(o.property,v,o.parameters)}}_handleOverridablePaintPropertyUpdate(n,o,d){return!(!this.layout||o.isDataDriven()||d.isDataDriven())&&b0.hasPaintOverride(this.layout,n)}static hasPaintOverride(n,o){const d=n.get("text-field"),g=z1.paint.properties[o];let v=!1;const E=L=>{for(const k of L)if(g.overrides&&g.overrides.hasOverride(k))return void(v=!0)};if(d.value.kind==="constant"&&d.value.value instanceof ks)E(d.value.value.sections);else if(d.value.kind==="source"){const L=V=>{v||(V instanceof oc&&Bs(V.value)===Rl?E(V.value.sections):V instanceof hl?E(V.sections):V.eachChild(L))},k=d.value;k._styleExpression&&L(k._styleExpression.expression)}return v}getProgramConfiguration(n){return new lh(this,n)}}var E3={paint:new Hn({"background-color":new Jt(Yt.paint_background["background-color"]),"background-pattern":new Jt(Yt.paint_background["background-pattern"]),"background-opacity":new Jt(Yt.paint_background["background-opacity"])})},T3={paint:new Hn({"raster-opacity":new Jt(Yt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Jt(Yt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Jt(Yt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Jt(Yt.paint_raster["raster-brightness-max"]),"raster-saturation":new Jt(Yt.paint_raster["raster-saturation"]),"raster-contrast":new Jt(Yt.paint_raster["raster-contrast"]),"raster-resampling":new Jt(Yt.paint_raster["raster-resampling"]),"raster-fade-duration":new Jt(Yt.paint_raster["raster-fade-duration"])})};class S3 extends vc{constructor(n){super(n,{}),this.implementation=n}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(n){this.implementation.onAdd&&this.implementation.onAdd(n,n.painter.context.gl)}onRemove(n){this.implementation.onRemove&&this.implementation.onRemove(n,n.painter.context.gl)}}var M3={paint:new Hn({"sky-type":new Jt(Yt.paint_sky["sky-type"]),"sky-atmosphere-sun":new Jt(Yt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Jt(Yt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Jt(Yt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Jt(Yt.paint_sky["sky-gradient-radius"]),"sky-gradient":new In(Yt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Jt(Yt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Jt(Yt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Jt(Yt.paint_sky["sky-opacity"])})};function k1(s,n,o){const d=[0,0,1],g=bg([]);return Bg(g,g,o?-Ge(s)+Math.PI:Ge(s)),uh(g,g,-Ge(n)),wg(d,d,g),so(d,d)}const I3={circle:class extends vc{constructor(s){super(s,gg)}createBucket(s){return new gp(s)}queryRadius(s){const n=s;return Su("circle-radius",this,n)+Su("circle-stroke-width",this,n)+_p(this.paint.get("circle-translate"))}queryIntersectsFeature(s,n,o,d,g,v,E,L){const k=Yr(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),v.angle,s.pixelToTileUnitsFactor),V=this.paint.get("circle-radius").evaluate(n,o)+this.paint.get("circle-stroke-width").evaluate(n,o);return Zy(s,d,v,E,L,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",k,V)}getProgramIds(){return["circle"]}getProgramConfiguration(s){return new lh(this,s)}},heatmap:class extends vc{createBucket(s){return new vp(s)}constructor(s){super(s,u1),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(s){s==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Tg({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(s){return Su("heatmap-radius",this,s)}queryIntersectsFeature(s,n,o,d,g,v,E,L){const k=this.paint.get("heatmap-radius").evaluate(n,o);return Zy(s,d,v,E,L,!0,!0,new me(0,0),k)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(s){return new lh(this,s)}},hillshade:class extends vc{constructor(s){super(s,A1)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends vc{constructor(s){super(s,r0)}getProgramIds(){const s=this.paint.get("fill-pattern"),n=s&&s.constantOr(1),o=[n?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&o.push(n&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),o}getProgramConfiguration(s){return new lh(this,s)}recalculate(s,n){super.recalculate(s,n);const o=this.paint._values["fill-outline-color"];o.value.kind==="constant"&&o.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(s){return new Mp(s)}queryRadius(){return _p(this.paint.get("fill-translate"))}queryIntersectsFeature(s,n,o,d,g,v){return!s.queryGeometry.isAboveHorizon&&Ag(mg(s.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),v.angle,s.pixelToTileUnitsFactor),d)}isTileClipped(){return!0}},"fill-extrusion":class extends vc{constructor(s){super(s,ui)}createBucket(s){return new Ce(s)}queryRadius(){return _p(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(s){return new lh(this,s)}queryIntersectsFeature(s,n,o,d,g,v,E,L,k){const V=Yr(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),v.angle,s.pixelToTileUnitsFactor),q=this.paint.get("fill-extrusion-height").evaluate(n,o),se=this.paint.get("fill-extrusion-base").evaluate(n,o),he=[0,0],_e=L&&v.elevation,Be=v.elevation?v.elevation.exaggeration():1,Le=s.tile.getBucket(this);if(_e&&Le instanceof Ce){const Tt=Le.centroidVertexArray,kt=k+1;ktTt.polygon).flat());const Xe=_e?L:null,[xt,Dt]=function(Tt,kt,Ut,ci,oi,Ti,Ki,gi,Si,Li,Vi){return Tt.projection.name==="globe"?function(Zi,yi,sn,Kn,dn,Ln,ln,Xn,Tr,wr,xr){const Jn=[],es=[],ir=Zi.projection.upVectorScale(xr,Zi.center.lat,Zi.worldSize).metersToTile,Sr=[0,0,0,1],rs=[0,0,0,1],gs=(_s,bs,Zs,Yo)=>{_s[0]=bs,_s[1]=Zs,_s[2]=Yo,_s[3]=1},ds=ri();sn>0&&(sn+=ds),Kn+=ds;for(const _s of yi){const bs=[],Zs=[];for(const Yo of _s){const ts=Yo.x+dn.x,Ao=Yo.y+dn.y,lo=Zi.projection.projectTilePoint(ts,Ao,xr),Vr=Zi.projection.upVector(xr,Yo.x,Yo.y);let Ps=sn,vo=Kn;if(ln){const ss=gn(ts,Ao,sn,Kn,ln,Xn,Tr,wr);Ps+=ss.base,vo+=ss.top}sn!==0?gs(Sr,lo.x+Vr[0]*ir*Ps,lo.y+Vr[1]*ir*Ps,lo.z+Vr[2]*ir*Ps):gs(Sr,lo.x,lo.y,lo.z),gs(rs,lo.x+Vr[0]*ir*vo,lo.y+Vr[1]*ir*vo,lo.z+Vr[2]*ir*vo),Ns(Sr,Sr,Ln),Ns(rs,rs,Ln),bs.push(new an(Sr[0],Sr[1],Sr[2])),Zs.push(new an(rs[0],rs[1],rs[2]))}Jn.push(bs),es.push(Zs)}return[Jn,es]}(Tt,kt,Ut,ci,oi,Ti,Ki,gi,Si,Li,Vi):Ki?function(Zi,yi,sn,Kn,dn,Ln,ln,Xn,Tr){const wr=[],xr=[],Jn=[0,0,0,1];for(const es of Zi){const ir=[],Sr=[];for(const rs of es){const gs=rs.x+Kn.x,ds=rs.y+Kn.y,_s=gn(gs,ds,yi,sn,Ln,ln,Xn,Tr);Jn[0]=gs,Jn[1]=ds,Jn[2]=_s.base,Jn[3]=1,TA(Jn,Jn,dn),Jn[3]=Math.max(Jn[3],1e-5);const bs=new an(Jn[0]/Jn[3],Jn[1]/Jn[3],Jn[2]/Jn[3]);Jn[0]=gs,Jn[1]=ds,Jn[2]=_s.top,Jn[3]=1,TA(Jn,Jn,dn),Jn[3]=Math.max(Jn[3],1e-5);const Zs=new an(Jn[0]/Jn[3],Jn[1]/Jn[3],Jn[2]/Jn[3]);ir.push(bs),Sr.push(Zs)}wr.push(ir),xr.push(Sr)}return[wr,xr]}(kt,Ut,ci,oi,Ti,Ki,gi,Si,Li):function(Zi,yi,sn,Kn,dn){const Ln=[],ln=[],Xn=dn[8]*yi,Tr=dn[9]*yi,wr=dn[10]*yi,xr=dn[11]*yi,Jn=dn[8]*sn,es=dn[9]*sn,ir=dn[10]*sn,Sr=dn[11]*sn;for(const rs of Zi){const gs=[],ds=[];for(const _s of rs){const bs=_s.x+Kn.x,Zs=_s.y+Kn.y,Yo=dn[0]*bs+dn[4]*Zs+dn[12],ts=dn[1]*bs+dn[5]*Zs+dn[13],Ao=dn[2]*bs+dn[6]*Zs+dn[14],lo=dn[3]*bs+dn[7]*Zs+dn[15],Vr=Yo+Xn,Ps=ts+Tr,vo=Ao+wr,ss=Math.max(lo+xr,1e-5),no=Yo+Jn,La=ts+es,Jo=Ao+ir,ea=Math.max(lo+Sr,1e-5);gs.push(new an(Vr/ss,Ps/ss,vo/ss)),ds.push(new an(no/ea,La/ea,Jo/ea))}Ln.push(gs),ln.push(ds)}return[Ln,ln]}(kt,Ut,ci,oi,Ti)}(v,d,se,q,V,E,Xe,he,Be,v.center.lat,s.tileID.canonical),_t=s.queryGeometry;return function(Tt,kt,Ut){let ci=1/0;Ag(Ut,kt)&&(ci=vn(Ut,kt[0]));for(let oi=0;oi=3){for(let Be=0;Be<_e.length;Be++)if(vA(V,_e[Be]))return!0}if(Vy(V,_e,se))return!0}return!1}(E,d,L)}isTileClipped(){return!0}},symbol:b0,background:class extends vc{constructor(s){super(s,E3)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends vc{constructor(s){super(s,T3)}getProgramIds(){return["raster"]}},sky:class extends vc{constructor(s){super(s,M3),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(s){s==="sky-gradient"?this._updateColorRamp():s!=="sky-atmosphere-sun"&&s!=="sky-atmosphere-halo-color"&&s!=="sky-atmosphere-color"&&s!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Tg({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(s){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const n=s.style.light.properties.get("position");return this._lightPosition.azimuthal!==n.azimuthal||this._lightPosition.polar!==n.polar}return!1}getCenter(s,n){if(this.paint.get("sky-type")==="atmosphere"){const d=this.paint.get("sky-atmosphere-sun"),g=!d,v=s.style.light,E=v.properties.get("position");return g&&v.properties.get("anchor")==="viewport"&&Ct("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),g?k1(E.azimuthal,90-E.polar,n):k1(d[0],90-d[1],n)}const o=this.paint.get("sky-gradient-center");return k1(o[0],90-o[1],n)}is3D(){return!1}isSky(){return!0}markSkyboxValid(s){this._skyboxInvalidated=!1,this._lightPosition=s.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const s=this.paint.get("sky-type");return s==="atmosphere"?["skyboxCapture","skybox"]:s==="gradient"?["skyboxGradient"]:null}}};class jg{constructor(n,o,d,g){this.context=n,this.format=d,this.texture=n.gl.createTexture(),this.update(o,g)}update(n,o,d){const{width:g,height:v}=n,{context:E}=this,{gl:L}=E,{HTMLImageElement:k,HTMLCanvasElement:V,HTMLVideoElement:q,ImageData:se,ImageBitmap:he}=C;if(L.bindTexture(L.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===L.RGBA&&(!o||o.premultiply!==!1)),d||this.size&&this.size[0]===g&&this.size[1]===v){const{x:_e,y:Be}=d||{x:0,y:0};n instanceof k||n instanceof V||n instanceof q||n instanceof se||he&&n instanceof he?L.texSubImage2D(L.TEXTURE_2D,0,_e,Be,L.RGBA,L.UNSIGNED_BYTE,n):L.texSubImage2D(L.TEXTURE_2D,0,_e,Be,g,v,L.RGBA,L.UNSIGNED_BYTE,n.data)}else this.size=[g,v],n instanceof k||n instanceof V||n instanceof q||n instanceof se||he&&n instanceof he?L.texImage2D(L.TEXTURE_2D,0,this.format,this.format,L.UNSIGNED_BYTE,n):L.texImage2D(L.TEXTURE_2D,0,this.format,g,v,0,this.format,L.UNSIGNED_BYTE,n.data);this.useMipmap=Boolean(o&&o.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&L.generateMipmap(L.TEXTURE_2D)}bind(n,o){const{context:d}=this,{gl:g}=d;g.bindTexture(g.TEXTURE_2D,this.texture),n!==this.filter&&(g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MAG_FILTER,n),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_MIN_FILTER,this.useMipmap?n===g.NEAREST?g.NEAREST_MIPMAP_NEAREST:g.LINEAR_MIPMAP_NEAREST:n),this.filter=n),o!==this.wrap&&(g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_S,o),g.texParameteri(g.TEXTURE_2D,g.TEXTURE_WRAP_T,o),this.wrap=o)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:n}=this.context;n.deleteTexture(this.texture),this.texture=null}}class F3{constructor(n){this._callback=n,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(){this._channel=void 0,this._callback=()=>{}}}class L3{constructor(){this.tasks={},this.taskQueue=[],be(["process"],this),this.invoker=new F3(this.process),this.nextId=0}add(n,o){const d=this.nextId++,g=function({type:v,isSymbolTile:E,zoom:L}){return L=L||0,v==="message"?0:v!=="maybePrepare"||E?v!=="parseTile"||E?v==="parseTile"&&E?300-L:v==="maybePrepare"&&E?400-L:500:200-L:100-L}(o);if(g===0){_i();try{n()}finally{}return{cancel:()=>{}}}return this.tasks[d]={fn:n,metadata:o,priority:g,id:d},this.taskQueue.push(d),this.invoker.trigger(),{cancel:()=>{delete this.tasks[d]}}}process(){_i();try{if(this.taskQueue=this.taskQueue.filter(d=>!!this.tasks[d]),!this.taskQueue.length)return;const n=this.pick();if(n===null)return;const o=this.tasks[n];if(delete this.tasks[n],this.taskQueue.length&&this.invoker.trigger(),!o)return;o.fn()}finally{}}pick(){let n=null,o=1/0;for(let g=0;g>=1)>1;){const V=o+g>>1,q=d+v>>1;1&n?(g=o,v=d,o=E,d=L):(o=g,d=v,g=E,v=L),E=V,L=q}const k=4*s;Ld[k+0]=o,Ld[k+1]=d,Ld[k+2]=g,Ld[k+3]=v}const Pu=new Uint16Array(2178),Dd=new Uint8Array(1089),B0=new Uint16Array(1089);function uC(s){return s===0?-.03125:s===32?.03125:0}var AC=_n([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const dC={type:2,extent:Zn,loadGeometry:()=>[[new me(0,0),new me(8193,0),new me(8193,8193),new me(0,8193),new me(0,0)]]};class O1{constructor(n,o,d,g,v){this.tileID=n,this.uid=Se(),this.uses=0,this.tileSize=o,this.tileZoom=d,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=v,this.expiredRequestCount=0,this.state="loading",g&&g.transform&&(this.projection=g.transform.projection)}registerFadeDuration(n){const o=n+this.timeAdded;ov.getLayer(V)).filter(Boolean);if(k.length!==0){L.layers=k,L.stateDependentLayerIds&&(L.stateDependentLayers=L.stateDependentLayerIds.map(V=>k.filter(q=>q.id===V)[0]));for(const V of k)E[V.id]=L}}return E}(n.buckets,o.style),this.hasSymbolBuckets=!1;for(const g in this.buckets){const v=this.buckets[g];if(v instanceof Fd){if(this.hasSymbolBuckets=!0,!d)break;v.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const g in this.buckets){const v=this.buckets[g];if(v instanceof Fd&&v.hasRTLText){this.hasRTLText=!0,si.isLoading()||si.isLoaded()||Ht()!=="deferred"||hi();break}}this.queryPadding=0;for(const g in this.buckets){const v=this.buckets[g];this.queryPadding=Math.max(this.queryPadding,o.style.getLayer(g).queryRadius(v))}n.imageAtlas&&(this.imageAtlas=n.imageAtlas),n.glyphAtlasImage&&(this.glyphAtlasImage=n.glyphAtlasImage),n.lineAtlas&&(this.lineAtlas=n.lineAtlas)}else this.collisionBoxArray=new sg}unloadVectorData(){if(this.hasData()){for(const n in this.buckets)this.buckets[n].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(n){return this.buckets[n.id]}upload(n){for(const d in this.buckets){const g=this.buckets[d];g.uploadPending()&&g.upload(n)}const o=n.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new jg(n,this.imageAtlas.image,o.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new jg(n,this.glyphAtlasImage,o.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new jg(n,this.lineAtlas.image,o.ALPHA),this.lineAtlas.uploaded=!0)}prepare(n){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(n,this.imageAtlasTexture)}queryRenderedFeatures(n,o,d,g,v,E,L,k){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:g,pixelPosMatrix:L,transform:E,params:v,tileTransform:this.tileTransform},n,o,d):{}}querySourceFeatures(n,o){const d=this.latestFeatureIndex;if(!d||!d.rawTileData)return;const g=d.loadVTLayers(),v=o?o.sourceLayer:"",E=g._geojsonTileLayer||g[v];if(!E)return;const L=uo(o&&o.filter),{z:k,x:V,y:q}=this.tileID.canonical,se={z:k,x:V,y:q};for(let he=0;hed)g=!1;else if(o)if(this.expirationTime=0;Xe--){const xt=4*Xe,Dt=Ld[xt+0],_t=Ld[xt+1],Tt=Ld[xt+2],kt=Ld[xt+3],Ut=Dt+Tt>>1,ci=_t+kt>>1,oi=Ut+ci-_t,Ti=ci+Dt-Ut,Ki=_t*Du+Dt,gi=kt*Du+Tt,Si=ci*Du+Ut,Li=Math.hypot((Pu[2*Ki+0]+Pu[2*gi+0])/2-Pu[2*Si+0],(Pu[2*Ki+1]+Pu[2*gi+1])/2-Pu[2*Si+1])>=16;if(Dd[Si]=Dd[Si]||(Li?1:0),Xe<1022){const Vi=(_t+Ti>>1)*Du+(Dt+oi>>1),Zi=(kt+Ti>>1)*Du+(Tt+oi>>1);Dd[Si]=Dd[Si]||Dd[Vi]||Dd[Zi]}}const se=new Qr,he=new _o;let _e=0;function Be(Xe,xt){const Dt=xt*Du+Xe;return B0[Dt]===0&&(se.emplaceBack(Pu[2*Dt+0],Pu[2*Dt+1],Xe*Zn/gh,xt*Zn/gh),B0[Dt]=++_e),B0[Dt]-1}function Le(Xe,xt,Dt,_t,Tt,kt){const Ut=Xe+Dt>>1,ci=xt+_t>>1;if(Math.abs(Xe-Tt)+Math.abs(xt-kt)>1&&Dd[ci*Du+Ut])Le(Tt,kt,Xe,xt,Ut,ci),Le(Dt,_t,Tt,kt,Ut,ci);else{const oi=Be(Xe,xt),Ti=Be(Dt,_t),Ki=Be(Tt,kt);he.emplaceBack(oi,Ti,Ki)}}return Le(0,0,gh,gh,gh,0),Le(gh,gh,0,0,0,gh),{vertices:se,indices:he}}(this.tileID.canonical,o);g=E.vertices,v=E.indices}else{g=new Qr,v=new _o;for(const{x:L,y:k}of d)g.emplaceBack(L,k,0,0);const E=xd.exports(g.int16,void 0,4);for(let L=0;L0&&(L=_g(new Float64Array(16),o.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(n,g,o,v,L,E),this._makeGlobeTileDebugTextBuffer(n,g,o,v,L,E)}_globePoint(n,o,d,g,v,E,L){let k=Ng(n,o,d);if(E){const V=1<.5?_e=-1:he<-.5&&(_e=1);let Be=(n/Zn+d.x)/V+_e,Le=(o/Zn+d.y)/V;Be=(Be-q)*g._pixelsPerMercatorPixel+q,Le=(Le-se)*g._pixelsPerMercatorPixel+se;const Xe=[Be*g.worldSize,Le*g.worldSize,0];Ns(Xe,Xe,E),k=Lp(k,Xe,L)}return Ns(k,k,v)}_makeGlobeTileDebugBorderBuffer(n,o,d,g,v,E){const L=new Or,k=new Xh,V=new Nr,q=(he,_e,Be,Le,Xe)=>{const xt=(Be-he)/(Xe-1),Dt=(Le-_e)/(Xe-1),_t=L.length;for(let Tt=0;Ttq*he+_e;for(let he=0;hen[E])return null}else{const L=1/d[E];let k=(s[E]-o[E])*L,V=(n[E]-o[E])*L;if(k>V){const q=k;k=V,V=q}if(k>g&&(g=k),Vv)return null}return g}function mC(s,n,o,d,g,v,E,L,k,V,q){const se=d-s,he=g-n,_e=v-o,Be=E-s,Le=L-n,Xe=k-o,xt=q[1]*Xe-q[2]*Le,Dt=q[2]*Be-q[0]*Xe,_t=q[0]*Le-q[1]*Be,Tt=se*xt+he*Dt+_e*_t;if(Math.abs(Tt)<1e-15)return null;const kt=1/Tt,Ut=V[0]-s,ci=V[1]-n,oi=V[2]-o,Ti=(Ut*xt+ci*Dt+oi*_t)*kt;if(Ti<0||Ti>1)return null;const Ki=ci*_e-oi*he,gi=oi*se-Ut*_e,Si=Ut*he-ci*se,Li=(q[0]*Ki+q[1]*gi+q[2]*Si)*kt;return Li<0||Ti+Li>1?null:(Be*Ki+Le*gi+Xe*Si)*kt}function gC(s,n,o){return(s-n)/(o-n)}function _C(s,n,o,d,g,v,E,L,k){const V=1<{const Dt=Xe?1:0,_t=(_e+1)*Le-Dt,Tt=Be*Le,kt=(Be+1)*Le-Dt;xt[0]=_e*Le,xt[1]=Tt,xt[2]=_t,xt[3]=kt};let se=new pC(k);const he=[];for(let _e=0;_e=1;k/=2){const _e=L[L.length-1];se=new pC(k);for(let Be=0;Be0;){const{idx:Be,t:Le,nodex:Xe,nodey:xt,depth:Dt}=_e.pop();if(this.leaves[Be]){_C(Xe,xt,Dt,n,o,d,g,se,he);const Tt=1<=yi[2])return Le}continue}let _t=0;for(let Tt=0;Tt=V[q[oi]]&&(q.splice(oi,0,Tt),ci=!0);ci||(q[_t]=Tt),_t++}}for(let Tt=0;Tt<_t;Tt++){const kt=q[Tt];_e.push({idx:this.childOffsets[Be]+kt,t:V[kt],nodex:(Xe<<1)+this._siblingOffset[kt][0],nodey:(xt<<1)+this._siblingOffset[kt][1],depth:Dt+1})}}return null}_addNode(n,o,d){return this.minimums.push(n),this.maximums.push(o),this.leaves.push(d),this.childOffsets.push(0),this.nodeCount++}_construct(n,o,d,g,v){if(n[g].isLeaf(o,d)===1)return;this.childOffsets[v]||(this.childOffsets[v]=this.nodeCount);const E=g-1,L=n[E];let k=0,V=0;for(let q=0;q=this.dim+1||o<-1||o>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(o+1)*this.stride+(n+1)}_unpackMapbox(n,o,d){return(256*n*256+256*o+d)/10-1e4}_unpackTerrarium(n,o,d){return 256*n+o+d/256-32768}static pack(n,o){const d=[0,0,0,0],g=C0.getUnpackVector(o);let v=Math.floor((n+g[3])/g[2]);return d[2]=v%256,v=Math.floor(v/256),d[1]=v%256,v=Math.floor(v/256),d[0]=v,d}getPixels(){return new Za({width:this.stride,height:this.stride},this.pixels)}backfillBorder(n,o,d){if(this.dim!==n.dim)throw new Error("dem dimension mismatch");let g=o*this.dim,v=o*this.dim+this.dim,E=d*this.dim,L=d*this.dim+this.dim;switch(o){case-1:g=v-1;break;case 1:v=g+1}switch(d){case-1:E=L-1;break;case 1:L=E+1}const k=-o*this.dim,V=-d*this.dim;for(let q=E;q{this.remove(n,v)},d)),this.data[g].push(v),this.order.push(g),this.order.length>this.max){const E=this._getAndRemoveByKey(this.order[0]);E&&this.onRemove(E)}return this}has(n){return n.wrapped().key in this.data}getAndRemove(n){return this.has(n)?this._getAndRemoveByKey(n.wrapped().key):null}_getAndRemoveByKey(n){const o=this.data[n].shift();return o.timeout&&clearTimeout(o.timeout),this.data[n].length===0&&delete this.data[n],this.order.splice(this.order.indexOf(n),1),o.value}getByKey(n){const o=this.data[n];return o?o[0].value:null}get(n){return this.has(n)?this.data[n.wrapped().key][0].value:null}remove(n,o){if(!this.has(n))return this;const d=n.wrapped().key,g=o===void 0?0:this.data[d].indexOf(o),v=this.data[d][g];return this.data[d].splice(g,1),v.timeout&&clearTimeout(v.timeout),this.data[d].length===0&&delete this.data[d],this.onRemove(v.value),this.order.splice(this.order.indexOf(d),1),this}setMaxSize(n){for(this.max=n;this.order.length>this.max;){const o=this._getAndRemoveByKey(this.order[0]);o&&this.onRemove(o)}return this}filter(n){const o=[];for(const d in this.data)for(const g of this.data[d])n(g.value)||o.push(g);for(const d of o)this.remove(d.value.tileID,d)}}class em{constructor(n,o,d){this.func=n,this.mask=o,this.range=d}}em.ReadOnly=!1,em.ReadWrite=!0,em.disabled=new em(519,em.ReadOnly,[0,1]);const N1=7680;class Q1{constructor(n,o,d,g,v,E){this.test=n,this.ref=o,this.mask=d,this.fail=g,this.depthFail=v,this.pass=E}}Q1.disabled=new Q1({func:519,mask:0},0,0,N1,N1,N1);class Uu{constructor(n,o,d){this.blendFunction=n,this.blendColor=o,this.mask=d}}Uu.Replace=[1,0],Uu.disabled=new Uu(Uu.Replace,ps.transparent,[!1,!1,!1,!1]),Uu.unblended=new Uu(Uu.Replace,ps.transparent,[!0,!0,!0,!0]),Uu.alphaBlended=new Uu([1,771],ps.transparent,[!0,!0,!0,!0]);const V1=1029,H1=2305;class ru{constructor(n,o,d){this.enable=n,this.mode=o,this.frontFace=d}}ru.disabled=new ru(!1,V1,H1),ru.backCCW=new ru(!0,V1,H1),ru.backCW=new ru(!0,V1,2304),ru.frontCW=new ru(!0,1028,2304),ru.frontCCW=new ru(!0,1028,H1);class Pp extends yn{constructor(n,o,d){super(),this.id=n,this._onlySymbols=d,o.on("data",g=>{g.dataType==="source"&&g.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&g.dataType==="source"&&g.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),o.on("error",()=>{this._sourceErrored=!0}),this._source=o,this._tiles={},this._cache=new U3(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=o.minTileCacheSize,this._maxTileCacheSize=o.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new P3,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(n){this.map=n,this._minTileCacheSize=this._minTileCacheSize===void 0&&n?n._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&n?n._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const n in this._tiles){const o=this._tiles[n];if(o.state!=="loaded"&&o.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const n=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,n&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(n,o){return n.isSymbolTile=this._onlySymbols,this._source.loadTile(n,o)}_unloadTile(n){if(this._source.unloadTile)return this._source.unloadTile(n,()=>{})}_abortTile(n){if(this._source.abortTile)return this._source.abortTile(n,()=>{})}serialize(){return this._source.serialize()}prepare(n){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const o in this._tiles){const d=this._tiles[o];d.upload(n),d.prepare(this.map.style.imageManager)}}getIds(){return We(this._tiles).map(n=>n.tileID).sort(wC).map(n=>n.key)}getRenderableIds(n){const o=[];for(const d in this._tiles)this._isIdRenderable(+d,n)&&o.push(this._tiles[d]);return n?o.sort((d,g)=>{const v=d.tileID,E=g.tileID,L=new me(v.canonical.x,v.canonical.y)._rotate(this.transform.angle),k=new me(E.canonical.x,E.canonical.y)._rotate(this.transform.angle);return v.overscaledZ-E.overscaledZ||k.y-L.y||k.x-L.x}).map(d=>d.tileID.key):o.map(d=>d.tileID).sort(wC).map(d=>d.key)}hasRenderableParent(n){const o=this.findLoadedParent(n,0);return!!o&&this._isIdRenderable(o.tileID.key)}_isIdRenderable(n,o){return this._tiles[n]&&this._tiles[n].hasData()&&!this._coveredTiles[n]&&(o||!this._tiles[n].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const n in this._tiles)this._tiles[n].state!=="errored"&&this._reloadTile(+n,"reloading")}}_reloadTile(n,o){const d=this._tiles[n];d&&(d.state!=="loading"&&(d.state=o),this._loadTile(d,this._tileLoaded.bind(this,d,n,o)))}_tileLoaded(n,o,d,g){if(g)if(n.state="errored",g.status!==404)this._source.fire(new rr(g,{tile:n}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const v=this.map.painter.terrain;this.update(this.transform,v.getScaledDemTileSize(),!0),v.resetTileLookupCache(this.id)}else this.update(this.transform);else n.timeAdded=bi.now(),d==="expired"&&(n.refreshedUponExpiration=!0),this._setTileReloadTimer(o,n),this._source.type==="raster-dem"&&n.dem&&this._backfillDEM(n),this._state.initializeTileState(n,this.map?this.map.painter:null),this._source.fire(new tn("data",{dataType:"source",tile:n,coord:n.tileID,sourceCacheId:this.id}))}_backfillDEM(n){const o=this.getRenderableIds();for(let g=0;g1||(Math.abs(E)>1&&(Math.abs(E+k)===1?E+=k:Math.abs(E-k)===1&&(E-=k)),v.dem&&g.dem&&(g.dem.backfillBorder(v.dem,E,L),g.neighboringTiles&&g.neighboringTiles[V]&&(g.neighboringTiles[V].backfilled=!0)))}}getTile(n){return this.getTileByID(n.key)}getTileByID(n){return this._tiles[n]}_retainLoadedChildren(n,o,d,g){for(const v in this._tiles){let E=this._tiles[v];if(g[v]||!E.hasData()||E.tileID.overscaledZ<=o||E.tileID.overscaledZ>d)continue;let L=E.tileID;for(;E&&E.tileID.overscaledZ>o+1;){const V=E.tileID.scaledTo(E.tileID.overscaledZ-1);E=this._tiles[V.key],E&&E.hasData()&&(L=V)}let k=L;for(;k.overscaledZ>o;)if(k=k.scaledTo(k.overscaledZ-1),n[k.key]){g[L.key]=L;break}}}findLoadedParent(n,o){if(n.key in this._loadedParentTiles){const d=this._loadedParentTiles[n.key];return d&&d.tileID.overscaledZ>=o?d:null}for(let d=n.overscaledZ-1;d>=o;d--){const g=n.scaledTo(d),v=this._getLoadedTile(g);if(v)return v}}_getLoadedTile(n){const o=this._tiles[n.key];return o&&o.hasData()?o:this._cache.getByKey(this._source.reparseOverscaled?n.wrapped().key:n.canonical.key)}updateCacheSize(n,o){o=o||this._source.tileSize;const d=Math.ceil(n.width/o)+1,g=Math.ceil(n.height/o)+1,v=Math.floor(d*g*5),E=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,v):v,L=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,E):E;this._cache.setMaxSize(L)}handleWrapJump(n){const o=Math.round((n-(this._prevLng===void 0?n:this._prevLng))/360);if(this._prevLng=n,o){const d={};for(const g in this._tiles){const v=this._tiles[g];v.tileID=v.tileID.unwrapTo(v.tileID.wrap+o),d[v.tileID.key]=v}this._tiles=d;for(const g in this._timers)clearTimeout(this._timers[g]),delete this._timers[g];for(const g in this._tiles)this._setTileReloadTimer(+g,this._tiles[g])}}update(n,o,d){if(this.transform=n,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!d)return;let g;this.updateCacheSize(n,o),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?g=n.getVisibleUnwrappedCoordinates(this._source.tileID).map(L=>new fn(L.canonical.z,L.wrap,L.canonical.z,L.canonical.x,L.canonical.y)):(g=n.coveringTiles({tileSize:o||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!d,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(g=g.filter(L=>this._source.hasTile(L)))):g=[];const v=this._updateRetainedTiles(g);if(bC(this._source.type)&&g.length!==0){const L={},k={},V=Object.keys(v);for(const se of V){const he=v[se],_e=this._tiles[se];if(!_e||_e.fadeEndTime&&_e.fadeEndTime<=bi.now())continue;const Be=this.findLoadedParent(he,Math.max(he.overscaledZ-Pp.maxOverzooming,this._source.minzoom));Be&&(this._addTile(Be.tileID),L[Be.tileID.key]=Be.tileID),k[se]=he}const q=g[g.length-1].overscaledZ;for(const se in this._tiles){const he=this._tiles[se];if(v[se]||!he.hasData())continue;let _e=he.tileID;for(;_e.overscaledZ>q;){_e=_e.scaledTo(_e.overscaledZ-1);const Be=this._tiles[_e.key];if(Be&&Be.hasData()&&k[_e.key]){v[se]=he.tileID;break}}}for(const se in L)v[se]||(this._coveredTiles[se]=!0,v[se]=L[se])}for(const L in v)this._tiles[L].clearFadeHold();const E=function(L,k){const V=[];for(const q in L)q in k||V.push(q);return V}(this._tiles,v);for(const L of E){const k=this._tiles[L];k.hasSymbolBuckets&&!k.holdingForFade()?k.setHoldDuration(this.map._fadeDuration):k.hasSymbolBuckets&&!k.symbolFadeFinished()||this._removeTile(+L)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const n in this._tiles)this._tiles[n].holdingForFade()&&this._removeTile(+n)}_updateRetainedTiles(n){const o={};if(n.length===0)return o;const d={},g=n.reduce((V,q)=>Math.min(V,q.overscaledZ),1/0),v=n[0].overscaledZ,E=Math.max(v-Pp.maxOverzooming,this._source.minzoom),L=Math.max(v+Pp.maxUnderzooming,this._source.minzoom),k={};for(const V of n){const q=this._addTile(V);o[V.key]=V,q.hasData()||g=this._source.maxzoom){const he=V.children(this._source.maxzoom)[0],_e=this.getTile(he);if(_e&&_e.hasData()){o[he.key]=he;continue}}else{const he=V.children(this._source.maxzoom);if(o[he[0].key]&&o[he[1].key]&&o[he[2].key]&&o[he[3].key])continue}let se=q.wasRequested();for(let he=V.overscaledZ-1;he>=E;--he){const _e=V.scaledTo(he);if(d[_e.key]||(d[_e.key]=!0,q=this.getTile(_e),!q&&se&&(q=this._addTile(_e)),q&&(o[_e.key]=_e,se=q.wasRequested(),q.hasData())))break}}return o}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const n in this._tiles){const o=[];let d,g=this._tiles[n].tileID;for(;g.overscaledZ>0;){if(g.key in this._loadedParentTiles){d=this._loadedParentTiles[g.key];break}o.push(g.key);const v=g.scaledTo(g.overscaledZ-1);if(d=this._getLoadedTile(v),d)break;g=v}for(const v of o)this._loadedParentTiles[v]=d}}_addTile(n){let o=this._tiles[n.key];if(o)return o;o=this._cache.getAndRemove(n),o&&(this._setTileReloadTimer(n.key,o),o.tileID=n,this._state.initializeTileState(o,this.map?this.map.painter:null),this._cacheTimers[n.key]&&(clearTimeout(this._cacheTimers[n.key]),delete this._cacheTimers[n.key],this._setTileReloadTimer(n.key,o)));const d=Boolean(o);if(!d){const g=this.map?this.map.painter:null;o=new O1(n,this._source.tileSize*n.overscaleFactor(),this.transform.tileZoom,g,this._isRaster),this._loadTile(o,this._tileLoaded.bind(this,o,n.key,o.state))}return o?(o.uses++,this._tiles[n.key]=o,d||this._source.fire(new tn("dataloading",{tile:o,coord:o.tileID,dataType:"source"})),o):null}_setTileReloadTimer(n,o){n in this._timers&&(clearTimeout(this._timers[n]),delete this._timers[n]);const d=o.getExpiryTimeout();d&&(this._timers[n]=setTimeout(()=>{this._reloadTile(n,"expired"),delete this._timers[n]},d))}_removeTile(n){const o=this._tiles[n];o&&(o.uses--,delete this._tiles[n],this._timers[n]&&(clearTimeout(this._timers[n]),delete this._timers[n]),o.uses>0||(o.hasData()&&o.state!=="reloading"?this._cache.add(o.tileID,o,o.getExpiryTimeout()):(o.aborted=!0,this._abortTile(o),this._unloadTile(o))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const n in this._tiles)this._removeTile(+n);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(n,o,d){const g=[],v=this.transform;if(!v)return g;const E=v.projection.name==="globe",L=wc(v.center.lng);for(const k in this._tiles){const V=this._tiles[k];if(d&&V.clearQueryDebugViz(),V.holdingForFade())continue;let q;if(E){const se=V.tileID.canonical;if(se.z===0){const he=[Math.abs(ye(L,...Kg(se,-1))-L),Math.abs(ye(L,...Kg(se,1))-L)];q=[0,2*he.indexOf(Math.min(...he))-1]}else{const he=[Math.abs(ye(L,...Kg(se,-1))-L),Math.abs(ye(L,...Kg(se,0))-L),Math.abs(ye(L,...Kg(se,1))-L)];q=[he.indexOf(Math.min(...he))-1]}}else q=[0];for(const se of q){const he=n.containsTile(V,v,o,se);he&&g.push(he)}}return g}getVisibleCoordinates(n){const o=this.getRenderableIds(n).map(d=>this._tiles[d].tileID);for(const d of o)d.projMatrix=this.transform.calculateProjMatrix(d.toUnwrapped());return o}hasTransition(){if(this._source.hasTransition())return!0;if(bC(this._source.type))for(const n in this._tiles){const o=this._tiles[n];if(o.fadeEndTime!==void 0&&o.fadeEndTime>=bi.now())return!0}return!1}setFeatureState(n,o,d){this._state.updateState(n=n||"_geojsonTileLayer",o,d)}removeFeatureState(n,o,d){this._state.removeFeatureState(n=n||"_geojsonTileLayer",o,d)}getFeatureState(n,o){return this._state.getState(n=n||"_geojsonTileLayer",o)}setDependencies(n,o,d){const g=this._tiles[n];g&&g.setDependencies(o,d)}reloadTilesForDependencies(n,o){for(const d in this._tiles)this._tiles[d].hasDependency(n,o)&&this._reloadTile(+d,"reloading");this._cache.filter(d=>!d.hasDependency(n,o))}_preloadTiles(n,o){const d=new Map,g=Array.isArray(n)?n:[n],v=this.map.painter.terrain,E=this.usedForTerrain&&v?v.getScaledDemTileSize():this._source.tileSize;for(const L of g){const k=L.coveringTiles({tileSize:E,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const V of k)d.set(V.key,V);this.usedForTerrain&&L.updateElevation(!1)}Oe(Array.from(d.values()),(L,k)=>{const V=new O1(L,this._source.tileSize*L.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(V,q=>{this._source.type==="raster-dem"&&V.dem&&this._backfillDEM(V),k(q,V)})},o)}}function wC(s,n){const o=Math.abs(2*s.wrap)-+(s.wrap<0),d=Math.abs(2*n.wrap)-+(n.wrap<0);return s.overscaledZ-n.overscaledZ||d-o||n.canonical.y-s.canonical.y||n.canonical.x-s.canonical.x}function bC(s){return s==="raster"||s==="image"||s==="video"||s==="custom"}function Kg(s,n){const o=1<=0&&se[3]>=0&&k.insert(L,se[0],se[1],se[2],se[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new f(new Fa(this.rawTileData)).layers,this.sourceLayerCoder=new cC(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const n in this.vtLayers)this.vtFeatures[n]=[]}return this.vtLayers}query(n,o,d,g){this.loadVTLayers();const v=n.params||{},E=uo(v.filter),L=n.tileResult,k=n.transform,V=L.bufferedTilespaceBounds,q=this.grid.query(V.min.x,V.min.y,V.max.x,V.max.y,(Be,Le,Xe,xt)=>ud(L.bufferedTilespaceGeometry,Be,Le,Xe,xt));q.sort(R3);let se=null;k.elevation&&q.length>0&&(se=E0.create(k.elevation,this.tileID));const he={};let _e;for(let Be=0;Be(xt||(xt=Yh(Dt,this.tileID.canonical,n.tileTransform)),_t.queryIntersectsFeature(L,Dt,Tt,xt,this.z,n.transform,n.pixelPosMatrix,se,kt)))}return he}loadMatchingFeature(n,o,d,g,v,E,L,k,V){const{featureIndex:q,bucketIndex:se,sourceLayerIndex:he,layoutVertexArrayOffset:_e}=o,Be=this.bucketLayerIDs[se];if(g&&!function(Dt,_t){for(let Tt=0;Tt=0)return!0;return!1}(g,Be))return;const Le=this.sourceLayerCoder.decode(he),Xe=this.vtLayers[Le].feature(q);if(d.needGeometry){const Dt=xA(Xe,!0);if(!d.filter(new qt(this.tileID.overscaledZ),Dt,this.tileID.canonical))return}else if(!d.filter(new qt(this.tileID.overscaledZ),Xe))return;const xt=this.getId(Xe,Le);for(let Dt=0;Dt{const L=n instanceof $i?n.get(E):null;return L&&L.evaluate?L.evaluate(o,d,g):L})}function R3(s,n){return n-s}zt(BC,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class EC{constructor(n,o){this.width=n,this.height=o,this.nextRow=0,this.image=new Yl({width:n,height:o}),this.positions={},this.uploaded=!1}getDash(n,o){const d=this.getKey(n,o);return this.positions[d]}trim(){const n=this.width,o=this.height=nt(this.nextRow);this.image.resize({width:n,height:o})}getKey(n,o){return n.join(",")+o}getDashRanges(n,o,d){const g=[];let v=n.length%2==1?-n[n.length-1]*d:0,E=n[0]*d,L=!0;g.push({left:v,right:E,isDash:L,zeroLength:n[0]===0});let k=n[0];for(let V=1;V1&&(k=n[++L]);const q=Math.abs(V-k.left),se=Math.abs(V-k.right),he=Math.min(q,se);let _e;const Be=v/d*(g+1);if(k.isDash){const Le=g-Math.abs(Be);_e=Math.sqrt(he*he+Le*Le)}else _e=g-Math.sqrt(he*he+Be*Be);this.image.data[E+V]=Math.max(0,Math.min(255,_e+128))}}}addRegularDash(n,o){for(let k=n.length-1;k>=0;--k){const V=n[k],q=n[k+1];V.zeroLength?n.splice(k,1):q&&q.isDash===V.isDash&&(q.left=V.left,n.splice(k,1))}const d=n[0],g=n[n.length-1];d.isDash===g.isDash&&(d.left=g.left-this.width,g.right=d.right+this.width);const v=this.width*this.nextRow;let E=0,L=n[E];for(let k=0;k1&&(L=n[++E]);const V=Math.abs(k-L.left),q=Math.abs(k-L.right),se=Math.min(V,q);this.image.data[v+k]=Math.max(0,Math.min(255,(L.isDash?se:-se)+o+128))}}addDash(n,o){const d=this.getKey(n,o);if(this.positions[d])return this.positions[d];const g=o==="round",v=g?7:0,E=2*v+1;if(this.nextRow+E>this.height)return Ct("LineAtlas out of space"),null;n.length===0&&n.push(1);let L=0;for(let q=0;q=Si.maxzoom||Si.visibility!=="none"&&(G1(gi,this.zoom,d),(k[Si.id]=Si.createBucket({index:L.bucketLayerIDs.length,layers:gi,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ti,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:d})).populate(Ki,q,this.tileID.canonical,this.tileTransform),L.bucketLayerIDs.push(gi.map(Li=>Li.id)))}}let he,_e,Be,Le;V.trim();const Xe={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},xt=ut(q.glyphDependencies,kt=>Object.keys(kt).map(Number));Object.keys(xt).length?g.send("getGlyphs",{uid:this.uid,stacks:xt},(kt,Ut)=>{he||(he=kt,_e=Ut,Tt.call(this))},void 0,!1,Xe):_e={};const Dt=Object.keys(q.iconDependencies);Dt.length?g.send("getImages",{icons:Dt,source:this.source,tileID:this.tileID,type:"icons"},(kt,Ut)=>{he||(he=kt,Be=Ut,Tt.call(this))},void 0,!1,Xe):Be={};const _t=Object.keys(q.patternDependencies);function Tt(){if(he)return v(he);if(_e&&Be&&Le){const kt=new TC(_e),Ut=new Tc(Be,Le);for(const ci in k){const oi=k[ci];oi instanceof Fd?(G1(oi.layers,this.zoom,d),s3(oi,_e,kt.positions,Be,Ut.iconPositions,this.showCollisionBoxes,d,this.tileID.canonical,this.tileZoom,this.projection)):oi.hasPattern&&(oi instanceof Qs||oi instanceof Mp||oi instanceof Ce)&&(G1(oi.layers,this.zoom,d),oi.addFeatures(q,this.tileID.canonical,Ut.patternPositions,d,this.tileTransform))}this.status="done",v(null,{buckets:We(k).filter(ci=>!ci.isEmpty()),featureIndex:L,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:kt.image,lineAtlas:V,imageAtlas:Ut,glyphMap:this.returnDependencies?_e:null,iconMap:this.returnDependencies?Be:null,glyphPositions:this.returnDependencies?kt.positions:null})}}_t.length?g.send("getImages",{icons:_t,source:this.source,tileID:this.tileID,type:"patterns"},(kt,Ut)=>{he||(he=kt,Le=Ut,Tt.call(this))},void 0,!1,Xe):Le={},Tt.call(this)}}function G1(s,n,o){const d=new qt(n);for(const g of s)g.recalculate(d,o)}class SC{constructor(n){this.entries={},this.scheduler=n}request(n,o,d,g){const v=this.entries[n]=this.entries[n]||{callbacks:[]};if(v.result){const[E,L]=v.result;return this.scheduler?this.scheduler.add(()=>{g(E,L)},o):g(E,L),()=>{}}return v.callbacks.push(g),v.cancel||(v.cancel=d((E,L)=>{v.result=[E,L];for(const k of v.callbacks)this.scheduler?this.scheduler.add(()=>{k(E,L)},o):k(E,L);setTimeout(()=>delete this.entries[n],3e3)})),()=>{v.result||(v.callbacks=v.callbacks.filter(E=>E!==g),v.callbacks.length||(v.cancel(),delete this.entries[n]))}}}function MC(s,n,o){const d=JSON.stringify(s.request);return s.data&&(this.deduped.entries[d]={result:[null,s.data]}),this.deduped.request(d,{type:"parseTile",isSymbolTile:s.isSymbolTile,zoom:s.tileZoom},g=>{const v=Cn(s.request,(E,L,k,V)=>{E?g(E):L&&g(null,{vectorTile:o?void 0:new f(new Fa(L)),rawData:L,cacheControl:k,expires:V})});return()=>{v.cancel(),g()}},n)}i.ARRAY_TYPE=Sa,i.AUTH_ERR_MSG=wi,i.Aabb=Ko,i.Actor=class{constructor(s,n,o){this.target=s,this.parent=n,this.mapId=o,this.callbacks={},this.cancelCallbacks={},be(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=_i()?s:C,this.scheduler=new L3}send(s,n,o,d,g=!1,v){const E=Math.round(1e18*Math.random()).toString(36).substring(0,10);o&&(o.metadata=v,this.callbacks[E]=o);const L=wn(this.globalScope)?void 0:[];return this.target.postMessage({id:E,type:s,hasCallback:!!o,targetMapId:d,mustQueue:g,sourceMapId:this.mapId,data:Bi(n,L)},L),{cancel:()=>{o&&delete this.callbacks[E],this.target.postMessage({id:E,type:"",targetMapId:d,sourceMapId:this.mapId})}}}receive(s){const n=s.data,o=n.id;if(o&&(!n.targetMapId||this.mapId===n.targetMapId))if(n.type===""){const d=this.cancelCallbacks[o];delete this.cancelCallbacks[o],d&&d.cancel()}else if(n.mustQueue||_i()){const d=this.callbacks[o];this.cancelCallbacks[o]=this.scheduler.add(()=>this.processTask(o,n),d&&d.metadata||{type:"message"})}else this.processTask(o,n)}processTask(s,n){if(n.type===""){const o=this.callbacks[s];delete this.callbacks[s],o&&(n.error?o(Hi(n.error)):o(null,Hi(n.data)))}else{const o=wn(this.globalScope)?void 0:[],d=n.hasCallback?(v,E)=>{delete this.cancelCallbacks[s],this.target.postMessage({id:s,type:"",sourceMapId:this.mapId,error:v?Bi(v):null,data:Bi(E,o)},o)}:v=>{},g=Hi(n.data);if(this.parent[n.type])this.parent[n.type](n.sourceMapId,g,d);else if(this.parent.getWorkerSource){const v=n.type.split(".");this.parent.getWorkerSource(n.sourceMapId,v[0],g.source)[v[1]](g,d)}else d(new Error(`Could not find function ${n.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=Fi,i.Color=ps,i.ColorMode=Uu,i.CullFaceMode=ru,i.DEMData=C0,i.DataConstantProperty=Jt,i.DedupedRequest=SC,i.DepthMode=em,i.EXTENT=Zn,i.Elevation=class{isDataAvailableAtPoint(s){const n=this._source();if(this.isUsingMockSource()||!n||s.y<0||s.y>1)return!1;const o=n.getSource().maxzoom,d=1<1)return n;const g=d.getSource().maxzoom,v=1<{const v=this.getAtTileOffset(s,g.x,g.y),E=d.upVector(s.canonical,g.x,g.y);return da(E,E,v*d.upVectorScale(s.canonical,n,o).metersToTile),E}}getForTilePoints(s,n,o,d){if(this.isUsingMockSource())return!1;const g=E0.create(this,s,d);return!!g&&(n.forEach(v=>{v[2]=this.exaggeration()*g.getElevationAt(v[0],v[1],o)}),!0)}getMinMaxForTile(s){if(this.isUsingMockSource())return null;const n=this.findDEMTileFor(s);if(!n||!n.dem)return null;const o=n.dem.tree,d=n.tileID,g=1<this._skuTokenExpiresAt}transformRequest(s,n){return this._transformRequestFn&&this._transformRequestFn(s,n)||{url:s}}normalizeStyleURL(s,n){if(!Wi(s))return s;const o=kr(s);return o.path=`/styles/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||n)}normalizeGlyphsURL(s,n){if(!Wi(s))return s;const o=kr(s);return o.path=`/fonts/v1${o.path}`,this._makeAPIURL(o,this._customAccessToken||n)}normalizeSourceURL(s,n,o,d){if(!Wi(s))return s;const g=kr(s);return g.path=`/v4/${g.authority}.json`,g.params.push("secure"),o&&g.params.push(`language=${o}`),d&&g.params.push(`worldview=${d}`),this._makeAPIURL(g,this._customAccessToken||n)}normalizeSpriteURL(s,n,o,d){const g=kr(s);return Wi(s)?(g.path=`/styles/v1${g.path}/sprite${n}${o}`,this._makeAPIURL(g,this._customAccessToken||d)):(g.path+=`${n}${o}`,Qn(g))}normalizeTileURL(s,n,o){if(this._isSkuTokenExpired()&&this._createSkuToken(),s&&!Wi(s))return s;const d=kr(s);d.path=d.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${n||o&&d.authority!=="raster"&&o===512?"@2x":""}${z.supported?".webp":"$1"}`),d.authority==="raster"?d.path=`/${Q.RASTER_URL_PREFIX}${d.path}`:(d.path=d.path.replace(/^.+\/v4\//,"/"),d.path=`/${Q.TILE_URL_VERSION}${d.path}`);const g=this._customAccessToken||function(v){for(const E of v){const L=E.match(/^access_token=(.*)$/);if(L)return L[1]}return null}(d.params)||Q.ACCESS_TOKEN;return Q.REQUIRE_ACCESS_TOKEN&&g&&this._skuToken&&d.params.push(`sku=${this._skuToken}`),this._makeAPIURL(d,g)}canonicalizeTileURL(s,n){const o=kr(s);if(!o.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!o.path.match(/\.[\w]+$/))return s;let d="mapbox://";o.path.match(/^\/raster\/v1\//)?d+=`raster/${o.path.replace(`/${Q.RASTER_URL_PREFIX}/`,"")}`:d+=`tiles/${o.path.replace(`/${Q.TILE_URL_VERSION}/`,"")}`;let g=o.params;return n&&(g=g.filter(v=>!v.match(/^access_token=/))),g.length&&(d+=`?${g.join("&")}`),d}canonicalizeTileset(s,n){const o=!!n&&Wi(n),d=[];for(const g of s.tiles||[])Ui(g)?d.push(this.canonicalizeTileURL(g,o)):d.push(g);return d}_makeAPIURL(s,n){const o="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",d=kr(Q.API_URL);if(s.protocol=d.protocol,s.authority=d.authority,s.protocol==="http"){const g=s.params.indexOf("secure");g>=0&&s.params.splice(g,1)}if(d.path!=="/"&&(s.path=`${d.path}${s.path}`),!Q.REQUIRE_ACCESS_TOKEN)return Qn(s);if(n=n||Q.ACCESS_TOKEN,!this._silenceAuthErrors){if(!n)throw new Error(`An API access token is required to use Mapbox GL. ${o}`);if(n[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${o}`)}return s.params=s.params.filter(g=>g.indexOf("access_token")===-1),s.params.push(`access_token=${n||""}`),Qn(s)}},i.ResourceType=ii,i.SegmentVector=to,i.SourceCache=Pp,i.StencilMode=Q1,i.StructArrayLayout1ui2=Xh,i.StructArrayLayout2f1f2i16=Io,i.StructArrayLayout2i4=Or,i.StructArrayLayout2ui4=Ka,i.StructArrayLayout3f12=ja,i.StructArrayLayout3ui6=_o,i.StructArrayLayout4i8=Qr,i.StructArrayLayout5f20=$h,i.Texture=jg,i.Tile=O1,i.Transitionable=Ci,i.Uniform1f=mA,i.Uniform1i=class extends oh{constructor(s){super(s),this.current=0}set(s,n,o){this.fetchUniformLocation(s,n)&&this.current!==o&&(this.current=o,this.gl.uniform1i(this.location,o))}},i.Uniform2f=class extends oh{constructor(s){super(s),this.current=[0,0]}set(s,n,o){this.fetchUniformLocation(s,n)&&(o[0]===this.current[0]&&o[1]===this.current[1]||(this.current=o,this.gl.uniform2f(this.location,o[0],o[1])))}},i.Uniform3f=class extends oh{constructor(s){super(s),this.current=[0,0,0]}set(s,n,o){this.fetchUniformLocation(s,n)&&(o[0]===this.current[0]&&o[1]===this.current[1]&&o[2]===this.current[2]||(this.current=o,this.gl.uniform3f(this.location,o[0],o[1],o[2])))}},i.Uniform4f=dp,i.UniformColor=ld,i.UniformMatrix2f=class extends oh{constructor(s){super(s),this.current=pp}set(s,n,o){if(this.fetchUniformLocation(s,n)){for(let d=0;d<4;d++)if(o[d]!==this.current[d]){this.current=o,this.gl.uniformMatrix2fv(this.location,!1,o);break}}}},i.UniformMatrix3f=class extends oh{constructor(s){super(s),this.current=Py}set(s,n,o){if(this.fetchUniformLocation(s,n)){for(let d=0;d<9;d++)if(o[d]!==this.current[d]){this.current=o,this.gl.uniformMatrix3fv(this.location,!1,o);break}}}},i.UniformMatrix4f=class extends oh{constructor(s){super(s),this.current=Dy}set(s,n,o){if(this.fetchUniformLocation(s,n)){if(o[12]!==this.current[12]||o[0]!==this.current[0])return this.current=o,void this.gl.uniformMatrix4fv(this.location,!1,o);for(let d=1;d<16;d++)if(o[d]!==this.current[d]){this.current=o,this.gl.uniformMatrix4fv(this.location,!1,o);break}}}},i.UnwrappedTileID=Sn,i.ValidationError=An,i.VectorTileFeature=w,i.VectorTileWorkerSource=class extends yn{constructor(s,n,o,d,g){super(),this.actor=s,this.layerIndex=n,this.availableImages=o,this.loadVectorData=g||MC,this.loading={},this.loaded={},this.deduped=new SC(s.scheduler),this.isSpriteLoaded=d,this.scheduler=s.scheduler}loadTile(s,n){const o=s.uid,d=s&&s.request,g=d&&d.collectResourceTiming,v=this.loading[o]=new z3(s);v.abort=this.loadVectorData(s,(E,L)=>{const k=!this.loading[o];if(delete this.loading[o],k||E||!L)return v.status="done",k||(this.loaded[o]=v),n(E);const V=L.rawData,q={};L.expires&&(q.expires=L.expires),L.cacheControl&&(q.cacheControl=L.cacheControl),v.vectorTile=L.vectorTile||new f(new Fa(V));const se=()=>{v.parse(v.vectorTile,this.layerIndex,this.availableImages,this.actor,(he,_e)=>{if(he||!_e)return n(he);const Be={};if(g){const Le=pt(d);Le.length>0&&(Be.resourceTiming=JSON.parse(JSON.stringify(Le)))}n(null,Ve({rawTileData:V.slice(0)},_e,q,Be))})};this.isSpriteLoaded?se():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(se,{type:"parseTile",isSymbolTile:s.isSymbolTile,zoom:s.tileZoom}):se()}),this.loaded=this.loaded||{},this.loaded[o]=v})}reloadTile(s,n){const o=this.loaded,d=s.uid,g=this;if(o&&o[d]){const v=o[d];v.showCollisionBoxes=s.showCollisionBoxes,v.enableTerrain=!!s.enableTerrain,v.projection=s.projection,v.tileTransform=Dp(s.tileID.canonical,s.projection);const E=(L,k)=>{const V=v.reloadCallback;V&&(delete v.reloadCallback,v.parse(v.vectorTile,g.layerIndex,this.availableImages,g.actor,V)),n(L,k)};v.status==="parsing"?v.reloadCallback=E:v.status==="done"&&(v.vectorTile?v.parse(v.vectorTile,this.layerIndex,this.availableImages,this.actor,E):E())}}abortTile(s,n){const o=s.uid,d=this.loading[o];d&&(d.abort&&d.abort(),delete this.loading[o]),n()}removeTile(s,n){const o=this.loaded,d=s.uid;o&&o[d]&&delete o[d],n()}},i.WritingMode=qo,i.add=Jh,i.addDynamicAttributes=w0,i.adjoint=function(s,n){var o=n[0],d=n[1],g=n[2],v=n[3],E=n[4],L=n[5],k=n[6],V=n[7],q=n[8];return s[0]=E*q-L*V,s[1]=g*V-d*q,s[2]=d*L-g*E,s[3]=L*k-v*q,s[4]=o*q-g*k,s[5]=g*v-o*L,s[6]=v*V-E*k,s[7]=d*k-o*V,s[8]=o*E-d*v,s},i.asyncAll=Oe,i.bezier=te,i.bindAll=be,i.boundsAttributes=AC,i.bufferConvexPolygon=function(s,n){const o=[];for(let d=0;dNi&&(s.getActor().send("enforceCacheSizeLimit",ti),at=0)},i.calculateGlobeLabelMatrix=function(s,n){const{x:o,y:d}=s.point,g=JB(o,d,s.worldSize/s._pixelsPerMercatorPixel,0,0);return bA(g,g,D1(Lu(n)))},i.calculateGlobeMatrix=function(s){const{x:n,y:o}=s.point,{lng:d,lat:g}=s._center;return JB(n,o,s.worldSize,d,g)},i.calculateGlobeMercatorMatrix=function(s){const n=s.pixelsPerMeter,o=n/Xl(1,s.center.lat),d=ql(new Float64Array(16));return xp(d,d,[s.point.x,s.point.y,0]),BA(d,d,[o,o,n]),Float32Array.from(d)},i.circumferenceAtLatitude=Tf,i.clamp=ye,i.clearTileCache=function(s){if(!qi())return;const n=C.caches.delete(kn);s&&n.catch(s).then(()=>s())},i.clipLine=OB,i.clone=function(s){var n=new Sa(16);return n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],n[9]=s[9],n[10]=s[10],n[11]=s[11],n[12]=s[12],n[13]=s[13],n[14]=s[14],n[15]=s[15],n},i.clone$1=Gt,i.collisionCircleLayout=pa,i.config=Q,i.conjugate=function(s,n){return s[0]=-n[0],s[1]=-n[1],s[2]=-n[2],s[3]=n[3],s},i.create=function(){var s=new Sa(16);return Sa!=Float32Array&&(s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0),s[0]=1,s[5]=1,s[10]=1,s[15]=1,s},i.create$1=hh,i.createExpression=Ms,i.createLayout=_n,i.createStyleLayer=function(s){return s.type==="custom"?new S3(s):new I3[s.type](s)},i.cross=md,i.degToRad=Ge,i.distance=function(s,n){return Math.hypot(n[0]-s[0],n[1]-s[1],n[2]-s[2])},i.div=function(s,n,o){return s[0]=n[0]/o[0],s[1]=n[1]/o[1],s[2]=n[2]/o[2],s},i.dot=Ma,i.earthRadius=Ef,i.ease=le,i.easeCubicInOut=xi,i.ecefToLatLng=function([s,n,o]){const d=Math.hypot(s,n,o),g=Math.atan2(s,o),v=.5*Math.PI-Math.acos(-n/d);return new Pr(Et(g),Et(v))},i.emitValidationErrors=Vt,i.endsWith=At,i.enforceCacheSizeLimit=function(s){en(),yt&&yt.then(n=>{n.keys().then(o=>{for(let d=0;dv&&(d+=(s[g]-v)*(s[g]-v)),n[g]0){const Be=180/d;wA(_e,_e,[Be/V+1,0,0,0,Be/q+1,0,-.5*Be/se,.5*Be/he,1])}return _e[2]=k,_e[5]=s.x,_e[8]=s.y,_e},i.getImage=Ot,i.getJSON=function(s,n){return on(Ve(s,{type:"json"}),n)},i.getLatitudinalLod=function(s){const n=80.051129;s=ye(s,-80.051129,n)/n*90;const o=Math.pow(Math.abs(Math.sin(Ge(s))),3);return Math.round(o*(Xf.length-1))},i.getMapSessionAPI=ne,i.getPerformanceMeasurement=pt,i.getProjection=aC,i.getRTLTextPluginStatus=Ht,i.getReferrer=Xi,i.getTilePoint=function(s,{x:n,y:o},d=0){return new me(((n-d)*s.scale-s.x)*Zn,(o*s.scale-s.y)*Zn)},i.getTileVec3=function(s,n,o=0){return pd(((n.x-o)*s.scale-s.x)*Zn,(n.y*s.scale-s.y)*Zn,Sf(n.z,n.y))},i.getVideo=function(s,n){const o=C.document.createElement("video");o.muted=!0,o.onloadstart=function(){n(null,o)};for(let d=0;d{}}},i.globeCenterToScreenPoint=function(s){const n=[0,0,0],o=ql(new Float64Array(16));return bA(o,s.pixelMatrix,s.globeMatrix),Ns(n,n,o),new me(n[0],n[1])},i.globeDenormalizeECEF=D1,i.globeECEFOrigin=function(s,n){const o=[0,0,0];return Ns(o,o,Qg(Lu(n.canonical))),Ns(o,o,s),o},i.globeNormalizeECEF=Qg,i.globePixelsToTileUnits=function(s,n){return Zn/(512*Math.pow(2,s))*g0(Lu(n))},i.globePoleMatrixForTile=function(s,n,o){const d=ql(new Float64Array(16)),g=(n/(1<0;return d===0&&!g&&!E&&v},i.identity=ql,i.identity$1=bg,i.invert=_g,i.isFullscreen=function(){return!!C.document.fullscreenElement||!!C.document.webkitFullscreenElement},i.isLngLatBehindGlobe=P1,i.isMapAuthenticated=function(s){return de.has(s)},i.isMapboxURL=Wi,i.isSafariWithAntialiasingBug=function(s){const n=s.navigator?s.navigator.userAgent:null;return!!wn(s)&&n&&(n.match("Version/15.4")||n.match("Version/15.5")||n.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},i.latFromMercatorY=Fo,i.latLngToECEF=Og,i.len=Ky,i.length=dd,i.length$1=function(s){return Math.hypot(s[0],s[1],s[2],s[3])},i.lngFromMercatorX=bl,i.loadVectorTile=MC,i.makeRequest=on,i.mapValue=function(s,n,o,d,g){return ye((s-n)/(o-n)*(g-d)+d,d,g)},i.mercatorScale=Mf,i.mercatorXfromLng=wc,i.mercatorYfromLat=ch,i.mercatorZfromAltitude=Xl,i.mul=c1,i.mul$1=jy,i.multiply=bA,i.multiply$1=wA,i.multiply$2=vg,i.nextPowerOfTwo=nt,i.normalize=so,i.normalize$1=Iu,i.normalize$2=Df,i.number=gr,i.ortho=function(s,n,o,d,g,v,E){var L=1/(n-o),k=1/(d-g),V=1/(v-E);return s[0]=-2*L,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*k,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*V,s[11]=0,s[12]=(n+o)*L,s[13]=(g+d)*k,s[14]=(E+v)*V,s[15]=1,s},i.pbf=Fa,i.perspective=function(s,n,o,d,g){var v,E=1/Math.tan(n/2);return s[0]=E/o,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=E,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[11]=-1,s[12]=0,s[13]=0,s[15]=0,g!=null&&g!==1/0?(s[10]=(g+d)*(v=1/(d-g)),s[14]=2*g*d*v):(s[10]=-1,s[14]=-2*d),s},i.pick=function(s,n){const o={};for(let d=0;d0&&o[0]<=s.width&&o[1]>0&&o[1]<=s.height&&!P1(s,new Pr(s.center.lat,90)),d[0]>0&&d[0]<=s.width&&d[1]>0&&d[1]<=s.height&&!P1(s,new Pr(s.center.lat,-90))]},i.polygonContainsPoint=vA,i.polygonIntersectsBox=ud,i.polygonIntersectsPolygon=Ny,i.polygonizeBounds=function(s,n,o=0,d=!0){const g=new me(o,o),v=s.sub(g),E=n.add(g),L=[v,new me(E.x,v.y),E,new me(v.x,E.y)];return d&&L.push(v.clone()),L},i.posAttributes=kg,i.postMapLoadEvent=wt,i.postPerformanceEvent=j,i.postTurnstileEvent=Pe,i.potpack=jf,i.prevPowerOfTwo=function(s){return s<=1?1:Math.pow(2,Math.floor(Math.log(s)/Math.LN2))},i.radToDeg=Et,i.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],i.registerForPluginStateChange=function(s){return s({pluginStatus:dt,pluginURL:ht}),It.on("pluginStateChange",s),s},i.removeAuthState=function(s){de.delete(s)},i.renderColorRamp=Tg,i.resample=zy,i.rotateX=yg,i.rotateX$1=uh,i.rotateY=Ff,i.rotateY$1=Bg,i.rotateZ=function(s,n,o){var d=Math.sin(o),g=Math.cos(o),v=n[0],E=n[1],L=n[2],k=n[3],V=n[4],q=n[5],se=n[6],he=n[7];return n!==s&&(s[8]=n[8],s[9]=n[9],s[10]=n[10],s[11]=n[11],s[12]=n[12],s[13]=n[13],s[14]=n[14],s[15]=n[15]),s[0]=v*g+V*d,s[1]=E*g+q*d,s[2]=L*g+se*d,s[3]=k*g+he*d,s[4]=V*g-v*d,s[5]=q*g-E*d,s[6]=se*g-L*d,s[7]=he*g-k*d,s},i.rotateZ$1=function(s,n,o){o*=.5;var d=n[0],g=n[1],v=n[2],E=n[3],L=Math.sin(o),k=Math.cos(o);return s[0]=d*k+g*L,s[1]=g*k-d*L,s[2]=v*k+E*L,s[3]=E*k-v*L,s},i.scale=BA,i.scale$1=Lf,i.scale$2=da,i.scaleAndAdd=eu,i.set=function(s,n,o,d){return s[0]=n,s[1]=o,s[2]=d,s},i.setCacheLimits=function(s,n){ti=s,Ni=n},i.setColumn=function(s,n,o){s[4*n+0]=o[0],s[4*n+1]=o[1],s[4*n+2]=o[2],s[4*n+3]=o[3]},i.setRTLTextPlugin=function(s,n,o=!1){if(dt===it||dt===lt||dt===qe)throw new Error("setRTLTextPlugin cannot be called multiple times.");ht=bi.resolveURL(s),dt=it,Ye=n,Pt(),o||hi()},i.smoothstep=xe,i.spec=Yt,i.squaredLength=function(s){var n=s[0],o=s[1],d=s[2];return n*n+o*o+d*d},i.storeAuthState=function(s,n){n?de.add(s):de.delete(s)},i.sub=bc,i.subtract=xg,i.symbolSize=qa,i.tileAABB=function(s,n,o,d,g,v,E,L,k){if(k.name==="globe")return u3(s,n,new Fi(o,d,g));const V=Dp({z:o,x:d,y:g},k);return new Ko([(v+V.x/V.scale)*n,n*(V.y/V.scale),E],[(v+V.x2/V.scale)*n,n*(V.y2/V.scale),L])},i.tileCornersToBounds=m0,i.tileTransform=Dp,i.transformMat3=function(s,n,o){var d=n[0],g=n[1],v=n[2];return s[0]=d*o[0]+g*o[3]+v*o[6],s[1]=d*o[1]+g*o[4]+v*o[7],s[2]=d*o[2]+g*o[5]+v*o[8],s},i.transformMat4=Ns,i.transformMat4$1=TA,i.transformQuat=wg,i.transitionTileAABBinECEF=XB,i.translate=xp,i.transpose=function(s,n){if(s===n){var o=n[1],d=n[2],g=n[5];s[1]=n[3],s[2]=n[6],s[3]=o,s[5]=n[7],s[6]=d,s[7]=g}else s[0]=n[0],s[1]=n[3],s[2]=n[6],s[3]=n[1],s[4]=n[4],s[5]=n[7],s[6]=n[2],s[7]=n[5],s[8]=n[8];return s},i.triggerPluginCompletionEvent=Bt,i.uniqueId=Se,i.updateGlobeVertexNormal=function(s,n,o,d,g){const v=5*n+2;s.float32[v+0]=o,s.float32[v+1]=d,s.float32[v+2]=g},i.validateCustomStyleLayer=function(s){const n=[],o=s.id;return o===void 0&&n.push({message:`layers.${o}: missing required property "id"`}),s.render===void 0&&n.push({message:`layers.${o}: missing required method "render"`}),s.renderingMode&&s.renderingMode!=="2d"&&s.renderingMode!=="3d"&&n.push({message:`layers.${o}: property "renderingMode" must be either "2d" or "3d"`}),n},i.validateFilter=s=>gt(hs(s)),i.validateFog=s=>gt(ue(s)),i.validateLayer=s=>gt(h(s)),i.validateLight=s=>gt(K(s)),i.validateSource=s=>gt(F(s)),i.validateStyle=je,i.validateTerrain=s=>gt(oe(s)),i.values=We,i.vectorTile=Fp,i.version=D,i.warnOnce=Ct,i.window=C,i.wrap=Re}),p(["./shared"],function(i){function C(ot){if(typeof ot=="number"||typeof ot=="boolean"||typeof ot=="string"||ot==null)return JSON.stringify(ot);if(Array.isArray(ot)){let Pe="[";for(const ct of ot)Pe+=`${C(ct)},`;return`${Pe}]`}let Ee="{";for(const Pe of Object.keys(ot).sort())Ee+=`${Pe}:${C(ot[Pe])},`;return`${Ee}}`}function D(ot){let Ee="";for(const Pe of i.refProperties)Ee+=`/${C(ot[Pe])}`;return Ee}class R{constructor(Ee){this.keyCache={},Ee&&this.replace(Ee)}replace(Ee){this._layerConfigs={},this._layers={},this.update(Ee,[])}update(Ee,Pe){for(const wt of Ee)this._layerConfigs[wt.id]=wt,(this._layers[wt.id]=i.createStyleLayer(wt)).compileFilter(),this.keyCache[wt.id]&&delete this.keyCache[wt.id];for(const wt of Pe)delete this.keyCache[wt],delete this._layerConfigs[wt],delete this._layers[wt];this.familiesBySource={};const ct=function(wt,X){const j={};for(let ne=0;nethis._layers[tt.id]),j=X[0];if(j.visibility==="none")continue;const ie=j.source||"";let ne=this.familiesBySource[ie];ne||(ne=this.familiesBySource[ie]={});const de=j.sourceLayer||"_geojsonTileLayer";let Ue=ne[de];Ue||(Ue=ne[de]=[]),Ue.push(X)}}}class Q{loadTile(Ee,Pe){const{uid:ct,encoding:wt,rawImageData:X,padding:j,buildQuadTree:ie}=Ee,ne=i.window.ImageBitmap&&X instanceof i.window.ImageBitmap?this.getImageData(X,j):X;Pe(null,new i.DEMData(ct,ne,wt,j<1,ie))}getImageData(Ee,Pe){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(Ee.width,Ee.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=Ee.width,this.offscreenCanvas.height=Ee.height,this.offscreenCanvasContext.drawImage(Ee,0,0,Ee.width,Ee.height);const ct=this.offscreenCanvasContext.getImageData(-Pe,-Pe,Ee.width+2*Pe,Ee.height+2*Pe);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),ct}}var z=function ot(Ee,Pe){var ct,wt=Ee&&Ee.type;if(wt==="FeatureCollection")for(ct=0;ct=Math.abs(ie)?Pe-ne+ie:ie-ne+Pe,Pe=ne}Pe+ct>=0!=!!Ee&&ot.reverse()}const Y=i.VectorTileFeature.prototype.toGeoJSON;class B{constructor(Ee){this._feature=Ee,this.extent=i.EXTENT,this.type=Ee.type,this.properties=Ee.tags,"id"in Ee&&!isNaN(Ee.id)&&(this.id=parseInt(Ee.id,10))}loadGeometry(){if(this._feature.type===1){const Ee=[];for(const Pe of this._feature.geometry)Ee.push([new i.pointGeometry(Pe[0],Pe[1])]);return Ee}{const Ee=[];for(const Pe of this._feature.geometry){const ct=[];for(const wt of Pe)ct.push(new i.pointGeometry(wt[0],wt[1]));Ee.push(ct)}return Ee}}toGeoJSON(Ee,Pe,ct){return Y.call(this,Ee,Pe,ct)}}class ae{constructor(Ee){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=Ee.length,this._features=Ee}feature(Ee){return new B(this._features[Ee])}}var ce={exports:{}},Ae=i.pointGeometry,we=i.vectorTile.VectorTileFeature,me=De;function De(ot,Ee){this.options=Ee||{},this.features=ot,this.length=ot.length}function Je(ot,Ee){this.id=typeof ot.id=="number"?ot.id:void 0,this.type=ot.type,this.rawGeometry=ot.type===1?[ot.geometry]:ot.geometry,this.properties=ot.tags,this.extent=Ee||4096}De.prototype.feature=function(ot){return new Je(this.features[ot],this.options.extent)},Je.prototype.loadGeometry=function(){var ot=this.rawGeometry;this.geometry=[];for(var Ee=0;Ee>31}function xe(ot,Ee){for(var Pe=ot.loadGeometry(),ct=ot.type,wt=0,X=0,j=Pe.length,ie=0;ie>1;We(ot,Ee,j,ct,wt,X%2),Oe(ot,Ee,Pe,ct,j-1,X+1),Oe(ot,Ee,Pe,j+1,wt,X+1)}function We(ot,Ee,Pe,ct,wt,X){for(;wt>ct;){if(wt-ct>600){const de=wt-ct+1,Ue=Pe-ct+1,tt=Math.log(de),He=.5*Math.exp(2*tt/3),et=.5*Math.sqrt(tt*He*(de-He)/de)*(Ue-de/2<0?-1:1);We(ot,Ee,Pe,Math.max(ct,Math.floor(Pe-Ue*He/de+et)),Math.min(wt,Math.floor(Pe+(de-Ue)*He/de+et)),X)}const j=Ee[2*Pe+X];let ie=ct,ne=wt;for(Ve(ot,Ee,ct,Pe),Ee[2*wt+X]>j&&Ve(ot,Ee,ct,wt);iej;)ne--}Ee[2*ct+X]===j?Ve(ot,Ee,ct,ne):(ne++,Ve(ot,Ee,ne,wt)),ne<=Pe&&(ct=ne+1),Pe<=ne&&(wt=ne-1)}}function Ve(ot,Ee,Pe,ct){Qe(ot,Pe,ct),Qe(Ee,2*Pe,2*ct),Qe(Ee,2*Pe+1,2*ct+1)}function Qe(ot,Ee,Pe){const ct=ot[Ee];ot[Ee]=ot[Pe],ot[Pe]=ct}function Se(ot,Ee,Pe,ct){const wt=ot-Pe,X=Ee-ct;return wt*wt+X*X}ce.exports=Et,ce.exports.fromVectorTileJs=Et,ce.exports.fromGeojsonVt=function(ot,Ee){Ee=Ee||{};var Pe={};for(var ct in ot)Pe[ct]=new Ge(ot[ct].features,Ee),Pe[ct].name=ct,Pe[ct].version=Ee.version,Pe[ct].extent=Ee.extent;return Et({layers:Pe})},ce.exports.GeoJSONWrapper=Ge;const Ke=ot=>ot[0],nt=ot=>ot[1];class vt{constructor(Ee,Pe=Ke,ct=nt,wt=64,X=Float64Array){this.nodeSize=wt,this.points=Ee;const j=Ee.length<65536?Uint16Array:Uint32Array,ie=this.ids=new j(Ee.length),ne=this.coords=new X(2*Ee.length);for(let de=0;de=ie&&pt<=de&&Lt>=ne&&Lt<=Ue&&et.push(X[Yi]);continue}const bi=Math.floor((ki+Wt)/2);pt=j[2*bi],Lt=j[2*bi+1],pt>=ie&&pt<=de&&Lt>=ne&&Lt<=Ue&&et.push(X[bi]);const Oi=(jt+1)%2;(jt===0?ie<=pt:ne<=Lt)&&(He.push(ki),He.push(bi-1),He.push(Oi)),(jt===0?de>=pt:Ue>=Lt)&&(He.push(bi+1),He.push(Wt),He.push(Oi))}return et}(this.ids,this.coords,Ee,Pe,ct,wt,this.nodeSize)}within(Ee,Pe,ct){return function(wt,X,j,ie,ne,de){const Ue=[0,wt.length-1,0],tt=[],He=ne*ne;for(;Ue.length;){const et=Ue.pop(),pt=Ue.pop(),Lt=Ue.pop();if(pt-Lt<=de){for(let Oi=Lt;Oi<=pt;Oi++)Se(X[2*Oi],X[2*Oi+1],j,ie)<=He&&tt.push(wt[Oi]);continue}const jt=Math.floor((Lt+pt)/2),Wt=X[2*jt],ki=X[2*jt+1];Se(Wt,ki,j,ie)<=He&&tt.push(wt[jt]);const bi=(et+1)%2;(et===0?j-ne<=Wt:ie-ne<=ki)&&(Ue.push(Lt),Ue.push(jt-1),Ue.push(bi)),(et===0?j+ne>=Wt:ie+ne>=ki)&&(Ue.push(jt+1),Ue.push(pt),Ue.push(bi))}return tt}(this.ids,this.coords,Ee,Pe,ct,this.nodeSize)}}const be={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:ot=>ot},At=Math.fround||(ut=new Float32Array(1),ot=>(ut[0]=+ot,ut[0]));var ut;class Nt{constructor(Ee){this.options=Gi(Object.create(be),Ee),this.trees=new Array(this.options.maxZoom+1)}load(Ee){const{log:Pe,minZoom:ct,maxZoom:wt,nodeSize:X}=this.options;Pe&&console.time("total time");const j=`prepare ${Ee.length} points`;Pe&&console.time(j),this.points=Ee;let ie=[];for(let ne=0;ne=ct;ne--){const de=+Date.now();ie=this._cluster(ie,ne),this.trees[ne]=new vt(ie,wn,zi,X,Float32Array),Pe&&console.log("z%d: %d clusters in %dms",ne,ie.length,+Date.now()-de)}return Pe&&console.timeEnd("total time"),this}getClusters(Ee,Pe){let ct=((Ee[0]+180)%360+360)%360-180;const wt=Math.max(-90,Math.min(90,Ee[1]));let X=Ee[2]===180?180:((Ee[2]+180)%360+360)%360-180;const j=Math.max(-90,Math.min(90,Ee[3]));if(Ee[2]-Ee[0]>=360)ct=-180,X=180;else if(ct>X){const Ue=this.getClusters([ct,wt,180,j],Pe),tt=this.getClusters([-180,wt,X,j],Pe);return Ue.concat(tt)}const ie=this.trees[this._limitZoom(Pe)],ne=ie.range(Xt(ct),_i(j),Xt(X),_i(wt)),de=[];for(const Ue of ne){const tt=ie.points[Ue];de.push(tt.numPoints?Ct(tt):this.points[tt.index])}return de}getChildren(Ee){const Pe=this._getOriginId(Ee),ct=this._getOriginZoom(Ee),wt="No cluster with the specified id.",X=this.trees[ct];if(!X)throw new Error(wt);const j=X.points[Pe];if(!j)throw new Error(wt);const ie=this.options.radius/(this.options.extent*Math.pow(2,ct-1)),ne=X.within(j.x,j.y,ie),de=[];for(const Ue of ne){const tt=X.points[Ue];tt.parentId===Ee&&de.push(tt.numPoints?Ct(tt):this.points[tt.index])}if(de.length===0)throw new Error(wt);return de}getLeaves(Ee,Pe,ct){const wt=[];return this._appendLeaves(wt,Ee,Pe=Pe||10,ct=ct||0,0),wt}getTile(Ee,Pe,ct){const wt=this.trees[this._limitZoom(Ee)],X=Math.pow(2,Ee),{extent:j,radius:ie}=this.options,ne=ie/j,de=(ct-ne)/X,Ue=(ct+1+ne)/X,tt={features:[]};return this._addTileFeatures(wt.range((Pe-ne)/X,de,(Pe+1+ne)/X,Ue),wt.points,Pe,ct,X,tt),Pe===0&&this._addTileFeatures(wt.range(1-ne/X,de,1,Ue),wt.points,X,ct,X,tt),Pe===X-1&&this._addTileFeatures(wt.range(0,de,ne/X,Ue),wt.points,-1,ct,X,tt),tt.features.length?tt:null}getClusterExpansionZoom(Ee){let Pe=this._getOriginZoom(Ee)-1;for(;Pe<=this.options.maxZoom;){const ct=this.getChildren(Ee);if(Pe++,ct.length!==1)break;Ee=ct[0].properties.cluster_id}return Pe}_appendLeaves(Ee,Pe,ct,wt,X){const j=this.getChildren(Pe);for(const ie of j){const ne=ie.properties;if(ne&&ne.cluster?X+ne.point_count<=wt?X+=ne.point_count:X=this._appendLeaves(Ee,ne.cluster_id,ct,wt,X):XPe&&(pt+=jt.numPoints||1)}if(pt>et&&pt>=ie){let Lt=Ue.x*et,jt=Ue.y*et,Wt=j&&et>1?this._map(Ue,!0):null;const ki=(de<<5)+(Pe+1)+this.points.length;for(const bi of He){const Oi=tt.points[bi];if(Oi.zoom<=Pe)continue;Oi.zoom=Pe;const Yi=Oi.numPoints||1;Lt+=Oi.x*Yi,jt+=Oi.y*Yi,Oi.parentId=ki,j&&(Wt||(Wt=this._map(Ue,!0)),j(Wt,this._map(Oi)))}Ue.parentId=ki,ct.push(Gt(Lt/pt,jt/pt,ki,pt,Wt))}else if(ct.push(Ue),pt>1)for(const Lt of He){const jt=tt.points[Lt];jt.zoom<=Pe||(jt.zoom=Pe,ct.push(jt))}}return ct}_getOriginId(Ee){return Ee-this.points.length>>5}_getOriginZoom(Ee){return(Ee-this.points.length)%32}_map(Ee,Pe){if(Ee.numPoints)return Pe?Gi({},Ee.properties):Ee.properties;const ct=this.points[Ee.index].properties,wt=this.options.map(ct);return Pe&&wt===ct?Gi({},wt):wt}}function Gt(ot,Ee,Pe,ct,wt){return{x:At(ot),y:At(Ee),zoom:1/0,id:Pe,parentId:-1,numPoints:ct,properties:wt}}function Qt(ot,Ee){const[Pe,ct]=ot.geometry.coordinates;return{x:At(Xt(Pe)),y:At(_i(ct)),zoom:1/0,index:Ee,parentId:-1}}function Ct(ot){return{type:"Feature",id:ot.id,properties:Ft(ot),geometry:{type:"Point",coordinates:[(Ee=ot.x,360*(Ee-.5)),fi(ot.y)]}};var Ee}function Ft(ot){const Ee=ot.numPoints,Pe=Ee>=1e4?`${Math.round(Ee/1e3)}k`:Ee>=1e3?Math.round(Ee/100)/10+"k":Ee;return Gi(Gi({},ot.properties),{cluster:!0,cluster_id:ot.id,point_count:Ee,point_count_abbreviated:Pe})}function Xt(ot){return ot/360+.5}function _i(ot){const Ee=Math.sin(ot*Math.PI/180),Pe=.5-.25*Math.log((1+Ee)/(1-Ee))/Math.PI;return Pe<0?0:Pe>1?1:Pe}function fi(ot){const Ee=(180-360*ot)*Math.PI/180;return 360*Math.atan(Math.exp(Ee))/Math.PI-90}function Gi(ot,Ee){for(const Pe in Ee)ot[Pe]=Ee[Pe];return ot}function wn(ot){return ot.x}function zi(ot){return ot.y}function Gn(ot,Ee,Pe,ct){for(var wt,X=ct,j=Pe-Ee>>1,ie=Pe-Ee,ne=ot[Ee],de=ot[Ee+1],Ue=ot[Pe],tt=ot[Pe+1],He=Ee+3;HeX)wt=He,X=et;else if(et===X){var pt=Math.abs(He-j);ptct&&(wt-Ee>3&&Gn(ot,Ee,wt,ct),ot[wt+2]=X,Pe-wt>3&&Gn(ot,wt,Pe,ct))}function kn(ot,Ee,Pe,ct,wt,X){var j=wt-Pe,ie=X-ct;if(j!==0||ie!==0){var ne=((ot-Pe)*j+(Ee-ct)*ie)/(j*j+ie*ie);ne>1?(Pe=wt,ct=X):ne>0&&(Pe+=j*ne,ct+=ie*ne)}return(j=ot-Pe)*j+(ie=Ee-ct)*ie}function yt(ot,Ee,Pe,ct){var wt={id:ot===void 0?null:ot,type:Ee,geometry:Pe,tags:ct,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(X){var j=X.geometry,ie=X.type;if(ie==="Point"||ie==="MultiPoint"||ie==="LineString")rt(X,j);else if(ie==="Polygon"||ie==="MultiLineString")for(var ne=0;ne0&&(j+=ct?(wt*de-ne*X)/2:Math.sqrt(Math.pow(ne-wt,2)+Math.pow(de-X,2))),wt=ne,X=de}var Ue=Ee.length-3;Ee[2]=1,Gn(Ee,0,Ue,Pe),Ee[Ue+2]=1,Ee.size=Math.abs(j),Ee.start=0,Ee.end=Ee.size}function en(ot,Ee,Pe,ct){for(var wt=0;wt1?1:Pe}function ii(ot,Ee,Pe,ct,wt,X,j,ie){if(ct/=Ee,X>=(Pe/=Ee)&&j=ct)return null;for(var ne=[],de=0;de=Pe&&pt=ct)){var Lt=[];if(He==="Point"||He==="MultiPoint")hn(tt,Lt,Pe,ct,wt);else if(He==="LineString")Xi(tt,Lt,Pe,ct,wt,!1,ie.lineMetrics);else if(He==="MultiLineString")Cn(tt,Lt,Pe,ct,wt,!1);else if(He==="Polygon")Cn(tt,Lt,Pe,ct,wt,!0);else if(He==="MultiPolygon")for(var jt=0;jt=Pe&&j<=ct&&(Ee.push(ot[X]),Ee.push(ot[X+1]),Ee.push(ot[X+2]))}}function Xi(ot,Ee,Pe,ct,wt,X,j){for(var ie,ne,de=on(ot),Ue=wt===0?nr:Ii,tt=ot.start,He=0;HePe&&(ne=Ue(de,et,pt,jt,Wt,Pe),j&&(de.start=tt+ie*ne)):ki>ct?bi=Pe&&(ne=Ue(de,et,pt,jt,Wt,Pe),Oi=!0),bi>ct&&ki<=ct&&(ne=Ue(de,et,pt,jt,Wt,ct),Oi=!0),!X&&Oi&&(j&&(de.end=tt+ie*ne),Ee.push(de),de=on(ot)),j&&(tt+=ie)}var Yi=ot.length-3;et=ot[Yi],pt=ot[Yi+1],Lt=ot[Yi+2],(ki=wt===0?et:pt)>=Pe&&ki<=ct&&Tn(de,et,pt,Lt),Yi=de.length-3,X&&Yi>=3&&(de[Yi]!==de[0]||de[Yi+1]!==de[1])&&Tn(de,de[0],de[1],de[2]),de.length&&Ee.push(de)}function on(ot){var Ee=[];return Ee.size=ot.size,Ee.start=ot.start,Ee.end=ot.end,Ee}function Cn(ot,Ee,Pe,ct,wt,X){for(var j=0;jj.maxX&&(j.maxX=Ue),tt>j.maxY&&(j.maxY=tt)}return j}function Pn(ot,Ee,Pe,ct){var wt=Ee.geometry,X=Ee.type,j=[];if(X==="Point"||X==="MultiPoint")for(var ie=0;ie0&&Ee.size<(wt?j:ct))Pe.numPoints+=Ee.length/3;else{for(var ie=[],ne=0;nej)&&(Pe.numSimplified++,ie.push(Ee[ne]),ie.push(Ee[ne+1])),Pe.numPoints++;wt&&function(de,Ue){for(var tt=0,He=0,et=de.length,pt=et-2;He0===Ue)for(He=0,et=de.length;He24)throw new Error("maxZoom should be in the 0-24 range");if(Ee.promoteId&&Ee.generateId)throw new Error("promoteId and generateId cannot be used together.");var ct=function(wt,X){var j=[];if(wt.type==="FeatureCollection")for(var ie=0;ie1&&console.time("creation"),He=this.tiles[tt]=Ui(ot,Ee,Pe,ct,ne),this.tileCoords.push({z:Ee,x:Pe,y:ct}),de)){de>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Ee,Pe,ct,He.numFeatures,He.numPoints,He.numSimplified),console.timeEnd("creation"));var et="z"+Ee;this.stats[et]=(this.stats[et]||0)+1,this.total++}if(He.source=ot,wt){if(Ee===ne.maxZoom||Ee===wt)continue;var pt=1<1&&console.time("clipping");var Lt,jt,Wt,ki,bi,Oi,Yi=.5*ne.buffer/ne.extent,tn=.5-Yi,rr=.5+Yi,yn=1+Yi;Lt=jt=Wt=ki=null,bi=ii(ot,Ue,Pe-Yi,Pe+rr,0,He.minX,He.maxX,ne),Oi=ii(ot,Ue,Pe+tn,Pe+yn,0,He.minX,He.maxX,ne),ot=null,bi&&(Lt=ii(bi,Ue,ct-Yi,ct+rr,1,He.minY,He.maxY,ne),jt=ii(bi,Ue,ct+tn,ct+yn,1,He.minY,He.maxY,ne),bi=null),Oi&&(Wt=ii(Oi,Ue,ct-Yi,ct+rr,1,He.minY,He.maxY,ne),ki=ii(Oi,Ue,ct+tn,ct+yn,1,He.minY,He.maxY,ne),Oi=null),de>1&&console.timeEnd("clipping"),ie.push(Lt||[],Ee+1,2*Pe,2*ct),ie.push(jt||[],Ee+1,2*Pe,2*ct+1),ie.push(Wt||[],Ee+1,2*Pe+1,2*ct),ie.push(ki||[],Ee+1,2*Pe+1,2*ct+1)}}},Hr.prototype.getTile=function(ot,Ee,Pe){var ct=this.options,wt=ct.extent,X=ct.debug;if(ot<0||ot>24)return null;var j=1<1&&console.log("drilling down to z%d-%d-%d",ot,Ee,Pe);for(var ne,de=ot,Ue=Ee,tt=Pe;!ne&&de>0;)de--,Ue=Math.floor(Ue/2),tt=Math.floor(tt/2),ne=this.tiles[fr(de,Ue,tt)];return ne&&ne.source?(X>1&&console.log("found parent tile z%d-%d-%d",de,Ue,tt),X>1&&console.time("drilling down"),this.splitTile(ne.source,de,Ue,tt,ot,Ee,Pe),X>1&&console.timeEnd("drilling down"),this.tiles[ie]?wi(this.tiles[ie],wt):null):null};class Qn extends i.VectorTileWorkerSource{constructor(Ee,Pe,ct,wt,X){super(Ee,Pe,ct,wt,kr),X&&(this.loadGeoJSON=X)}loadData(Ee,Pe){const ct=Ee&&Ee.request,wt=ct&&ct.collectResourceTiming;this.loadGeoJSON(Ee,(X,j)=>{if(X||!j)return Pe(X);if(typeof j!="object")return Pe(new Error(`Input data given to '${Ee.source}' is not a valid GeoJSON object.`));{z(j,!0);try{if(Ee.filter){const ne=i.createExpression(Ee.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(ne.result==="error")throw new Error(ne.value.map(Ue=>`${Ue.key}: ${Ue.message}`).join(", "));j={type:"FeatureCollection",features:j.features.filter(Ue=>ne.value.evaluate({zoom:0},Ue))}}this._geoJSONIndex=Ee.cluster?new Nt(function({superclusterOptions:ne,clusterProperties:de}){if(!de||!ne)return ne;const Ue={},tt={},He={accumulated:null,zoom:0},et={properties:null},pt=Object.keys(de);for(const Lt of pt){const[jt,Wt]=de[Lt],ki=i.createExpression(Wt),bi=i.createExpression(typeof jt=="string"?[jt,["accumulated"],["get",Lt]]:jt);Ue[Lt]=ki.value,tt[Lt]=bi.value}return ne.map=Lt=>{et.properties=Lt;const jt={};for(const Wt of pt)jt[Wt]=Ue[Wt].evaluate(He,et);return jt},ne.reduce=(Lt,jt)=>{et.properties=jt;for(const Wt of pt)He.accumulated=Lt[Wt],Lt[Wt]=tt[Wt].evaluate(He,et)},ne}(Ee)).load(j.features):function(ne,de){return new Hr(ne,de)}(j,Ee.geojsonVtOptions)}catch(ne){return Pe(ne)}this.loaded={};const ie={};if(wt){const ne=i.getPerformanceMeasurement(ct);ne&&(ie.resourceTiming={},ie.resourceTiming[Ee.source]=JSON.parse(JSON.stringify(ne)))}Pe(null,ie)}})}reloadTile(Ee,Pe){const ct=this.loaded;return ct&&ct[Ee.uid]?super.reloadTile(Ee,Pe):this.loadTile(Ee,Pe)}loadGeoJSON(Ee,Pe){if(Ee.request)i.getJSON(Ee.request,Pe);else{if(typeof Ee.data!="string")return Pe(new Error(`Input data given to '${Ee.source}' is not a valid GeoJSON object.`));try{return Pe(null,JSON.parse(Ee.data))}catch{return Pe(new Error(`Input data given to '${Ee.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(Ee,Pe){try{Pe(null,this._geoJSONIndex.getClusterExpansionZoom(Ee.clusterId))}catch(ct){Pe(ct)}}getClusterChildren(Ee,Pe){try{Pe(null,this._geoJSONIndex.getChildren(Ee.clusterId))}catch(ct){Pe(ct)}}getClusterLeaves(Ee,Pe){try{Pe(null,this._geoJSONIndex.getLeaves(Ee.clusterId,Ee.limit,Ee.offset))}catch(ct){Pe(ct)}}}class Rs{constructor(Ee){this.self=Ee,this.actor=new i.Actor(Ee,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:Qn},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(Pe,ct)=>{if(this.workerSourceTypes[Pe])throw new Error(`Worker source with name "${Pe}" already registered.`);this.workerSourceTypes[Pe]=ct},this.self.registerRTLTextPlugin=Pe=>{if(i.plugin.isParsed())throw new Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=Pe.applyArabicShaping,i.plugin.processBidirectionalText=Pe.processBidirectionalText,i.plugin.processStyledBidirectionalText=Pe.processStyledBidirectionalText}}clearCaches(Ee,Pe,ct){delete this.layerIndexes[Ee],delete this.availableImages[Ee],delete this.workerSources[Ee],delete this.demWorkerSources[Ee],ct()}checkIfReady(Ee,Pe,ct){ct()}setReferrer(Ee,Pe){this.referrer=Pe}spriteLoaded(Ee,Pe){this.isSpriteLoaded[Ee]=Pe;for(const ct in this.workerSources[Ee]){const wt=this.workerSources[Ee][ct];for(const X in wt)wt[X]instanceof i.VectorTileWorkerSource&&(wt[X].isSpriteLoaded=Pe,wt[X].fire(new i.Event("isSpriteLoaded")))}}setImages(Ee,Pe,ct){this.availableImages[Ee]=Pe;for(const wt in this.workerSources[Ee]){const X=this.workerSources[Ee][wt];for(const j in X)X[j].availableImages=Pe}ct()}enableTerrain(Ee,Pe,ct){this.terrain=Pe,ct()}setProjection(Ee,Pe){this.projections[Ee]=i.getProjection(Pe)}setLayers(Ee,Pe,ct){this.getLayerIndex(Ee).replace(Pe),ct()}updateLayers(Ee,Pe,ct){this.getLayerIndex(Ee).update(Pe.layers,Pe.removedIds),ct()}loadTile(Ee,Pe,ct){const wt=this.enableTerrain?i.extend({enableTerrain:this.terrain},Pe):Pe;wt.projection=this.projections[Ee]||this.defaultProjection,this.getWorkerSource(Ee,Pe.type,Pe.source).loadTile(wt,ct)}loadDEMTile(Ee,Pe,ct){const wt=this.enableTerrain?i.extend({buildQuadTree:this.terrain},Pe):Pe;this.getDEMWorkerSource(Ee,Pe.source).loadTile(wt,ct)}reloadTile(Ee,Pe,ct){const wt=this.enableTerrain?i.extend({enableTerrain:this.terrain},Pe):Pe;wt.projection=this.projections[Ee]||this.defaultProjection,this.getWorkerSource(Ee,Pe.type,Pe.source).reloadTile(wt,ct)}abortTile(Ee,Pe,ct){this.getWorkerSource(Ee,Pe.type,Pe.source).abortTile(Pe,ct)}removeTile(Ee,Pe,ct){this.getWorkerSource(Ee,Pe.type,Pe.source).removeTile(Pe,ct)}removeSource(Ee,Pe,ct){if(!this.workerSources[Ee]||!this.workerSources[Ee][Pe.type]||!this.workerSources[Ee][Pe.type][Pe.source])return;const wt=this.workerSources[Ee][Pe.type][Pe.source];delete this.workerSources[Ee][Pe.type][Pe.source],wt.removeSource!==void 0?wt.removeSource(Pe,ct):ct()}loadWorkerSource(Ee,Pe,ct){try{this.self.importScripts(Pe.url),ct()}catch(wt){ct(wt.toString())}}syncRTLPluginState(Ee,Pe,ct){try{i.plugin.setState(Pe);const wt=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&wt!=null){this.self.importScripts(wt);const X=i.plugin.isParsed();ct(X?void 0:new Error(`RTL Text Plugin failed to import scripts from ${wt}`),X)}}catch(wt){ct(wt.toString())}}getAvailableImages(Ee){let Pe=this.availableImages[Ee];return Pe||(Pe=[]),Pe}getLayerIndex(Ee){let Pe=this.layerIndexes[Ee];return Pe||(Pe=this.layerIndexes[Ee]=new R),Pe}getWorkerSource(Ee,Pe,ct){if(this.workerSources[Ee]||(this.workerSources[Ee]={}),this.workerSources[Ee][Pe]||(this.workerSources[Ee][Pe]={}),!this.workerSources[Ee][Pe][ct]){const wt={send:(X,j,ie,ne,de,Ue)=>{this.actor.send(X,j,ie,Ee,de,Ue)},scheduler:this.actor.scheduler};this.workerSources[Ee][Pe][ct]=new this.workerSourceTypes[Pe](wt,this.getLayerIndex(Ee),this.getAvailableImages(Ee),this.isSpriteLoaded[Ee])}return this.workerSources[Ee][Pe][ct]}getDEMWorkerSource(Ee,Pe){return this.demWorkerSources[Ee]||(this.demWorkerSources[Ee]={}),this.demWorkerSources[Ee][Pe]||(this.demWorkerSources[Ee][Pe]=new Q),this.demWorkerSources[Ee][Pe]}enforceCacheSizeLimit(Ee,Pe){i.enforceCacheSizeLimit(Pe)}getWorkerPerformanceMetrics(Ee,Pe,ct){ct(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new Rs(self)),Rs}),p(["./shared"],function(i){function C(x,a){if(Array.isArray(x)){if(!Array.isArray(a)||x.length!==a.length)return!1;for(let m=0;m"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var b,S,P=new Blob([""],{type:"text/javascript"}),H=URL.createObjectURL(P);try{S=new Worker(H),b=!0}catch{b=!1}return S&&S.terminate(),URL.revokeObjectURL(H),b}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var b=document.createElement("canvas");b.width=b.height=1;var S=b.getContext("2d");if(!S)return!1;var P=S.getImageData(0,0,1,1);return P&&P.width===b.width}()?(Q[m=a&&a.failIfMajorPerformanceCaveat]===void 0&&(Q[m]=function(b){var S,P=function(H){var W=document.createElement("canvas"),ee=Object.create(R.webGLContextAttributes);return ee.failIfMajorPerformanceCaveat=H,W.getContext("webgl",ee)||W.getContext("experimental-webgl",ee)}(b);if(!P)return!1;try{S=P.createShader(P.VERTEX_SHADER)}catch{return!1}return!(!S||P.isContextLost())&&(P.shaderSource(S,"void main() {}"),P.compileShader(S),P.getShaderParameter(S,P.COMPILE_STATUS)===!0)}(m)),Q[m]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var m}(x)}var Q={};function z(x,a,m){const b=i.window.document.createElement(x);return a!==void 0&&(b.className=a),m&&m.appendChild(b),b}function G(x,a,m){const b=i.window.document.createElementNS("http://www.w3.org/2000/svg",x);for(const S of Object.keys(a))b.setAttributeNS(null,S,a[S]);return m&&m.appendChild(b),b}R.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const J=i.window.document&&i.window.document.documentElement.style,Y=J&&J.userSelect!==void 0?"userSelect":"WebkitUserSelect";let B;function ae(){J&&Y&&(B=J[Y],J[Y]="none")}function ce(){J&&Y&&(J[Y]=B)}function Ae(x){x.preventDefault(),x.stopPropagation(),i.window.removeEventListener("click",Ae,!0)}function we(){i.window.addEventListener("click",Ae,!0),i.window.setTimeout(()=>{i.window.removeEventListener("click",Ae,!0)},0)}function me(x,a){const m=x.getBoundingClientRect();return Fe(x,m,a)}function De(x,a){const m=x.getBoundingClientRect(),b=[];for(let S=0;S=0?0:x.button}function Fe(x,a,m){const b=x.offsetWidth===a.width?1:x.offsetWidth/a.width;return new i.pointGeometry((m.clientX-a.left)*b,(m.clientY-a.top)*b)}function Ge(x,a){var m=a[0],b=a[1],S=a[2],P=a[3],H=m*P-S*b;return H?(x[0]=P*(H=1/H),x[1]=-b*H,x[2]=-S*H,x[3]=m*H,x):null}function Et(x){const{userImage:a}=x;return!!(a&&a.render&&a.render())&&(x.data.replace(new Uint8Array(a.data.buffer)),!0)}class li extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(a){if(this.loaded!==a&&(this.loaded=a,a)){for(const{ids:m,callback:b}of this.requestors)this._notify(m,b);this.requestors=[]}}hasImage(a){return!!this.getImage(a)}getImage(a){return this.images[a]}addImage(a,m){this._validate(a,m)&&(this.images[a]=m)}_validate(a,m){let b=!0;return this._validateStretch(m.stretchX,m.data&&m.data.width)||(this.fire(new i.ErrorEvent(new Error(`Image "${a}" has invalid "stretchX" value`))),b=!1),this._validateStretch(m.stretchY,m.data&&m.data.height)||(this.fire(new i.ErrorEvent(new Error(`Image "${a}" has invalid "stretchY" value`))),b=!1),this._validateContent(m.content,m)||(this.fire(new i.ErrorEvent(new Error(`Image "${a}" has invalid "content" value`))),b=!1),b}_validateStretch(a,m){if(!a)return!0;let b=0;for(const S of a){if(S[0]{this.ready=!0})}broadcast(a,m,b){i.asyncAll(this.actors,(S,P)=>{S.send(a,m,P)},b=b||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(a=>{a.remove()}),this.actors=[],this.workerPool.release(this.id)}}function nt(x,a,m){return a*(i.EXTENT/(x.tileSize*Math.pow(2,m-x.tileID.overscaledZ)))}Ke.Actor=i.Actor;class vt{constructor(a,m,b,S){this.screenBounds=a,this.cameraPoint=m,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=b,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,S)}static createFromScreenPoints(a,m){let b,S;if(a instanceof i.pointGeometry||typeof a[0]=="number"){const P=i.pointGeometry.convert(a);b=[P],S=m.isPointAboveHorizon(P)}else{const P=i.pointGeometry.convert(a[0]),H=i.pointGeometry.convert(a[1]);b=[P,H],S=i.polygonizeBounds(P,H).every(W=>m.isPointAboveHorizon(W))}return new vt(b,m.getCameraPoint(),S,m)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(a){return i.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],a)}bufferedCameraGeometry(a){const m=this.screenBounds[0],b=this.screenBounds.length===1?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],S=i.polygonizeBounds(m,b,0,!1);return this.cameraPoint.y>b.y&&(this.cameraPoint.x>m.x&&this.cameraPoint.x=b.x?S[2]=this.cameraPoint:this.cameraPoint.x<=m.x&&(S[3]=this.cameraPoint)),i.bufferConvexPolygon(S,a)}bufferedCameraGeometryGlobe(a){const m=this.screenBounds[0],b=this.screenBounds.length===1?this.screenBounds[0].add(new i.pointGeometry(1,1)):this.screenBounds[1],S=i.polygonizeBounds(m,b,a),P=this.cameraPoint.clone();switch(3*((P.y>m.y)+(P.y>b.y))+((P.x>m.x)+(P.x>b.x))){case 0:S[0]=P,S[4]=P.clone();break;case 1:S.splice(1,0,P);break;case 2:S[1]=P;break;case 3:S.splice(4,0,P);break;case 5:S.splice(2,0,P);break;case 6:S[3]=P;break;case 7:S.splice(3,0,P);break;case 8:S[2]=P}return S}containsTile(a,m,b,S=0){const P=a.queryPadding/m._pixelsPerMercatorPixel+1,H=b?this._bufferedCameraMercator(P,m):this._bufferedScreenMercator(P,m);let W=a.tileID.wrap+(H.unwrapped?S:0);const ee=H.polygon.map(qe=>i.getTilePoint(a.tileTransform,qe,W));if(!i.polygonIntersectsBox(ee,0,0,i.EXTENT,i.EXTENT))return;W=a.tileID.wrap+(this.screenGeometryMercator.unwrapped?S:0);const pe=this.screenGeometryMercator.polygon.map(qe=>i.getTileVec3(a.tileTransform,qe,W)),fe=pe.map(qe=>new i.pointGeometry(qe[0],qe[1])),Me=m.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),Ne=i.getTileVec3(a.tileTransform,Me,W),st=pe.map(qe=>{const Ye=i.sub(qe,qe,Ne);return i.normalize(Ye,Ye),new i.Ray(Ne,Ye)}),it=nt(a,1,m.zoom)*m._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:fe,tilespaceRays:st,bufferedTilespaceGeometry:ee,bufferedTilespaceBounds:(lt=i.getBounds(ee),lt.min.x=i.clamp(lt.min.x,0,i.EXTENT),lt.min.y=i.clamp(lt.min.y,0,i.EXTENT),lt.max.x=i.clamp(lt.max.x,0,i.EXTENT),lt.max.y=i.clamp(lt.max.y,0,i.EXTENT),lt),tile:a,tileID:a.tileID,pixelToTileUnitsFactor:it};var lt}_bufferedScreenMercator(a,m){const b=ut(a);if(this._screenRaycastCache[b])return this._screenRaycastCache[b];{let S;return S=m.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(a),m):{polygon:this.bufferedScreenGeometry(a).map(P=>m.pointCoordinate3D(P)),unwrapped:!0},this._screenRaycastCache[b]=S,S}}_bufferedCameraMercator(a,m){const b=ut(a);if(this._cameraRaycastCache[b])return this._cameraRaycastCache[b];{let S;return S=m.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(a),m):{polygon:this.bufferedCameraGeometry(a).map(P=>m.pointCoordinate3D(P)),unwrapped:!0},this._cameraRaycastCache[b]=S,S}}_projectAndResample(a,m){const b=function(P,H){const W=i.multiply([],H.pixelMatrix,H.globeMatrix),ee=[0,-i.GLOBE_RADIUS,0,1],pe=[0,i.GLOBE_RADIUS,0,1],fe=[0,0,0,1];i.transformMat4$1(ee,ee,W),i.transformMat4$1(pe,pe,W),i.transformMat4$1(fe,fe,W);const Me=new i.pointGeometry(ee[0]/ee[3],ee[1]/ee[3]),Ne=new i.pointGeometry(pe[0]/pe[3],pe[1]/pe[3]),st=i.polygonContainsPoint(P,Me)&&ee[3]1?be(P.slice(0,qe),H):[],ht=qenew i.pointGeometry(At(Ht.x),Ht.y)),ht=ht.map(Ht=>new i.pointGeometry(At(Ht.x),Ht.y));const Bt=[...dt];Bt.length===0&&Bt.push(ht[ht.length-1]);const Pt=i.number(Bt[Bt.length-1].y,(ht.length===0?dt[0]:ht[0]).y,Ye);let It;return It=st?[new i.pointGeometry(0,Pt),new i.pointGeometry(0,0),new i.pointGeometry(1,0),new i.pointGeometry(1,Pt)]:[new i.pointGeometry(1,Pt),new i.pointGeometry(1,1),new i.pointGeometry(0,1),new i.pointGeometry(0,Pt)],Bt.push(...It),ht.length===0?Bt.push(dt[0]):Bt.push(...ht),{polygon:Bt.map(Ht=>new i.MercatorCoordinate(Ht.x,Ht.y)),unwrapped:!1}}(a,m);if(b)return b;const S=function(P,H){let W=!1,ee=-1/0,pe=0;for(let Me=0;Meee&&(ee=P[Me].x,pe=Me);for(let Me=0;Me.5&&(st.x{Me.x-=1}),{polygon:P,unwrapped:W}}(be(a,m).map(P=>new i.pointGeometry(At(P.x),P.y)),m);return{polygon:S.polygon.map(P=>new i.MercatorCoordinate(P.x,P.y)),unwrapped:S.unwrapped}}}function be(x,a){return i.resample(x,m=>{const b=a.pointCoordinate3D(m);m.x=b.x,m.y=b.y},1/256)}function At(x){return x<0?1+x%1:x%1}function ut(x){return 100*x|0}function Nt(x,a,m,b,S){const P=function(H,W){if(H)return S(H);if(W){x.url&&W.tiles&&x.tiles&&delete x.tiles;const ee=i.pick(i.extend(W,x),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);W.vector_layers&&(ee.vectorLayers=W.vector_layers,ee.vectorLayerIds=ee.vectorLayers.map(pe=>pe.id)),ee.tiles=a.canonicalizeTileset(ee,x.url),S(null,ee)}};return x.url?i.getJSON(a.transformRequest(a.normalizeSourceURL(x.url,null,m,b),i.ResourceType.Source),P):i.exported.frame(()=>P(null,x))}class Gt{constructor(a,m,b){this.bounds=i.LngLatBounds.convert(this.validateBounds(a)),this.minzoom=m||0,this.maxzoom=b||24}validateBounds(a){return Array.isArray(a)&&a.length===4?[Math.max(-180,a[0]),Math.max(-90,a[1]),Math.min(180,a[2]),Math.min(90,a[3])]:[-180,-90,180,90]}contains(a){const m=Math.pow(2,a.z),b=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*m),S=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*m),P=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*m),H=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*m);return a.x>=b&&a.x=S&&a.y{this._tileJSONRequest=null,this._loaded=!0,a?this.fire(new i.ErrorEvent(a)):m&&(i.extend(this,m),m.bounds&&(this.tileBounds=new Gt(m.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(m.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(a){this.map=a,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return i.extend({},this._options)}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}loadTile(a,m){const b=i.exported.devicePixelRatio>=2,S=this.map._requestManager.normalizeTileURL(a.tileID.canonical.url(this.tiles,this.scheme),b,this.tileSize);a.request=i.getImage(this.map._requestManager.transformRequest(S,i.ResourceType.Tile),(P,H,W,ee)=>(delete a.request,a.aborted?(a.state="unloaded",m(null)):P?(a.state="errored",m(P)):H?(this.map._refreshExpiredTiles&&a.setExpiryData({cacheControl:W,expires:ee}),a.setTexture(H,this.map.painter),a.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),void m(null)):m(null)))}static loadTileData(a,m,b){a.setTexture(m,b)}static unloadTileData(a,m){a.texture&&m.saveTileTexture(a.texture)}abortTile(a,m){a.request&&(a.request.cancel(),delete a.request),m()}unloadTile(a,m){a.texture&&this.map.painter.saveTileTexture(a.texture),m()}hasTransition(){return!1}}let ct;function wt(x,a,m,b,S,P,H,W){const ee=[x,m,S,a,b,P,1,1,1],pe=[H,W,1],fe=i.adjoint([],ee),[Me,Ne,st]=i.transformMat3(pe,pe,i.transpose(fe,fe));return i.multiply$1(ee,[Me,0,0,0,Ne,0,0,0,st],ee)}class X extends i.Evented{constructor(a,m,b,S){super(),this.id=a,this.dispatcher=b,this.coordinates=m.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(S),this.options=m,this._dirty=!1}load(a,m){this._loaded=m||!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(b,S)=>{if(this._imageRequest=null,this._loaded=!0,b)this.fire(new i.ErrorEvent(b));else if(S){const{HTMLImageElement:P}=i.window;this.image=S instanceof P?i.exported.getImageData(S):S,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,a&&(this.coordinates=a),this._finishLoading()}})}loaded(){return this._loaded}updateImage(a){return this.image&&a.url?(this._imageRequest&&a.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=a.url,this.load(a.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(a){this.map=a,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(a){this.coordinates=a,this._boundsArray=void 0;const m=a.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(b){let S=1/0,P=1/0,H=-1/0,W=-1/0;for(const Me of b)S=Math.min(S,Me.x),P=Math.min(P,Me.y),H=Math.max(H,Me.x),W=Math.max(W,Me.y);const ee=Math.max(H-S,W-P),pe=Math.max(0,Math.floor(-Math.log(ee)/Math.LN2)),fe=Math.pow(2,pe);return new i.CanonicalTileID(pe,Math.floor((S+H)/2*fe),Math.floor((P+W)/2*fe))}(m),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(a){for(const ee in this.tiles){const pe=this.tiles[ee];pe.state!=="loaded"&&(pe.state="loaded",pe.texture=this.texture)}if(this._boundsArray)return;const m=i.tileTransform(this.tileID,this.map.transform.projection),[b,S,P,H]=this.coordinates.map(ee=>{const pe=m.projection.project(ee[0],ee[1]);return i.getTilePoint(m,pe)._round()});this.perspectiveTransform=function(ee,pe,fe,Me,Ne,st,it,lt,qe,Ye){const dt=wt(0,0,ee,0,0,pe,ee,pe),ht=wt(fe,Me,Ne,st,it,lt,qe,Ye);return i.multiply$1(ht,i.adjoint(dt,dt),ht),[ht[6]/ht[8]*ee/i.EXTENT,ht[7]/ht[8]*pe/i.EXTENT]}(this.width,this.height,b.x,b.y,S.x,S.y,H.x,H.y,P.x,P.y);const W=this._boundsArray=new i.StructArrayLayout4i8;W.emplaceBack(b.x,b.y,0,0),W.emplaceBack(S.x,S.y,i.EXTENT,0),W.emplaceBack(H.x,H.y,0,i.EXTENT),W.emplaceBack(P.x,P.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=a.createVertexBuffer(W,i.boundsAttributes.members),this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const a=this.map.painter.context,m=a.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new i.Texture(a,this.image,m.RGBA),this.texture.bind(m.LINEAR,m.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(a)}loadTile(a,m){this.tileID&&this.tileID.equals(a.tileID.canonical)?(this.tiles[String(a.tileID.wrap)]=a,a.buckets={},m(null)):(a.state="errored",m(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const j={vector:class extends i.Evented{constructor(x,a,m,b){if(super(),this.id=x,this.dispatcher=m,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(a,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},a),this._collectResourceTiming=a.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(b),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(x){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"}));const a=Array.isArray(this.map._language)?this.map._language.join():this.map._language,m=this.map._worldview;this._tileJSONRequest=Nt(this._options,this.map._requestManager,a,m,(b,S)=>{this._tileJSONRequest=null,this._loaded=!0,b?(a&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${a}`),m&&m.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${m}`),this.fire(new i.ErrorEvent(b))):S&&(i.extend(this,S),S.bounds&&(this.tileBounds=new Gt(S.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(S.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))),x&&x(b)})}loaded(){return this._loaded}hasTile(x){return!this.tileBounds||this.tileBounds.contains(x.canonical)}onAdd(x){this.map=x,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>{const x=this.map.style._getSourceCaches(this.id);for(const a of x)a.clearTiles()})}setSourceProperty(x){x(),this.reload()}setTiles(x){return this._options.tiles=x,this.reload(),this}setUrl(x){return this.url=x,this._options.url=x,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return i.extend({},this._options)}loadTile(x,a){const m=this.map._requestManager.normalizeTileURL(x.tileID.canonical.url(this.tiles,this.scheme)),b={request:this.map._requestManager.transformRequest(m,i.ResourceType.Tile),data:void 0,uid:x.uid,tileID:x.tileID,tileZoom:x.tileZoom,zoom:x.tileID.overscaledZ,tileSize:this.tileSize*x.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:x.isSymbolTile};if(b.request.collectResourceTiming=this._collectResourceTiming,x.actor&&x.state!=="expired")x.state==="loading"?x.reloadCallback=a:x.request=x.actor.send("reloadTile",b,S.bind(this));else if(x.actor=this._tileWorkers[m]=this._tileWorkers[m]||this.dispatcher.getActor(),this.dispatcher.ready)x.request=x.actor.send("loadTile",b,S.bind(this),void 0,!0);else{const P=i.loadVectorTile.call({deduped:this._deduped},b,(H,W)=>{H||!W?S.call(this,H):(b.data={cacheControl:W.cacheControl,expires:W.expires,rawData:W.rawData.slice(0)},x.actor&&x.actor.send("loadTile",b,S.bind(this),void 0,!0))},!0);x.request={cancel:P}}function S(P,H){return delete x.request,x.aborted?a(null):P&&P.status!==404?a(P):(H&&H.resourceTiming&&(x.resourceTiming=H.resourceTiming),this.map._refreshExpiredTiles&&H&&x.setExpiryData(H),x.loadVectorData(H,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),a(null),void(x.reloadCallback&&(this.loadTile(x,x.reloadCallback),x.reloadCallback=null)))}}abortTile(x){x.request&&(x.request.cancel(),delete x.request),x.actor&&x.actor.send("abortTile",{uid:x.uid,type:this.type,source:this.id})}unloadTile(x){x.unloadVectorData(),x.actor&&x.actor.send("removeTile",{uid:x.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}},raster:Pe,"raster-dem":class extends Pe{constructor(x,a,m,b){super(x,a,m,b),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},a),this.encoding=a.encoding||"mapbox"}loadTile(x,a){const m=this.map._requestManager.normalizeTileURL(x.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function b(S,P){S&&(x.state="errored",a(S)),P&&(x.dem=P,x.dem.onDeserialize(),x.needsHillshadePrepare=!0,x.needsDEMTextureUpload=!0,x.state="loaded",a(null))}x.request=i.getImage(this.map._requestManager.transformRequest(m,i.ResourceType.Tile),function(S,P,H,W){if(delete x.request,x.aborted)x.state="unloaded",a(null);else if(S)x.state="errored",a(S);else if(P){this.map._refreshExpiredTiles&&x.setExpiryData({cacheControl:H,expires:W});const ee=i.window.ImageBitmap&&P instanceof i.window.ImageBitmap&&(ct==null&&(ct=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&typeof i.window.createImageBitmap=="function"),ct),pe=1-(P.width-i.prevPowerOfTwo(P.width))/2;pe<1||x.neighboringTiles||(x.neighboringTiles=this._getNeighboringTiles(x.tileID));const fe=ee?P:i.exported.getImageData(P,pe),Me={uid:x.uid,coord:x.tileID,source:this.id,rawImageData:fe,encoding:this.encoding,padding:pe};x.actor&&x.state!=="expired"||(x.actor=this.dispatcher.getActor(),x.actor.send("loadDEMTile",Me,b.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(x){const a=x.canonical,m=Math.pow(2,a.z),b=(a.x-1+m)%m,S=a.x===0?x.wrap-1:x.wrap,P=(a.x+1+m)%m,H=a.x+1===m?x.wrap+1:x.wrap,W={};return W[new i.OverscaledTileID(x.overscaledZ,S,a.z,b,a.y).key]={backfilled:!1},W[new i.OverscaledTileID(x.overscaledZ,H,a.z,P,a.y).key]={backfilled:!1},a.y>0&&(W[new i.OverscaledTileID(x.overscaledZ,S,a.z,b,a.y-1).key]={backfilled:!1},W[new i.OverscaledTileID(x.overscaledZ,x.wrap,a.z,a.x,a.y-1).key]={backfilled:!1},W[new i.OverscaledTileID(x.overscaledZ,H,a.z,P,a.y-1).key]={backfilled:!1}),a.y+1{if(this._loaded=!0,this._pendingLoad=null,m)this.fire(new i.ErrorEvent(m));else{const S={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&b&&b.resourceTiming&&b.resourceTiming[this.id]&&(S.resourceTiming=b.resourceTiming[this.id]),this.fire(new i.Event("data",S)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(x,a){const m=x.actor?"reloadTile":"loadTile";x.actor=this.actor,x.request=this.actor.send(m,{type:this.type,uid:x.uid,tileID:x.tileID,tileZoom:x.tileZoom,zoom:x.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(b,S)=>(delete x.request,x.unloadVectorData(),x.aborted?a(null):b?a(b):(x.loadVectorData(S,this.map.painter,m==="reloadTile"),a(null))),void 0,m==="loadTile")}abortTile(x){x.request&&(x.request.cancel(),delete x.request),x.aborted=!0}unloadTile(x){x.unloadVectorData(),this.actor.send("removeTile",{uid:x.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends X{constructor(x,a,m,b){super(x,a,m,b),this.roundZoom=!0,this.type="video",this.options=a}load(){this._loaded=!1;const x=this.options;this.urls=[];for(const a of x.urls)this.urls.push(this.map._requestManager.transformRequest(a,i.ResourceType.Source).url);i.getVideo(this.urls,(a,m)=>{this._loaded=!0,a?this.fire(new i.ErrorEvent(a)):m&&(this.video=m,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(x){if(this.video){const a=this.video.seekable;xa.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${a.start(0)} and ${a.end(0)}-second mark.`))):this.video.currentTime=x}}getVideo(){return this.video}onAdd(x){this.map||(this.map=x,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const x=this.map.painter.context,a=x.gl;this.texture?this.video.paused||(this.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.texSubImage2D(a.TEXTURE_2D,0,0,0,a.RGBA,a.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(x,this.video,a.RGBA),this.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(x)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:X,canvas:class extends X{constructor(x,a,m,b){super(x,a,m,b),a.coordinates?Array.isArray(a.coordinates)&&a.coordinates.length===4&&!a.coordinates.some(S=>!Array.isArray(S)||S.length!==2||S.some(P=>typeof P!="number"))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${x}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${x}`,null,'missing required property "coordinates"'))),a.animate&&typeof a.animate!="boolean"&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${x}`,null,'optional "animate" property must be a boolean value'))),a.canvas?typeof a.canvas=="string"||a.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${x}`,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 i.ErrorEvent(new i.ValidationError(`sources.${x}`,null,'missing required property "canvas"'))),this.options=a,this.animate=a.animate===void 0||a.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(x){this.map=x,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let x=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,x=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,x=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const a=this.map.painter.context;this.texture?(x||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(a,this.canvas,a.gl.RGBA,{premultiply:!0}),this._prepareData(a)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const x of[this.canvas.width,this.canvas.height])if(isNaN(x)||x<=0)return!0;return!1}},custom:class extends i.Evented{constructor(x,a,m,b){super(),this.id=x,this.type="custom",this._dataType="raster",this._dispatcher=m,this._implementation=a,this.setEventedParent(b),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new i.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Gt(this._implementation.bounds,this.minzoom,this.maxzoom)),a.update=this._update.bind(this),a.clearTiles=this._clearTiles.bind(this),a.coveringTiles=this._coveringTiles.bind(this),i.extend(this,i.pick(a,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(x){this._map=x,this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(x),this.load()}onRemove(x){this._implementation.onRemove&&this._implementation.onRemove(x)}hasTile(x){if(this._implementation.hasTile){const{x:a,y:m,z:b}=x.canonical;return this._implementation.hasTile({x:a,y:m,z:b})}return!this.tileBounds||this.tileBounds.contains(x.canonical)}loadTile(x,a){const{x:m,y:b,z:S}=x.tileID.canonical,P=new i.window.AbortController;x.request=Promise.resolve(this._implementation.loadTile({x:m,y:b,z:S},{signal:P.signal})).then(function(H){return delete x.request,x.aborted?(x.state="unloaded",a(null)):H===void 0?(x.state="errored",a(null)):H===null?(this.loadTileData(x,{width:this.tileSize,height:this.tileSize,data:null}),x.state="loaded",a(null)):function(W){return W instanceof i.window.ImageData||W instanceof i.window.HTMLCanvasElement||W instanceof i.window.ImageBitmap||W instanceof i.window.HTMLImageElement}(H)?(this.loadTileData(x,H),x.state="loaded",void a(null)):(x.state="errored",a(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(H=>{H.code!==20&&(x.state="errored",a(H))}),x.request.cancel=()=>P.abort()}loadTileData(x,a){Pe.loadTileData(x,a,this._map.painter)}unloadTileData(x){Pe.unloadTileData(x,this._map.painter)}unloadTile(x,a){if(this.unloadTileData(x),this._implementation.unloadTile){const{x:m,y:b,z:S}=x.tileID.canonical;this._implementation.unloadTile({x:m,y:b,z:S})}a()}abortTile(x,a){x.request&&x.request.cancel&&(x.request.cancel(),delete x.request),a()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(x=>({x:x.canonical.x,y:x.canonical.y,z:x.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))}}},ie=function(x,a,m,b){const S=new j[a.type](x,a,m,b);if(S.id!==x)throw new Error(`Expected Source id to be ${x} instead of ${S.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],S),S};function ne(x,a){const m=i.identity([]);return i.scale(m,m,[.5*x.width,.5*-x.height,1]),i.translate(m,m,[1,-1,0]),i.multiply(m,m,x.calculateProjMatrix(a.toUnwrapped())),Float32Array.from(m)}function de(x,a,m,b,S,P,H,W=!1){const ee=x.tilesIn(b,H,W);ee.sort(tt);const pe=[];for(const Me of ee)pe.push({wrappedTileID:Me.tile.tileID.wrapped().key,queryResults:Me.tile.queryRenderedFeatures(a,m,x._state,Me,S,P,ne(x.transform,Me.tile.tileID),W)});const fe=function(Me){const Ne={},st={};for(const it of Me){const lt=it.queryResults,qe=it.wrappedTileID,Ye=st[qe]=st[qe]||{};for(const dt in lt){const ht=lt[dt],Bt=Ye[dt]=Ye[dt]||{},Pt=Ne[dt]=Ne[dt]||[];for(const It of ht)Bt[It.featureIndex]||(Bt[It.featureIndex]=!0,Pt.push(It))}}return Ne}(pe);for(const Me in fe)fe[Me].forEach(Ne=>{const st=Ne.feature,it=st.layer;it&&it.type!=="background"&&it.type!=="sky"&&(st.source=it.source,it["source-layer"]&&(st.sourceLayer=it["source-layer"]),st.state=st.id!==void 0?x.getFeatureState(it["source-layer"],st.id):{})});return fe}function Ue(x,a){const m=x.getRenderableIds().map(P=>x.getTileByID(P)),b=[],S={};for(let P=0;P{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[et]}numActive(){return Object.keys(this.active).length}}let Lt;function jt(){return Lt||(Lt=new pt),Lt}function Wt(x,a){const m={};for(const b in x)b!=="ref"&&(m[b]=x[b]);return i.refProperties.forEach(b=>{b in a&&(m[b]=a[b])}),m}function ki(x){x=x.slice();const a=Object.create(null);for(let m=0;m0?(S-H)/W:0;return this.points[P].mult(1-ee).add(this.points[m].mult(ee))}}class Wr{constructor(a,m,b){const S=this.boxCells=[],P=this.circleCells=[];this.xCellCount=Math.ceil(a/b),this.yCellCount=Math.ceil(m/b);for(let H=0;Hthis.width||S<0||m>this.height)return!P&&[];const W=[];if(a<=0&&m<=0&&this.width<=b&&this.height<=S){if(P)return!0;for(let ee=0;ee0:W}_queryCircle(a,m,b,S,P){const H=a-b,W=a+b,ee=m-b,pe=m+b;if(W<0||H>this.width||pe<0||ee>this.height)return!S&&[];const fe=[];return this._forEachCell(H,ee,W,pe,this._queryCellCircle,fe,{hitTest:S,circle:{x:a,y:m,radius:b},seenUids:{box:{},circle:{}}},P),S?fe.length>0:fe}query(a,m,b,S,P){return this._query(a,m,b,S,!1,P)}hitTest(a,m,b,S,P){return this._query(a,m,b,S,!0,P)}hitTestCircle(a,m,b,S){return this._queryCircle(a,m,b,!0,S)}_queryCell(a,m,b,S,P,H,W,ee){const pe=W.seenUids,fe=this.boxCells[P];if(fe!==null){const Ne=this.bboxes;for(const st of fe)if(!pe.box[st]){pe.box[st]=!0;const it=4*st;if(a<=Ne[it+2]&&m<=Ne[it+3]&&b>=Ne[it+0]&&S>=Ne[it+1]&&(!ee||ee(this.boxKeys[st]))){if(W.hitTest)return H.push(!0),!0;H.push({key:this.boxKeys[st],x1:Ne[it],y1:Ne[it+1],x2:Ne[it+2],y2:Ne[it+3]})}}}const Me=this.circleCells[P];if(Me!==null){const Ne=this.circles;for(const st of Me)if(!pe.circle[st]){pe.circle[st]=!0;const it=3*st;if(this._circleAndRectCollide(Ne[it],Ne[it+1],Ne[it+2],a,m,b,S)&&(!ee||ee(this.circleKeys[st]))){if(W.hitTest)return H.push(!0),!0;{const lt=Ne[it],qe=Ne[it+1],Ye=Ne[it+2];H.push({key:this.circleKeys[st],x1:lt-Ye,y1:qe-Ye,x2:lt+Ye,y2:qe+Ye})}}}}}_queryCellCircle(a,m,b,S,P,H,W,ee){const pe=W.circle,fe=W.seenUids,Me=this.boxCells[P];if(Me!==null){const st=this.bboxes;for(const it of Me)if(!fe.box[it]){fe.box[it]=!0;const lt=4*it;if(this._circleAndRectCollide(pe.x,pe.y,pe.radius,st[lt+0],st[lt+1],st[lt+2],st[lt+3])&&(!ee||ee(this.boxKeys[it])))return H.push(!0),!0}}const Ne=this.circleCells[P];if(Ne!==null){const st=this.circles;for(const it of Ne)if(!fe.circle[it]){fe.circle[it]=!0;const lt=3*it;if(this._circlesCollide(st[lt],st[lt+1],st[lt+2],pe.x,pe.y,pe.radius)&&(!ee||ee(this.circleKeys[it])))return H.push(!0),!0}}}_forEachCell(a,m,b,S,P,H,W,ee){const pe=this._convertToXCellCoord(a),fe=this._convertToYCellCoord(m),Me=this._convertToXCellCoord(b),Ne=this._convertToYCellCoord(S);for(let st=pe;st<=Me;st++)for(let it=fe;it<=Ne;it++)if(P.call(this,a,m,b,S,this.xCellCount*it+st,H,W,ee))return}_convertToXCellCoord(a){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(a*this.xScale)))}_convertToYCellCoord(a){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(a*this.yScale)))}_circlesCollide(a,m,b,S,P,H){const W=S-a,ee=P-m,pe=b+H;return pe*pe>W*W+ee*ee}_circleAndRectCollide(a,m,b,S,P,H,W){const ee=(H-S)/2,pe=Math.abs(a-(S+ee));if(pe>ee+b)return!1;const fe=(W-P)/2,Me=Math.abs(m-(P+fe));if(Me>fe+b)return!1;if(pe<=ee||Me<=fe)return!0;const Ne=pe-ee,st=Me-fe;return Ne*Ne+st*st<=b*b}}const mr=Math.tan(85*Math.PI/180);function Mr(x,a,m,b,S,P,H){const W=i.create();if(m)if(P.name==="globe"){const ee=i.calculateGlobeLabelMatrix(S,a);i.multiply(W,W,ee)}else{const ee=Ge([],H);W[0]=ee[0],W[1]=ee[1],W[4]=ee[2],W[5]=ee[3],b||i.rotateZ(W,W,S.angle)}else i.multiply(W,S.labelPlaneMatrix,x);return W}function Oo(x,a,m,b,S,P,H){const W=Mr(x,a,m,b,S,P,H);return P.name==="globe"&&m||(W[2]=W[6]=W[10]=W[14]=0),W}function zs(x,a,m,b,S,P,H){if(m){if(P.name==="globe"){const W=Mr(x,a,m,b,S,P,H);return i.invert(W,W),i.multiply(W,x,W),W}{const W=i.clone(x),ee=i.identity([]);return ee[0]=H[0],ee[1]=H[1],ee[4]=H[2],ee[5]=H[3],i.multiply(W,W,ee),b||i.rotateZ(W,W,-S.angle),W}}return S.glCoordMatrix}function or(x,a,m,b){const S=[x,a,m,1];m?i.transformMat4$1(S,S,b):cs(S,S,b);const P=S[3];return S[0]/=P,S[1]/=P,S[2]/=P,S}function rn(x,a){return Math.min(.5+x/a*.5,1.5)}function cr(x,a){const m=x[0]/x[3],b=x[1]/x[3];return m>=-a[0]&&m<=a[0]&&b>=-a[1]&&b<=a[1]}function Ar(x,a,m,b,S,P,H,W,ee,pe){const fe=m.transform,Me=b?x.textSizeData:x.iconSizeData,Ne=i.evaluateSizeForZoom(Me,m.transform.zoom),st=fe.projection.name==="globe",it=[256/m.width*2+1,256/m.height*2+1],lt=b?x.text.dynamicLayoutVertexArray:x.icon.dynamicLayoutVertexArray;lt.clear();let qe=null;st&&(qe=b?x.text.globeExtVertexArray:x.icon.globeExtVertexArray);const Ye=x.lineVertexArray,dt=b?x.text.placedSymbolArray:x.icon.placedSymbolArray,ht=m.transform.width/m.transform.height;let Bt,Pt=!1;for(let It=0;ItMath.abs(m)?{useVertical:!0}:x===i.WritingMode.vertical?b>0?{needsFlipping:!0}:null:a!==0&&function(S,P){return S===0||Math.abs(P/S)>mr}(m,b)?a===1?{needsFlipping:!0}:null:m<0?{needsFlipping:!0}:null}function dr(x,a,m,b,S,P,H,W,ee,pe,fe,Me,Ne,st,it,lt,qe,Ye,dt){const ht=a/24,Bt=x.lineOffsetX*ht,Pt=x.lineOffsetY*ht,{lineStartIndex:It,glyphStartIndex:Ht,numGlyphs:hi,segment:si,writingMode:qt,flipState:ji}=x,Kt=It+x.lineLength,Ci=di=>{if(fe){const[$i,Jt,pi]=di.up,In=pe.length;i.updateGlobeVertexNormal(fe,In+0,$i,Jt,pi),i.updateGlobeVertexNormal(fe,In+1,$i,Jt,pi),i.updateGlobeVertexNormal(fe,In+2,$i,Jt,pi),i.updateGlobeVertexNormal(fe,In+3,$i,Jt,pi)}const[Ri,Ai,Mi]=di.point;i.addDynamicAttributes(pe,Ri,Ai,Mi,di.angle)};if(hi>1){const di=aa(ht,W,Bt,Pt,m,Me,Ne,x,ee,P,st,lt,!1,qe,Ye,dt);if(!di)return{notEnoughRoom:!0};if(b&&!m){let[Ri,Ai,Mi]=di.first.point,[$i,Jt,pi]=di.last.point;[Ri,Ai]=or(Ri,Ai,Mi,H),[$i,Jt]=or($i,Jt,pi,H);const In=al(qt,ji,($i-Ri)*it,Jt-Ai);if(x.flipState=In&&In.needsFlipping?1:2,In)return In}Ci(di.first);for(let Ri=Ht+1;Ri0?$i:Rl(Ne,Mi,Ri,1,S,void 0,qe,Ye.canonical),pi=al(qt,ji,(Jt[0]-Ri[0])*it,Jt[1]-Ri[1]);if(x.flipState=pi&&pi.needsFlipping?1:2,pi)return pi}const di=ll(ht*W.getoffsetX(Ht),Bt,Pt,m,Me,Ne,si,It,Kt,ee,P,st,lt,!1,!1,qe,Ye,dt);if(!di)return{notEnoughRoom:!0};Ci(di)}return{}}function Ul(x,a,m,b,S){const{x:P,y:H,z:W}=b.projectTilePoint(x.x,x.y,a);if(!S)return or(P,H,W,m);const[ee,pe,fe]=S(x);return or(P+ee,H+pe,W+fe,m)}function Rl(x,a,m,b,S,P,H,W){const ee=Ul(x.sub(a)._unit()._add(x),W,S,H,P);return i.sub(ee,m,ee),i.normalize(ee,ee),i.scaleAndAdd(ee,m,ee,b)}function ll(x,a,m,b,S,P,H,W,ee,pe,fe,Me,Ne,st,it,lt,qe,Ye){const dt=b?x-a:x+a;let ht=dt>0?1:-1,Bt=0;b&&(ht*=-1,Bt=Math.PI),ht<0&&(Bt+=Math.PI);let Pt=W+H+(ht>0?0:1)|0,It=S,Ht=S,hi=0,si=0;const qt=Math.abs(dt),ji=[],Kt=[];let Ci=P,di=Ci;const Ri=()=>Rl(di,Ci,Ht,qt-hi+1,fe,Ne,lt,qe.canonical);for(;hi+si<=qt;){if(Pt+=ht,Pt=ee)return null;if(Ht=It,di=Ci,ji.push(Ht),st&&Kt.push(di),Ci=new i.pointGeometry(pe.getx(Pt),pe.gety(Pt)),It=Me[Pt],!It){const $n=Ul(Ci,qe.canonical,fe,lt,Ne);It=$n[3]>0?Me[Pt]=$n:Ri()}hi+=si,si=i.distance(Ht,It)}it&&Ne&&(Me[Pt]&&(It=Ri(),si=i.distance(Ht,It)),Me[Pt]=It);const Ai=(qt-hi)/si,Mi=Ci.sub(di)._mult(Ai)._add(di),$i=i.sub([],It,Ht),Jt=i.scaleAndAdd([],Ht,$i,Ai);let pi=[0,0,1],In=$i[0],Hn=$i[1];if(Ye&&(pi=lt.upVector(qe.canonical,Mi.x,Mi.y),pi[0]!==0||pi[1]!==0||pi[2]!==1)){const $n=[pi[2],0,-pi[0]],lr=i.cross([],pi,$n);i.normalize($n,$n),i.normalize(lr,lr),In=i.dot($i,$n),Hn=i.dot($i,lr)}if(m){const $n=i.cross([],pi,$i);i.normalize($n,$n),i.scaleAndAdd(Jt,Jt,$n,m*ht)}const Mn=Bt+Math.atan2(Hn,In);return ji.push(Jt),st&&Kt.push(Mi),{point:Jt,angle:Mn,path:ji,tilePath:Kt,up:pi}}function qs(x,a){const m=a.length,b=m+4*x;a.resize(b),a.float32.fill(-1/0,4*m,4*b)}function cs(x,a,m){const b=a[0],S=a[1];return x[0]=m[0]*b+m[4]*S+m[12],x[1]=m[1]*b+m[5]*S+m[13],x[3]=m[3]*b+m[7]*S+m[15],x}const ho=100;class cl{constructor(a,m,b=new Wr(a.width+200,a.height+200,25),S=new Wr(a.width+200,a.height+200,25)){this.transform=a,this.grid=b,this.ignoredGrid=S,this.pitchfactor=Math.cos(a._pitch)*a.cameraToCenterDistance,this.screenRightBoundary=a.width+ho,this.screenBottomBoundary=a.height+ho,this.gridRightBoundary=a.width+200,this.gridBottomBoundary=a.height+200,this.fogState=m}placeCollisionBox(a,m,b,S,P,H,W,ee){let pe=b.projectedAnchorX,fe=b.projectedAnchorY,Me=b.projectedAnchorZ;const Ne=b.elevation,st=b.tileID,it=a.getProjection();if(Ne&&st){const[It,Ht,hi]=it.upVector(st.canonical,b.tileAnchorX,b.tileAnchorY),si=it.upVectorScale(st.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;pe+=It*Ne*si,fe+=Ht*Ne*si,Me+=hi*Ne*si}const lt=this.projectAndGetPerspectiveRatio(W,pe,fe,Me,b.tileID,it.name==="globe"||!!Ne||this.transform.pitch>0,it),qe=H*lt.perspectiveRatio,Ye=(b.x1*m+S.x-b.padding)*qe+lt.point.x,dt=(b.y1*m+S.y-b.padding)*qe+lt.point.y,ht=(b.x2*m+S.x+b.padding)*qe+lt.point.x,Bt=(b.y2*m+S.y+b.padding)*qe+lt.point.y,Pt=lt.perspectiveRatio<=.55||lt.occluded;return!this.isInsideGrid(Ye,dt,ht,Bt)||!P&&this.grid.hitTest(Ye,dt,ht,Bt,ee)||Pt?{box:[],offscreen:!1,occluded:lt.occluded}:{box:[Ye,dt,ht,Bt],offscreen:this.isOffscreen(Ye,dt,ht,Bt),occluded:!1}}placeCollisionCircles(a,m,b,S,P,H,W,ee,pe,fe,Me,Ne,st,it,lt){const qe=[],Ye=this.transform.elevation,dt=a.getProjection(),ht=Ye?Ye.getAtTileOffsetFunc(lt,this.transform.center.lat,this.transform.worldSize,dt):null,Bt=new i.pointGeometry(b.tileAnchorX,b.tileAnchorY);let{x:Pt,y:It,z:Ht}=dt.projectTilePoint(Bt.x,Bt.y,lt.canonical);if(ht){const[Mi,$i,Jt]=ht(Bt);Pt+=Mi,It+=$i,Ht+=Jt}const hi=dt.name==="globe",si=this.projectAndGetPerspectiveRatio(W,Pt,It,Ht,lt,hi||!!Ye||this.transform.pitch>0,dt),{perspectiveRatio:qt}=si,ji=(Me?H/qt:H*qt)/i.ONE_EM,Kt=or(Pt,It,Ht,ee),Ci=si.signedDistanceFromCamera>0?aa(ji,P,b.lineOffsetX*ji,b.lineOffsetY*ji,!1,Kt,Bt,b,S,ee,{},Ye&&!Me?ht:null,Me&&!!Ye,dt,lt,Me):null;let di=!1,Ri=!1,Ai=!0;if(Ci&&!si.occluded){const Mi=.5*st*qt+it,$i=new i.pointGeometry(-100,-100),Jt=new i.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),pi=new Yn,{first:In,last:Hn}=Ci,Mn=In.path.length;let $n=[];for(let _n=Mn-1;_n>=1;_n--)$n.push(In.path[_n]);for(let _n=1;_n(ht&&!hi&&(Or=ht(Nr_n[3]<=0)&&($n=[]));let On=[];if($n.length>0){let _n=1/0,Dr=-1/0,Or=1/0,Nr=-1/0;for(const Qr of $n)_n=Math.min(_n,Qr[0]),Or=Math.min(Or,Qr[1]),Dr=Math.max(Dr,Qr[0]),Nr=Math.max(Nr,Qr[1]);Dr>=$i.x&&_n<=Jt.x&&Nr>=$i.y&&Or<=Jt.y&&(On=[$n.map(Qr=>new i.pointGeometry(Qr[0],Qr[1]))],(_n<$i.x||Dr>Jt.x||Or<$i.y||Nr>Jt.y)&&(On=i.clipLine(On,$i.x,$i.y,Jt.x,Jt.y)))}for(const _n of On){pi.reset(_n,.25*Mi);let Dr=0;Dr=pi.length<=.5*Mi?1:Math.ceil(pi.paddedLength/lr)+1;for(let Or=0;Or0){i.transformMat4$1(ee,ee,a);const Me=W.name==="globe";this.fogState&&P&&!Me&&(pe=function(st,it,lt,qe,Ye,dt){const ht=dt.calculateFogTileMatrix(Ye),Bt=[it,lt,qe];return i.transformMat4(Bt,Bt,ht),Oe(st,Bt,dt.pitch,dt._fov)}(this.fogState,m,b,S,P.toUnwrapped(),this.transform)>.9)}else cs(ee,ee,a);const fe=ee[3];return{point:new i.pointGeometry((ee[0]/fe+1)/2*this.transform.width+ho,(-ee[1]/fe+1)/2*this.transform.height+ho),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(W)/fe*.5,1.5),signedDistanceFromCamera:fe,occluded:H&&ee[2]>fe||pe}}isOffscreen(a,m,b,S){return b=this.screenRightBoundary||Sthis.screenBottomBoundary}isInsideGrid(a,m,b,S){return b>=0&&a=0&&mb.collisionGroupID===m}}return this.collisionGroups[a]}}function ps(x,a,m,b,S){const{horizontalAlign:P,verticalAlign:H}=i.getAnchorAlignment(x),W=-(P-.5)*a,ee=-(H-.5)*m,pe=i.evaluateVariableOffset(x,b);return new i.pointGeometry(W+pe[0]*S,ee+pe[1]*S)}function Rc(x,a,m,b,S){const P=new i.pointGeometry(x,a);return m&&P._rotate(b?S:-S),P}class Eh{constructor(a,m,b,S,P){this.transform=a.clone(),this.projection=a.projection.name,this.collisionIndex=new cl(this.transform,P),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=m,this.retainedQueryData={},this.collisionGroups=new Ys(b),this.collisionCircleArrays={},this.prevPlacement=S,S&&(S.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(a,m,b,S){const P=b.getBucket(m),H=b.latestFeatureIndex;if(!P||!H||m.id!==P.layerIds[0])return;const W=P.layers[0].layout,ee=b.collisionBoxArray,pe=Math.pow(2,this.transform.zoom-b.tileID.overscaledZ),fe=b.tileSize/i.EXTENT,Me=b.tileID.toUnwrapped();this.transform.setProjection(P.projection);const Ne=(st=b.tileID,it=P.getProjection(),lt=this.transform,it.name===this.projection?lt.calculateProjMatrix(st.toUnwrapped()):Oa(lt,it,st));var st,it,lt;const qe=W.get("text-pitch-alignment")==="map",Ye=W.get("text-rotation-alignment")==="map";m.compileFilter();const dt=m.dynamicFilter(),ht=m.dynamicFilterNeedsFeature(),Bt=this.transform.calculatePixelsToTileUnitsMatrix(b),Pt=Oo(Ne,b.tileID.canonical,qe,Ye,this.transform,P.getProjection(),Bt);let It=null;if(qe){const si=zs(Ne,b.tileID.canonical,qe,Ye,this.transform,P.getProjection(),Bt);It=i.multiply([],this.transform.labelPlaneMatrix,si)}let Ht=null;dt&&b.latestFeatureIndex&&(Ht={unwrappedTileID:Me,dynamicFilter:dt,dynamicFilterNeedsFeature:ht,featureIndex:b.latestFeatureIndex}),this.retainedQueryData[P.bucketInstanceId]=new is(P.bucketInstanceId,H,P.sourceLayerIndex,P.index,b.tileID);const hi={bucket:P,layout:W,posMatrix:Ne,textLabelPlaneMatrix:Pt,labelToScreenMatrix:It,clippingData:Ht,scale:pe,textPixelRatio:fe,holdingForFade:b.holdingForFade(),collisionBoxArray:ee,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(P.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(P.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(P.sourceID)};if(S)for(const si of P.sortKeyRanges){const{sortKey:qt,symbolInstanceStart:ji,symbolInstanceEnd:Kt}=si;a.push({sortKey:qt,symbolInstanceStart:ji,symbolInstanceEnd:Kt,parameters:hi})}else a.push({symbolInstanceStart:0,symbolInstanceEnd:P.symbolInstances.length,parameters:hi})}attemptAnchorPlacement(a,m,b,S,P,H,W,ee,pe,fe,Me,Ne,st,it,lt,qe,Ye,dt){const{textOffset0:ht,textOffset1:Bt,crossTileID:Pt}=Ne,It=[ht,Bt],Ht=ps(a,b,S,It,P),hi=this.collisionIndex.placeCollisionBox(it,P,m,Rc(Ht.x,Ht.y,H,W,this.transform.angle),Me,ee,pe,fe.predicate);if(qe){const si=it.getSymbolInstanceIconSize(dt,this.transform.zoom,Ne.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(it,si,qe,Rc(Ht.x,Ht.y,H,W,this.transform.angle),Me,ee,pe,fe.predicate).box.length===0)return}if(hi.box.length>0){let si;return this.prevPlacement&&this.prevPlacement.variableOffsets[Pt]&&this.prevPlacement.placements[Pt]&&this.prevPlacement.placements[Pt].text&&(si=this.prevPlacement.variableOffsets[Pt].anchor),this.variableOffsets[Pt]={textOffset:It,width:b,height:S,anchor:a,textScale:P,prevAnchor:si},this.markUsedJustification(it,a,Ne,lt),it.allowVerticalPlacement&&(this.markUsedOrientation(it,lt,Ne),this.placedOrientations[Pt]=lt),{shift:Ht,placedGlyphBoxes:hi}}}placeLayerBucketPart(a,m,b,S){const{bucket:P,layout:H,posMatrix:W,textLabelPlaneMatrix:ee,labelToScreenMatrix:pe,clippingData:fe,textPixelRatio:Me,holdingForFade:Ne,collisionBoxArray:st,partiallyEvaluatedTextSize:it,partiallyEvaluatedIconSize:lt,collisionGroup:qe}=a.parameters,Ye=H.get("text-optional"),dt=H.get("icon-optional"),ht=H.get("text-allow-overlap"),Bt=H.get("icon-allow-overlap"),Pt=H.get("text-rotation-alignment")==="map",It=H.get("text-pitch-alignment")==="map",Ht=H.get("icon-text-fit")!=="none",hi=H.get("symbol-z-order")==="viewport-y";this.transform.setProjection(P.projection);let si=ht&&(Bt||!P.hasIconData()||dt),qt=Bt&&(ht||!P.hasTextData()||Ye);!P.collisionArrays&&st&&P.deserializeCollisionBoxes(st),b&&S&&P.updateCollisionDebugBuffers(this.transform.zoom,st);const ji=(Kt,Ci,di)=>{const{crossTileID:Ri,numVerticalGlyphVertices:Ai}=Kt;if(fe){const _r={zoom:this.transform.zoom,pitch:this.transform.pitch};let Xr=null;if(fe.dynamicFilterNeedsFeature){const Fr=this.retainedQueryData[P.bucketInstanceId];Xr=fe.featureIndex.loadFeature({featureIndex:Kt.featureIndex,bucketIndex:Fr.bucketIndex,sourceLayerIndex:Fr.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,fe.dynamicFilter)(_r,Xr,this.retainedQueryData[P.bucketInstanceId].tileID.canonical,new i.pointGeometry(Kt.tileAnchorX,Kt.tileAnchorY),this.transform.calculateDistanceTileData(fe.unwrappedTileID)))return this.placements[Ri]=new Nl(!1,!1,!1,!0),void(m[Ri]=!0)}if(m[Ri])return;if(Ne)return void(this.placements[Ri]=new Nl(!1,!1,!1));let Mi=!1,$i=!1,Jt=!0,pi=!1,In=!1,Hn=null,Mn={box:null,offscreen:null,occluded:null},$n={box:null,offscreen:null,occluded:null},lr=null,On=null,_n=null,Dr=0,Or=0,Nr=0;di.textFeatureIndex?Dr=di.textFeatureIndex:Kt.useRuntimeCollisionCircles&&(Dr=Kt.featureIndex),di.verticalTextFeatureIndex&&(Or=di.verticalTextFeatureIndex);const Qr=_r=>{_r.tileID=this.retainedQueryData[P.bucketInstanceId].tileID;const Xr=this.transform.elevation;(Xr||_r.elevation)&&(_r.elevation=Xr?Xr.getAtTileOffset(_r.tileID,_r.tileAnchorX,_r.tileAnchorY):0)},go=di.textBox;if(go){Qr(go);const _r=Fr=>{let Fs=i.WritingMode.horizontal;if(P.allowVerticalPlacement&&!Fr&&this.prevPlacement){const eo=this.prevPlacement.placedOrientations[Ri];eo&&(this.placedOrientations[Ri]=eo,Fs=eo,this.markUsedOrientation(P,Fs,Kt))}return Fs},Xr=(Fr,Fs)=>{if(P.allowVerticalPlacement&&Ai>0&&di.verticalTextBox){for(const eo of P.writingModes)if(eo===i.WritingMode.vertical?(Mn=Fs(),$n=Mn):Mn=Fr(),Mn&&Mn.box&&Mn.box.length)break}else Mn=Fr()};if(H.get("text-variable-anchor")){let Fr=H.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[Ri]){const ns=this.prevPlacement.variableOffsets[Ri];Fr.indexOf(ns.anchor)>0&&(Fr=Fr.filter(Io=>Io!==ns.anchor),Fr.unshift(ns.anchor))}const Fs=(ns,Io,Bu)=>{const ja=P.getSymbolInstanceTextSize(it,Kt,this.transform.zoom,Ci),_o=(ns.x2-ns.x1)*ja+2*ns.padding,Ea=(ns.y2-ns.y1)*ja+2*ns.padding,vl=Ht&&!Bt?Io:null;vl&&Qr(vl);let Zl={box:[],offscreen:!1,occluded:!1};const $h=ht?2*Fr.length:Fr.length;for(let Zh=0;Zh<$h;++Zh){const Ka=this.attemptAnchorPlacement(Fr[Zh%Fr.length],ns,_o,Ea,ja,Pt,It,Me,W,qe,Zh>=Fr.length,Kt,Ci,P,Bu,vl,it,lt);if(Ka&&(Zl=Ka.placedGlyphBoxes,Zl&&Zl.box&&Zl.box.length)){Mi=!0,Hn=Ka.shift;break}}return Zl};Xr(()=>Fs(go,di.iconBox,i.WritingMode.horizontal),()=>{const ns=di.verticalTextBox;return ns&&Qr(ns),P.allowVerticalPlacement&&!(Mn&&Mn.box&&Mn.box.length)&&Ai>0&&ns?Fs(ns,di.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),Mn&&(Mi=Mn.box,Jt=Mn.offscreen,pi=Mn.occluded);const eo=_r(Mn&&Mn.box);if(!Mi&&this.prevPlacement){const ns=this.prevPlacement.variableOffsets[Ri];ns&&(this.variableOffsets[Ri]=ns,this.markUsedJustification(P,ns.anchor,Kt,eo))}}else{const Fr=(Fs,eo)=>{const ns=P.getSymbolInstanceTextSize(it,Kt,this.transform.zoom,Ci),Io=this.collisionIndex.placeCollisionBox(P,ns,Fs,new i.pointGeometry(0,0),ht,Me,W,qe.predicate);return Io&&Io.box&&Io.box.length&&(this.markUsedOrientation(P,eo,Kt),this.placedOrientations[Ri]=eo),Io};Xr(()=>Fr(go,i.WritingMode.horizontal),()=>{const Fs=di.verticalTextBox;return P.allowVerticalPlacement&&Ai>0&&Fs?(Qr(Fs),Fr(Fs,i.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),_r(Mn&&Mn.box&&Mn.box.length)}}if(lr=Mn,Mi=lr&&lr.box&&lr.box.length>0,Jt=lr&&lr.offscreen,pi=lr&&lr.occluded,Kt.useRuntimeCollisionCircles){const _r=P.text.placedSymbolArray.get(Kt.centerJustifiedTextSymbolIndex>=0?Kt.centerJustifiedTextSymbolIndex:Kt.verticalPlacedTextSymbolIndex),Xr=i.evaluateSizeForFeature(P.textSizeData,it,_r),Fr=H.get("text-padding");On=this.collisionIndex.placeCollisionCircles(P,ht,_r,P.lineVertexArray,P.glyphOffsetArray,Xr,W,ee,pe,b,It,qe.predicate,Kt.collisionCircleDiameter*Xr/i.ONE_EM,Fr,this.retainedQueryData[P.bucketInstanceId].tileID),Mi=ht||On.circles.length>0&&!On.collisionDetected,Jt=Jt&&On.offscreen,pi=On.occluded}if(di.iconFeatureIndex&&(Nr=di.iconFeatureIndex),di.iconBox){const _r=Xr=>{Qr(Xr);const Fr=Ht&&Hn?Rc(Hn.x,Hn.y,Pt,It,this.transform.angle):new i.pointGeometry(0,0),Fs=P.getSymbolInstanceIconSize(lt,this.transform.zoom,Kt.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(P,Fs,Xr,Fr,Bt,Me,W,qe.predicate)};$n&&$n.box&&$n.box.length&&di.verticalIconBox?(_n=_r(di.verticalIconBox),$i=_n.box.length>0):(_n=_r(di.iconBox),$i=_n.box.length>0),Jt=Jt&&_n.offscreen,In=_n.occluded}const Ca=Ye||Kt.numHorizontalGlyphVertices===0&&Ai===0,jo=dt||Kt.numIconVertices===0;if(Ca||jo?jo?Ca||($i=$i&&Mi):Mi=$i&&Mi:$i=Mi=$i&&Mi,Mi&&lr&&lr.box&&this.collisionIndex.insertCollisionBox(lr.box,H.get("text-ignore-placement"),P.bucketInstanceId,$n&&$n.box&&Or?Or:Dr,qe.ID),$i&&_n&&this.collisionIndex.insertCollisionBox(_n.box,H.get("icon-ignore-placement"),P.bucketInstanceId,Nr,qe.ID),On&&(Mi&&this.collisionIndex.insertCollisionCircles(On.circles,H.get("text-ignore-placement"),P.bucketInstanceId,Dr,qe.ID),b)){const _r=P.bucketInstanceId;let Xr=this.collisionCircleArrays[_r];Xr===void 0&&(Xr=this.collisionCircleArrays[_r]=new Ql);for(let Fr=0;Fr=0;--Ci){const di=Kt[Ci];ji(P.symbolInstances.get(di),di,P.collisionArrays[di])}}else for(let Kt=a.symbolInstanceStart;Kt=0&&(a.text.placedSymbolArray.get(P).crossTileID=Me>=0&&P!==Me?0:pe),H>=0&&(a.text.placedSymbolArray.get(H).crossTileID=Me>=0&&H!==Me?0:pe),W>=0&&(a.text.placedSymbolArray.get(W).crossTileID=Me>=0&&W!==Me?0:pe),ee>=0&&(a.text.placedSymbolArray.get(ee).crossTileID=Me>=0&&ee!==Me?0:pe)}markUsedOrientation(a,m,b){const S=m===i.WritingMode.horizontal||m===i.WritingMode.horizontalOnly?m:0,P=m===i.WritingMode.vertical?m:0,{leftJustifiedTextSymbolIndex:H,centerJustifiedTextSymbolIndex:W,rightJustifiedTextSymbolIndex:ee,verticalPlacedTextSymbolIndex:pe}=b,fe=a.text.placedSymbolArray;H>=0&&(fe.get(H).placedOrientation=S),W>=0&&(fe.get(W).placedOrientation=S),ee>=0&&(fe.get(ee).placedOrientation=S),pe>=0&&(fe.get(pe).placedOrientation=P)}commit(a){this.commitTime=a,this.zoomAtLastRecencyCheck=this.transform.zoom;const m=this.prevPlacement;let b=!1;this.prevZoomAdjustment=m?m.zoomAdjustment(this.transform.zoom):0;const S=m?m.symbolFadeChange(a):1,P=m?m.opacities:{},H=m?m.variableOffsets:{},W=m?m.placedOrientations:{};for(const ee in this.placements){const pe=this.placements[ee],fe=P[ee];fe?(this.opacities[ee]=new Na(fe,S,pe.text,pe.icon,null,pe.clipped),b=b||pe.text!==fe.text.placed||pe.icon!==fe.icon.placed):(this.opacities[ee]=new Na(null,S,pe.text,pe.icon,pe.skipFade,pe.clipped),b=b||pe.text||pe.icon)}for(const ee in P){const pe=P[ee];if(!this.opacities[ee]){const fe=new Na(pe,S,!1,!1);fe.isHidden()||(this.opacities[ee]=fe,b=b||pe.text.placed||pe.icon.placed)}}for(const ee in H)this.variableOffsets[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.variableOffsets[ee]=H[ee]);for(const ee in W)this.placedOrientations[ee]||!this.opacities[ee]||this.opacities[ee].isHidden()||(this.placedOrientations[ee]=W[ee]);b?this.lastPlacementChangeTime=a:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=m?m.lastPlacementChangeTime:a)}updateLayerOpacities(a,m){const b={};for(const S of m){const P=S.getBucket(a);P&&S.latestFeatureIndex&&a.id===P.layerIds[0]&&this.updateBucketOpacities(P,b,S.collisionBoxArray)}}updateBucketOpacities(a,m,b){a.hasTextData()&&a.text.opacityVertexArray.clear(),a.hasIconData()&&a.icon.opacityVertexArray.clear(),a.hasIconCollisionBoxData()&&a.iconCollisionBox.collisionVertexArray.clear(),a.hasTextCollisionBoxData()&&a.textCollisionBox.collisionVertexArray.clear();const S=a.layers[0].layout,P=!!a.layers[0].dynamicFilter(),H=new Na(null,0,!1,!1,!0),W=S.get("text-allow-overlap"),ee=S.get("icon-allow-overlap"),pe=S.get("text-variable-anchor"),fe=S.get("text-rotation-alignment")==="map",Me=S.get("text-pitch-alignment")==="map",Ne=S.get("icon-text-fit")!=="none",st=new Na(null,0,W&&(ee||!a.hasIconData()||S.get("icon-optional")),ee&&(W||!a.hasTextData()||S.get("text-optional")),!0);!a.collisionArrays&&b&&(a.hasIconCollisionBoxData()||a.hasTextCollisionBoxData())&&a.deserializeCollisionBoxes(b);const it=(qe,Ye,dt)=>{for(let ht=0;ht0||ht>0,hi=Pt>0,si=this.placedOrientations[Bt],qt=si===i.WritingMode.vertical,ji=si===i.WritingMode.horizontal||si===i.WritingMode.horizontalOnly;if(!Ht&&!hi||It.isHidden()||lt++,Ht){const Kt=er(It.text);it(a.text,dt,qt?ac:Kt),it(a.text,ht,ji?ac:Kt);const Ci=It.text.isHidden(),{leftJustifiedTextSymbolIndex:di,centerJustifiedTextSymbolIndex:Ri,rightJustifiedTextSymbolIndex:Ai,verticalPlacedTextSymbolIndex:Mi}=Ye,$i=a.text.placedSymbolArray,Jt=Ci||qt?1:0;di>=0&&($i.get(di).hidden=Jt),Ri>=0&&($i.get(Ri).hidden=Jt),Ai>=0&&($i.get(Ai).hidden=Jt),Mi>=0&&($i.get(Mi).hidden=Ci||ji?1:0);const pi=this.variableOffsets[Bt];pi&&this.markUsedJustification(a,pi.anchor,Ye,si);const In=this.placedOrientations[Bt];In&&(this.markUsedJustification(a,"left",Ye,In),this.markUsedOrientation(a,In,Ye))}if(hi){const Kt=er(It.icon),{placedIconSymbolIndex:Ci,verticalPlacedIconSymbolIndex:di}=Ye,Ri=a.icon.placedSymbolArray,Ai=It.icon.isHidden()?1:0;Ci>=0&&(it(a.icon,Pt,qt?ac:Kt),Ri.get(Ci).hidden=Ai),di>=0&&(it(a.icon,Ye.numVerticalIconVertices,ji?ac:Kt),Ri.get(di).hidden=Ai)}if(a.hasIconCollisionBoxData()||a.hasTextCollisionBoxData()){const Kt=a.collisionArrays[qe];if(Kt){let Ci=new i.pointGeometry(0,0),di=!0;if(Kt.textBox||Kt.verticalTextBox){if(pe){const Ai=this.variableOffsets[Bt];Ai?(Ci=ps(Ai.anchor,Ai.width,Ai.height,Ai.textOffset,Ai.textScale),fe&&Ci._rotate(Me?this.transform.angle:-this.transform.angle)):di=!1}P&&(di=!It.clipped),Kt.textBox&&ks(a.textCollisionBox.collisionVertexArray,It.text.placed,!di||qt,Ci.x,Ci.y),Kt.verticalTextBox&&ks(a.textCollisionBox.collisionVertexArray,It.text.placed,!di||ji,Ci.x,Ci.y)}const Ri=di&&Boolean(!ji&&Kt.verticalIconBox);Kt.iconBox&&ks(a.iconCollisionBox.collisionVertexArray,It.icon.placed,Ri,Ne?Ci.x:0,Ne?Ci.y:0),Kt.verticalIconBox&&ks(a.iconCollisionBox.collisionVertexArray,It.icon.placed,!Ri,Ne?Ci.x:0,Ne?Ci.y:0)}}}if(a.fullyClipped=lt===0,a.sortFeatures(this.transform.angle),this.retainedQueryData[a.bucketInstanceId]&&(this.retainedQueryData[a.bucketInstanceId].featureSortOrder=a.featureSortOrder),a.hasTextData()&&a.text.opacityVertexBuffer&&a.text.opacityVertexBuffer.updateData(a.text.opacityVertexArray),a.hasIconData()&&a.icon.opacityVertexBuffer&&a.icon.opacityVertexBuffer.updateData(a.icon.opacityVertexArray),a.hasIconCollisionBoxData()&&a.iconCollisionBox.collisionVertexBuffer&&a.iconCollisionBox.collisionVertexBuffer.updateData(a.iconCollisionBox.collisionVertexArray),a.hasTextCollisionBoxData()&&a.textCollisionBox.collisionVertexBuffer&&a.textCollisionBox.collisionVertexBuffer.updateData(a.textCollisionBox.collisionVertexArray),a.bucketInstanceId in this.collisionCircleArrays){const qe=this.collisionCircleArrays[a.bucketInstanceId];a.placementInvProjMatrix=qe.invProjMatrix,a.placementViewportMatrix=qe.viewportMatrix,a.collisionCircleArray=qe.circles,delete this.collisionCircleArrays[a.bucketInstanceId]}}symbolFadeChange(a){return this.fadeDuration===0?1:(a-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(a){return Math.max(0,(this.transform.zoom-a)/1.5)}hasTransitions(a){return this.stale||a-this.lastPlacementChangeTimea}setStale(){this.stale=!0}}function ks(x,a,m,b,S){x.emplaceBack(a?1:0,m?1:0,b||0,S||0),x.emplaceBack(a?1:0,m?1:0,b||0,S||0),x.emplaceBack(a?1:0,m?1:0,b||0,S||0),x.emplaceBack(a?1:0,m?1:0,b||0,S||0)}const No=Math.pow(2,25),JA=Math.pow(2,24),fu=Math.pow(2,17),Bs=Math.pow(2,16),sc=Math.pow(2,9),Th=Math.pow(2,8),oc=Math.pow(2,1);function er(x){if(x.opacity===0&&!x.placed)return 0;if(x.opacity===1&&x.placed)return 4294967295;const a=x.placed?1:0,m=Math.floor(127*x.opacity);return m*No+a*JA+m*fu+a*Bs+m*sc+a*Th+m*oc+a}const ac=0;class Ju{constructor(a){this._sortAcrossTiles=a.layout.get("symbol-z-order")!=="viewport-y"&&a.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(a,m,b,S,P){const H=this._bucketParts;for(;this._currentTileIndexW.sortKey-ee.sortKey));this._currentPartIndex{const H=i.exported.now()-S;return!this._forceFullPlacement&&H>2};for(;this._currentPlacementIndex>=0;){const H=m[a[this._currentPlacementIndex]],W=this.placement.collisionIndex.transform.zoom;if(H.type==="symbol"&&(!H.minzoom||H.minzoom<=W)&&(!H.maxzoom||H.maxzoom>W)){if(this._inProgressLayer||(this._inProgressLayer=new Ju(H)),this._inProgressLayer.continuePlacement(b[H.source],this.placement,this._showCollisionBoxes,H,P))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(a){return this.placement.commit(a),this.placement}}const hl=512/i.EXTENT/2;class Sh{constructor(a,m,b){this.tileID=a,this.indexedSymbolInstances={},this.bucketInstanceId=b;for(let S=0;Sa.overscaledZ)for(const W in H){const ee=H[W];ee.tileID.isChildOf(a)&&ee.findMatches(m.symbolInstances,a,S)}else{const W=H[a.scaledTo(Number(P)).key];W&&W.findMatches(m.symbolInstances,a,S)}}for(let P=0;P{m[b]=!0});for(const b in this.layerIndexes)m[b]||delete this.layerIndexes[b]}}const lc=(x,a)=>i.emitValidationErrors(x,a&&a.filter(m=>m.identifier!=="source.canvas")),mu=i.pick(bi,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Vl=i.pick(bi,["setCenter","setZoom","setBearing","setPitch"]),ya={version:8,layers:[],sources:{}},zc={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Ws extends i.Evented{constructor(a,m={}){super(),this.map=a,this.dispatcher=new Ke(jt(),this),this.imageManager=new li,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(a._requestManager,m.localFontFamily?i.LocalGlyphMode.all:m.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,m.localFontFamily||m.localIdeographFontFamily),this.crossTileSymbolIndex=new Qa,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const b=this;this._rtlTextPluginCallback=Ws.registerForPluginStateChange(S=>{b.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:S.pluginStatus,pluginURL:S.pluginURL},(P,H)=>{if(i.triggerPluginCompletionEvent(P),H&&H.every(W=>W))for(const W in b._sourceCaches){const ee=b._sourceCaches[W],pe=ee.getSource().type;pe!=="vector"&&pe!=="geojson"||ee.reload()}})}),this.on("data",S=>{if(S.dataType!=="source"||S.sourceDataType!=="metadata")return;const P=this.getSource(S.sourceId);if(P&&P.vectorLayerIds)for(const H in this._layers){const W=this._layers[H];W.source===P.id&&this._validateLayer(W)}})}loadURL(a,m={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const b=typeof m.validate=="boolean"?m.validate:!i.isMapboxURL(a);a=this.map._requestManager.normalizeStyleURL(a,m.accessToken);const S=this.map._requestManager.transformRequest(a,i.ResourceType.Style);this._request=i.getJSON(S,(P,H)=>{this._request=null,P?this.fire(new i.ErrorEvent(P)):H&&this._load(H,b)})}loadJSON(a,m={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(a,m.validate!==!1)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(ya,!1)}_updateLayerCount(a,m){const b=m?1:-1;a.is3D()&&(this._num3DLayers+=b),a.type==="circle"&&(this._numCircleLayers+=b),a.type==="symbol"&&(this._numSymbolLayers+=b)}_load(a,m){if(m&&lc(this,i.validateStyle(a)))return;this._loaded=!0,this.stylesheet=i.clone$1(a),this._updateMapProjection();for(const S in a.sources)this.addSource(S,a.sources[S],{validate:!1});this._changed=!1,a.sprite?this._loadSprite(a.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(a.glyphs);const b=ki(this.stylesheet.layers);this._order=b.map(S=>S.id),this._layers={},this._serializedLayers={};for(let S of b)S=i.createStyleLayer(S),S.setEventedParent(this,{layer:{id:S.id}}),this._layers[S.id]=S,this._serializedLayers[S.id]=S.serialize(),this._updateLayerCount(S,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new le(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(a){a?this.stylesheet.projection=a:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(a){this._spriteRequest=function(m,b,S){let P,H,W;const ee=i.exported.devicePixelRatio>1?"@2x":"";let pe=i.getJSON(b.transformRequest(b.normalizeSpriteURL(m,ee,".json"),i.ResourceType.SpriteJSON),(Ne,st)=>{pe=null,W||(W=Ne,P=st,Me())}),fe=i.getImage(b.transformRequest(b.normalizeSpriteURL(m,ee,".png"),i.ResourceType.SpriteImage),(Ne,st)=>{fe=null,W||(W=Ne,H=st,Me())});function Me(){if(W)S(W);else if(P&&H){const Ne=i.exported.getImageData(H),st={};for(const it in P){const{width:lt,height:qe,x:Ye,y:dt,sdf:ht,pixelRatio:Bt,stretchX:Pt,stretchY:It,content:Ht}=P[it],hi=new i.RGBAImage({width:lt,height:qe});i.RGBAImage.copy(Ne,hi,{x:Ye,y:dt},{x:0,y:0},{width:lt,height:qe}),st[it]={data:hi,pixelRatio:Bt,sdf:ht,stretchX:Pt,stretchY:It,content:Ht}}S(null,st)}}return{cancel(){pe&&(pe.cancel(),pe=null),fe&&(fe.cancel(),fe=null)}}}(a,this.map._requestManager,(m,b)=>{if(this._spriteRequest=null,m)this.fire(new i.ErrorEvent(m));else if(b)for(const S in b)this.imageManager.addImage(S,b[S]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(a){const m=this.getSource(a.source);if(!m)return;const b=a.sourceLayer;b&&(m.type==="geojson"||m.vectorLayerIds&&m.vectorLayerIds.indexOf(b)===-1)&&this.fire(new i.ErrorEvent(new Error(`Source layer "${b}" does not exist on source "${m.id}" as specified by style layer "${a.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const a in this._sourceCaches)if(!this._sourceCaches[a].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(a){const m=[];for(const b of a){const S=this._layers[b];S.type!=="custom"&&m.push(S.serialize())}return m}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const a in this._sourceCaches)if(this._sourceCaches[a].hasTransition())return!0;for(const a in this._layers)if(this._layers[a].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(a){return!!this.terrain&&zc[a.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(a){if(!this._loaded)return;const m=this._changed;if(this._changed){const S=Object.keys(this._updatedLayers),P=Object.keys(this._removedLayers);(S.length||P.length)&&this._updateWorkerLayers(S,P);for(const H in this._updatedSources){const W=this._updatedSources[H];W==="reload"?this._reloadSource(H):W==="clear"&&this._clearSource(H)}this._updateTilesForChangedImages();for(const H in this._updatedPaintProps)this._layers[H].updateTransitions(a);this.light.updateTransitions(a),this.fog&&this.fog.updateTransitions(a),this._resetUpdates()}const b={};for(const S in this._sourceCaches){const P=this._sourceCaches[S];b[S]=P.used,P.used=!1}for(const S of this._order){const P=this._layers[S];if(P.recalculate(a,this._availableImages),!P.isHidden(a.zoom)){const W=this._getLayerSourceCache(P);W&&(W.used=!0)}const H=this.map.painter;if(H){const W=P.getProgramIds();if(!W)continue;const ee=P.getProgramConfiguration(a.zoom);for(const pe of W)H.useProgram(pe,ee)}}for(const S in b){const P=this._sourceCaches[S];b[S]!==P.used&&P.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:P.getSource().id}))}this.light.recalculate(a),this.terrain&&this.terrain.recalculate(a),this.fog&&this.fog.recalculate(a),this.z=a.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),m&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const a=Object.keys(this._changedImages);if(a.length){for(const m in this._sourceCaches)this._sourceCaches[m].reloadTilesForDependencies(["icons","patterns"],a);this._changedImages={}}}_updateWorkerLayers(a,m){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(a),removedIds:m})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(a){if(this._checkLoaded(),lc(this,i.validateStyle(a)))return!1;(a=i.clone$1(a)).layers=ki(a.layers);const m=function(S,P){if(!S)return[{command:bi.setStyle,args:[P]}];let H=[];try{if(!C(S.version,P.version))return[{command:bi.setStyle,args:[P]}];C(S.center,P.center)||H.push({command:bi.setCenter,args:[P.center]}),C(S.zoom,P.zoom)||H.push({command:bi.setZoom,args:[P.zoom]}),C(S.bearing,P.bearing)||H.push({command:bi.setBearing,args:[P.bearing]}),C(S.pitch,P.pitch)||H.push({command:bi.setPitch,args:[P.pitch]}),C(S.sprite,P.sprite)||H.push({command:bi.setSprite,args:[P.sprite]}),C(S.glyphs,P.glyphs)||H.push({command:bi.setGlyphs,args:[P.glyphs]}),C(S.transition,P.transition)||H.push({command:bi.setTransition,args:[P.transition]}),C(S.light,P.light)||H.push({command:bi.setLight,args:[P.light]}),C(S.fog,P.fog)||H.push({command:bi.setFog,args:[P.fog]}),C(S.projection,P.projection)||H.push({command:bi.setProjection,args:[P.projection]});const W={},ee=[];(function(Me,Ne,st,it){let lt;for(lt in Ne=Ne||{},Me=Me||{})Me.hasOwnProperty(lt)&&(Ne.hasOwnProperty(lt)||Yi(lt,st,it));for(lt in Ne)Ne.hasOwnProperty(lt)&&(Me.hasOwnProperty(lt)?C(Me[lt],Ne[lt])||(Me[lt].type==="geojson"&&Ne[lt].type==="geojson"&&rr(Me,Ne,lt)?st.push({command:bi.setGeoJSONSourceData,args:[lt,Ne[lt].data]}):tn(lt,Ne,st,it)):Oi(lt,Ne,st))})(S.sources,P.sources,ee,W);const pe=[];S.layers&&S.layers.forEach(Me=>{Me.source&&W[Me.source]?H.push({command:bi.removeLayer,args:[Me.id]}):pe.push(Me)});let fe=S.terrain;fe&&W[fe.source]&&(H.push({command:bi.setTerrain,args:[void 0]}),fe=void 0),H=H.concat(ee),C(fe,P.terrain)||H.push({command:bi.setTerrain,args:[P.terrain]}),function(Me,Ne,st){Ne=Ne||[];const it=(Me=Me||[]).map(Yt),lt=Ne.map(Yt),qe=Me.reduce(sr,{}),Ye=Ne.reduce(sr,{}),dt=it.slice(),ht=Object.create(null);let Bt,Pt,It,Ht,hi,si,qt;for(Bt=0,Pt=0;Bt!(S.command in Vl));if(m.length===0)return!1;const b=m.filter(S=>!(S.command in mu));if(b.length>0)throw new Error(`Unimplemented: ${b.map(S=>S.command).join(", ")}.`);return m.forEach(S=>{S.command!=="setTransition"&&S.command!=="setProjection"&&this[S.command].apply(this,S.args)}),this.stylesheet=a,this._updateMapProjection(),!0}addImage(a,m){return this.getImage(a)?this.fire(new i.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(a,m),this._afterImageUpdated(a),this)}updateImage(a,m){this.imageManager.updateImage(a,m)}getImage(a){return this.imageManager.getImage(a)}removeImage(a){return this.getImage(a)?(this.imageManager.removeImage(a),this._afterImageUpdated(a),this):this.fire(new i.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(a){this._availableImages=this.imageManager.listImages(),this._changedImages[a]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(a,m,b={}){if(this._checkLoaded(),this.getSource(a)!==void 0)throw new Error("There is already a source with this ID");if(!m.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(m).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(m.type)>=0&&this._validate(i.validateSource,`sources.${a}`,m,null,b))return;this.map&&this.map._collectResourceTiming&&(m.collectResourceTiming=!0);const S=ie(a,m,this.dispatcher,this);S.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(a),source:S.serialize(),sourceId:a}));const P=H=>{const W=(H?"symbol:":"other:")+a,ee=this._sourceCaches[W]=new i.SourceCache(W,S,H);(H?this._symbolSourceCaches:this._otherSourceCaches)[a]=ee,ee.style=this,ee.onAdd(this.map)};P(!1),m.type!=="vector"&&m.type!=="geojson"||P(!0),S.onAdd&&S.onAdd(this.map),this._changed=!0}removeSource(a){this._checkLoaded();const m=this.getSource(a);if(!m)throw new Error("There is no source with this ID");for(const S in this._layers)if(this._layers[S].source===a)return this.fire(new i.ErrorEvent(new Error(`Source "${a}" cannot be removed while layer "${S}" is using it.`)));if(this.terrain&&this.terrain.get().source===a)return this.fire(new i.ErrorEvent(new Error(`Source "${a}" cannot be removed while terrain is using it.`)));const b=this._getSourceCaches(a);for(const S of b)delete this._sourceCaches[S.id],delete this._updatedSources[S.id],S.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:S.getSource().id})),S.setEventedParent(null),S.clearTiles();return delete this._otherSourceCaches[a],delete this._symbolSourceCaches[a],m.setEventedParent(null),m.onRemove&&m.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(a,m){this._checkLoaded(),this.getSource(a).setData(m),this._changed=!0}getSource(a){const m=this._getSourceCache(a);return m&&m.getSource()}_getSources(){const a=[];for(const m in this._otherSourceCaches){const b=this._getSourceCache(m);b&&a.push(b.getSource())}return a}addLayer(a,m,b={}){this._checkLoaded();const S=a.id;if(this.getLayer(S))return void this.fire(new i.ErrorEvent(new Error(`Layer with id "${S}" already exists on this map`)));let P;if(a.type==="custom"){if(lc(this,i.validateCustomStyleLayer(a)))return;P=i.createStyleLayer(a)}else{if(typeof a.source=="object"&&(this.addSource(S,a.source),a=i.clone$1(a),a=i.extend(a,{source:S})),this._validate(i.validateLayer,`layers.${S}`,a,{arrayIndex:-1},b))return;P=i.createStyleLayer(a),this._validateLayer(P),P.setEventedParent(this,{layer:{id:S}}),this._serializedLayers[P.id]=P.serialize(),this._updateLayerCount(P,!0)}const H=m?this._order.indexOf(m):this._order.length;if(m&&H===-1)return void this.fire(new i.ErrorEvent(new Error(`Layer with id "${m}" does not exist on this map.`)));this._order.splice(H,0,S),this._layerOrderChanged=!0,this._layers[S]=P;const W=this._getLayerSourceCache(P);if(this._removedLayers[S]&&P.source&&W&&P.type!=="custom"){const ee=this._removedLayers[S];delete this._removedLayers[S],ee.type!==P.type?this._updatedSources[P.source]="clear":(this._updatedSources[P.source]="reload",W.pause())}this._updateLayer(P),P.onAdd&&P.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(a,m){if(this._checkLoaded(),this._changed=!0,!this._layers[a])return void this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be moved.`)));if(a===m)return;const b=this._order.indexOf(a);this._order.splice(b,1);const S=m?this._order.indexOf(m):this._order.length;m&&S===-1?this.fire(new i.ErrorEvent(new Error(`Layer with id "${m}" does not exist on this map.`))):(this._order.splice(S,0,a),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(a){this._checkLoaded();const m=this._layers[a];if(!m)return void this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be removed.`)));m.setEventedParent(null),this._updateLayerCount(m,!1);const b=this._order.indexOf(a);this._order.splice(b,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[a]=m,delete this._layers[a],delete this._serializedLayers[a],delete this._updatedLayers[a],delete this._updatedPaintProps[a],m.onRemove&&m.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(a){return this._layers[a]}hasLayer(a){return a in this._layers}hasLayerType(a){for(const m in this._layers)if(this._layers[m].type===a)return!0;return!1}setLayerZoomRange(a,m,b){this._checkLoaded();const S=this.getLayer(a);S?S.minzoom===m&&S.maxzoom===b||(m!=null&&(S.minzoom=m),b!=null&&(S.maxzoom=b),this._updateLayer(S)):this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(a,m,b={}){this._checkLoaded();const S=this.getLayer(a);if(S){if(!C(S.filter,m))return m==null?(S.filter=void 0,void this._updateLayer(S)):void(this._validate(i.validateFilter,`layers.${S.id}.filter`,m,{layerType:S.type},b)||(S.filter=i.clone$1(m),this._updateLayer(S)))}else this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be filtered.`)))}getFilter(a){const m=this.getLayer(a);return m&&i.clone$1(m.filter)}setLayoutProperty(a,m,b,S={}){this._checkLoaded();const P=this.getLayer(a);P?C(P.getLayoutProperty(m),b)||(P.setLayoutProperty(m,b,S),this._updateLayer(P)):this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(a,m){const b=this.getLayer(a);if(b)return b.getLayoutProperty(m);this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style.`)))}setPaintProperty(a,m,b,S={}){this._checkLoaded();const P=this.getLayer(a);P?C(P.getPaintProperty(m),b)||(P.setPaintProperty(m,b,S)&&this._updateLayer(P),this._changed=!0,this._updatedPaintProps[a]=!0):this.fire(new i.ErrorEvent(new Error(`The layer '${a}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(a,m){const b=this.getLayer(a);return b&&b.getPaintProperty(m)}setFeatureState(a,m){this._checkLoaded();const b=a.source,S=a.sourceLayer,P=this.getSource(b);if(!P)return void this.fire(new i.ErrorEvent(new Error(`The source '${b}' does not exist in the map's style.`)));const H=P.type;if(H==="geojson"&&S)return void this.fire(new i.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(H==="vector"&&!S)return void this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));a.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided.")));const W=this._getSourceCaches(b);for(const ee of W)ee.setFeatureState(S,a.id,m)}removeFeatureState(a,m){this._checkLoaded();const b=a.source,S=this.getSource(b);if(!S)return void this.fire(new i.ErrorEvent(new Error(`The source '${b}' does not exist in the map's style.`)));const P=S.type,H=P==="vector"?a.sourceLayer:void 0;if(P==="vector"&&!H)return void this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(m&&typeof a.id!="string"&&typeof a.id!="number")return void this.fire(new i.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const W=this._getSourceCaches(b);for(const ee of W)ee.removeFeatureState(H,a.id,m)}getFeatureState(a){this._checkLoaded();const m=a.source,b=a.sourceLayer,S=this.getSource(m);if(S){if(S.type!=="vector"||b)return a.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(m)[0].getFeatureState(b,a.id);this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(new Error(`The source '${m}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const a={};for(const m in this._sourceCaches){const b=this._sourceCaches[m].getSource();a[b.id]||(a[b.id]=b.serialize())}return i.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:a,layers:this._serializeLayers(this._order)},m=>m!==void 0)}_updateLayer(a){this._updatedLayers[a.id]=!0;const m=this._getLayerSourceCache(a);a.source&&!this._updatedSources[a.source]&&m&&m.getSource().type!=="raster"&&(this._updatedSources[a.source]="reload",m.pause()),this._changed=!0,a.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(a){const m=H=>this._layers[H].type==="fill-extrusion",b={},S=[];for(let H=this._order.length-1;H>=0;H--){const W=this._order[H];if(m(W)){b[W]=H;for(const ee of a){const pe=ee[W];if(pe)for(const fe of pe)S.push(fe)}}}S.sort((H,W)=>W.intersectionZ-H.intersectionZ);const P=[];for(let H=this._order.length-1;H>=0;H--){const W=this._order[H];if(m(W))for(let ee=S.length-1;ee>=0;ee--){const pe=S[ee].feature;if(b[pe.layer.id]{const pe=this.getLayer(ee);return pe&&pe.is3D()}):this.has3DLayers(),W=vt.createFromScreenPoints(a,b);for(const ee in this._sourceCaches){const pe=this._sourceCaches[ee].getSource().id;m.layers&&!S[pe]||P.push(de(this._sourceCaches[ee],this._layers,this._serializedLayers,W,m,b,H,!!this.map._showQueryGeometry))}return this.placement&&P.push(function(ee,pe,fe,Me,Ne,st,it){const lt={},qe=st.queryRenderedSymbols(Me),Ye=[];for(const dt of Object.keys(qe).map(Number))Ye.push(it[dt]);Ye.sort(tt);for(const dt of Ye){const ht=dt.featureIndex.lookupSymbolFeatures(qe[dt.bucketInstanceId],pe,dt.bucketIndex,dt.sourceLayerIndex,Ne.filter,Ne.layers,Ne.availableImages,ee);for(const Bt in ht){const Pt=lt[Bt]=lt[Bt]||[],It=ht[Bt];It.sort((Ht,hi)=>{const si=dt.featureSortOrder;if(si){const qt=si.indexOf(Ht.featureIndex);return si.indexOf(hi.featureIndex)-qt}return hi.featureIndex-Ht.featureIndex});for(const Ht of It)Pt.push(Ht)}}for(const dt in lt)lt[dt].forEach(ht=>{const Bt=ht.feature,Pt=fe(ee[dt]).getFeatureState(Bt.layer["source-layer"],Bt.id);Bt.source=Bt.layer.source,Bt.layer["source-layer"]&&(Bt.sourceLayer=Bt.layer["source-layer"]),Bt.state=Pt});return lt}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),W.screenGeometry,m,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(P)}querySourceFeatures(a,m){m&&m.filter&&this._validate(i.validateFilter,"querySourceFeatures.filter",m.filter,null,m);const b=this._getSourceCaches(a);let S=[];for(const P of b)S=S.concat(Ue(P,m));return S}addSourceType(a,m,b){return Ws.getSourceType(a)?b(new Error(`A source type called "${a}" already exists.`)):(Ws.setSourceType(a,m),m.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:a,url:m.workerSourceURL},b):b(null,null))}getLight(){return this.light.getLight()}setLight(a,m={}){this._checkLoaded();const b=this.light.getLight();let S=!1;for(const H in a)if(!C(a[H],b[H])){S=!0;break}if(!S)return;const P=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(a,m),this.light.updateTransitions(P)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(a,m=1){if(this._checkLoaded(),!a)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(m===1){if(typeof a.source=="object"){const b="terrain-dem-src";this.addSource(b,a.source),a=i.clone$1(a),a=i.extend(a,{source:b})}if(this._validate(i.validateTerrain,"terrain",a))return}if(!this.terrain||this.terrain&&m!==this.terrain.drapeRenderMode)this._createTerrain(a,m);else{const b=this.terrain,S=b.get();for(const P of Object.keys(i.spec.terrain))!a.hasOwnProperty(P)&&i.spec.terrain[P].default&&(a[P]=i.spec.terrain[P].default);for(const P in a)if(!C(a[P],S[P])){b.set(a),this.stylesheet.terrain=a;const H=this._setTransitionParameters({duration:0});b.updateTransitions(H);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(a){const m=this.fog=new Se(a,this.map.transform);this.stylesheet.fog=a;const b=this._setTransitionParameters({duration:0});m.updateTransitions(b)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const a of this.map._markers)a._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(a){if(this._checkLoaded(),!a)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const m=this.fog,b=m.get();Object.keys(a).length===0&&m.set(a);for(const S in a)if(!C(a[S],b[S])){m.set(a),this.stylesheet.fog=a;const P=this._setTransitionParameters({duration:0});m.updateTransitions(P);break}}else this._createFog(a);this._markersNeedUpdate=!0}_setTransitionParameters(a){return{now:i.exported.now(),transition:i.extend(a,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const a=this._order.filter(b=>this.isLayerDraped(this._layers[b])),m=this._order.filter(b=>!this.isLayerDraped(this._layers[b]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...a),this._drapedFirstOrder.push(...m)}_createTerrain(a,m){const b=this.terrain=new Re(a,m);this.stylesheet.terrain=a,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const S=this._setTransitionParameters({duration:0});b.updateTransitions(S)}_force3DLayerUpdate(){for(const a in this._layers){const m=this._layers[a];m.type==="fill-extrusion"&&this._updateLayer(m)}}_forceSymbolLayerUpdate(){for(const a in this._layers){const m=this._layers[a];m.type==="symbol"&&this._updateLayer(m)}}_validate(a,m,b,S,P={}){return(!P||P.validate!==!1)&&lc(this,a.call(i.validateStyle,i.extend({key:m,style:this.serialize(),value:b,styleSpec:i.spec},S)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const a in this._layers)this._layers[a].setEventedParent(null);for(const a in this._sourceCaches)this._sourceCaches[a].clearTiles(),this._sourceCaches[a].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(a){const m=this._getSourceCaches(a);for(const b of m)b.clearTiles()}_reloadSource(a){const m=this._getSourceCaches(a);for(const b of m)b.resume(),b.reload()}_reloadSources(){for(const a of this._getSources())a.reload&&a.reload()}_updateSources(a){for(const m in this._sourceCaches)this._sourceCaches[m].update(a)}_generateCollisionBoxes(){for(const a in this._sourceCaches){const m=this._sourceCaches[a];m.resume(),m.reload()}}_updatePlacement(a,m,b,S,P=!1){let H=!1,W=!1;const ee={};for(const pe of this._order){const fe=this._layers[pe];if(fe.type!=="symbol")continue;if(!ee[fe.source]){const Ne=this._getLayerSourceCache(fe);if(!Ne)continue;ee[fe.source]=Ne.getRenderableIds(!0).map(st=>Ne.getTileByID(st)).sort((st,it)=>it.tileID.overscaledZ-st.tileID.overscaledZ||(st.tileID.isLessThan(it.tileID)?-1:1))}const Me=this.crossTileSymbolIndex.addLayer(fe,ee[fe.source],a.center.lng,a.projection);H=H||Me}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),P=P||this._layerOrderChanged||b===0,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(P||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),a.zoom))&&(this.pauseablePlacement=new Qo(a,this._order,P,m,b,S,this.placement,this.fog&&a.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,ee),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),W=!0),H&&this.pauseablePlacement.placement.setStale()),W||H)for(const pe of this._order){const fe=this._layers[pe];fe.type==="symbol"&&this.placement.updateLayerOpacities(fe,ee[fe.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const a in this._sourceCaches)this._sourceCaches[a].releaseSymbolFadeTiles()}getImages(a,m,b){this.imageManager.getImages(m.icons,b),this._updateTilesForChangedImages();const S=P=>{P&&P.setDependencies(m.tileID.key,m.type,m.icons)};S(this._otherSourceCaches[m.source]),S(this._symbolSourceCaches[m.source])}getGlyphs(a,m,b){this.glyphManager.getGlyphs(m.stacks,b)}getResource(a,m,b){return i.makeRequest(m,b)}_getSourceCache(a){return this._otherSourceCaches[a]}_getLayerSourceCache(a){return a.type==="symbol"?this._symbolSourceCaches[a.source]:this._otherSourceCaches[a.source]}_getSourceCaches(a){const m=[];return this._otherSourceCaches[a]&&m.push(this._otherSourceCaches[a]),this._symbolSourceCaches[a]&&m.push(this._symbolSourceCaches[a]),m}_isSourceCacheLoaded(a){const m=this._getSourceCaches(a);return m.length===0?(this.fire(new i.ErrorEvent(new Error(`There is no source with ID '${a}'`))),!1):m.every(b=>b.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Ws.getSourceType=function(x){return j[x]},Ws.setSourceType=function(x,a){j[x]=a},Ws.registerForPluginStateChange=i.registerForPluginStateChange;var cc=` #define EPSILON 0.0000001 #define PI 3.141592653589793 #define EXTENT 8192.0 #define HALF_PI PI/2.0 #define QUARTER_PI PI/4.0 #define RAD_TO_DEG 180.0/PI #define DEG_TO_RAD PI/180.0 #define GLOBE_RADIUS EXTENT/PI/2.0`,kc="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",eA=` #define ELEVATION_SCALE 7.0 #define ELEVATION_OFFSET 450.0 #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix( mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;} #else vec3 elevationVector(vec2 pos) { return vec3(0,0,1); } #endif #ifdef TERRAIN #ifdef TERRAIN_DEM_FLOAT_FORMAT uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev; #else uniform sampler2D u_dem;uniform sampler2D u_dem_prev; #endif uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos)); #ifdef TERRAIN_DEM_NEAREST_FILTER return u_exaggeration*tl; #endif float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif }float prevElevation(vec2 apos) { #ifdef TERRAIN_DEM_FLOAT_FORMAT vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a; #else float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y); #endif } #ifdef TERRAIN_VERTEX_MORPHING float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);} #else float elevation(vec2 apos) { #ifdef ZERO_EXAGGERATION return 0.0; #endif return currentElevation(apos);} #endif highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4( unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy)) );return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) { #ifdef TERRAIN_DEM_FLOAT_FORMAT float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a; #else vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack); #endif return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);} #else float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; } #endif`,hc=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);} #endif`,gu=`#ifdef FOG uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);} #endif`;let ed={},_u={};const Ih=[];ul(cc,Ih),ul(eA,Ih),ul(hc,Ih),ul(gu,Ih),ed=Ir("",eA),_u=Ir(gu,hc);const tA=Ir(` highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth) {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}`,` float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;} #ifdef PROJECTION_GLOBE_VIEW vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) { #ifndef PROJECTED_POS_ON_VIEWPORT float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz; #else return vec3(0.0); #endif }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);} #endif vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4( unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),td=cc,uc=` #ifdef GL_ES precision mediump float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif`;var Oc={background:Ir(`uniform vec4 u_color;uniform float u_opacity; #ifdef LIGHTING_3D_MODE varying vec4 v_color; #endif void main() {vec4 out_color; #ifdef LIGHTING_3D_MODE out_color=v_color; #else out_color=u_color; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #ifdef LIGHTING_3D_MODE uniform vec4 u_color;varying vec4 v_color; #endif void main() {gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef LIGHTING_3D_MODE v_color=apply_lighting(u_color); #endif #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),backgroundPattern:Ir(`uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),circle:Ir(`varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep( antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width) );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_apply_premultiplied(out_color,v_fog_pos); #endif gl_FragColor=out_color*(v_visibility*opacity_t); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`#define NUM_VISIBILITY_RINGS 2 #define INV_SQRT2 0.70710678 #define ELEVATION_BIAS 0.0001 #define NUM_SAMPLES_PER_RING 16 uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) { #if defined(TERRAIN) return elevation(pos)+ELEVATION_BIAS; #else return 0.0; #endif }vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale); #ifdef PITCH_WITH_MAP #ifdef PROJECTION_GLOBE_VIEW return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) ); #else return u_matrix*( world_center+vec4(sample_offset,0,0) ); #endif #else return projected_center+vec4(sample_offset,0,0); #endif }float get_sample_step() { #ifdef PITCH_WITH_MAP return 2.0*PI/float(NUM_SAMPLES_PER_RING); #else return PI/float(NUM_SAMPLES_PER_RING); #endif }void main(void) { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1); #else surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1); #endif vec4 projected_center=u_matrix*world_center;float view_scale=0.0; #ifdef PITCH_WITH_MAP #ifdef SCALE_WITH_MAP view_scale=1.0; #else view_scale=projected_center.w/u_camera_to_center_distance; #endif #else #ifdef SCALE_WITH_MAP view_scale=u_camera_to_center_distance; #else view_scale=projected_center.w; #endif #endif gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0; #ifdef TERRAIN float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center; #ifdef PITCH_WITH_MAP float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center; #else occlusion_world_center=world_center;occlusion_projected_center=projected_center; #endif for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING); #else visibility=1.0; #endif #ifdef PROJECTION_GLOBE_VIEW visibility=1.0; #endif v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur); #ifdef FOG v_fog_pos=fog_position(world_center.xyz); #endif }`),clippingMask:Ir("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Ir(`uniform highp float u_intensity;varying vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0); #ifdef FOG if (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);} #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir; #endif varying vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos; #ifdef PROJECTION_GLOBE_VIEW vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #else pos=vec3(tilePos+extrude,elevation(tilePos)); #endif gl_Position=u_matrix*vec4(pos,1); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),heatmapTexture:Ir(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(0.0); #endif }`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Ir("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Ir("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",`attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2( mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp( 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Ir("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",`attribute vec2 a_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3; #endif varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0; #ifdef PROJECTION_GLOBE_VIEW gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1); #else gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1); #endif }`),fill:Ir(`#pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity vec4 out_color=color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutline:Ir(`varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color; #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillOutlinePattern:Ir(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillPattern:Ir(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos); #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),fillExtrusion:Ir(`varying vec4 v_color; #ifdef RENDER_SHADOWS varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #ifdef ZERO_ROOF_RADIUS varying vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) varying highp vec3 v_normal; #endif void main() { #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) vec3 normal=v_normal; #endif float z;vec4 color; #ifdef ZERO_ROOF_RADIUS z=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z); #else color=v_color; #endif #ifdef FAUX_AO float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x; #ifdef ZERO_ROOF_RADIUS concave*=(1.0-z); #endif float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade; #endif #ifdef RENDER_SHADOWS #ifdef ZERO_ROOF_RADIUS normal=mix(normal,vec3(0.0,0.0,1.0),z); #endif color.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth); #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif varying vec4 v_color; #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth; #endif #ifdef ZERO_ROOF_RADIUS varying vec4 v_roof_color; #endif #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) varying highp vec3 v_normal; #endif #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0)); #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) v_normal=normal; #endif base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=0.0;float c_ele;vec3 pos; #ifdef TERRAIN bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h); #else h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden); #ifdef RENDER_SHADOWS v_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w; #endif float NdotL=0.0;float colorvalue=0.0; #ifdef LIGHTING_3D_MODE NdotL=calculate_NdotL(normal); #else colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL); #endif if (normal.y !=0.0) {float r=0.84; #ifndef LIGHTING_3D_MODE r=mix(0.7,0.98,1.0-u_lightintensity); #endif NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0); #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_color=apply_lighting(color,NdotL); #else v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0)); #endif v_color*=u_opacity; #ifdef ZERO_ROOF_RADIUS v_roof_color=vec4(0.0,0.0,0.0,1.0); #ifdef LIGHTING_3D_MODE v_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0))); #else float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0)); #endif v_roof_color*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),fillExtrusionPattern:Ir(`uniform vec2 u_texsize;uniform sampler2D u_image; #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE varying float v_NdotL; #endif varying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color,v_NdotL)*u_opacity; #else out_color=out_color*v_lighting; #endif #ifdef FAUX_AO float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade; #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif gl_FragColor=out_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift; #endif varying vec2 v_pos;varying vec4 v_lighting; #ifdef FAUX_AO uniform lowp vec2 u_ao;varying vec3 v_ao; #endif #ifdef LIGHTING_3D_MODE varying float v_NdotL; #endif #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0); #if defined(HAS_CENTROID) || defined(TERRAIN) centroid_pos=a_centroid_pos; #endif float ele=0.0;float h=z;vec3 p;float c_ele; #ifdef TERRAIN bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h); #else p=vec3(pos_nx.xy,z); #endif #ifdef PROJECTION_GLOBE_VIEW float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition); #endif float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0 ? pos_nx.xy : vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0; #ifdef LIGHTING_3D_MODE NdotL=calculate_NdotL(normal); #else NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL); #endif if (normal.y !=0.0) {float r=0.84; #ifndef LIGHTING_3D_MODE r=mix(0.7,0.98,1.0-u_lightintensity); #endif NdotL*=( (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));} #ifdef FAUX_AO float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height; #ifdef TERRAIN top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height); #endif v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]); #ifdef PROJECTION_GLOBE_VIEW top_height+=u_height_lift; #endif gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w; #endif #ifdef LIGHTING_3D_MODE v_NdotL=NdotL; #else v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity; #endif #ifdef FOG v_fog_pos=fog_position(p); #endif }`),hillshadePrepare:Ir(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) { #ifdef TERRAIN_DEM_FLOAT_FORMAT return texture2D(u_image,coord).a/4.0; #else vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0; #endif }void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2( (c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c) )/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4( deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Ir(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef LIGHTING_3D_MODE gl_FragColor=apply_lighting(gl_FragColor); #endif #ifdef FOG gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos)); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),line:Ir(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv; #ifdef RENDER_LINE_DASH uniform sampler2D u_dash_image;varying vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform sampler2D u_gradient_image; #endif uniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;} #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0); #ifdef RENDER_LINE_DASH float sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist); #endif highp vec4 out_color; #ifdef RENDER_LINE_GRADIENT out_color=texture2D(u_gradient_image,v_uv.xy); #else out_color=color; #endif #ifdef RENDER_LINE_TRIM_OFFSET highp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);}} #endif #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos)); #endif #ifdef RENDER_LINE_ALPHA_DISCARD if (alpha < u_alpha_discard_threshold) {discard;} #endif #ifdef RENDER_LINE_BORDER float edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2); #ifdef RENDER_LINE_BORDER_AUTO float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);} #else out_color.rgb=mix(u_border_color.rgb,out_color.rgb,smoothAlpha); #endif } #endif gl_FragColor=out_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define EXTRUDE_SCALE 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data; #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) attribute highp vec4 a_packed; #endif #ifdef RENDER_LINE_DASH attribute float a_linesofar; #endif uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv; #ifdef RENDER_LINE_DASH uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex; #endif #ifdef RENDER_LINE_GRADIENT uniform float u_image_height; #endif #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 dash #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize lowp vec4 dash #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude; #ifndef RENDER_TO_TEXTURE float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #else v_gamma_scale=1.0; #endif #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET) float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3]; #ifdef RENDER_LINE_GRADIENT highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end); #else v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end); #endif #endif #ifdef RENDER_LINE_DASH float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y); #endif v_width2=vec2(outset,inset); #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),linePattern:Ir(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos); #ifdef LIGHTING_3D_MODE color=apply_lighting(color); #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 pattern #pragma mapbox: define lowp float pixel_ratio void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump vec4 pattern #pragma mapbox: initialize lowp float pixel_ratio float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude; #ifndef RENDER_TO_TEXTURE float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #else v_gamma_scale=1.0; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth; #ifdef FOG v_fog_pos=fog_position(pos); #endif }`),raster:Ir(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3( dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb); #ifdef LIGHTING_3D_MODE out_color=apply_lighting(out_color); #endif #ifdef FOG out_color=fog_dither(fog_apply(out_color,v_fog_pos)); #endif gl_FragColor=vec4(out_color*color.a,color.a); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent; #ifdef FOG v_fog_pos=fog_position(a_pos); #endif }`),symbolIcon:Ir(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal; #endif uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? 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,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point; #ifdef PROJECTION_GLOBE_VIEW vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1); #else offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1); #endif vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #else gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #endif float projection_transition_fade=1.0; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:Ir(`#define SDF_PX 8.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal; #endif uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #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_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? 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,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point; #ifdef PROJECTION_GLOBE_VIEW vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1); #else offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1); #endif vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #else gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #endif float gamma_scale=gl_Position.w;float projection_transition_fade=1.0; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:Ir(`#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity; #ifdef PROJECTION_GLOBE_VIEW attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal; #endif uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon; #ifdef PROJECTION_GLOBE_VIEW uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix; #endif varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #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_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos; #ifdef PROJECTION_GLOBE_VIEW mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0; #else world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0; #endif vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ? 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,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos; #ifdef PROJECTION_GLOBE_VIEW vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); #else projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0); #endif 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale); #ifdef TERRAIN #ifdef PITCH_WITH_MAP_TERRAIN vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy); #endif #endif float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade; #ifdef PROJECTION_GLOBE_VIEW vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #else gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0)); #endif float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0; #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW) projection_transition_fade=1.0-step(EPSILON,u_zoom_transition); #endif v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:Ir(`uniform sampler2D u_image0;varying vec2 v_pos0; #ifdef FOG varying float v_fog_opacity; #endif #ifdef RENDER_SHADOWS varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth; #endif void main() {vec4 color=texture2D(u_image0,v_pos0); #ifdef RENDER_SHADOWS color.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth); #endif #ifdef FOG #ifdef ZERO_EXAGGERATION color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #else color=fog_dither(fog_apply_from_vert(color,v_fog_opacity)); #endif #endif gl_FragColor=color; #ifdef TERRAIN_WIREFRAME gl_FragColor=vec4(1.0,0.0,0.0,0.8); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0; #ifdef FOG varying float v_fog_opacity; #endif #ifdef RENDER_SHADOWS uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth; #endif const float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height; #ifdef TERRAIN_WIREFRAME elevation+=u_skirt_height*u_skirt_height*wireframeOffset; #endif vec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0); #ifdef FOG #ifdef ZERO_EXAGGERATION v_fog_pos=fog_position(decodedPos); #else v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation))); #endif #endif #ifdef RENDER_SHADOWS vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w; #endif }`),terrainDepth:Ir(`#ifdef GL_ES precision highp float; #endif varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:Ir(` varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep( cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb; #ifdef FOG sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color); #endif sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,kc),skyboxGradient:Ir(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5)); #ifdef FOG color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a; #endif color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,kc),skyboxCapture:Ir(` varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m; #ifdef GL_ES precision highp float; #endif #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6) #define BETA_M vec3(21e-6,21e-6,21e-6) #define MIE_G 0.76 #define DENSITY_HEIGHT_SCALE_R 8000.0 #define DENSITY_HEIGHT_SCALE_M 1200.0 #define PLANET_RADIUS 6360e3 #define ATMOSPHERE_RADIUS 6420e3 #define SAMPLE_STEPS 10 #define DENSITY_STEPS 4 float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Ir(`uniform sampler2D u_image0;varying vec2 v_pos0; #ifndef FOG uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport; #endif void main() {vec4 color; #ifdef CUSTOM_ANTIALIASING vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias); #else color=texture2D(u_image0,v_pos0); #endif #ifdef FOG color=fog_dither(fog_apply_premultiplied(color,v_fog_pos)); #endif gl_FragColor=color; #ifdef TERRAIN_WIREFRAME gl_FragColor=vec4(1.0,0.0,0.0,0.8); #endif #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix; #ifdef GLOBE_POLES attribute vec3 a_globe_pos;attribute vec2 a_uv; #else attribute vec2 a_pos; #endif varying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() { #ifdef GLOBE_POLES vec3 globe_pos=a_globe_pos;vec2 uv=a_uv; #else float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY); #endif v_pos0=uv;vec2 tile_pos=uv*EXTENT; #ifdef GLOBE_POLES vec3 up_vector=normalize(globe_pos)*u_tile_up_scale; #else vec3 up_vector=elevationVector(tile_pos); #endif float height=elevation(tile_pos); #ifdef TERRAIN_WIREFRAME height+=wireframeOffset; #endif globe_pos+=up_vector*height; #ifdef GLOBE_POLES vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0); #else vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0); #endif gl_Position=u_proj_matrix*interpolated_pos; #ifdef FOG v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz); #endif }`),globeAtmosphere:Ir(`uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir; #ifdef PROJECTION_GLOBE_VIEW globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;} #endif highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ? 0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle; #ifdef PROJECTION_GLOBE_VIEW highp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ? PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t); #else horizon_angle=horizon_angle_mercator; #endif horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x: (n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y: uv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}`,`attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix( mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix( mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`)};function ul(x,a){const m=x.replace(/\s*\/\/[^\n]*\n/g,` `).split(` `);for(let b of m)if(b=b.trim(),b[0]==="#"&&b.includes("if")&&!b.includes("endif")){b=b.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const S=b.split(" ");for(const P of S)a.includes(P)||a.push(P)}}function Ir(x,a){const m=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,b=a.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),S={},P=[...Ih];return ul(x,P),ul(a,P),{fragmentSource:x=x.replace(m,(H,W,ee,pe,fe)=>(S[fe]=!0,W==="define"?` #ifndef HAS_UNIFORM_u_${fe} varying ${ee} ${pe} ${fe}; #else uniform ${ee} ${pe} u_${fe}; #endif `:` #ifdef HAS_UNIFORM_u_${fe} ${ee} ${pe} ${fe} = u_${fe}; #endif `)),vertexSource:a=a.replace(m,(H,W,ee,pe,fe)=>{const Me=pe==="float"?"vec2":"vec4",Ne=fe.match(/color/)?"color":Me;return S[fe]?W==="define"?` #ifndef HAS_UNIFORM_u_${fe} uniform lowp float u_${fe}_t; attribute ${ee} ${Me} a_${fe}; varying ${ee} ${pe} ${fe}; #else uniform ${ee} ${pe} u_${fe}; #endif `:Ne==="vec4"?` #ifndef HAS_UNIFORM_u_${fe} ${fe} = a_${fe}; #else ${ee} ${pe} ${fe} = u_${fe}; #endif `:` #ifndef HAS_UNIFORM_u_${fe} ${fe} = unpack_mix_${Ne}(a_${fe}, u_${fe}_t); #else ${ee} ${pe} ${fe} = u_${fe}; #endif `:W==="define"?` #ifndef HAS_UNIFORM_u_${fe} uniform lowp float u_${fe}_t; attribute ${ee} ${Me} a_${fe}; #else uniform ${ee} ${pe} u_${fe}; #endif `:Ne==="vec4"?` #ifndef HAS_UNIFORM_u_${fe} ${ee} ${pe} ${fe} = a_${fe}; #else ${ee} ${pe} ${fe} = u_${fe}; #endif `:` #ifndef HAS_UNIFORM_u_${fe} ${ee} ${pe} ${fe} = unpack_mix_${Ne}(a_${fe}, u_${fe}_t); #else ${ee} ${pe} ${fe} = u_${fe}; #endif `}),staticAttributes:b,usedDefines:P}}class Ac{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(a,m,b,S,P,H,W){this.context=a;let ee=this.boundPaintVertexBuffers.length!==S.length;for(let fe=0;!ee&&fe{const ht=Ye.paint.get("hillshade-shadow-color"),Bt=Ye.paint.get("hillshade-highlight-color"),Pt=Ye.paint.get("hillshade-accent-color");let It=Ye.paint.get("hillshade-illumination-direction")*(Math.PI/180);Ye.paint.get("hillshade-illumination-anchor")==="viewport"&&(It-=lt.transform.angle);const Ht=!lt.options.moving;return{u_matrix:dt||lt.transform.calculateProjMatrix(qe.tileID.toUnwrapped(),Ht),u_image:0,u_latrange:Nc(0,qe.tileID),u_light:[Ye.paint.get("hillshade-exaggeration"),It],u_shadow:ht,u_highlight:Bt,u_accent:Pt}})(x,m,b,x.terrain?a.projMatrix:null);x.prepareDrawProgram(W,fe,a.toUnwrapped());const{tileBoundsBuffer:Ne,tileBoundsIndexBuffer:st,tileBoundsSegments:it}=x.getTileBoundsBuffers(m);fe.draw(W,ee.TRIANGLES,S,P,H,i.CullFaceMode.disabled,Me,b.id,Ne,st,it)}function Al(x,a,m){if(!a.needsDEMTextureUpload)return;const b=x.context,S=b.gl;b.pixelStoreUnpackPremultiplyAlpha.set(!1),a.demTexture=a.demTexture||x.getTileTexture(m.stride);const P=m.getPixels();a.demTexture?a.demTexture.update(P,{premultiply:!1}):a.demTexture=new i.Texture(b,P,S.RGBA,{premultiply:!1}),a.needsDEMTextureUpload=!1}function Va(x,a,m,b,S,P){const H=x.context,W=H.gl;if(!a.dem)return;const ee=a.dem;if(H.activeTexture.set(W.TEXTURE1),Al(x,a,ee),!a.demTexture)return;a.demTexture.bind(W.NEAREST,W.CLAMP_TO_EDGE);const pe=ee.dim;H.activeTexture.set(W.TEXTURE0);let fe=a.fbo;if(!fe){const it=new i.Texture(H,{width:pe,height:pe,data:null},W.RGBA);it.bind(W.LINEAR,W.CLAMP_TO_EDGE),fe=a.fbo=H.createFramebuffer(pe,pe,!0),fe.colorAttachment.set(it.texture)}H.bindFramebuffer.set(fe.framebuffer),H.viewport.set([0,0,pe,pe]);const{tileBoundsBuffer:Me,tileBoundsIndexBuffer:Ne,tileBoundsSegments:st}=x.getMercatorTileBoundsBuffers();x.useProgram("hillshadePrepare").draw(H,W.TRIANGLES,b,S,P,i.CullFaceMode.disabled,((it,lt)=>{const qe=lt.stride,Ye=i.create();return i.ortho(Ye,0,i.EXTENT,-i.EXTENT,0,0,1),i.translate(Ye,Ye,[0,-i.EXTENT,0]),{u_matrix:Ye,u_image:1,u_dimension:[qe,qe],u_zoom:it.overscaledZ,u_unpack:lt.unpackVector}})(a.tileID,ee),m.id,Me,Ne,st),a.needsHillshadePrepare=!1}const Qc=x=>({u_matrix:new i.UniformMatrix4f(x),u_image0:new i.Uniform1i(x),u_skirt_height:new i.Uniform1f(x)}),dl=(x,a)=>({u_matrix:x,u_image0:0,u_skirt_height:a}),qr=(x,a,m,b,S,P,H,W,ee,pe,fe,Me,Ne,st)=>({u_proj_matrix:Float32Array.from(x),u_globe_matrix:a,u_normalize_matrix:Float32Array.from(b),u_merc_matrix:m,u_zoom_transition:S,u_merc_center:P,u_image0:0,u_frustum_tl:H,u_frustum_tr:W,u_frustum_br:ee,u_frustum_bl:pe,u_globe_pos:fe,u_globe_radius:Me,u_viewport:Ne,u_grid_matrix:st?Float32Array.from(st):new Float32Array(9)});function Fh(x,a){return x!=null&&a!=null&&!(!x.hasData()||!a.hasData())&&x.demTexture!=null&&a.demTexture!=null&&x.tileID.key!==a.tileID.key}const hr=new class{constructor(){this.operations={}}newMorphing(x,a,m,b,S){if(x in this.operations){const P=this.operations[x];P.to.tileID.key!==m.tileID.key&&(P.queued=m)}else this.operations[x]={startTime:b,phase:0,duration:S,from:a,to:m,queued:null}}getMorphValuesForProxy(x){if(!(x in this.operations))return null;const a=this.operations[x];return{from:a.from,to:a.to,phase:a.phase}}update(x){for(const a in this.operations){const m=this.operations[a];for(m.phase=(x-m.startTime)/m.duration;m.phase>=1||!this._validOp(m);)if(!this._nextOp(m,x)){delete this.operations[a];break}}}_nextOp(x,a){return!!x.queued&&(x.from=x.to,x.to=x.queued,x.queued=null,x.phase=0,x.startTime=a,!0)}_validOp(x){return x.from.hasData()&&x.to.hasData()}},Br={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function jr(x,a){const m=1<({u_matrix:x});function Hl(x,a,m,b,S){if(S>0){const P=i.exported.now(),H=(P-x.timeAdded)/S,W=a?(P-a.timeAdded)/S:-1,ee=m.getSource(),pe=b.coveringZoomLevel({tileSize:ee.tileSize,roundZoom:ee.roundZoom}),fe=!a||Math.abs(a.tileID.overscaledZ-pe)>Math.abs(x.tileID.overscaledZ-pe),Me=fe&&x.refreshedUponExpiration?1:i.clamp(fe?H:1-W,0,1);return x.refreshedUponExpiration&&H>=1&&(x.refreshedUponExpiration=!1),a?{opacity:1,mix:1-Me}:{opacity:Me,mix:0}}return{opacity:1,mix:0}}class gr extends i.SourceCache{constructor(a){const m={type:"raster-dem",maxzoom:a.transform.maxZoom},b=new Ke(jt(),null),S=ie("mock-dem",m,b,a.style);super("mock-dem",S,!1),S.setEventedParent(this),this._sourceLoaded=!0}_loadTile(a,m){a.state="loaded",m(null)}}class xu extends i.SourceCache{constructor(a){const m=ie("proxy",{type:"geojson",maxzoom:a.transform.maxZoom},new Ke(jt(),null),a.style);super("proxy",m,!1),m.setEventedParent(this),this.map=this.getSource().map=a,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(a,m,b){if(a.freezeTileCoverage)return;this.transform=a;const S=a.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((P,H)=>{if(P[H.key]="",!this._tiles[H.key]){const W=new i.Tile(H,this._source.tileSize*H.overscaleFactor(),a.tileZoom);W.state="loaded",this._tiles[H.key]=W}return P},{});for(const P in this._tiles)P in S||(this.freeFBO(P),this._tiles[P].unloadVectorData(),delete this._tiles[P])}freeFBO(a){const m=this.proxyCachedFBO[a];if(m!==void 0){const b=Object.values(m);this.renderCachePool.push(...b),delete this.proxyCachedFBO[a]}}deallocRenderCache(){this.renderCache.forEach(a=>a.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class iA extends i.OverscaledTileID{constructor(a,m,b){super(a.overscaledZ,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y),this.proxyTileKey=m,this.projMatrix=b}}class nA extends i.Elevation{constructor(a,m){super(),this.painter=a,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[b,S,P]=function(ee){const pe=new i.StructArrayLayout4i8,fe=new i.StructArrayLayout3ui6,Me=131;pe.reserve(17161),fe.reserve(33800);const Ne=i.EXTENT/128,st=i.EXTENT+Ne/2,it=st+Ne;for(let qe=-Ne;qest||qe<0||qe>st?24575:0,ht=i.clamp(Math.round(Ye),0,i.EXTENT),Bt=i.clamp(Math.round(qe),0,i.EXTENT);pe.emplaceBack(ht+dt,Bt,ht,Bt)}const lt=(qe,Ye)=>{const dt=Ye*Me+qe;fe.emplaceBack(dt+1,dt,dt+Me),fe.emplaceBack(dt+Me,dt+Me+1,dt+1)};for(let qe=1;qe<129;qe++)for(let Ye=1;Ye<129;Ye++)lt(Ye,qe);return[0,129].forEach(qe=>{for(let Ye=0;Ye<130;Ye++)lt(Ye,qe),lt(qe,Ye)}),[pe,fe,32768]}(),H=a.context;this.gridBuffer=H.createVertexBuffer(b,i.boundsAttributes.members),this.gridIndexBuffer=H.createIndexBuffer(S),this.gridSegments=i.SegmentVector.simpleSegment(0,0,b.length,S.length),this.gridNoSkirtSegments=i.SegmentVector.simpleSegment(0,0,b.length,P),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new xu(m.map),this.orthoMatrix=i.create(),i.ortho(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,i.EXTENT,0,i.EXTENT,0,1);const W=H.gl;this._overlapStencilMode=new i.StencilMode({func:W.GEQUAL,mask:255},0,255,W.KEEP,W.KEEP,W.REPLACE),this._previousZoom=a.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=m,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new gr(m.map)}set style(a){a.on("data",this._onStyleDataEvent.bind(this)),a.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=a,this._checkRenderCacheEfficiency()}update(a,m,b){if(a&&a.terrain){this._style!==a&&(this.style=a),this.enabled=!0;const S=a.terrain.properties;this.sourceCache=a.terrain.drapeRenderMode===0?this._mockSourceCache:a._getSourceCache(S.get("source")),this._exaggeration=S.get("exaggeration");const P=()=>{this.sourceCache.used&&i.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source. This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const H=this.getScaledDemTileSize();this.sourceCache.update(m,H,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,P(),this._initializing=!0),P(),m.updateElevation(!0,b),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(m),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(a){this._findCoveringTileCache[a]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const a=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||a.efficiency!==100&&i.warnOnce(`Terrain render cache efficiency is not optimal (${a.efficiency}%) and performance may be affected negatively, consider placing all background, fill and line layers before layer with id '${a.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(a){a.coord&&a.dataType==="source"?this._clearRenderCacheForTile(a.sourceCacheId,a.coord):a.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const a in this._style._sourceCaches)this._style._sourceCaches[a].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(a=>a.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const a=2*this.proxySourceCache.getSource().tileSize;return[a,a]}set useVertexMorphing(a){this._useVertexMorphing=a}updateTileBinding(a){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const m=this.proxySourceCache,b=this.painter.transform;this._initializing&&(this._initializing=b._centerAltitude===0&&this.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(b.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const S=this.proxyCoords=m.getIds().map(ee=>{const pe=m.getTileByID(ee).tileID;return pe.projMatrix=b.calculateProjMatrix(pe.toUnwrapped()),pe});(function(ee,pe){const fe=pe.transform.pointCoordinate(pe.transform.getCameraPoint()),Me=new i.pointGeometry(fe.x,fe.y);ee.sort((Ne,st)=>{if(st.overscaledZ-Ne.overscaledZ)return st.overscaledZ-Ne.overscaledZ;const it=new i.pointGeometry(Ne.canonical.x+(1<{this.proxyToSource[ee.key]={}}),this.terrainTileForTile={};const H=this._style._sourceCaches;for(const ee in H){const pe=H[ee];if(!pe.used||(pe!==this.sourceCache&&this.resetTileLookupCache(pe.id),this._setupProxiedCoordsForOrtho(pe,a[ee],P),pe.usedForTerrain))continue;const fe=a[ee];pe.getSource().reparseOverscaled&&this._assignTerrainTiles(fe)}this.proxiedCoords[m.id]=S.map(ee=>new iA(ee,ee.key,this.orthoMatrix)),this._assignTerrainTiles(S),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(P),this.renderingToTexture=!1,this._updateTimestamp=i.exported.now();const W={};this._visibleDemTiles=[];for(const ee of this.proxyCoords){const pe=this.terrainTileForTile[ee.key];if(!pe)continue;const fe=pe.tileID.key;fe in W||(this._visibleDemTiles.push(pe),W[fe]=fe)}}_assignTerrainTiles(a){this._initializing||a.forEach(m=>{if(this.terrainTileForTile[m.key])return;const b=this._findTileCoveringTileID(m,this.sourceCache);b&&(this.terrainTileForTile[m.key]=b)})}_prepareDEMTextures(){const a=this.painter.context,m=a.gl;for(const b in this.terrainTileForTile){const S=this.terrainTileForTile[b],P=S.dem;!P||S.demTexture&&!S.needsDEMTextureUpload||(a.activeTexture.set(m.TEXTURE1),Al(this.painter,S,P))}}_prepareDemTileUniforms(a,m,b,S){if(!m||m.demTexture==null)return!1;const P=a.tileID.canonical,H=Math.pow(2,m.tileID.canonical.z-P.z),W=S||"";return b[`u_dem_tl${W}`]=[P.x*H%1,P.y*H%1],b[`u_dem_scale${W}`]=H,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const a=this.painter.context,m=a.gl;if(!this._emptyDepthBufferTexture){const b=new i.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new i.Texture(a,b,m.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let a=0;const m=this._visibleDemTiles.reduce((b,S)=>{if(!S.dem)return b;const P=S.dem.tree.minimums[0];return P>0&&a++,b+P},0);return a?m/a:0}_updateEmptyDEMTexture(){const a=this.painter.context,m=a.gl;a.activeTexture.set(m.TEXTURE2);const b=this._getLoadedAreaMinimum(),S=new i.RGBAImage({width:1,height:1},new Uint8Array(i.DEMData.pack(b,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let P=this._emptyDEMTexture;return P?P.update(S,{premultiply:!1}):P=this._emptyDEMTexture=new i.Texture(a,S,m.RGBA,{premultiply:!1}),P}setupElevationDraw(a,m,b){const S=this.painter.context,P=S.gl,H=(W=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:i.DEMData.getUnpackVector(W),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var W;H.u_dem_size=this.sourceCache.getSource().tileSize,H.u_exaggeration=this.exaggeration();let ee=null,pe=null,fe=1;if(b&&b.morphing&&this._useVertexMorphing){const Me=b.morphing.srcDemTile,Ne=b.morphing.dstDemTile;fe=b.morphing.phase,Me&&Ne&&(this._prepareDemTileUniforms(a,Me,H,"_prev")&&(pe=Me),this._prepareDemTileUniforms(a,Ne,H)&&(ee=Ne))}if(pe&&ee?(S.activeTexture.set(P.TEXTURE2),ee.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE,P.NEAREST),S.activeTexture.set(P.TEXTURE4),pe.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE,P.NEAREST),H.u_dem_lerp=fe):(ee=this.terrainTileForTile[a.tileID.key],S.activeTexture.set(P.TEXTURE2),(this._prepareDemTileUniforms(a,ee,H)?ee.demTexture:this.emptyDEMTexture).bind(P.NEAREST,P.CLAMP_TO_EDGE)),S.activeTexture.set(P.TEXTURE3),b&&b.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE),this._depthFBO&&(H.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE),H.u_depth_size_inv=[1,1]),b&&b.useMeterToDem&&ee){const Me=(1<{if(Ye===Ri)return;const Mi=[Br[Ri],"PROJECTION_GLOBE_VIEW"];Bt&&Mi.push("CUSTOM_ANTIALIASING"),Ai&&Mi.push(Br[dt]),qe=pe.useProgram("globeRaster",null,Mi),Ye=Ri},It=pe.colorModeForRenderPass(),Ht=new i.DepthMode(lt.LEQUAL,i.DepthMode.ReadWrite,pe.depthRangeFor3D);hr.update(st);const hi=i.calculateGlobeMercatorMatrix(ht),si=[i.mercatorXfromLng(ht.center.lng),i.mercatorYfromLat(ht.center.lat)],qt=dt?[!1,!0]:[!1],ji=pe.globeSharedBuffers,Kt=[ht.width*i.exported.devicePixelRatio,ht.height*i.exported.devicePixelRatio],Ci=Float32Array.from(ht.globeMatrix),di={useDenormalizedUpVectorScale:!0};if(qt.forEach(Ri=>{Ye=-1;const Ai=Ri?lt.LINES:lt.TRIANGLES;for(const Mi of Ne){const $i=Me.getTile(Mi),Jt=i.StencilMode.disabled,pi=fe.prevTerrainTileForTile[Mi.key],In=fe.terrainTileForTile[Mi.key];Fh(pi,In)&&hr.newMorphing(Mi.key,pi,In,st,250),it.activeTexture.set(lt.TEXTURE0),$i.texture.bind(lt.LINEAR,lt.CLAMP_TO_EDGE);const Hn=hr.getMorphValuesForProxy(Mi.key),Mn=Hn?1:0;Hn&&i.extend$1(di,{morphing:{srcDemTile:Hn.from,dstDemTile:Hn.to,phase:i.easeCubicInOut(Hn.phase)}});const $n=i.tileCornersToBounds(Mi.canonical),lr=i.getLatitudinalLod($n.getCenter().lat),On=i.getGridMatrix(Mi.canonical,$n,lr,ht.worldSize/ht._pixelsPerMercatorPixel),_n=i.globeNormalizeECEF(i.globeTileBounds(Mi.canonical)),Dr=qr(ht.projMatrix,Ci,hi,_n,i.globeToMercatorTransition(ht.zoom),si,ht.frustumCorners.TL,ht.frustumCorners.TR,ht.frustumCorners.BR,ht.frustumCorners.BL,ht.globeCenterInViewSpace,ht.globeRadius,Kt,On);if(Pt(Mn,Ri),fe.setupElevationDraw($i,qe,di),pe.prepareDrawProgram(it,qe,Mi.toUnwrapped()),ji){const[Or,Nr,Qr]=Ri?ji.getWirefameBuffers(pe.context,lr):ji.getGridBuffers(lr);qe.draw(it,Ai,Ht,Jt,It,i.CullFaceMode.backCCW,Dr,"globe_raster",Or,Nr,Qr)}}}),ji){const Ri=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Bt&&Ri.push("CUSTOM_ANTIALIASING"),qe=pe.useProgram("globeRaster",null,Ri);for(const Ai of Ne){const{x:Mi,y:$i,z:Jt}=Ai.canonical,pi=$i===0,In=$i===(1<Nr.draw(it,lt.TRIANGLES,Ht,i.StencilMode.disabled,It,i.CullFaceMode.disabled,qr(ht.projMatrix,_n,_n,Dr,0,si,ht.frustumCorners.TL,ht.frustumCorners.TR,ht.frustumCorners.BR,ht.frustumCorners.BL,ht.globeCenterInViewSpace,ht.globeRadius,Kt),"globe_pole_raster",Qr,$n,lr);fe.setupElevationDraw(On,qe,di),pe.prepareDrawProgram(it,qe,Ai.toUnwrapped()),pi&&Or(qe,Hn),In&&(_n=i.scale(i.create(),_n,[1,-1,1]),Or(qe,Mn))}}}})(S,P,H,W,ee);else{const pe=S.context,fe=pe.gl;let Me,Ne;const st=S.options.showTerrainWireframe?2:0,it=(ht,Bt)=>{if(Ne===ht)return;const Pt=[Br[ht]];Bt&&Pt.push(Br[st]),Me=S.useProgram("terrainRaster",null,Pt),Ne=ht},lt=S.colorModeForRenderPass(),qe=new i.DepthMode(fe.LEQUAL,i.DepthMode.ReadWrite,S.depthRangeFor3D);hr.update(ee);const Ye=S.transform,dt=6*Math.pow(1.5,22-Ye.zoom)*P.exaggeration();(st?[!1,!0]:[!1]).forEach(ht=>{Ne=-1;const Bt=ht?fe.LINES:fe.TRIANGLES,[Pt,It]=ht?P.getWirefameBuffer():[P.gridIndexBuffer,P.gridSegments];for(const Ht of W){const hi=H.getTile(Ht),si=i.StencilMode.disabled,qt=P.prevTerrainTileForTile[Ht.key],ji=P.terrainTileForTile[Ht.key];Fh(qt,ji)&&hr.newMorphing(Ht.key,qt,ji,ee,250),pe.activeTexture.set(fe.TEXTURE0),hi.texture.bind(fe.LINEAR,fe.CLAMP_TO_EDGE,fe.LINEAR_MIPMAP_NEAREST);const Kt=hr.getMorphValuesForProxy(Ht.key),Ci=Kt?1:0;let di;Kt&&(di={morphing:{srcDemTile:Kt.from,dstDemTile:Kt.to,phase:i.easeCubicInOut(Kt.phase)}});const Ri=dl(Ht.projMatrix,jr(Ht.canonical,Ye.renderWorldCopies)?dt/10:dt);it(Ci,ht),P.setupElevationDraw(hi,Me,di),S.prepareDrawProgram(pe,Me,Ht.toUnwrapped()),Me.draw(pe,Bt,qe,si,lt,i.CullFaceMode.backCCW,Ri,"terrain_raster",P.gridBuffer,Pt,It)}})}}(m,this,this.proxySourceCache,a,this._updateTimestamp),this.renderingToTexture=!0,m.gpuTimingDeferredRenderEnd(),a.splice(0,a.length))}renderBatch(a){if(this._drapedRenderBatches.length===0)return a+1;this.renderingToTexture=!0;const m=this.painter,b=this.painter.context,S=this.proxySourceCache,P=this.proxiedCoords[S.id],H=this._drapedRenderBatches.shift(),W=[],ee=m.style.order;let pe=0;for(const fe of P){const Me=S.getTileByID(fe.proxyTileKey),Ne=S.proxyCachedFBO[fe.key]?S.proxyCachedFBO[fe.key][a]:void 0,st=Ne!==void 0?S.renderCache[Ne]:this.pool[pe++],it=Ne!==void 0;if(Me.texture=st.tex,it&&!st.dirty){W.push(Me.tileID);continue}let lt;b.bindFramebuffer.set(st.fb.framebuffer),this.renderedToTile=!1,st.dirty&&(b.clear({color:i.Color.transparent,stencil:0}),st.dirty=!1);for(let qe=H.start;qe<=H.end;++qe){const Ye=m.style._layers[ee[qe]];if(Ye.isHidden(m.transform.zoom))continue;const dt=m.style._getLayerSourceCache(Ye),ht=dt?this.proxyToSource[fe.key][dt.id]:[fe];if(!ht)continue;const Bt=ht;b.viewport.set([0,0,st.fb.width,st.fb.height]),lt!==(dt?dt.id:null)&&(this._setupStencil(st,ht,Ye,dt),lt=dt?dt.id:null),m.renderLayer(m,dt,Ye,Bt)}this.renderedToTile?(st.dirty=!0,W.push(Me.tileID)):it||--pe,pe===5&&(pe=0,this.renderToBackBuffer(W))}return this.renderToBackBuffer(W),this.renderingToTexture=!1,b.bindFramebuffer.set(null),b.viewport.set([0,0,m.width,m.height]),H.end+1}postRender(){}renderCacheEfficiency(a){const m=a.order.length;if(m===0)return{efficiency:100};let b,S=0,P=0,H=!1;for(let W=0;Wm.dem).forEach(m=>{a=Math.min(a,m.dem.tree.minimums[0])}),a===0?a:(a-30)*this._exaggeration}raycast(a,m,b){if(!this._visibleDemTiles)return null;const S=this._visibleDemTiles.filter(P=>P.dem).map(P=>{const H=P.tileID,W=1<(P.t!==null?P.t:Number.MAX_VALUE)-(H.t!==null?H.t:Number.MAX_VALUE));for(const P of S){if(P.t==null)return null;const H=P.tile.dem.tree.raycast(P.minx,P.miny,P.maxx,P.maxy,a,m,b);if(H!=null)return H}return null}_createFBO(){const a=this.painter.context,m=a.gl,b=this.drapeBufferSize;a.activeTexture.set(m.TEXTURE0);const S=new i.Texture(a,{width:b[0],height:b[1],data:null},m.RGBA);S.bind(m.LINEAR,m.CLAMP_TO_EDGE);const P=a.createFramebuffer(b[0],b[1],!1);return P.colorAttachment.set(S.texture),P.depthAttachment=new Rs(a,P.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=a.createRenderbuffer(a.gl.DEPTH_STENCIL,b[0],b[1]),this._stencilRef=0,P.depthAttachment.set(this._sharedDepthStencil),a.clear({stencil:0})):P.depthAttachment.set(this._sharedDepthStencil),a.extTextureFilterAnisotropic&&!a.extTextureFilterAnisotropicForceOff&&m.texParameterf(m.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax),{fb:P,tex:S,dirty:!1}}_initFBOPool(){for(;this.pool.length{const m=this._style._layers[a],b=m.isHidden(this.painter.transform.zoom);return m.type!=="custom"&&!b&&m.hasTransition()})}_clearRasterFadeFromRenderCache(){let a=!1;for(const m in this._style._sourceCaches)if(this._style._sourceCaches[m]._source instanceof Pe){a=!0;break}if(a)for(let m=0;mm.renderCachePool.length){const H=Object.values(m.proxyCachedFBO);m.proxyCachedFBO={};for(let W=0;W=0;H--){const W=b[H];if(m.getTileByID(W.key),m.proxyCachedFBO[W.key]!==void 0){const ee=a[W.key],pe=this.proxyToSource[W.key];let fe=0;for(const Me in pe){const Ne=pe[Me],st=ee[Me];if(!st||st.length!==Ne.length||Ne.some((it,lt)=>it!==st[lt]||S[Me]&&S[Me].hasOwnProperty(it.key))){fe=-1;break}++fe}for(const Me in m.proxyCachedFBO[W.key])m.renderCache[m.proxyCachedFBO[W.key][Me]].dirty=fe<0||fe!==Object.values(ee).length}}const P=[...this._drapedRenderBatches];P.sort((H,W)=>W.end-W.start-(H.end-H.start));for(const H of P)for(const W of b){if(m.proxyCachedFBO[W.key])continue;let ee=m.renderCachePool.pop();ee===void 0&&m.renderCache.length<50&&(ee=m.renderCache.length,m.renderCache.push(this._createFBO())),ee!==void 0&&(m.proxyCachedFBO[W.key]={},m.proxyCachedFBO[W.key][H.start]=ee,m.renderCache[ee].dirty=!0)}this._tilesDirty={}}_setupStencil(a,m,b,S){if(!S||!this._sourceTilesOverlap[S.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const P=this.painter.context,H=P.gl;if(m.length<=1)return void(this._overlapStencilType=!1);let W;if(b.isTileClipped())W=m.length,this._overlapStencilMode.test={func:H.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(m[0].overscaledZ>m[m.length-1].overscaledZ))return void(this._overlapStencilType=!1);W=1,this._overlapStencilMode.test={func:H.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+W>255&&(P.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=W,this._overlapStencilMode.ref=this._stencilRef,b.isTileClipped()&&this._renderTileClippingMasks(m,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(a){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[a.key]),this._overlapStencilMode):i.StencilMode.disabled}_renderTileClippingMasks(a,m){const b=this.painter,S=this.painter.context,P=S.gl;b._tileClippingMaskIDs={},S.setColorMode(i.ColorMode.disabled),S.setDepthMode(i.DepthMode.disabled);const H=b.useProgram("clippingMask");for(const W of a){const ee=b._tileClippingMaskIDs[W.key]=--m;H.draw(S,P.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:P.ALWAYS,mask:0},ee,255,P.KEEP,P.KEEP,P.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,$r(W.projMatrix),"$clipping",b.tileExtentBuffer,b.quadTriangleIndexBuffer,b.tileExtentSegments)}}pointCoordinate(a){const m=this.painter.transform;if(a.x<0||a.x>m.width||a.y<0||a.y>m.height)return null;const b=[a.x,a.y,1,1];i.transformMat4$1(b,b,m.pixelMatrixInverse),i.scale$1(b,b,1/b[3]),b[0]/=m.worldSize,b[1]/=m.worldSize;const S=m._camera.position,P=i.mercatorZfromAltitude(1,m.center.lat),H=[S[0],S[1],S[2]/P,0],W=i.subtract([],b.slice(0,3),H);i.normalize(W,W);const ee=this.raycast(H,W,this._exaggeration);return ee!==null&&ee?(i.scaleAndAdd(H,H,W,ee),H[3]=H[2],H[2]*=P,H):null}drawDepth(){const a=this.painter,m=a.context,b=this.proxySourceCache,S=Math.ceil(a.width),P=Math.ceil(a.height);if(!this._depthFBO||this._depthFBO.width===S&&this._depthFBO.height===P||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const H=m.gl,W=m.createFramebuffer(S,P,!0);m.activeTexture.set(H.TEXTURE0);const ee=new i.Texture(m,{width:S,height:P,data:null},H.RGBA);ee.bind(H.NEAREST,H.CLAMP_TO_EDGE),W.colorAttachment.set(ee.texture);const pe=m.createRenderbuffer(m.gl.DEPTH_COMPONENT16,S,P);W.depthAttachment.set(pe),this._depthFBO=W,this._depthTexture=ee}m.bindFramebuffer.set(this._depthFBO.framebuffer),m.viewport.set([0,0,S,P]),function(H,W,ee,pe){if(H.transform.projection.name==="globe")return;const fe=H.context,Me=fe.gl;fe.clear({depth:1});const Ne=H.useProgram("terrainDepth"),st=new i.DepthMode(Me.LESS,i.DepthMode.ReadWrite,H.depthRangeFor3D);for(const it of pe){const lt=ee.getTile(it),qe=dl(it.projMatrix,0);W.setupElevationDraw(lt,Ne),Ne.draw(fe,Me.TRIANGLES,st,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.backCCW,qe,"terrain_depth",W.gridBuffer,W.gridIndexBuffer,W.gridNoSkirtSegments)}}(a,this,b,this.proxyCoords)}_setupProxiedCoordsForOrtho(a,m,b){if(a.getSource()instanceof X)return this._setupProxiedCoordsForImageSource(a,m,b);this._findCoveringTileCache[a.id]=this._findCoveringTileCache[a.id]||{};const S=this.proxiedCoords[a.id]=[],P=this.proxyCoords;for(let W=0;W(fe.min.x=Math.min(fe.min.x,Me.x-W.x),fe.min.y=Math.min(fe.min.y,Me.y-W.y),fe.max.x=Math.max(fe.max.x,Me.x-W.x),fe.max.y=Math.max(fe.max.y,Me.y-W.y),fe),{min:new i.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),pe=(fe,Me)=>{const Ne=fe.wrap+fe.canonical.x/(1<lt+ee.max.x||st+itqe+ee.max.y};for(let fe=0;feH.key===m.tileID.key);if(P)return P}if(m.tileID.key!==a.key){const P=a.canonical.z-m.tileID.canonical.z;let H,W,ee;S=i.create();const pe=m.tileID.wrap-a.wrap<0?(H=i.EXTENT>>P,W=H*((m.tileID.canonical.x<=Me){const Ne=a.canonical.z-Me;m.getSource().reparseOverscaled?(W=Math.max(a.canonical.z+2,m.transform.tileZoom),H=new i.OverscaledTileID(W,a.wrap,Me,a.canonical.x>>Ne,a.canonical.y>>Ne)):Ne!==0&&(W=Me,H=new i.OverscaledTileID(W,a.wrap,Me,a.canonical.x>>Ne,a.canonical.y>>Ne))}H.key!==a.key&&(pe.push(H.key),b=m.getTile(H))}const fe=Me=>{pe.forEach(Ne=>{S[Ne]=Me}),pe.length=0};for(W-=1;W>=ee&&(!b||!b.hasData());W--){b&&fe(b.tileID.key);const Me=H.calculateScaledKey(W);if(b=m.getTileByID(Me),b&&b.hasData())break;const Ne=S[Me];if(Ne===null)break;Ne===void 0?pe.push(Me):b=m.getTileByID(Ne)}return fe(b?b.tileID.key:null),b&&b.hasData()?b:null}findDEMTileFor(a){return this.enabled?this._findTileCoveringTileID(a,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(a,m){let b=this._tilesDirty[a];b||(b=this._tilesDirty[a]={}),b[m.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const a=function(m){let b=0;const S=new i.StructArrayLayout2ui4,P=131;for(let H=1;H<129;H++){for(let W=1;W<129;W++)b=H*P+W,S.emplaceBack(b,b+1),S.emplaceBack(b,b+P),S.emplaceBack(b+1,b+P),H===128&&S.emplaceBack(b+P,b+P+1);S.emplaceBack(b+1,b+1+P)}return S}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(a),this.wireframeSegments=i.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,a.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class rA{static cacheKey(a,m,b,S){let P=`${m}${S?S.cacheKey:""}`;for(const H of b)a.usedDefines.includes(H)&&(P+=`/${H}`);return P}constructor(a,m,b,S,P,H){const W=a.gl;this.program=W.createProgram();const ee=function(qe){const Ye=[];for(let dt=0;dt`#define ${qe}`));const Ne=Me.concat(a.extStandardDerivatives?`#extension GL_OES_standard_derivatives : enable `.concat(uc):uc,uc,td,tA.fragmentSource,_u.fragmentSource,b.fragmentSource).join(` `),st=Me.concat(` #ifdef GL_ES precision highp float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif`,td,tA.vertexSource,_u.vertexSource,ed.vertexSource,b.vertexSource).join(` `),it=W.createShader(W.FRAGMENT_SHADER);if(W.isContextLost())return void(this.failedToCreate=!0);W.shaderSource(it,Ne),W.compileShader(it),W.attachShader(this.program,it);const lt=W.createShader(W.VERTEX_SHADER);if(W.isContextLost())this.failedToCreate=!0;else{W.shaderSource(lt,st),W.compileShader(lt),W.attachShader(this.program,lt),this.attributes={},this.numAttributes=fe.length;for(let qe=0;qe({u_dem:new i.Uniform1i(qe),u_dem_prev:new i.Uniform1i(qe),u_dem_unpack:new i.Uniform4f(qe),u_dem_tl:new i.Uniform2f(qe),u_dem_scale:new i.Uniform1f(qe),u_dem_tl_prev:new i.Uniform2f(qe),u_dem_scale_prev:new i.Uniform1f(qe),u_dem_size:new i.Uniform1f(qe),u_dem_lerp:new i.Uniform1f(qe),u_exaggeration:new i.Uniform1f(qe),u_depth:new i.Uniform1i(qe),u_depth_size_inv:new i.Uniform2f(qe),u_meter_to_dem:new i.Uniform1f(qe),u_label_plane_matrix_inv:new i.UniformMatrix4f(qe)}))(a)),H.includes("GLOBE")&&(this.globeUniforms=(qe=>({u_tile_tl_up:new i.Uniform3f(qe),u_tile_tr_up:new i.Uniform3f(qe),u_tile_br_up:new i.Uniform3f(qe),u_tile_bl_up:new i.Uniform3f(qe),u_tile_up_scale:new i.Uniform1f(qe)}))(a)),H.includes("FOG")&&(this.fogUniforms=(qe=>({u_fog_matrix:new i.UniformMatrix4f(qe),u_fog_range:new i.Uniform2f(qe),u_fog_color:new i.Uniform4f(qe),u_fog_horizon_blend:new i.Uniform1f(qe),u_fog_temporal_offset:new i.Uniform1f(qe),u_frustum_tl:new i.Uniform3f(qe),u_frustum_tr:new i.Uniform3f(qe),u_frustum_br:new i.Uniform3f(qe),u_frustum_bl:new i.Uniform3f(qe),u_globe_pos:new i.Uniform3f(qe),u_globe_radius:new i.Uniform1f(qe),u_globe_transition:new i.Uniform1f(qe),u_is_globe:new i.Uniform1i(qe),u_viewport:new i.Uniform2f(qe)}))(a))}}setTerrainUniformValues(a,m){if(!this.terrainUniforms)return;const b=this.terrainUniforms;if(!this.failedToCreate){a.program.set(this.program);for(const S in m)b[S]&&b[S].set(this.program,S,m[S])}}setGlobeUniformValues(a,m){if(!this.globeUniforms)return;const b=this.globeUniforms;if(!this.failedToCreate){a.program.set(this.program);for(const S in m)b[S]&&b[S].set(this.program,S,m[S])}}setFogUniformValues(a,m){if(!this.fogUniforms)return;const b=this.fogUniforms;if(!this.failedToCreate){a.program.set(this.program);for(const S in m)b[S].set(this.program,S,m[S])}}draw(a,m,b,S,P,H,W,ee,pe,fe,Me,Ne,st,it,lt){const qe=a.gl;if(this.failedToCreate)return;a.program.set(this.program),a.setDepthMode(b),a.setStencilMode(S),a.setColorMode(P),a.setCullFace(H);for(const dt of Object.keys(this.fixedUniforms))this.fixedUniforms[dt].set(this.program,dt,W[dt]);it&&it.setUniforms(this.program,a,this.binderUniforms,Ne,{zoom:st});const Ye={[qe.LINES]:2,[qe.TRIANGLES]:3,[qe.LINE_STRIP]:1}[m];for(const dt of Me.get()){const ht=dt.vaos||(dt.vaos={});(ht[ee]||(ht[ee]=new Ac)).bind(a,this,pe,it?it.getPaintVertexBuffers():[],fe,dt.vertexOffset,lt||[]),qe.drawElements(m,dt.primitiveLength*Ye,qe.UNSIGNED_SHORT,dt.primitiveOffset*Ye*2)}}}function dc(x,a){const m=Math.pow(2,a.tileID.overscaledZ),b=a.tileSize*Math.pow(2,x.transform.tileZoom)/m,S=b*(a.tileID.canonical.x+a.tileID.wrap*m),P=b*a.tileID.canonical.y;return{u_image:0,u_texsize:a.imageAtlasTexture.size,u_tile_units_to_pixels:1/nt(a,1,x.transform.tileZoom),u_pixel_coord_upper:[S>>16,P>>16],u_pixel_coord_lower:[65535&S,65535&P]}}const Vc=i.create(),Hc=(x,a,m,b,S,P,H,W,ee,pe,fe)=>{const Me=a.style.light,Ne=Me.properties.get("position"),st=[Ne.x,Ne.y,Ne.z],it=i.create$1();Me.properties.get("anchor")==="viewport"&&(i.fromRotation(it,-a.transform.angle),i.transformMat3(st,st,it));const lt=Me.properties.get("color"),qe=a.transform,Ye={u_matrix:x,u_lightpos:st,u_lightintensity:Me.properties.get("intensity"),u_lightcolor:[lt.r,lt.g,lt.b],u_vertical_gradient:+m,u_opacity:b,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Vc,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:S,u_edge_radius:P};return qe.projection.name==="globe"&&(Ye.u_tile_id=[H.canonical.x,H.canonical.y,1<{const Ne=Hc(x,a,m,b,S,P,H,ee,pe,fe,Me),st={u_height_factor:-Math.pow(2,H.overscaledZ)/W.tileSize/8};return i.extend(Ne,dc(a,W),st)},Gc=x=>({u_matrix:x}),Dh=(x,a,m)=>i.extend(Gc(x),dc(a,m)),Wc=(x,a)=>({u_matrix:x,u_world:a}),jc=(x,a,m,b)=>i.extend(Dh(x,a,m),{u_world:b}),la=i.create(),sA=(x,a,m,b,S,P)=>{const H=x.transform,W=H.projection.name==="globe";let ee;if(P.paint.get("circle-pitch-alignment")==="map")if(W){const fe=i.globePixelsToTileUnits(H.zoom,a.canonical)*H._pixelsPerMercatorPixel;ee=Float32Array.from([fe,0,0,fe])}else ee=H.calculatePixelsToTileUnitsMatrix(m);else ee=new Float32Array([H.pixelsToGLUnits[0],0,0,H.pixelsToGLUnits[1]]);const pe={u_camera_to_center_distance:H.cameraToCenterDistance,u_matrix:x.translatePosMatrix(a.projMatrix,m,P.paint.get("circle-translate"),P.paint.get("circle-translate-anchor")),u_device_pixel_ratio:i.exported.devicePixelRatio,u_extrude_scale:ee,u_inv_rot_matrix:la,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(W){pe.u_inv_rot_matrix=b,pe.u_merc_center=S,pe.u_tile_id=[a.canonical.x,a.canonical.y,1<{const a=[];return x.paint.get("circle-pitch-alignment")==="map"&&a.push("PITCH_WITH_MAP"),x.paint.get("circle-pitch-scale")==="map"&&a.push("SCALE_WITH_MAP"),a},Kc=(x,a,m,b)=>{const S=i.EXTENT/m.tileSize;return{u_matrix:x,u_camera_to_center_distance:a.getCameraToCenterDistance(b),u_extrude_scale:[a.pixelsToGLUnits[0]/S,a.pixelsToGLUnits[1]/S]}},ca=(x,a,m=1)=>({u_matrix:x,u_color:a,u_overlay:0,u_overlay_scale:m}),$c=i.create(),pl=(x,a,m,b,S,P,H)=>{const W=x.transform,ee=W.projection.name==="globe",pe=ee?i.globePixelsToTileUnits(W.zoom,a.canonical)*W._pixelsPerMercatorPixel:nt(m,1,P),fe={u_matrix:a.projMatrix,u_extrude_scale:pe,u_intensity:H,u_inv_rot_matrix:$c,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(ee){fe.u_inv_rot_matrix=b,fe.u_merc_center=S,fe.u_tile_id=[a.canonical.x,a.canonical.y,1<{const W=x.transform,ee=W.calculatePixelsToTileUnitsMatrix(a);return{u_matrix:vu(x,a,m,b),u_pixels_to_tile_units:ee,u_device_pixel_ratio:P,u_units_to_pixels:[1/W.pixelsToGLUnits[0],1/W.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:S,u_texsize:Gl(m)?a.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Ph(a,x.transform),u_alpha_discard_threshold:0,u_trim_offset:H}},Ho=(x,a,m,b,S)=>{const P=x.transform;return{u_matrix:vu(x,a,m,b),u_texsize:a.imageAtlasTexture.size,u_pixels_to_tile_units:P.calculatePixelsToTileUnitsMatrix(a),u_device_pixel_ratio:S,u_image:0,u_tile_units_to_pixels:Ph(a,P),u_units_to_pixels:[1/P.pixelsToGLUnits[0],1/P.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Ph(x,a){return 1/nt(x,1,a.tileZoom)}function vu(x,a,m,b){return x.translatePosMatrix(b||a.tileID.projMatrix,a,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}function Gl(x){const a=x.paint.get("line-dasharray").value;return a.value||a.kind!=="constant"}const wu=(x,a,m,b,S,P)=>{return{u_matrix:x,u_tl_parent:a,u_scale_parent:m,u_fade_t:b.mix,u_opacity:b.opacity*S.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:S.paint.get("raster-brightness-min"),u_brightness_high:S.paint.get("raster-brightness-max"),u_saturation_factor:(W=S.paint.get("raster-saturation"),W>0?1-1/(1.001-W):-W),u_contrast_factor:(H=S.paint.get("raster-contrast"),H>0?1/(1-H):1+H),u_spin_weights:Zc(S.paint.get("raster-hue-rotate")),u_perspective_transform:P};var H,W};function Zc(x){x*=Math.PI/180;const a=Math.sin(x),m=Math.cos(x);return[(2*m+1)/3,(-Math.sqrt(3)*a-m+1)/3,(Math.sqrt(3)*a-m+1)/3]}const Xc=i.create(),fl=(x,a,m,b,S,P,H,W,ee,pe,fe,Me,Ne,st,it,lt)=>{const qe=S.transform,Ye={u_is_size_zoom_constant:+(x==="constant"||x==="source"),u_is_size_feature_constant:+(x==="constant"||x==="camera"),u_size_t:a?a.uSizeT:0,u_size:a?a.uSize:0,u_camera_to_center_distance:qe.cameraToCenterDistance,u_rotate_symbol:+m,u_aspect_ratio:qe.width/qe.height,u_fade_change:S.options.fadeDuration?S.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:H,u_coord_matrix:W,u_is_text:+ee,u_pitch_with_map:+b,u_texsize:pe,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Xc,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Xc,u_up_vector:[0,-1,0]};return lt.name==="globe"&&(Ye.u_tile_id=[fe.canonical.x,fe.canonical.y,1<i.extend(fl(x,a,m,b,S,P,H,W,ee,pe,Me,Ne,st,it,lt,qe),{u_gamma_scale:b?S.transform.cameraToCenterDistance*Math.cos(S.terrain?0:S.transform._pitch):1,u_device_pixel_ratio:i.exported.devicePixelRatio,u_is_halo:+fe}),Uh=(x,a,m,b,S,P,H,W,ee,pe,fe,Me,Ne,st,it,lt)=>i.extend(qc(x,a,m,b,S,P,H,W,!0,ee,!0,fe,Me,Ne,st,it,lt),{u_texsize_icon:pe,u_texture_icon:1}),Rh=(x,a,m)=>({u_matrix:x,u_opacity:a,u_color:m}),bu=(x,a,m,b,S)=>i.extend(function(P,H,W){const ee=H.imageManager.getPattern(P.toString()),{width:pe,height:fe}=H.imageManager.getPixelSize(),Me=Math.pow(2,W.tileID.overscaledZ),Ne=W.tileSize*Math.pow(2,H.transform.tileZoom)/Me,st=Ne*(W.tileID.canonical.x+W.tileID.wrap*Me),it=Ne*W.tileID.canonical.y;return{u_image:0,u_pattern_tl:ee.tl,u_pattern_br:ee.br,u_texsize:[pe,fe],u_pattern_size:ee.displaySize,u_tile_units_to_pixels:1/nt(W,1,H.transform.tileZoom),u_pixel_coord_upper:[st>>16,it>>16],u_pixel_coord_lower:[65535&st,65535&it]}}(b,m,S),{u_matrix:x,u_opacity:a}),id={fillExtrusion:x=>({u_matrix:new i.UniformMatrix4f(x),u_lightpos:new i.Uniform3f(x),u_lightintensity:new i.Uniform1f(x),u_lightcolor:new i.Uniform3f(x),u_vertical_gradient:new i.Uniform1f(x),u_opacity:new i.Uniform1f(x),u_edge_radius:new i.Uniform1f(x),u_ao:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_up_dir:new i.Uniform3f(x),u_height_lift:new i.Uniform1f(x)}),fillExtrusionPattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_lightpos:new i.Uniform3f(x),u_lightintensity:new i.Uniform1f(x),u_lightcolor:new i.Uniform3f(x),u_vertical_gradient:new i.Uniform1f(x),u_height_factor:new i.Uniform1f(x),u_edge_radius:new i.Uniform1f(x),u_ao:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_up_dir:new i.Uniform3f(x),u_height_lift:new i.Uniform1f(x),u_image:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_pixel_coord_upper:new i.Uniform2f(x),u_pixel_coord_lower:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x),u_opacity:new i.Uniform1f(x)}),fill:x=>({u_matrix:new i.UniformMatrix4f(x)}),fillPattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_image:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_pixel_coord_upper:new i.Uniform2f(x),u_pixel_coord_lower:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x)}),fillOutline:x=>({u_matrix:new i.UniformMatrix4f(x),u_world:new i.Uniform2f(x)}),fillOutlinePattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_world:new i.Uniform2f(x),u_image:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_pixel_coord_upper:new i.Uniform2f(x),u_pixel_coord_lower:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x)}),circle:x=>({u_camera_to_center_distance:new i.Uniform1f(x),u_extrude_scale:new i.UniformMatrix2f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_up_dir:new i.Uniform3f(x)}),collisionBox:x=>({u_matrix:new i.UniformMatrix4f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_extrude_scale:new i.Uniform2f(x)}),collisionCircle:x=>({u_matrix:new i.UniformMatrix4f(x),u_inv_matrix:new i.UniformMatrix4f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_viewport_size:new i.Uniform2f(x)}),debug:x=>({u_color:new i.UniformColor(x),u_matrix:new i.UniformMatrix4f(x),u_overlay:new i.Uniform1i(x),u_overlay_scale:new i.Uniform1f(x)}),clippingMask:x=>({u_matrix:new i.UniformMatrix4f(x)}),heatmap:x=>({u_extrude_scale:new i.Uniform1f(x),u_intensity:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_up_dir:new i.Uniform3f(x)}),heatmapTexture:x=>({u_image:new i.Uniform1i(x),u_color_ramp:new i.Uniform1i(x),u_opacity:new i.Uniform1f(x)}),hillshade:x=>({u_matrix:new i.UniformMatrix4f(x),u_image:new i.Uniform1i(x),u_latrange:new i.Uniform2f(x),u_light:new i.Uniform2f(x),u_shadow:new i.UniformColor(x),u_highlight:new i.UniformColor(x),u_accent:new i.UniformColor(x)}),hillshadePrepare:x=>({u_matrix:new i.UniformMatrix4f(x),u_image:new i.Uniform1i(x),u_dimension:new i.Uniform2f(x),u_zoom:new i.Uniform1f(x),u_unpack:new i.Uniform4f(x)}),line:x=>({u_matrix:new i.UniformMatrix4f(x),u_pixels_to_tile_units:new i.UniformMatrix2f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_units_to_pixels:new i.Uniform2f(x),u_dash_image:new i.Uniform1i(x),u_gradient_image:new i.Uniform1i(x),u_image_height:new i.Uniform1f(x),u_texsize:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x),u_alpha_discard_threshold:new i.Uniform1f(x),u_trim_offset:new i.Uniform2f(x)}),linePattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_texsize:new i.Uniform2f(x),u_pixels_to_tile_units:new i.UniformMatrix2f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_image:new i.Uniform1i(x),u_units_to_pixels:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x),u_alpha_discard_threshold:new i.Uniform1f(x)}),raster:x=>({u_matrix:new i.UniformMatrix4f(x),u_tl_parent:new i.Uniform2f(x),u_scale_parent:new i.Uniform1f(x),u_fade_t:new i.Uniform1f(x),u_opacity:new i.Uniform1f(x),u_image0:new i.Uniform1i(x),u_image1:new i.Uniform1i(x),u_brightness_low:new i.Uniform1f(x),u_brightness_high:new i.Uniform1f(x),u_saturation_factor:new i.Uniform1f(x),u_contrast_factor:new i.Uniform1f(x),u_spin_weights:new i.Uniform3f(x),u_perspective_transform:new i.Uniform2f(x)}),symbolIcon:x=>({u_is_size_zoom_constant:new i.Uniform1i(x),u_is_size_feature_constant:new i.Uniform1i(x),u_size_t:new i.Uniform1f(x),u_size:new i.Uniform1f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_rotate_symbol:new i.Uniform1i(x),u_aspect_ratio:new i.Uniform1f(x),u_fade_change:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_label_plane_matrix:new i.UniformMatrix4f(x),u_coord_matrix:new i.UniformMatrix4f(x),u_is_text:new i.Uniform1i(x),u_pitch_with_map:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_camera_forward:new i.Uniform3f(x),u_tile_matrix:new i.UniformMatrix4f(x),u_up_vector:new i.Uniform3f(x),u_ecef_origin:new i.Uniform3f(x),u_texture:new i.Uniform1i(x)}),symbolSDF:x=>({u_is_size_zoom_constant:new i.Uniform1i(x),u_is_size_feature_constant:new i.Uniform1i(x),u_size_t:new i.Uniform1f(x),u_size:new i.Uniform1f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_rotate_symbol:new i.Uniform1i(x),u_aspect_ratio:new i.Uniform1f(x),u_fade_change:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_label_plane_matrix:new i.UniformMatrix4f(x),u_coord_matrix:new i.UniformMatrix4f(x),u_is_text:new i.Uniform1i(x),u_pitch_with_map:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_texture:new i.Uniform1i(x),u_gamma_scale:new i.Uniform1f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_tile_id:new i.Uniform3f(x),u_zoom_transition:new i.Uniform1f(x),u_inv_rot_matrix:new i.UniformMatrix4f(x),u_merc_center:new i.Uniform2f(x),u_camera_forward:new i.Uniform3f(x),u_tile_matrix:new i.UniformMatrix4f(x),u_up_vector:new i.Uniform3f(x),u_ecef_origin:new i.Uniform3f(x),u_is_halo:new i.Uniform1i(x)}),symbolTextAndIcon:x=>({u_is_size_zoom_constant:new i.Uniform1i(x),u_is_size_feature_constant:new i.Uniform1i(x),u_size_t:new i.Uniform1f(x),u_size:new i.Uniform1f(x),u_camera_to_center_distance:new i.Uniform1f(x),u_rotate_symbol:new i.Uniform1i(x),u_aspect_ratio:new i.Uniform1f(x),u_fade_change:new i.Uniform1f(x),u_matrix:new i.UniformMatrix4f(x),u_label_plane_matrix:new i.UniformMatrix4f(x),u_coord_matrix:new i.UniformMatrix4f(x),u_is_text:new i.Uniform1i(x),u_pitch_with_map:new i.Uniform1i(x),u_texsize:new i.Uniform2f(x),u_texsize_icon:new i.Uniform2f(x),u_texture:new i.Uniform1i(x),u_texture_icon:new i.Uniform1i(x),u_gamma_scale:new i.Uniform1f(x),u_device_pixel_ratio:new i.Uniform1f(x),u_is_halo:new i.Uniform1i(x)}),background:x=>({u_matrix:new i.UniformMatrix4f(x),u_opacity:new i.Uniform1f(x),u_color:new i.UniformColor(x)}),backgroundPattern:x=>({u_matrix:new i.UniformMatrix4f(x),u_opacity:new i.Uniform1f(x),u_image:new i.Uniform1i(x),u_pattern_tl:new i.Uniform2f(x),u_pattern_br:new i.Uniform2f(x),u_texsize:new i.Uniform2f(x),u_pattern_size:new i.Uniform2f(x),u_pixel_coord_upper:new i.Uniform2f(x),u_pixel_coord_lower:new i.Uniform2f(x),u_tile_units_to_pixels:new i.Uniform1f(x)}),terrainRaster:Qc,terrainDepth:Qc,skybox:x=>({u_matrix:new i.UniformMatrix4f(x),u_sun_direction:new i.Uniform3f(x),u_cubemap:new i.Uniform1i(x),u_opacity:new i.Uniform1f(x),u_temporal_offset:new i.Uniform1f(x)}),skyboxGradient:x=>({u_matrix:new i.UniformMatrix4f(x),u_color_ramp:new i.Uniform1i(x),u_center_direction:new i.Uniform3f(x),u_radius:new i.Uniform1f(x),u_opacity:new i.Uniform1f(x),u_temporal_offset:new i.Uniform1f(x)}),skyboxCapture:x=>({u_matrix_3f:new i.UniformMatrix3f(x),u_sun_direction:new i.Uniform3f(x),u_sun_intensity:new i.Uniform1f(x),u_color_tint_r:new i.Uniform4f(x),u_color_tint_m:new i.Uniform4f(x),u_luminance:new i.Uniform1f(x)}),globeRaster:x=>({u_proj_matrix:new i.UniformMatrix4f(x),u_globe_matrix:new i.UniformMatrix4f(x),u_normalize_matrix:new i.UniformMatrix4f(x),u_merc_matrix:new i.UniformMatrix4f(x),u_zoom_transition:new i.Uniform1f(x),u_merc_center:new i.Uniform2f(x),u_image0:new i.Uniform1i(x),u_grid_matrix:new i.UniformMatrix3f(x),u_frustum_tl:new i.Uniform3f(x),u_frustum_tr:new i.Uniform3f(x),u_frustum_br:new i.Uniform3f(x),u_frustum_bl:new i.Uniform3f(x),u_globe_pos:new i.Uniform3f(x),u_globe_radius:new i.Uniform1f(x),u_viewport:new i.Uniform2f(x)}),globeAtmosphere:x=>({u_frustum_tl:new i.Uniform3f(x),u_frustum_tr:new i.Uniform3f(x),u_frustum_br:new i.Uniform3f(x),u_frustum_bl:new i.Uniform3f(x),u_horizon:new i.Uniform1f(x),u_transition:new i.Uniform1f(x),u_fadeout_range:new i.Uniform1f(x),u_color:new i.Uniform4f(x),u_high_color:new i.Uniform4f(x),u_space_color:new i.Uniform4f(x),u_star_intensity:new i.Uniform1f(x),u_star_density:new i.Uniform1f(x),u_star_size:new i.Uniform1f(x),u_temporal_offset:new i.Uniform1f(x),u_horizon_angle:new i.Uniform1f(x),u_rotation_matrix:new i.UniformMatrix4f(x)})};let pc;function fc(x,a,m,b,S,P,H){const W=x.context,ee=W.gl,pe=x.transform,fe=x.useProgram("collisionBox"),Me=[];let Ne=0,st=0;for(let Bt=0;Bt0){const Kt=i.create(),Ci=si;i.mul(Kt,Ht.placementInvProjMatrix,pe.glCoordMatrix),i.mul(Kt,Kt,Ht.placementViewportMatrix),Me.push({circleArray:ji,circleOffset:st,transform:Ci,invTransform:Kt,projection:Ht.getProjection()}),Ne+=ji.length/4,st=Ne}qt&&(x.terrain&&x.terrain.setupElevationDraw(It,fe),fe.draw(W,ee.LINES,i.DepthMode.disabled,i.StencilMode.disabled,x.colorModeForRenderPass(),i.CullFaceMode.disabled,Kc(si,pe,It,Ht.getProjection()),m.id,qt.layoutVertexBuffer,qt.indexBuffer,qt.segments,null,pe.zoom,null,[qt.collisionVertexBuffer,qt.collisionVertexBufferExt]))}if(!H||!Me.length)return;const it=x.useProgram("collisionCircle"),lt=new i.StructArrayLayout2f1f2i16;lt.resize(4*Ne),lt._trim();let qe=0;for(const Bt of Me)for(let Pt=0;Pt=0&&(it[Bt.associatedIconIndex]={x:Ci,y:di,z:Ri,angle:pi})}else qs(Ht,Ne)}if(fe){st.clear();const ht=x.icon.placedSymbolArray;for(let Bt=0;BtKt.sortKey-Ci.sortKey);for(const Kt of si){const Ci=Kt.state;if(x.terrain&&x.terrain.setupElevationDraw(Ci.tile,Ci.program,{useDepthForOcclusion:!hi,labelPlaneMatrixInv:Ci.labelPlaneMatrixInv}),Ne.activeTexture.set(st.TEXTURE0),Ci.atlasTexture.bind(Ci.atlasInterpolation,st.CLAMP_TO_EDGE),Ci.atlasTextureIcon&&(Ne.activeTexture.set(st.TEXTURE1),Ci.atlasTextureIcon&&Ci.atlasTextureIcon.bind(Ci.atlasInterpolationIcon,st.CLAMP_TO_EDGE)),Ci.isSDF){const di=Ci.uniformValues;Ci.hasHalo&&(di.u_is_halo=1,Mo(Ci.buffers,Kt.segments,m,x,Ci.program,Pt,fe,Me,di)),di.u_is_halo=0}Mo(Ci.buffers,Kt.segments,m,x,Ci.program,Pt,fe,Me,Ci.uniformValues)}}function Mo(x,a,m,b,S,P,H,W,ee){const pe=b.context,fe=[x.dynamicLayoutVertexBuffer,x.opacityVertexBuffer,x.globeExtVertexBuffer];S.draw(pe,pe.gl.TRIANGLES,P,H,W,i.CullFaceMode.disabled,ee,m.id,x.layoutVertexBuffer,x.indexBuffer,a,m.paint,b.transform.zoom,x.programConfigurations.get(m.id),fe)}function nd(x,a,m,b,S,P,H){const W=x.context.gl,ee=m.paint.get("fill-pattern"),pe=ee&&ee.constantOr(1);let fe,Me,Ne,st,it;H?(Me=pe&&!m.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",fe=W.LINES):(Me=pe?"fillPattern":"fill",fe=W.TRIANGLES);for(const lt of b){const qe=a.getTile(lt);if(pe&&!qe.patternsLoaded())continue;const Ye=qe.getBucket(m);if(!Ye)continue;x.prepareDrawTile();const dt=Ye.programConfigurations.get(m.id),ht=x.useProgram(Me,dt);pe&&(x.context.activeTexture.set(W.TEXTURE0),qe.imageAtlasTexture.bind(W.LINEAR,W.CLAMP_TO_EDGE),dt.updatePaintBuffers());const Bt=ee.constantOr(null);if(Bt&&qe.imageAtlas){const It=qe.imageAtlas.patternPositions[Bt.toString()];It&&dt.setConstantPatternPositions(It)}const Pt=x.translatePosMatrix(lt.projMatrix,qe,m.paint.get("fill-translate"),m.paint.get("fill-translate-anchor"));if(H){st=Ye.indexBuffer2,it=Ye.segments2;const It=x.terrain&&x.terrain.renderingToTexture?x.terrain.drapeBufferSize:[W.drawingBufferWidth,W.drawingBufferHeight];Ne=Me==="fillOutlinePattern"&&pe?jc(Pt,x,qe,It):Wc(Pt,It)}else st=Ye.indexBuffer,it=Ye.segments,Ne=pe?Dh(Pt,x,qe):Gc(Pt);x.prepareDrawProgram(x.context,ht,lt.toUnwrapped()),ht.draw(x.context,fe,S,x.stencilModeForClipping(lt),P,i.CullFaceMode.disabled,Ne,m.id,Ye.layoutVertexBuffer,st,it,m.paint,x.transform.zoom,dt)}}function Ha(x,a,m,b,S,P,H){const W=x.context,ee=W.gl,pe=x.transform,fe=m.paint.get("fill-extrusion-pattern"),Me=fe.constantOr(1),Ne=m.paint.get("fill-extrusion-opacity"),st=[m.paint.get("fill-extrusion-ambient-occlusion-intensity"),m.paint.get("fill-extrusion-ambient-occlusion-radius")],it=m.layout.get("fill-extrusion-edge-radius"),lt=pe.projection.name==="globe"?i.fillExtrusionHeightLift():0,qe=pe.projection.name==="globe",Ye=qe?i.globeToMercatorTransition(pe.zoom):0,dt=[i.mercatorXfromLng(pe.center.lng),i.mercatorYfromLat(pe.center.lat)],ht=[];qe&&(ht.push("PROJECTION_GLOBE_VIEW"),x.style.terrainSetForDrapingOnly()&&ht.push("TERRAIN")),st[0]>0&&ht.push("FAUX_AO");for(const Bt of b){const Pt=a.getTile(Bt),It=Pt.getBucket(m);if(!It||It.projection.name!==pe.projection.name)continue;const Ht=It.programConfigurations.get(m.id),hi=x.useProgram(Me?"fillExtrusionPattern":"fillExtrusion",Ht,ht);if(x.terrain){const Ri=x.terrain;if(x.style.terrainSetForDrapingOnly())Ri.setupElevationDraw(Pt,hi,{useMeterToDem:!0});else{if(!It.enableTerrain)continue;if(Ri.setupElevationDraw(Pt,hi,{useMeterToDem:!0}),rd(W,a,Bt,It,m,Ri),!It.centroidVertexBuffer){const Ai=hi.attributes.a_centroid_pos;Ai!==void 0&&ee.vertexAttrib2f(Ai,0,0)}}}Me&&(x.context.activeTexture.set(ee.TEXTURE0),Pt.imageAtlasTexture.bind(ee.LINEAR,ee.CLAMP_TO_EDGE),Ht.updatePaintBuffers());const si=fe.constantOr(null);if(si&&Pt.imageAtlas){const Ri=Pt.imageAtlas.patternPositions[si.toString()];Ri&&Ht.setConstantPatternPositions(Ri)}const qt=x.translatePosMatrix(Bt.projMatrix,Pt,m.paint.get("fill-extrusion-translate"),m.paint.get("fill-extrusion-translate-anchor")),ji=pe.projection.createInversionMatrix(pe,Bt.canonical),Kt=m.paint.get("fill-extrusion-vertical-gradient"),Ci=Me?Lh(qt,x,Kt,Ne,st,it,Bt,Pt,lt,Ye,dt,ji):Hc(qt,x,Kt,Ne,st,it,Bt,lt,Ye,dt,ji);x.prepareDrawProgram(W,hi,Bt.toUnwrapped());const di=[];x.terrain&&di.push(It.centroidVertexBuffer),qe&&di.push(It.layoutVertexExtBuffer),hi.draw(W,W.gl.TRIANGLES,S,P,H,i.CullFaceMode.backCCW,Ci,m.id,It.layoutVertexBuffer,It.indexBuffer,It.segments,m.paint,x.transform.zoom,Ht,di)}}function rd(x,a,m,b,S,P){const H=[Ye=>{let dt=Ye.canonical.x-1,ht=Ye.wrap;return dt<0&&(dt=(1<{let dt=Ye.canonical.x+1,ht=Ye.wrap;return dt===1<new i.OverscaledTileID(Ye.overscaledZ,Ye.wrap,Ye.canonical.z,Ye.canonical.x,(Ye.canonical.y===0?1<new i.OverscaledTileID(Ye.overscaledZ,Ye.wrap,Ye.canonical.z,Ye.canonical.x,Ye.canonical.y===(1<{const dt=a.getSource().minzoom,ht=Pt=>{const It=a.getTileByID(Pt);if(It&&It.hasData())return It.getBucket(S)},Bt=[0,-1,1];for(const Pt of Bt){if(Ye.overscaledZ+Pt(ee[0]=Math.min(Ye.min.y,dt.min.y),ee[1]=Math.max(Ye.max.y,dt.max.y),ee[2]=i.EXTENT-dt.min.x>Ye.max.x?dt.min.x-i.EXTENT:Ye.max.x,ee),fe=(Ye,dt)=>(ee[0]=Math.min(Ye.min.x,dt.min.x),ee[1]=Math.max(Ye.max.x,dt.max.x),ee[2]=i.EXTENT-dt.min.y>Ye.max.y?dt.min.y-i.EXTENT:Ye.max.y,ee),Me=[(Ye,dt)=>pe(Ye,dt),(Ye,dt)=>pe(dt,Ye),(Ye,dt)=>fe(Ye,dt),(Ye,dt)=>fe(dt,Ye)],Ne=new i.pointGeometry(0,0);let st,it,lt;const qe=(Ye,dt,ht,Bt,Pt)=>{const It=[[Bt?ht:Ye,Bt?Ye:ht,0],[Bt?ht:dt,Bt?dt:ht,0]],Ht=Pt<0?i.EXTENT+Pt:Pt,hi=[Bt?Ht:(Ye+dt)/2,Bt?(Ye+dt)/2:Ht,0];return ht===0&&Pt<0||ht!==0&&Pt>0?P.getForTilePoints(lt,[hi],!0,it):It.push(hi),P.getForTilePoints(m,It,!0,st),Math.max(It[0][2],It[1][2],hi[2])/P.exaggeration()};for(let Ye=0;Ye<4;Ye++){const dt=(Ye<2?1:5)-Ye,ht=b.borders[Ye];if(ht.length===0)continue;const Bt=lt=H[Ye](m),Pt=W(Bt);if(!(Pt&&Pt instanceof i.FillExtrusionBucket&&Pt.enableTerrain)||b.borderDoneWithNeighborZ[Ye]===Pt.canonical.z&&Pt.borderDoneWithNeighborZ[dt]===b.canonical.z||(it=P.findDEMTileFor(Bt),!it||!it.dem))continue;if(!st){const si=P.findDEMTileFor(m);if(!si||!si.dem)return;st=si}const It=Pt.borders[dt];let Ht=0;const hi=Pt.borderDoneWithNeighborZ[dt]!==b.canonical.z;if(b.canonical.z===Pt.canonical.z){for(let si=0;siji[0]+3));)hi&&Pt.encodeCentroid(void 0,Kt,!1),Ht++;if(Kt&&Htji[1]-3)&&(di++,++Ht!==It.length);)Kt=Pt.featuresOnBorder[It[Ht]];if(Kt=Pt.featuresOnBorder[It[Ci]],qt.intersectsCount()>1||Kt.intersectsCount()>1||di!==1){di!==1&&(Ht=Ci),b.encodeCentroid(void 0,qt,!1),hi&&Pt.encodeCentroid(void 0,Kt,!1);continue}const Ri=Me[Ye](qt,Kt),Ai=Ye%2?i.EXTENT-1:0;Ne.x=qe(Ri[0],Math.min(i.EXTENT-1,Ri[1]),Ai,Ye<2,Ri[2]),Ne.y=0,b.encodeCentroid(Ne,qt,!1),hi&&Pt.encodeCentroid(Ne,Kt,!1)}else b.encodeCentroid(void 0,qt,!1)}b.borderDoneWithNeighborZ[Ye]=Pt.canonical.z,b.needsCentroidUpdate=!0,hi&&(Pt.borderDoneWithNeighborZ[dt]=b.canonical.z,Pt.needsCentroidUpdate=!0)}else{for(const si of ht)b.encodeCentroid(void 0,b.featuresOnBorder[si],!1);if(hi){for(const si of It)Pt.encodeCentroid(void 0,Pt.featuresOnBorder[si],!1);Pt.borderDoneWithNeighborZ[dt]=b.canonical.z,Pt.needsCentroidUpdate=!0}b.borderDoneWithNeighborZ[Ye]=Pt.canonical.z,b.needsCentroidUpdate=!0}}(b.needsCentroidUpdate||!b.centroidVertexBuffer&&b.centroidVertexArray.length!==0)&&b.uploadCentroid(x)}const ml=new i.Color(1,0,0,1),kh=new i.Color(0,1,0,1),Oh=new i.Color(0,0,1,1),lA=new i.Color(1,0,1,1),sd=new i.Color(0,1,1,1);function Nh(x,a,m){const b=x.context,S=x.transform,P=b.gl,H=S.projection.name==="globe",W=H?["PROJECTION_GLOBE_VIEW"]:null;let ee=m.projMatrix;if(H&&i.globeToMercatorTransition(S.zoom)>0){const qt=i.transitionTileAABBinECEF(m.canonical,S),ji=i.globeDenormalizeECEF(qt);ee=i.multiply(new Float32Array(16),S.globeMatrix,ji),i.multiply(ee,S.projMatrix,ee)}const pe=x.useProgram("debug",null,W),fe=a.getTileByID(m.key);x.terrain&&x.terrain.setupElevationDraw(fe,pe);const Me=i.DepthMode.disabled,Ne=i.StencilMode.disabled,st=x.colorModeForRenderPass(),it="$debug";b.activeTexture.set(P.TEXTURE0),x.emptyTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),H?fe._makeGlobeTileDebugBuffers(x.context,S):fe._makeDebugTileBoundsBuffers(x.context,S.projection);const lt=fe._tileDebugBuffer||x.debugBuffer,qe=fe._tileDebugIndexBuffer||x.debugIndexBuffer,Ye=fe._tileDebugSegments||x.debugSegments;pe.draw(b,P.LINE_STRIP,Me,Ne,st,i.CullFaceMode.disabled,ca(ee,i.Color.red),it,lt,qe,Ye,null,null,null,[fe._globeTileDebugBorderBuffer]);const dt=fe.latestRawTileData,ht=Math.floor((dt&&dt.byteLength||0)/1024),Bt=a.getTile(m).tileSize,Pt=512/Math.min(Bt,512)*(m.overscaledZ/S.zoom)*.5;let It=m.canonical.toString();m.overscaledZ!==m.canonical.z&&(It+=` => ${m.overscaledZ}`),It+=` ${ht}kb`,function(qt,ji){qt.initDebugOverlayCanvas();const Kt=qt.debugOverlayCanvas,Ci=qt.context.gl,di=qt.debugOverlayCanvas.getContext("2d");di.clearRect(0,0,Kt.width,Kt.height),di.shadowColor="white",di.shadowBlur=2,di.lineWidth=1.5,di.strokeStyle="white",di.textBaseline="top",di.font="bold 36px Open Sans, sans-serif",di.fillText(ji,5,5),di.strokeText(ji,5,5),qt.debugOverlayTexture.update(Kt),qt.debugOverlayTexture.bind(Ci.LINEAR,Ci.CLAMP_TO_EDGE)}(x,It);const Ht=fe._tileDebugTextBuffer||x.debugBuffer,hi=fe._tileDebugTextIndexBuffer||x.quadTriangleIndexBuffer,si=fe._tileDebugTextSegments||x.debugSegments;pe.draw(b,P.TRIANGLES,Me,Ne,i.ColorMode.alphaBlended,i.CullFaceMode.disabled,ca(ee,i.Color.transparent,Pt),it,Ht,hi,si,null,null,null,[fe._globeTileDebugTextBuffer])}function mc(x,a,m,b){pn(x,0,a+m/2,x.transform.width,m,b)}function ha(x,a,m,b){pn(x,a-m/2,0,m,x.transform.height,b)}function pn(x,a,m,b,S,P){const H=x.context,W=H.gl;W.enable(W.SCISSOR_TEST),W.scissor(a*i.exported.devicePixelRatio,m*i.exported.devicePixelRatio,b*i.exported.devicePixelRatio,S*i.exported.devicePixelRatio),H.clear({color:P}),W.disable(W.SCISSOR_TEST)}const eh=i.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Wl}=eh;function Os(x,a,m,b){x.emplaceBack(a,m,b)}class gl{constructor(a){this.vertexArray=new i.StructArrayLayout3f12,this.indices=new i.StructArrayLayout3ui6,Os(this.vertexArray,-1,-1,1),Os(this.vertexArray,1,-1,1),Os(this.vertexArray,-1,1,1),Os(this.vertexArray,1,1,1),Os(this.vertexArray,-1,-1,-1),Os(this.vertexArray,1,-1,-1),Os(this.vertexArray,-1,1,-1),Os(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=a.createVertexBuffer(this.vertexArray,Wl),this.indexBuffer=a.createIndexBuffer(this.indices),this.segment=i.SegmentVector.simpleSegment(0,0,36,12)}}function un(x,a,m,b,S,P){const H=x.gl,W=a.paint.get("sky-atmosphere-color"),ee=a.paint.get("sky-atmosphere-halo-color"),pe=a.paint.get("sky-atmosphere-sun-intensity"),fe=((Me,Ne,st,it,lt)=>({u_matrix_3f:Me,u_sun_direction:Ne,u_sun_intensity:st,u_color_tint_r:[it.r,it.g,it.b,it.a],u_color_tint_m:[lt.r,lt.g,lt.b,lt.a],u_luminance:5e-5}))(i.fromMat4(i.create$1(),b),S,pe,W,ee);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+P,a.skyboxTexture,0),m.draw(x,H.TRIANGLES,i.DepthMode.disabled,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.frontCW,fe,"skyboxCapture",a.skyboxGeometry.vertexBuffer,a.skyboxGeometry.indexBuffer,a.skyboxGeometry.segment)}const th=i.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Ur{constructor(a){const m=new i.StructArrayLayout5f20;m.emplaceBack(-1,1,1,0,0),m.emplaceBack(1,1,1,1,0),m.emplaceBack(1,-1,1,1,1),m.emplaceBack(-1,-1,1,0,1);const b=new i.StructArrayLayout3ui6;b.emplaceBack(0,1,2),b.emplaceBack(2,3,0),this.vertexBuffer=a.createVertexBuffer(m,th.members),this.indexBuffer=a.createIndexBuffer(b),this.segments=i.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const gc={symbol:function(x,a,m,b,S){if(x.renderPass!=="translucent")return;const P=i.StencilMode.disabled,H=x.colorModeForRenderPass();m.layout.get("text-variable-anchor")&&function(W,ee,pe,fe,Me,Ne,st){const it=ee.transform,lt=Me==="map",qe=Ne==="map";for(const Ye of W){const dt=fe.getTile(Ye),ht=dt.getBucket(pe);if(!ht||!ht.text||!ht.text.segments.get().length)continue;const Bt=i.evaluateSizeForZoom(ht.textSizeData,it.zoom),Pt=kl(Ye,ht.getProjection(),it),It=it.calculatePixelsToTileUnitsMatrix(dt),Ht=Mr(Pt,dt.tileID.canonical,qe,lt,it,ht.getProjection(),It),hi=pe.layout.get("icon-text-fit")!=="none"&&ht.hasIconData();if(Bt){const si=Math.pow(2,it.zoom-dt.tileID.overscaledZ);Jc(ht,lt,qe,st,i.symbolSize,it,Ht,Ye,si,Bt,hi)}}}(b,x,m,a,m.layout.get("text-rotation-alignment"),m.layout.get("text-pitch-alignment"),S),m.paint.get("icon-opacity").constantOr(1)!==0&&xa(x,a,m,b,!1,m.paint.get("icon-translate"),m.paint.get("icon-translate-anchor"),m.layout.get("icon-rotation-alignment"),m.layout.get("icon-pitch-alignment"),m.layout.get("icon-keep-upright"),P,H),m.paint.get("text-opacity").constantOr(1)!==0&&xa(x,a,m,b,!0,m.paint.get("text-translate"),m.paint.get("text-translate-anchor"),m.layout.get("text-rotation-alignment"),m.layout.get("text-pitch-alignment"),m.layout.get("text-keep-upright"),P,H),a.map.showCollisionBoxes&&(fc(x,a,m,b,m.paint.get("text-translate"),m.paint.get("text-translate-anchor"),!0),fc(x,a,m,b,m.paint.get("icon-translate"),m.paint.get("icon-translate-anchor"),!1))},circle:function(x,a,m,b){if(x.renderPass!=="translucent")return;const S=m.paint.get("circle-opacity"),P=m.paint.get("circle-stroke-width"),H=m.paint.get("circle-stroke-opacity"),W=m.layout.get("circle-sort-key").constantOr(1)!==void 0;if(S.constantOr(1)===0&&(P.constantOr(1)===0||H.constantOr(1)===0))return;const ee=x.context,pe=ee.gl,fe=x.transform,Me=x.depthModeForSublayer(0,i.DepthMode.ReadOnly),Ne=i.StencilMode.disabled,st=x.colorModeForRenderPass(),it=fe.projection.name==="globe",lt=[i.mercatorXfromLng(fe.center.lng),i.mercatorYfromLat(fe.center.lat)],qe=[];for(let dt=0;dtdt.sortKey-ht.sortKey);const Ye={useDepthForOcclusion:!it};for(const dt of qe){const{programConfiguration:ht,program:Bt,layoutVertexBuffer:Pt,globeExtVertexBuffer:It,indexBuffer:Ht,uniformValues:hi,tile:si}=dt.state,qt=dt.segments;x.terrain&&x.terrain.setupElevationDraw(si,Bt,Ye),x.prepareDrawProgram(ee,Bt,si.tileID.toUnwrapped()),Bt.draw(ee,pe.TRIANGLES,Me,Ne,st,i.CullFaceMode.disabled,hi,m.id,Pt,Ht,qt,m.paint,fe.zoom,ht,[It])}},heatmap:function(x,a,m,b){if(m.paint.get("heatmap-opacity")!==0)if(x.renderPass==="offscreen"){const S=x.context,P=S.gl,H=i.StencilMode.disabled,W=new i.ColorMode([P.ONE,P.ONE],i.Color.transparent,[!0,!0,!0,!0]);(function(st,it,lt,qe){const Ye=st.gl,dt=it.width*qe,ht=it.height*qe;st.activeTexture.set(Ye.TEXTURE1),st.viewport.set([0,0,dt,ht]);let Bt=lt.heatmapFbo;if(!Bt||Bt&&(Bt.width!==dt||Bt.height!==ht)){Bt&&Bt.destroy();const Pt=Ye.createTexture();Ye.bindTexture(Ye.TEXTURE_2D,Pt),Ye.texParameteri(Ye.TEXTURE_2D,Ye.TEXTURE_WRAP_S,Ye.CLAMP_TO_EDGE),Ye.texParameteri(Ye.TEXTURE_2D,Ye.TEXTURE_WRAP_T,Ye.CLAMP_TO_EDGE),Ye.texParameteri(Ye.TEXTURE_2D,Ye.TEXTURE_MIN_FILTER,Ye.LINEAR),Ye.texParameteri(Ye.TEXTURE_2D,Ye.TEXTURE_MAG_FILTER,Ye.LINEAR),Bt=lt.heatmapFbo=st.createFramebuffer(dt,ht,!1),function(It,Ht,hi,si,qt,ji){const Kt=It.gl;Kt.texImage2D(Kt.TEXTURE_2D,0,Kt.RGBA,qt,ji,0,Kt.RGBA,It.extRenderToTextureHalfFloat?It.extTextureHalfFloat.HALF_FLOAT_OES:Kt.UNSIGNED_BYTE,null),si.colorAttachment.set(hi)}(st,0,Pt,Bt,dt,ht)}else Ye.bindTexture(Ye.TEXTURE_2D,Bt.colorAttachment.get()),st.bindFramebuffer.set(Bt.framebuffer)})(S,x,m,x.transform.projection.name==="globe"?.5:.25),S.clear({color:i.Color.transparent});const ee=x.transform,pe=ee.projection.name==="globe",fe=pe?["PROJECTION_GLOBE_VIEW"]:null,Me=pe?i.CullFaceMode.frontCCW:i.CullFaceMode.disabled,Ne=[i.mercatorXfromLng(ee.center.lng),i.mercatorYfromLat(ee.center.lat)];for(let st=0;st({u_image:0,u_color_ramp:1,u_opacity:Me.paint.get("heatmap-opacity")}))(0,P),P.id,S.viewportBuffer,S.quadTriangleIndexBuffer,S.viewportSegments,P.paint,S.transform.zoom)}(x,m))},line:function(x,a,m,b){if(x.renderPass!=="translucent")return;const S=m.paint.get("line-opacity"),P=m.paint.get("line-width");if(S.constantOr(1)===0||P.constantOr(1)===0)return;const H=x.depthModeForSublayer(0,i.DepthMode.ReadOnly),W=x.colorModeForRenderPass(),ee=x.terrain&&x.terrain.renderingToTexture?1:i.exported.devicePixelRatio,pe=m.paint.get("line-dasharray"),fe=pe.constantOr(1),Me=m.layout.get("line-cap"),Ne=m.paint.get("line-pattern"),st=Ne.constantOr(1),it=m.paint.get("line-gradient"),lt=st?"linePattern":"line",qe=x.context,Ye=qe.gl,dt=(Bt=>{const Pt=[];Gl(Bt)&&Pt.push("RENDER_LINE_DASH"),Bt.paint.get("line-gradient")&&Pt.push("RENDER_LINE_GRADIENT");const It=Bt.paint.get("line-trim-offset");It[0]===0&&It[1]===0||Pt.push("RENDER_LINE_TRIM_OFFSET");const Ht=Bt.paint.get("line-pattern").constantOr(1),hi=Bt.paint.get("line-opacity").constantOr(1)!==1;return!Ht&&hi&&Pt.push("RENDER_LINE_ALPHA_DISCARD"),Pt})(m);let ht=dt.includes("RENDER_LINE_ALPHA_DISCARD");x.terrain&&x.terrain.clipOrMaskOverlapStencilType()&&(ht=!1);for(const Bt of b){const Pt=a.getTile(Bt);if(st&&!Pt.patternsLoaded())continue;const It=Pt.getBucket(m);if(!It)continue;x.prepareDrawTile();const Ht=It.programConfigurations.get(m.id),hi=x.useProgram(lt,Ht,dt),si=Ne.constantOr(null);if(si&&Pt.imageAtlas){const Mi=Pt.imageAtlas.patternPositions[si.toString()];Mi&&Ht.setConstantPatternPositions(Mi)}const qt=pe.constantOr(null),ji=Me.constantOr(null);if(!st&&qt&&ji&&Pt.lineAtlas){const Mi=Pt.lineAtlas.getDash(qt,ji);Mi&&Ht.setConstantPatternPositions(Mi)}let[Kt,Ci]=m.paint.get("line-trim-offset");(ji==="round"||ji==="square")&&Kt!==Ci&&(Kt===0&&(Kt-=1),Ci===1&&(Ci+=1));const di=x.terrain?Bt.projMatrix:null,Ri=st?Ho(x,Pt,m,di,ee):aA(x,Pt,m,di,It.lineClipsArray.length,ee,[Kt,Ci]);if(it){const Mi=It.gradients[m.id];let $i=Mi.texture;if(m.gradientVersion!==Mi.version){let Jt=256;if(m.stepInterpolant){const pi=a.getSource().maxzoom,In=Bt.canonical.z===pi?Math.ceil(1<{hi.draw(qe,Ye.TRIANGLES,H,Mi,W,i.CullFaceMode.disabled,Ri,m.id,It.layoutVertexBuffer,It.indexBuffer,It.segments,m.paint,x.transform.zoom,Ht,[It.layoutVertexBuffer2])};if(ht){const Mi=x.stencilModeForClipping(Bt).ref;Mi===0&&x.terrain&&qe.clear({stencil:0});const $i={func:Ye.EQUAL,mask:255};Ri.u_alpha_discard_threshold=.8,Ai(new i.StencilMode($i,Mi,255,Ye.KEEP,Ye.KEEP,Ye.INVERT)),Ri.u_alpha_discard_threshold=0,Ai(new i.StencilMode($i,Mi,255,Ye.KEEP,Ye.KEEP,Ye.KEEP))}else Ai(x.stencilModeForClipping(Bt))}ht&&(x.resetStencilClippingMasks(),x.terrain&&qe.clear({stencil:0}))},fill:function(x,a,m,b){const S=m.paint.get("fill-color"),P=m.paint.get("fill-opacity");if(P.constantOr(1)===0)return;const H=x.colorModeForRenderPass(),W=m.paint.get("fill-pattern"),ee=x.opaquePassEnabledForLayer()&&!W.constantOr(1)&&S.constantOr(i.Color.transparent).a===1&&P.constantOr(0)===1?"opaque":"translucent";if(x.renderPass===ee){const pe=x.depthModeForSublayer(1,x.renderPass==="opaque"?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly);nd(x,a,m,b,pe,H,!1)}if(x.renderPass==="translucent"&&m.paint.get("fill-antialias")){const pe=x.depthModeForSublayer(m.getPaintProperty("fill-outline-color")?2:0,i.DepthMode.ReadOnly);nd(x,a,m,b,pe,H,!0)}},"fill-extrusion":function(x,a,m,b){const S=m.paint.get("fill-extrusion-opacity");if(S!==0&&x.renderPass==="translucent"){const P=new i.DepthMode(x.context.gl.LEQUAL,i.DepthMode.ReadWrite,x.depthRangeFor3D);if(S!==1||m.paint.get("fill-extrusion-pattern").constantOr(1))Ha(x,a,m,b,P,i.StencilMode.disabled,i.ColorMode.disabled),Ha(x,a,m,b,P,x.stencilModeFor3D(),x.colorModeForRenderPass()),x.resetStencilClippingMasks();else{const H=x.colorModeForRenderPass();Ha(x,a,m,b,P,i.StencilMode.disabled,H)}}},hillshade:function(x,a,m,b){if(x.renderPass!=="offscreen"&&x.renderPass!=="translucent")return;const S=x.context,P=x.depthModeForSublayer(0,i.DepthMode.ReadOnly),H=x.colorModeForRenderPass(),W=x.terrain&&x.terrain.renderingToTexture,[ee,pe]=x.renderPass!=="translucent"||W?[{},b]:x.stencilConfigForOverlap(b);for(const fe of pe){const Me=a.getTile(fe);if(Me.needsHillshadePrepare&&x.renderPass==="offscreen")Va(x,Me,m,P,i.StencilMode.disabled,H);else if(x.renderPass==="translucent"){const Ne=W&&x.terrain?x.terrain.stencilModeForRTTOverlap(fe):ee[fe.overscaledZ];yu(x,fe,Me,m,P,Ne,H)}}S.viewport.set([0,0,x.width,x.height]),x.resetStencilClippingMasks()},raster:function(x,a,m,b,S,P){if(x.renderPass!=="translucent"||m.paint.get("raster-opacity")===0||!b.length)return;const H=x.context,W=H.gl,ee=a.getSource(),pe=x.useProgram("raster"),fe=x.colorModeForRenderPass(),Me=x.terrain&&x.terrain.renderingToTexture,[Ne,st]=ee instanceof X||Me?[{},b]:x.stencilConfigForOverlap(b),it=st[st.length-1].overscaledZ,lt=!x.options.moving;for(const qe of st){const Ye=Me?i.DepthMode.disabled:x.depthModeForSublayer(qe.overscaledZ-it,m.paint.get("raster-opacity")===1?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly,W.LESS),dt=qe.toUnwrapped(),ht=a.getTile(qe);if(Me&&(!ht||!ht.hasData()))continue;const Bt=Me?qe.projMatrix:x.transform.calculateProjMatrix(dt,lt),Pt=x.terrain&&Me?x.terrain.stencilModeForRTTOverlap(qe):Ne[qe.overscaledZ],It=P?0:m.paint.get("raster-fade-duration");ht.registerFadeDuration(It);const Ht=a.findLoadedParent(qe,0),hi=Hl(ht,Ht,a,x.transform,It);let si,qt;x.terrain&&x.terrain.prepareDrawTile();const ji=m.paint.get("raster-resampling")==="nearest"?W.NEAREST:W.LINEAR;H.activeTexture.set(W.TEXTURE0),ht.texture.bind(ji,W.CLAMP_TO_EDGE),H.activeTexture.set(W.TEXTURE1),Ht?(Ht.texture.bind(ji,W.CLAMP_TO_EDGE),si=Math.pow(2,Ht.tileID.overscaledZ-ht.tileID.overscaledZ),qt=[ht.tileID.canonical.x*si%1,ht.tileID.canonical.y*si%1]):ht.texture.bind(ji,W.CLAMP_TO_EDGE);const Kt=wu(Bt,qt||[0,0],si||1,hi,m,ee instanceof X?ee.perspectiveTransform:[0,0]);if(x.prepareDrawProgram(H,pe,dt),ee instanceof X)ee.boundsBuffer&&ee.boundsSegments&&pe.draw(H,W.TRIANGLES,Ye,i.StencilMode.disabled,fe,i.CullFaceMode.disabled,Kt,m.id,ee.boundsBuffer,x.quadTriangleIndexBuffer,ee.boundsSegments);else{const{tileBoundsBuffer:Ci,tileBoundsIndexBuffer:di,tileBoundsSegments:Ri}=x.getTileBoundsBuffers(ht);pe.draw(H,W.TRIANGLES,Ye,Pt,fe,i.CullFaceMode.disabled,Kt,m.id,Ci,di,Ri)}}x.resetStencilClippingMasks()},background:function(x,a,m,b){const S=m.paint.get("background-color"),P=m.paint.get("background-opacity");if(P===0)return;const H=x.context,W=H.gl,ee=x.transform,pe=ee.tileSize,fe=m.paint.get("background-pattern");if(x.isPatternMissing(fe))return;const Me=!fe&&S.a===1&&P===1&&x.opaquePassEnabledForLayer()?"opaque":"translucent";if(x.renderPass!==Me)return;const Ne=i.StencilMode.disabled,st=x.depthModeForSublayer(0,Me==="opaque"?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly),it=x.colorModeForRenderPass(),lt=x.useProgram(fe?"backgroundPattern":"background");let qe,Ye=b;Ye||(qe=x.getBackgroundTiles(),Ye=Object.values(qe).map(dt=>dt.tileID)),fe&&(H.activeTexture.set(W.TEXTURE0),x.imageManager.bind(x.context));for(const dt of Ye){const ht=dt.toUnwrapped(),Bt=b?dt.projMatrix:x.transform.calculateProjMatrix(ht);x.prepareDrawTile();const Pt=a?a.getTile(dt):qe?qe[dt.key]:new i.Tile(dt,pe,ee.zoom,x),It=fe?bu(Bt,P,x,fe,{tileID:dt,tileSize:pe}):Rh(Bt,P,S);x.prepareDrawProgram(H,lt,ht);const{tileBoundsBuffer:Ht,tileBoundsIndexBuffer:hi,tileBoundsSegments:si}=x.getTileBoundsBuffers(Pt);lt.draw(H,W.TRIANGLES,st,Ne,it,i.CullFaceMode.disabled,It,m.id,Ht,hi,si)}},sky:function(x,a,m){const b=x.transform,S=b.projection.name==="mercator"||b.projection.name==="globe"?1:i.smoothstep(7,8,b.zoom),P=m.paint.get("sky-opacity")*S;if(P===0)return;const H=x.context,W=m.paint.get("sky-type"),ee=new i.DepthMode(H.gl.LEQUAL,i.DepthMode.ReadOnly,[0,1]),pe=x.frameCounter/1e3%1;W==="atmosphere"?x.renderPass==="offscreen"?m.needsSkyboxCapture(x)&&(function(fe,Me,Ne,st){const it=fe.context,lt=it.gl;let qe=Me.skyboxFbo;if(!qe){qe=Me.skyboxFbo=it.createFramebuffer(32,32,!1),Me.skyboxGeometry=new gl(it),Me.skyboxTexture=it.gl.createTexture(),lt.bindTexture(lt.TEXTURE_CUBE_MAP,Me.skyboxTexture),lt.texParameteri(lt.TEXTURE_CUBE_MAP,lt.TEXTURE_WRAP_S,lt.CLAMP_TO_EDGE),lt.texParameteri(lt.TEXTURE_CUBE_MAP,lt.TEXTURE_WRAP_T,lt.CLAMP_TO_EDGE),lt.texParameteri(lt.TEXTURE_CUBE_MAP,lt.TEXTURE_MIN_FILTER,lt.LINEAR),lt.texParameteri(lt.TEXTURE_CUBE_MAP,lt.TEXTURE_MAG_FILTER,lt.LINEAR);for(let Bt=0;Bt<6;++Bt)lt.texImage2D(lt.TEXTURE_CUBE_MAP_POSITIVE_X+Bt,0,lt.RGBA,32,32,0,lt.RGBA,lt.UNSIGNED_BYTE,null)}it.bindFramebuffer.set(qe.framebuffer),it.viewport.set([0,0,32,32]);const Ye=Me.getCenter(fe,!0),dt=fe.useProgram("skyboxCapture"),ht=new Float64Array(16);i.identity(ht),i.rotateY(ht,ht,.5*-Math.PI),un(it,Me,dt,ht,Ye,0),i.identity(ht),i.rotateY(ht,ht,.5*Math.PI),un(it,Me,dt,ht,Ye,1),i.identity(ht),i.rotateX(ht,ht,.5*-Math.PI),un(it,Me,dt,ht,Ye,2),i.identity(ht),i.rotateX(ht,ht,.5*Math.PI),un(it,Me,dt,ht,Ye,3),i.identity(ht),un(it,Me,dt,ht,Ye,4),i.identity(ht),i.rotateY(ht,ht,Math.PI),un(it,Me,dt,ht,Ye,5),it.viewport.set([0,0,fe.width,fe.height])}(x,m),m.markSkyboxValid(x)):x.renderPass==="sky"&&function(fe,Me,Ne,st,it){const lt=fe.context,qe=lt.gl,Ye=fe.transform,dt=fe.useProgram("skybox");lt.activeTexture.set(qe.TEXTURE0),qe.bindTexture(qe.TEXTURE_CUBE_MAP,Me.skyboxTexture);const ht=((Bt,Pt,It,Ht,hi)=>({u_matrix:Bt,u_sun_direction:Pt,u_cubemap:0,u_opacity:Ht,u_temporal_offset:hi}))(Ye.skyboxMatrix,Me.getCenter(fe,!1),0,st,it);fe.prepareDrawProgram(lt,dt),dt.draw(lt,qe.TRIANGLES,Ne,i.StencilMode.disabled,fe.colorModeForRenderPass(),i.CullFaceMode.backCW,ht,"skybox",Me.skyboxGeometry.vertexBuffer,Me.skyboxGeometry.indexBuffer,Me.skyboxGeometry.segment)}(x,m,ee,P,pe):W==="gradient"&&x.renderPass==="sky"&&function(fe,Me,Ne,st,it){const lt=fe.context,qe=lt.gl,Ye=fe.transform,dt=fe.useProgram("skyboxGradient");Me.skyboxGeometry||(Me.skyboxGeometry=new gl(lt)),lt.activeTexture.set(qe.TEXTURE0);let ht=Me.colorRampTexture;ht||(ht=Me.colorRampTexture=new i.Texture(lt,Me.colorRamp,qe.RGBA)),ht.bind(qe.LINEAR,qe.CLAMP_TO_EDGE);const Bt=((Pt,It,Ht,hi,si)=>({u_matrix:Pt,u_color_ramp:0,u_center_direction:It,u_radius:i.degToRad(Ht),u_opacity:hi,u_temporal_offset:si}))(Ye.skyboxMatrix,Me.getCenter(fe,!1),Me.paint.get("sky-gradient-radius"),st,it);fe.prepareDrawProgram(lt,dt),dt.draw(lt,qe.TRIANGLES,Ne,i.StencilMode.disabled,fe.colorModeForRenderPass(),i.CullFaceMode.backCW,Bt,"skyboxGradient",Me.skyboxGeometry.vertexBuffer,Me.skyboxGeometry.indexBuffer,Me.skyboxGeometry.segment)}(x,m,ee,P,pe)},debug:function(x,a,m){for(let b=0;bS)return void(this.transform.fogCullDistSq=null);const P=b+.78*(S-b);this.transform.fogCullDistSq=P*P}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(a,m){if(this.width=a*i.exported.devicePixelRatio,this.height=m*i.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const b of this.style.order)this.style._layers[b].resize()}setup(){const a=this.context,m=new i.StructArrayLayout2i4;m.emplaceBack(0,0),m.emplaceBack(i.EXTENT,0),m.emplaceBack(0,i.EXTENT),m.emplaceBack(i.EXTENT,i.EXTENT),this.tileExtentBuffer=a.createVertexBuffer(m,i.posAttributes.members),this.tileExtentSegments=i.SegmentVector.simpleSegment(0,0,4,2);const b=new i.StructArrayLayout2i4;b.emplaceBack(0,0),b.emplaceBack(i.EXTENT,0),b.emplaceBack(0,i.EXTENT),b.emplaceBack(i.EXTENT,i.EXTENT),this.debugBuffer=a.createVertexBuffer(b,i.posAttributes.members),this.debugSegments=i.SegmentVector.simpleSegment(0,0,4,5);const S=new i.StructArrayLayout2i4;S.emplaceBack(-1,-1),S.emplaceBack(1,-1),S.emplaceBack(-1,1),S.emplaceBack(1,1),this.viewportBuffer=a.createVertexBuffer(S,i.posAttributes.members),this.viewportSegments=i.SegmentVector.simpleSegment(0,0,4,2);const P=new i.StructArrayLayout4i8;P.emplaceBack(0,0,0,0),P.emplaceBack(i.EXTENT,0,i.EXTENT,0),P.emplaceBack(0,i.EXTENT,0,i.EXTENT),P.emplaceBack(i.EXTENT,i.EXTENT,i.EXTENT,i.EXTENT),this.mercatorBoundsBuffer=a.createVertexBuffer(P,i.boundsAttributes.members),this.mercatorBoundsSegments=i.SegmentVector.simpleSegment(0,0,4,2);const H=new i.StructArrayLayout3ui6;H.emplaceBack(0,1,2),H.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=a.createIndexBuffer(H);const W=new i.StructArrayLayout1ui2;for(const pe of[0,1,3,2,0])W.emplaceBack(pe);this.debugIndexBuffer=a.createIndexBuffer(W),this.emptyTexture=new i.Texture(a,new i.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),a.gl.RGBA),this.identityMat=i.create();const ee=this.context.gl;this.stencilClearMode=new i.StencilMode({func:ee.ALWAYS,mask:0},0,255,ee.ZERO,ee.ZERO,ee.ZERO),this.loadTimeStamps.push(i.window.performance.now()),this.atmosphereBuffer=new Ur(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(a){return a._makeTileBoundsBuffers(this.context,this.transform.projection),a._tileBoundsBuffer?{tileBoundsBuffer:a._tileBoundsBuffer,tileBoundsIndexBuffer:a._tileBoundsIndexBuffer,tileBoundsSegments:a._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const a=this.context,m=a.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(a,m.TRIANGLES,i.DepthMode.disabled,this.stencilClearMode,i.ColorMode.disabled,i.CullFaceMode.disabled,$r(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(a,m,b){if(!m||this.currentStencilSource===m.id||!a.isTileClipped()||!b||b.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let W=!1;for(const ee of b)if(this._tileClippingMaskIDs[ee.key]===void 0){W=!0;break}if(!W)return}this.currentStencilSource=m.id;const S=this.context,P=S.gl;this.nextStencilID+b.length>256&&this.clearStencil(),S.setColorMode(i.ColorMode.disabled),S.setDepthMode(i.DepthMode.disabled);const H=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const W of b){const ee=m.getTile(W),pe=this._tileClippingMaskIDs[W.key]=this.nextStencilID++,{tileBoundsBuffer:fe,tileBoundsIndexBuffer:Me,tileBoundsSegments:Ne}=this.getTileBoundsBuffers(ee);H.draw(S,P.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:P.ALWAYS,mask:0},pe,255,P.KEEP,P.KEEP,P.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,$r(W.projMatrix),"$clipping",fe,Me,Ne)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const a=this.nextStencilID++,m=this.context.gl;return new i.StencilMode({func:m.NOTEQUAL,mask:255},a,255,m.KEEP,m.KEEP,m.REPLACE)}stencilModeForClipping(a){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(a);const m=this.context.gl;return new i.StencilMode({func:m.EQUAL,mask:255},this._tileClippingMaskIDs[a.key],0,m.KEEP,m.KEEP,m.REPLACE)}stencilConfigForOverlap(a){const m=this.context.gl,b=a.sort((H,W)=>W.overscaledZ-H.overscaledZ),S=b[b.length-1].overscaledZ,P=b[0].overscaledZ-S+1;if(P>1){this.currentStencilSource=void 0,this.nextStencilID+P>256&&this.clearStencil();const H={};for(let W=0;W=0;this.currentLayer--){const ee=this.style._layers[b[this.currentLayer]],pe=a._getLayerSourceCache(ee);if(ee.isSky())continue;const fe=pe?H[pe.id]:void 0;this._renderTileClippingMasks(ee,pe,fe),this.renderLayer(this,pe,ee,fe)}if(this.style.fog&&this.transform.projection.supportsFog&&function(ee,pe){const fe=ee.context,Me=fe.gl,Ne=ee.transform,st=new i.DepthMode(Me.LEQUAL,i.DepthMode.ReadOnly,[0,1]),it=ee.useProgram("globeAtmosphere",null,Ne.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),lt=i.globeToMercatorTransition(Ne.zoom),qe=pe.properties.get("color").toArray01(),Ye=pe.properties.get("high-color").toArray01(),dt=pe.properties.get("space-color").toArray01PremultipliedAlpha(),ht=i.identity$1([]);i.rotateY$1(ht,ht,-i.degToRad(Ne._center.lng)),i.rotateX$1(ht,ht,i.degToRad(Ne._center.lat)),i.rotateZ$1(ht,ht,Ne.angle),i.rotateX$1(ht,ht,-Ne._pitch);const Bt=i.fromQuat(new Float32Array(16),ht),Pt=i.mapValue(pe.properties.get("star-intensity"),0,1,0,.25),It=5e-4,Ht=i.mapValue(pe.properties.get("horizon-blend"),0,1,It,.25),hi=i.globeUseCustomAntiAliasing(ee,fe,Ne)&&Ht===It?Ne.worldSize/(2*Math.PI*1.025)-1:Ne.globeRadius,si=ee.frameCounter/1e3%1,qt=i.length(Ne.globeCenterInViewSpace),ji=Math.sqrt(Math.pow(qt,2)-Math.pow(hi,2)),Kt=Math.acos(ji/qt),Ci=((Ri,Ai,Mi,$i,Jt,pi,In,Hn,Mn,$n,lr,On,_n,Dr)=>({u_frustum_tl:Ri,u_frustum_tr:Ai,u_frustum_br:Mi,u_frustum_bl:$i,u_horizon:Jt,u_transition:pi,u_fadeout_range:In,u_color:Hn,u_high_color:Mn,u_space_color:$n,u_star_intensity:lr,u_star_size:5*i.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:On,u_horizon_angle:_n,u_rotation_matrix:Dr}))(Ne.frustumCorners.TL,Ne.frustumCorners.TR,Ne.frustumCorners.BR,Ne.frustumCorners.BL,Ne.frustumCorners.horizon,lt,Ht,qe,Ye,dt,Pt,si,Kt,Bt);ee.prepareDrawProgram(fe,it);const di=ee.atmosphereBuffer;di&&it.draw(fe,Me.TRIANGLES,st,i.StencilMode.disabled,i.ColorMode.alphaBlended,i.CullFaceMode.backCW,Ci,"skybox",di.vertexBuffer,di.indexBuffer,di.segments)}(this,this.style.fog),this.renderPass="sky",(i.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const fe=a._getLayerSourceCache(pe);fe&&!pe.isHidden(this.transform.zoom)&&(!ee||ee.getSource().maxzoom0?m.pop():null}isPatternMissing(a){return a===null||a!==void 0&&!this.imageManager.getPattern(a.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const a=this.terrain&&this.terrain.renderingToTexture,m=this.terrain&&this.terrain.exaggeration()===0,b=this.style&&this.style.fog,S=[];return this.terrainRenderModeElevated()&&S.push("TERRAIN"),this.transform.projection.name==="globe"&&S.push("GLOBE"),m&&S.push("ZERO_EXAGGERATION"),b&&!a&&b.getOpacity(this.transform.pitch)!==0&&S.push("FOG"),a&&S.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&S.push("OVERDRAW_INSPECTOR"),S}useProgram(a,m,b){this.cache=this.cache||{};const S=b||[],P=this.currentGlobalDefines().concat(S),H=rA.cacheKey(Oc[a],a,P,m);return this.cache[H]||(this.cache[H]=new rA(this.context,a,Oc[a],m,id[a],P)),this.cache[H]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const a=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(a.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=i.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(a,m,b){if(this.terrain&&this.terrain.renderingToTexture)return;const S=this.style.fog;if(S){const P=S.getOpacity(this.transform.pitch),H=((W,ee,pe,fe,Me,Ne,st,it,lt,qe,Ye)=>{const dt=W.transform,ht=ee.properties.get("color").toArray01();ht[3]=fe;const Bt=W.frameCounter/1e3%1;return{u_fog_matrix:pe?dt.calculateFogTileMatrix(pe):W.identityMat,u_fog_range:ee.getFovAdjustedRange(dt._fov),u_fog_color:ht,u_fog_horizon_blend:ee.properties.get("horizon-blend"),u_fog_temporal_offset:Bt,u_frustum_tl:Me,u_frustum_tr:Ne,u_frustum_br:st,u_frustum_bl:it,u_globe_pos:lt,u_globe_radius:qe,u_viewport:Ye,u_globe_transition:i.globeToMercatorTransition(dt.zoom),u_is_globe:+(dt.projection.name==="globe")}})(this,S,b,P,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.exported.devicePixelRatio,this.transform.height*i.exported.devicePixelRatio]);m.setFogUniformValues(a,H)}}setTileLoadedFlag(a){this.tileLoaded=a}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const a=this.context.gl,m=a.createTexture();return a.bindTexture(a.TEXTURE_2D,m),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,a.drawingBufferWidth,a.drawingBufferHeight,0),m}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const a=this.style&&this.style.fog;return!!a&&a.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const a=this._backgroundTiles,m=this._backgroundTiles={},b=this.transform.coveringTiles({tileSize:512});for(const S of b)m[S.key]=a[S.key]||new i.Tile(S,512,this.transform.tileZoom,this);return m}clearBackgroundTiles(){this._backgroundTiles={}}}class Qh{constructor(a=0,m=0,b=0,S=0){if(isNaN(a)||a<0||isNaN(m)||m<0||isNaN(b)||b<0||isNaN(S)||S<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=a,this.bottom=m,this.left=b,this.right=S}interpolate(a,m,b){return m.top!=null&&a.top!=null&&(this.top=i.number(a.top,m.top,b)),m.bottom!=null&&a.bottom!=null&&(this.bottom=i.number(a.bottom,m.bottom,b)),m.left!=null&&a.left!=null&&(this.left=i.number(a.left,m.left,b)),m.right!=null&&a.right!=null&&(this.right=i.number(a.right,m.right,b)),this}getCenter(a,m){const b=i.clamp((this.left+a-this.right)/2,0,a),S=i.clamp((this.top+m-this.bottom)/2,0,m);return new i.pointGeometry(b,S)}equals(a){return this.top===a.top&&this.bottom===a.bottom&&this.left===a.left&&this.right===a.right}clone(){return new Qh(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function _c(x,a){const m=i.getColumn(x,3);i.fromQuat(x,a),i.setColumn(x,3,m)}function hA(x,a){const m=i.identity$1([]);return i.rotateZ$1(m,m,-a),i.rotateX$1(m,m,-x),m}function uA(x,a){const m=[x[0],x[1],0],b=[a[0],a[1],0];if(i.length(m)>=1e-15){const H=i.normalize([],m);i.scale$2(b,H,i.dot(b,H)),a[0]=b[0],a[1]=b[1]}const S=i.cross([],a,x);if(i.len(S)<1e-15)return null;const P=Math.atan2(-S[1],S[0]);return hA(Math.atan2(Math.sqrt(x[0]*x[0]+x[1]*x[1]),-x[2]),P)}class Vh{constructor(a,m){this.position=a,this.orientation=m}get position(){return this._position}set position(a){if(a){const m=a instanceof i.MercatorCoordinate?a:new i.MercatorCoordinate(a[0],a[1],a[2]);this._renderWorldCopies&&(m.x=i.wrap(m.x,0,1)),this._position=m}else this._position=null}lookAtPoint(a,m){if(this.orientation=null,!this.position)return;const b=this._elevation?this._elevation.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(a)):0,S=this.position,P=i.MercatorCoordinate.fromLngLat(a,b),H=[P.x-S.x,P.y-S.y,P.z-S.z];m||(m=[0,0,1]),m[2]=Math.abs(m[2]),this.orientation=uA(H,m)}setPitchBearing(a,m){this.orientation=hA(i.degToRad(a),i.degToRad(-m))}}class Hh{constructor(a,m){this._transform=i.identity([]),this.orientation=m,this.position=a}get mercatorPosition(){const a=this.position;return new i.MercatorCoordinate(a[0],a[1],a[2])}get position(){const a=i.getColumn(this._transform,3);return[a[0],a[1],a[2]]}set position(a){var m;a&&i.setColumn(this._transform,3,[(m=a)[0],m[1],m[2],1])}get orientation(){return this._orientation}set orientation(a){this._orientation=a||i.identity$1([]),a&&_c(this._transform,this._orientation)}getPitchBearing(){const a=this.forward(),m=this.right();return{bearing:Math.atan2(-m[1],m[0]),pitch:Math.atan2(Math.sqrt(a[0]*a[0]+a[1]*a[1]),-a[2])}}setPitchBearing(a,m){this._orientation=hA(a,m),_c(this._transform,this._orientation)}forward(){const a=i.getColumn(this._transform,2);return[-a[0],-a[1],-a[2]]}up(){const a=i.getColumn(this._transform,1);return[-a[0],-a[1],-a[2]]}right(){const a=i.getColumn(this._transform,0);return[a[0],a[1],a[2]]}getCameraToWorld(a,m){const b=new Float64Array(16);return i.invert(b,this.getWorldToCamera(a,m)),b}getWorldToCameraPosition(a,m,b){const S=this.position;i.scale$2(S,S,-a);const P=new Float64Array(16);return i.fromScaling(P,[b,b,b]),i.translate(P,P,S),P[10]*=m,P}getWorldToCamera(a,m){const b=new Float64Array(16),S=new Float64Array(4),P=this.position;return i.conjugate(S,this._orientation),i.scale$2(P,P,-a),i.fromQuat(b,S),i.translate(b,b,P),b[1]*=-1,b[5]*=-1,b[9]*=-1,b[13]*=-1,b[8]*=m,b[9]*=m,b[10]*=m,b[11]*=m,b}getCameraToClipPerspective(a,m,b,S){const P=new Float64Array(16);return i.perspective(P,a,m,b,S),P}getDistanceToElevation(a,m=!1){const b=a===0?0:i.mercatorZfromAltitude(a,m?i.latFromMercatorY(this.position[1]):this.position[1]),S=this.forward();return(b-this.position[2])/S[2]}clone(){return new Hh([...this.position],[...this.orientation])}}function ih(x,a){const m=Ms(x.projection,x.zoom,x.width,x.height),b=function(P,H,W,ee,pe){const fe=new i.LngLat(W.lng-180*fo,W.lat),Me=new i.LngLat(W.lng+180*fo,W.lat),Ne=P.project(fe.lng,fe.lat),st=P.project(Me.lng,Me.lat),it=-Math.atan2(st.y-Ne.y,st.x-Ne.x),lt=i.MercatorCoordinate.fromLngLat(W);lt.y=i.clamp(lt.y,-.999975,.999975);const qe=lt.toLngLat(),Ye=P.project(qe.lng,qe.lat),dt=i.MercatorCoordinate.fromLngLat(qe);dt.x+=fo;const ht=dt.toLngLat(),Bt=P.project(ht.lng,ht.lat),Pt=jl(Bt.x-Ye.x,Bt.y-Ye.y,it),It=i.MercatorCoordinate.fromLngLat(qe);It.y+=fo;const Ht=It.toLngLat(),hi=P.project(Ht.lng,Ht.lat),si=jl(hi.x-Ye.x,hi.y-Ye.y,it),qt=Math.abs(Pt.x)/Math.abs(si.y),ji=i.identity([]);i.rotateZ(ji,ji,-it*(1-(pe?0:ee)));const Kt=i.identity([]);return i.scale(Kt,Kt,[1,1-(1-qt)*ee,1]),Kt[4]=-si.x/si.y*ee,i.rotateZ(Kt,Kt,it),i.multiply(Kt,ji,Kt),Kt}(x.projection,0,x.center,m,a),S=yc(x);return i.scale(b,b,[S,S,1]),b}function yc(x){const a=x.projection,m=Ms(x.projection,x.zoom,x.width,x.height),b=Gh(a,x.center),S=Gh(a,i.LngLat.convert(a.center));return Math.pow(2,b*m+(1-m)*S)}function Ms(x,a,m,b,S=1/0){const P=x.range;if(!P)return 0;const H=Math.min(S,Math.max(m,b)),W=Math.log(H/1024)/Math.LN2;return i.smoothstep(P[0]+W,P[1]+W,a)}const fo=1/4e4;function Gh(x,a){const m=i.clamp(a.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),b=new i.LngLat(a.lng-180*fo,m),S=new i.LngLat(a.lng+180*fo,m),P=x.project(b.lng,m),H=x.project(S.lng,m),W=i.MercatorCoordinate.fromLngLat(b),ee=i.MercatorCoordinate.fromLngLat(S),pe=H.x-P.x,fe=H.y-P.y,Me=ee.x-W.x,Ne=ee.y-W.y,st=Math.sqrt((Me*Me+Ne*Ne)/(pe*pe+fe*fe));return Math.log(st)/Math.LN2}function jl(x,a,m){const b=Math.cos(m),S=Math.sin(m);return{x:x*b-a*S,y:x*S+a*b}}class Kl{constructor(a,m,b,S,P,H,W){this.tileSize=512,this._renderWorldCopies=P===void 0||P,this._minZoom=a||0,this._maxZoom=m||22,this._minPitch=b==null?0:b,this._maxPitch=S==null?60:S,this.setProjection(H),this.setMaxBounds(W),this.width=0,this.height=0,this._center=new i.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Qh,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Hh,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const a=new Kl(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return a._elevation=this._elevation,a._centerAltitude=this._centerAltitude,a._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,a.tileSize=this.tileSize,a.mercatorFromTransition=this.mercatorFromTransition,a.width=this.width,a.height=this.height,a.cameraElevationReference=this.cameraElevationReference,a._center=this._center,a._setZoom(this.zoom),a._seaLevelZoom=this._seaLevelZoom,a.angle=this.angle,a._fov=this._fov,a._pitch=this._pitch,a._nearZ=this._nearZ,a._farZ=this._farZ,a._averageElevation=this._averageElevation,a._unmodified=this._unmodified,a._edgeInsets=this._edgeInsets.clone(),a._camera=this._camera.clone(),a._calcMatrices(),a.freezeTileCoverage=this.freezeTileCoverage,a.frustumCorners=this.frustumCorners,a}get elevation(){return this._elevation}set elevation(a){this._elevation!==a&&(this._elevation=a,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(a,m=!1){const b=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||b)&&this._updateCameraOnTerrain(),(a||b)&&this._constrainCamera(m),this._calcMatrices()}getProjection(){return i.pick(this.projection,["name","center","parallels"])}setProjection(a){this.projectionOptions=a||{name:"mercator"};const m=this.projection?this.getProjection():void 0;this.projection=i.getProjection(this.projectionOptions);const b=!C(m,this.getProjection());return b&&this._calcMatrices(),this.mercatorFromTransition=!1,b}setMercatorFromTransition(){const a=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=i.getProjection({name:"mercator"});const m=a!==this.projection.name;return m&&this._calcMatrices(),m}get minZoom(){return this._minZoom}set minZoom(a){this._minZoom!==a&&(this._minZoom=a,this.zoom=Math.max(this.zoom,a))}get maxZoom(){return this._maxZoom}set maxZoom(a){this._maxZoom!==a&&(this._maxZoom=a,this.zoom=Math.min(this.zoom,a))}get minPitch(){return this._minPitch}set minPitch(a){this._minPitch!==a&&(this._minPitch=a,this.pitch=Math.max(this.pitch,a))}get maxPitch(){return this._maxPitch}set maxPitch(a){this._maxPitch!==a&&(this._maxPitch=a,this.pitch=Math.min(this.pitch,a))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(a){a===void 0?a=!0:a===null&&(a=!1),this._renderWorldCopies=a}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const a=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(a))}get cameraWorldSize(){const a=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(a))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return i.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new i.pointGeometry(this.width,this.height)}get bearing(){return i.wrap(this.rotation,-180,180)}set bearing(a){this.rotation=a}get rotation(){return-this.angle/Math.PI*180}set rotation(a){const m=-a*Math.PI/180;var b;this.angle!==m&&(this._unmodified=!1,this.angle=m,this._calcMatrices(),this.rotationMatrix=(b=new i.ARRAY_TYPE(4),i.ARRAY_TYPE!=Float32Array&&(b[1]=0,b[2]=0),b[0]=1,b[3]=1,b),function(S,P,H){var W=P[0],ee=P[1],pe=P[2],fe=P[3],Me=Math.sin(H),Ne=Math.cos(H);S[0]=W*Ne+pe*Me,S[1]=ee*Ne+fe*Me,S[2]=W*-Me+pe*Ne,S[3]=ee*-Me+fe*Ne}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(a){const m=i.clamp(a,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==m&&(this._unmodified=!1,this._pitch=m,this._calcMatrices())}get aspect(){return this.width/this.height}get fovX(){return this._fov}get fovY(){const a=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/a)}set fov(a){a=Math.max(.01,Math.min(60,a)),this._fov!==a&&(this._unmodified=!1,this._fov=i.degToRad(a),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(a){this._averageElevation=a,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(a){const m=Math.min(Math.max(a,this.minZoom),this.maxZoom);this._zoom!==m&&(this._unmodified=!1,this._setZoom(m),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(a){this._zoom=a,this.scale=this.zoomScale(a),this.tileZoom=Math.floor(a),this.zoomFraction=a-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const a=this._elevation;this._centerAltitude=a.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=a.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==void 0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const a=this._elevation,m=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],b=this.horizonLineFromTop();let S=0,P=0;for(let H=0;Ha.maxzoom&&(m=a.maxzoom);const H=this.locationCoordinate(this.center),W=this.center.lat,ee=1<{const $i=new i.MercatorCoordinate(Ai.x+25e-6,Ai.y,Ai.z),Jt=new i.MercatorCoordinate(Ai.x,Ai.y+25e-6,Ai.z),pi=Ai.toLngLat(),In=$i.toLngLat(),Hn=Jt.toLngLat(),Mn=this.locationCoordinate(pi),$n=this.locationCoordinate(In),lr=this.locationCoordinate(Hn),On=Math.hypot($n.x-Mn.x,$n.y-Mn.y),_n=Math.hypot(lr.x-Mn.x,lr.y-Mn.y);return Math.sqrt(On*_n)*Pt/25e-6},Ht=Ai=>{const Mi=ht,$i=Bt;return{aabb:i.tileAABB(this,ee,0,0,0,Ai,$i,Mi,this.projection),zoom:0,x:0,y:0,minZ:$i,maxZ:Mi,wrap:Ai,fullyVisible:!1}},hi=[];let si=[];const qt=m,ji=a.reparseOverscaled?b:m,Kt=Ai=>Ai*Ai,Ci=Kt((lt-this._centerAltitude)*it),di=Ai=>{if(!this._elevation||!Ai.tileID||!P)return;const Mi=this._elevation.getMinMaxForTile(Ai.tileID),$i=Ai.aabb;Mi?($i.min[2]=Mi.min,$i.max[2]=Mi.max,$i.center[2]=($i.min[2]+$i.max[2])/2):(Ai.shouldSplit=Ri(Ai),Ai.shouldSplit||($i.min[2]=$i.max[2]=$i.center[2]=this._centerAltitude))},Ri=Ai=>{if(Ai.zoom=.9)return!0}else if(S&&(Jt=Kt(Ai.aabb.distanceZ(qe)*it)),this.projection.isReprojectedInTileSpace&&b<=5){const Mn=Math.pow(2,Ai.zoom),$n=It(new i.MercatorCoordinate((Ai.x+.5)/Mn,(Ai.y+.5)/Mn));pi=$n>.85?1:$n}const In=Mi*Mi+$i*$i+Jt,Hn=Kt((1<{if($n*Kt(.707)0;){const Ai=hi.pop(),Mi=Ai.x,$i=Ai.y;let Jt=Ai.fullyVisible;if(!Jt){const pi=Ai.aabb.intersects(Ne);if(pi===0)continue;Jt=pi===2}if(Ai.zoom!==qt&&Ri(Ai))for(let pi=0;pi<4;pi++){const In=(Mi<<1)+pi%2,Hn=($i<<1)+(pi>>1),Mn={aabb:P?Ai.aabb.quadrant(pi):i.tileAABB(this,ee,Ai.zoom+1,In,Hn,Ai.wrap,Ai.minZ,Ai.maxZ,this.projection),zoom:Ai.zoom+1,x:In,y:Hn,wrap:Ai.wrap,fullyVisible:Jt,tileID:void 0,shouldSplit:void 0,minZ:Ai.minZ,maxZ:Ai.maxZ};S&&!fe&&(Mn.tileID=new i.OverscaledTileID(Ai.zoom+1===qt?ji:Ai.zoom+1,Ai.wrap,Ai.zoom+1,In,Hn),di(Mn)),hi.push(Mn)}else{const pi=Ai.zoom===qt?ji:Ai.zoom;if(a.minzoom&&a.minzoom>pi)continue;const In=pe[0]-(.5+Mi+(Ai.wrap<{const Jt=[0,0,0,1],pi=[i.EXTENT,i.EXTENT,0,1],In=this.calculateFogTileMatrix($i.tileID.toUnwrapped());i.transformMat4$1(Jt,Jt,In),i.transformMat4$1(pi,pi,In);const Hn=i.getAABBPointSquareDist(Jt,pi);if(Hn===0)return!0;let Mn=!1;const $n=this._elevation;if($n&&Hn>Ai&&Mi!==0){const lr=this.calculateProjMatrix($i.tileID.toUnwrapped());let On;a.isTerrainDEM||(On=$n.getMinMaxForTile($i.tileID)),On||(On={min:Bt,max:ht});const _n=i.furthestTileCorner(this.rotation),Dr=[_n[0]*i.EXTENT,_n[1]*i.EXTENT,On.max];i.transformMat4(Dr,Dr,lr),Mn=(1-Dr[1])*this.height*.5Ai.distanceSq-Mi.distanceSq).map(Ai=>Ai.tileID)}resize(a,m){this.width=a,this.height=m,this.pixelsToGLUnits=[2/a,-2/m],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(a){return Math.pow(2,a)}scaleZoom(a){return Math.log(a)/Math.LN2}project(a){const m=i.clamp(a.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),b=this.projection.project(a.lng,m);return new i.pointGeometry(b.x*this.worldSize,b.y*this.worldSize)}unproject(a){return this.projection.unproject(a.x/this.worldSize,a.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(a,m){let b,S;const P=this.centerPoint;if(this.projection.name==="globe"){const W=this.worldSize;b=(m.x-P.x)/W,S=(m.y-P.y)/W}else{const W=this.pointCoordinate(m),ee=this.pointCoordinate(P);b=W.x-ee.x,S=W.y-ee.y}const H=this.locationCoordinate(a);this.setLocation(new i.MercatorCoordinate(H.x-b,H.y-S))}setLocation(a){this.center=this.coordinateLocation(a),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(a){return this.projection.locationPoint(this,a)}locationPoint3D(a){return this.projection.locationPoint(this,a,!0)}pointLocation(a){return this.coordinateLocation(this.pointCoordinate(a))}pointLocation3D(a){return this.coordinateLocation(this.pointCoordinate3D(a))}locationCoordinate(a,m){const b=m?i.mercatorZfromAltitude(m,a.lat):void 0,S=this.projection.project(a.lng,a.lat);return new i.MercatorCoordinate(S.x,S.y,b)}coordinateLocation(a){return this.projection.unproject(a.x,a.y)}pointRayIntersection(a,m){const b=m!=null?m:this._centerAltitude,S=[a.x,a.y,0,1],P=[a.x,a.y,1,1];i.transformMat4$1(S,S,this.pixelMatrixInverse),i.transformMat4$1(P,P,this.pixelMatrixInverse);const H=P[3];i.scale$1(S,S,1/S[3]),i.scale$1(P,P,1/H);const W=S[2],ee=P[2];return{p0:S,p1:P,t:W===ee?0:(b-W)/(ee-W)}}screenPointToMercatorRay(a){const m=[a.x,a.y,0,1],b=[a.x,a.y,1,1];return i.transformMat4$1(m,m,this.pixelMatrixInverse),i.transformMat4$1(b,b,this.pixelMatrixInverse),i.scale$1(m,m,1/m[3]),i.scale$1(b,b,1/b[3]),m[2]=i.mercatorZfromAltitude(m[2],this._center.lat)*this.worldSize,b[2]=i.mercatorZfromAltitude(b[2],this._center.lat)*this.worldSize,i.scale$1(m,m,1/this.worldSize),i.scale$1(b,b,1/this.worldSize),new i.Ray([m[0],m[1],m[2]],i.normalize([],i.sub([],b,m)))}rayIntersectionCoordinate(a){const{p0:m,p1:b,t:S}=a,P=i.mercatorZfromAltitude(m[2],this._center.lat),H=i.mercatorZfromAltitude(b[2],this._center.lat);return new i.MercatorCoordinate(i.number(m[0],b[0],S)/this.worldSize,i.number(m[1],b[1],S)/this.worldSize,i.number(P,H,S))}pointCoordinate(a,m=this._centerAltitude){return this.projection.pointCoordinate(this,a.x,a.y,m)}pointCoordinate3D(a){if(!this.elevation)return this.pointCoordinate(a);let m=this.projection.pointCoordinate3D(this,a.x,a.y);if(m)return new i.MercatorCoordinate(m[0],m[1],m[2]);let b=0,S=this.horizonLineFromTop();if(a.y>S)return this.pointCoordinate(a);const P=.02*S,H=a.clone();for(let W=0;W<10&&S-b>P;W++){H.y=i.number(b,S,.66);const ee=this.projection.pointCoordinate3D(this,H.x,H.y);ee?(S=H.y,m=ee):b=H.y}return m?new i.MercatorCoordinate(m[0],m[1],m[2]):this.pointCoordinate(a)}isPointAboveHorizon(a){return this.projection.isPointAboveHorizon(this,a)}_coordinatePoint(a,m){const b=m&&this.elevation?this.elevation.getAtPointOrZero(a,this._centerAltitude):this._centerAltitude,S=[a.x*this.worldSize,a.y*this.worldSize,b+a.toAltitude(),1];return i.transformMat4$1(S,S,this.pixelMatrix),S[3]>0?new i.pointGeometry(S[0]/S[3],S[1]/S[3]):new i.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getGlobeBounds(){const{top:a,left:m}=this._edgeInsets,b=this.height-this._edgeInsets.bottom,S=this.width-this._edgeInsets.right,P=this.pointCoordinate3D(new i.pointGeometry(m,a)),H=this.pointCoordinate3D(new i.pointGeometry(S,a)),W=this.pointCoordinate3D(new i.pointGeometry(S,b)),ee=this.pointCoordinate3D(new i.pointGeometry(m,b));let pe=Math.min(P.x,ee.x),fe=Math.max(H.x,W.x),Me=Math.min(P.y,H.y),Ne=Math.max(ee.y,W.y);const st=Math.pow(2,-this.zoom)/16,it=(It,Ht,hi,si)=>{const qt=(It+hi)/2,ji=(Ht+si)/2,Kt=new i.pointGeometry(qt,ji),Ci=this.pointCoordinate3D(Kt),di=Math.max(0,pe-Ci.x,Me-Ci.y,Ci.x-fe,Ci.y-Ne);pe=Math.min(pe,Ci.x),fe=Math.max(fe,Ci.x),Me=Math.min(Me,Ci.y),Ne=Math.max(Ne,Ci.y),di>st&&(it(It,Ht,qt,ji),it(qt,ji,hi,si))};it(m,a,S,a),it(S,a,S,b),it(S,b,m,b),it(m,b,m,a);const[lt,qe]=i.polesInViewport(this),Ye=lt||qe,dt=lt?90:i.latFromMercatorY(Me),ht=Ye?180:i.lngFromMercatorX(fe),Bt=qe?-90:i.latFromMercatorY(Ne),Pt=Ye?-180:i.lngFromMercatorX(pe);return new i.LngLatBounds(new i.LngLat(Pt,Bt),new i.LngLat(ht,dt))}_getBounds(a,m){if(this.projection.name==="globe")return this._getGlobeBounds();const b=new i.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),S=new i.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),P=new i.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),H=new i.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let W=this.pointCoordinate(b,a),ee=this.pointCoordinate(S,a);const pe=this.pointCoordinate(P,m),fe=this.pointCoordinate(H,m),Me=(Ne,st)=>(st.y-Ne.y)/(st.x-Ne.x);return W.y>1&&ee.y>=0?W=new i.MercatorCoordinate((1-fe.y)/Me(fe,W)+fe.x,1):W.y<0&&ee.y<=1&&(W=new i.MercatorCoordinate(-fe.y/Me(fe,W)+fe.x,0)),ee.y>1&&W.y>=0?ee=new i.MercatorCoordinate((1-pe.y)/Me(pe,ee)+pe.x,1):ee.y<0&&W.y<=1&&(ee=new i.MercatorCoordinate(-pe.y/Me(pe,ee)+pe.x,0)),new i.LngLatBounds().extend(this.coordinateLocation(W)).extend(this.coordinateLocation(ee)).extend(this.coordinateLocation(fe)).extend(this.coordinateLocation(pe))}_getBounds3D(){const a=this.elevation;if(!a.visibleDemTiles.length||a.isUsingMockSource())return this._getBounds(0,0);const m=a.visibleDemTiles.reduce((b,S)=>{if(S.dem){const P=S.dem.tree;b.min=Math.min(b.min,P.minimums[0]),b.max=Math.max(b.max,P.maximums[0])}return b},{min:Number.MAX_VALUE,max:0});return this._getBounds(m.min*a.exaggeration(),m.max*a.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(a=!0){const m=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,b=this.height/2-m*(1-this._horizonShift);return a?Math.max(0,b):b}getMaxBounds(){return this.maxBounds}setMaxBounds(a){this.maxBounds=a,this.minLat=-i.MAX_MERCATOR_LATITUDE,this.maxLat=i.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,a&&(this.minLat=a.getSouth(),this.maxLat=a.getNorth(),this.minLng=a.getWest(),this.maxLng=a.getEast(),this.maxLngMe&&(W=Me-pe),Me-fest&&(H=st-ee),st-Ne.5?dt-1:dt,ht>.5?ht-1:ht,0]),this.alignedProjMatrix=Bt,H=i.create(),i.scale(H,H,[this.width/2,-this.height/2,1]),i.translate(H,H,[1,-1,0]),this.labelPlaneMatrix=H,H=i.create(),i.scale(H,H,[1,-1,1]),i.translate(H,H,[-1,-1,0]),i.scale(H,H,[2/this.width,2/this.height,1]),this.glCoordMatrix=H,this.pixelMatrix=i.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},H=i.invert(new Float64Array(16),this.pixelMatrix),!H)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=H,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.calculateGlobeMatrix(this);const Pt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.transformMat4(Pt,Pt,S),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=H;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const a=this.cameraWorldSizeForFog,m=this.cameraPixelsPerMeter,b=this._camera.position,S=1/this.height/this._pixelsPerMercatorPixel,P=[a,a,m];i.scale$2(P,P,S),i.scale$2(b,b,-1),i.multiply$2(b,b,P);const H=i.create();i.translate(H,H,b),i.scale(H,H,P),this.mercatorFogMatrix=H,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(a,m,S)}_computeCameraPosition(a){const m=(a=a||this.pixelsPerMeter)/this.pixelsPerMeter,b=this._camera.forward(),S=this.point,P=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*m-a/this.worldSize*this._centerAltitude;return[S.x/this.worldSize-b[0]*P,S.y/this.worldSize-b[1]*P,a/this.worldSize*this._centerAltitude-b[2]*P]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(a){const m=this._maxCameraBoundsDistance()*Math.cos(this._pitch),b=this._camera.position[2],S=a[2];let P=1;this.projection.wrap&&(this.center=this.center.wrap()),S>0&&(P=Math.min((m-b)/S,1)),this._camera.position=i.scaleAndAdd([],this._camera.position,a,P),this._updateStateFromCamera()}_updateStateFromCamera(){const a=this._camera.position,m=this._camera.forward(),{pitch:b,bearing:S}=this._camera.getPitchBearing(),P=i.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,H=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.degToRad(this._maxPitch)),W=Math.max((a[2]-P)/Math.cos(b),H),ee=this._zoomFromMercatorZ(W);i.scaleAndAdd(a,a,m,W),this._pitch=i.clamp(b,i.degToRad(this.minPitch),i.degToRad(this.maxPitch)),this.angle=i.wrap(S,-Math.PI,Math.PI),this._setZoom(i.clamp(ee,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.MercatorCoordinate(a[0],a[1],a[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(a){return Math.pow(2,a)*this.tileSize}_mercatorZfromZoom(a){return this.cameraToCenterDistance/this._worldSizeFromZoom(a)}_minimumHeightOverTerrain(){const a=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(a)}_zoomFromMercatorZ(a){return this.scaleZoom(this.cameraToCenterDistance/(a*this.tileSize))}zoomFromMercatorZAdjusted(a){const m=H=>{const W=this.getCameraToCenterDistance(this.projection,H);return this.scaleZoom(W/(a*this.tileSize))};let b,S=m(this.zoom),P=Math.abs(S-m(S));for(;b!==P;)S=m(S),b=P,P=Math.abs(S-m(S));return S}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(i.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(a,m){const b=Math.min(a.x,m.x),S=Math.max(a.x,m.x),P=Math.min(a.y,m.y),H=Math.max(a.y,m.y);if(Ppe||Ne.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.pointGeometry(0,0),new i.pointGeometry(this.width,this.height))}zoomDeltaToMovement(a,m){const b=i.length(i.sub([],this._camera.position,a)),S=this._zoomFromMercatorZ(b)+m;return b-this._mercatorZfromZoom(S)}getCameraPoint(){if(this.projection.name==="globe"){const a=function([m,b,S],P){const H=[m,b,S,1];i.transformMat4$1(H,H,P);const W=H[3]=Math.max(H[3],1e-6);return H[0]/=W,H[1]/=W,H[2]/=W,H}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.pointGeometry(a[0],a[1])}{const a=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.pointGeometry(0,a))}}getCameraToCenterDistance(a,m=this.zoom){const b=Ms(a,m,this.width,this.height,1024),S=a.pixelSpaceConversion(this.center.lat,this.worldSize,b);return .5/Math.tan(.5*this._fov)*this.height*S}getWorldToCameraMatrix(){const a=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.multiply(a,a,this.globeMatrix),a}}function _l(x,a){let m=!1,b=null;const S=()=>{b=null,m&&(x(),b=setTimeout(S,a),m=!1)};return()=>(m=!0,b||S(),b)}class An{constructor(a){this._hashName=a&&encodeURIComponent(a),i.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=_l(this._updateHashUnthrottled.bind(this),300)}addTo(a){return this._map=a,i.window.addEventListener("hashchange",this._onHashChange,!1),a.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),i.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const a=this._map;if(!a)return"";const m=xs(a);if(this._hashName){const b=this._hashName;let S=!1;const P=i.window.location.hash.slice(1).split("&").map(H=>{const W=H.split("=")[0];return W===b?(S=!0,`${W}=${m}`):H}).filter(H=>H);return S||P.push(`${b}=${m}`),`#${P.join("&")}`}return`#${m}`}_getCurrentHash(){const a=i.window.location.hash.replace("#","");if(this._hashName){let m;return a.split("&").map(b=>b.split("=")).forEach(b=>{b[0]===this._hashName&&(m=b)}),(m&&m[1]||"").split("/")}return a.split("/")}_onHashChange(){const a=this._map;if(!a)return!1;const m=this._getCurrentHash();if(m.length>=3&&!m.some(b=>isNaN(b))){const b=a.dragRotate.isEnabled()&&a.touchZoomRotate.isEnabled()?+(m[3]||0):a.getBearing();return a.jumpTo({center:[+m[2],+m[1]],zoom:+m[0],bearing:b,pitch:+(m[4]||0)}),!0}return!1}_updateHashUnthrottled(){const a=i.window.location.href.replace(/(#.+)?$/,this.getHashString());i.window.history.replaceState(i.window.history.state,null,a)}}function xs(x,a){const m=x.getCenter(),b=Math.round(100*x.getZoom())/100,S=Math.ceil((b*Math.LN2+Math.log(512/360/.5))/Math.LN10),P=Math.pow(10,S),H=Math.round(m.lng*P)/P,W=Math.round(m.lat*P)/P,ee=x.getBearing(),pe=x.getPitch();let fe=a?`/${H}/${W}/${b}`:`${b}/${W}/${H}`;return(ee||pe)&&(fe+="/"+Math.round(10*ee)/10),pe&&(fe+=`/${Math.round(pe)}`),fe}const Zr={linearity:.3,easing:i.bezier(0,0,.3,1)},nh=i.extend({deceleration:2500,maxSpeed:1400},Zr),Wh=i.extend({deceleration:20,maxSpeed:1400},Zr),xc=i.extend({deceleration:1e3,maxSpeed:360},Zr),AA=i.extend({deceleration:1e3,maxSpeed:90},Zr);class jh{constructor(a){this._map=a,this.clear()}clear(){this._inertiaBuffer=[]}record(a){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.exported.now(),settings:a})}_drainInertiaBuffer(){const a=this._inertiaBuffer,m=i.exported.now();for(;a.length>0&&m-a[0].time>160;)a.shift()}_onMoveEnd(a){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const m={zoom:0,bearing:0,pitch:0,pan:new i.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:P}of this._inertiaBuffer)m.zoom+=P.zoomDelta||0,m.bearing+=P.bearingDelta||0,m.pitch+=P.pitchDelta||0,P.panDelta&&m.pan._add(P.panDelta),P.around&&(m.around=P.around),P.pinchAround&&(m.pinchAround=P.pinchAround);const b=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,S={};if(m.pan.mag()){const P=uo(m.pan.mag(),b,i.extend({},nh,a||{}));S.offset=m.pan.mult(P.amount/m.pan.mag()),S.center=this._map.transform.center,rh(S,P)}if(m.zoom){const P=uo(m.zoom,b,Wh);S.zoom=this._map.transform.zoom+P.amount,rh(S,P)}if(m.bearing){const P=uo(m.bearing,b,xc);S.bearing=this._map.transform.bearing+i.clamp(P.amount,-179,179),rh(S,P)}if(m.pitch){const P=uo(m.pitch,b,AA);S.pitch=this._map.transform.pitch+P.amount,rh(S,P)}if(S.zoom||S.bearing){const P=m.pinchAround===void 0?m.around:m.pinchAround;S.around=P?this._map.unproject(P):this._map.getCenter()}return this.clear(),S.noMoveStart=!0,S}}function rh(x,a){(!x.duration||x.durationm.unproject(ee)),W=P.reduce((ee,pe,fe,Me)=>ee.add(pe.div(Me.length)),new i.pointGeometry(0,0));super(a,{points:P,point:W,lngLats:H,lngLat:m.unproject(W),originalEvent:b}),this._defaultPrevented=!1}}class Vn extends i.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(a,m,b){super(a,{originalEvent:b}),this._defaultPrevented=!1}}class sh{constructor(a,m){this._map=a,this._clickTolerance=m.clickTolerance}reset(){this._mousedownPos=void 0}wheel(a){return this._firePreventable(new Vn(a.type,this._map,a))}mousedown(a,m){return this._mousedownPos=m,this._firePreventable(new Js(a.type,this._map,a))}mouseup(a){this._map.fire(new Js(a.type,this._map,a))}preclick(a){const m=i.extend({},a);m.type="preclick",this._map.fire(new Js(m.type,this._map,m))}click(a,m){this._mousedownPos&&this._mousedownPos.dist(m)>=this._clickTolerance||(this.preclick(a),this._map.fire(new Js(a.type,this._map,a)))}dblclick(a){return this._firePreventable(new Js(a.type,this._map,a))}mouseover(a){this._map.fire(new Js(a.type,this._map,a))}mouseout(a){this._map.fire(new Js(a.type,this._map,a))}touchstart(a){return this._firePreventable(new Fn(a.type,this._map,a))}touchmove(a){this._map.fire(new Fn(a.type,this._map,a))}touchend(a){this._map.fire(new Fn(a.type,this._map,a))}touchcancel(a){this._map.fire(new Fn(a.type,this._map,a))}_firePreventable(a){if(this._map.fire(a),a.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class dA{constructor(a){this._map=a}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(a){this._map.fire(new Js(a.type,this._map,a))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Js("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(a){this._delayContextMenu?this._contextMenuEvent=a:this._map.fire(new Js(a.type,this._map,a)),this._map.listens("contextmenu")&&a.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class yl{constructor(a,m){this._map=a,this._el=a.getCanvasContainer(),this._container=a.getContainer(),this._clickTolerance=m.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(a,m){this.isEnabled()&&a.shiftKey&&a.button===0&&(ae(),this._startPos=this._lastPos=m,this._active=!0)}mousemoveWindow(a,m){if(!this._active)return;const b=m,S=this._startPos,P=this._lastPos;if(!S||!P||P.equals(b)||!this._box&&b.dist(S){this._box&&(this._box.style.transform=`translate(${H}px,${ee}px)`,this._box.style.width=W-H+"px",this._box.style.height=pe-ee+"px")})}mouseupWindow(a,m){if(!this._active)return;const b=this._startPos,S=m;if(b&&a.button===0){if(this.reset(),we(),b.x!==S.x||b.y!==S.y)return this._map.fire(new i.Event("boxzoomend",{originalEvent:a})),{cameraAnimation:P=>P.fitScreenCoordinates(b,S,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",a)}}keydown(a){this._active&&a.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",a))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),ce(),delete this._startPos,delete this._lastPos}_fireEvent(a,m){return this._map.fire(new i.Event(a,{originalEvent:m}))}}function Cs(x,a){const m={};for(let b=0;bthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=a.timeStamp),b.length===this.numTouches&&(this.centroid=function(S){const P=new i.pointGeometry(0,0);for(const H of S)P._add(H);return P.div(S.length)}(m),this.touches=Cs(b,m)))}touchmove(a,m,b){if(this.aborted||!this.centroid)return;const S=Cs(b,m);for(const P in this.touches){const H=this.touches[P],W=S[P];(!W||W.dist(H)>30)&&(this.aborted=!0)}}touchend(a,m,b){if((!this.centroid||a.timeStamp-this.startTime>500)&&(this.aborted=!0),b.length===0){const S=!this.aborted&&this.centroid;if(this.reset(),S)return S}}}class Go{constructor(a){this.singleTap=new Ga(a),this.numTaps=a.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(a,m,b){this.singleTap.touchstart(a,m,b)}touchmove(a,m,b){this.singleTap.touchmove(a,m,b)}touchend(a,m,b){const S=this.singleTap.touchend(a,m,b);if(S){const P=a.timeStamp-this.lastTime<500,H=!this.lastTap||this.lastTap.dist(S)<30;if(P&&H||this.reset(),this.count++,this.lastTime=a.timeStamp,this.lastTap=S,this.count===this.numTaps)return this.reset(),S}}}class pA{constructor(){this._zoomIn=new Go({numTouches:1,numTaps:2}),this._zoomOut=new Go({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(a,m,b){this._zoomIn.touchstart(a,m,b),this._zoomOut.touchstart(a,m,b)}touchmove(a,m,b){this._zoomIn.touchmove(a,m,b),this._zoomOut.touchmove(a,m,b)}touchend(a,m,b){const S=this._zoomIn.touchend(a,m,b),P=this._zoomOut.touchend(a,m,b);return S?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:H=>H.easeTo({duration:300,zoom:H.getZoom()+1,around:H.unproject(S)},{originalEvent:a})}):P?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:H=>H.easeTo({duration:300,zoom:H.getZoom()-1,around:H.unproject(P)},{originalEvent:a})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const va={0:1,2:2};class hs{constructor(a){this.reset(),this._clickTolerance=a.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(a,m){return!1}_move(a,m){return{}}mousedown(a,m){if(this._lastPoint)return;const b=Je(a);this._correctButton(a,b)&&(this._lastPoint=m,this._eventButton=b)}mousemoveWindow(a,m){const b=this._lastPoint;if(b){if(a.preventDefault(),this._eventButton!=null&&function(S,P){const H=va[P];return S.buttons===void 0||(S.buttons&H)!==H}(a,this._eventButton))this.reset();else if(this._moved||!(m.dist(b)0&&(this._active=!0);const S=Cs(b,m),P=new i.pointGeometry(0,0),H=new i.pointGeometry(0,0);let W=0;for(const pe in S){const fe=S[pe],Me=this._touches[pe];Me&&(P._add(fe),H._add(fe.sub(Me)),W++,S[pe]=fe)}if(this._touches=S,W{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class h{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(a){}_move(a,m,b){return{}}touchstart(a,m,b){this._firstTwoTouches||b.length<2||(this._firstTwoTouches=[b[0].identifier,b[1].identifier],this._start([m[0],m[1]]))}touchmove(a,m,b){const S=this._firstTwoTouches;if(!S)return;a.preventDefault();const[P,H]=S,W=_(b,m,P),ee=_(b,m,H);if(!W||!ee)return;const pe=this._aroundCenter?null:W.add(ee).div(2);return this._move([W,ee],pe,a)}touchend(a,m,b){if(!this._firstTwoTouches)return;const[S,P]=this._firstTwoTouches,H=_(b,m,S),W=_(b,m,P);H&&W||(this._active&&we(),this.reset())}touchcancel(){this.reset()}enable(a){this._enabled=!0,this._aroundCenter=!!a&&a.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function _(x,a,m){for(let b=0;bMath.abs(x.x)}class ue extends h{constructor(a){super(),this._map=a}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(a){this._lastPoints=a,oe(a[0].sub(a[1]))&&(this._valid=!1)}_move(a,m,b){const S=this._lastPoints;if(!S)return;const P=a[0].sub(S[0]),H=a[1].sub(S[1]);return this._map._cooperativeGestures&&!i.isFullscreen()&&b.touches.length<3||(this._valid=this.gestureBeginsVertically(P,H,b.timeStamp),!this._valid)?void 0:(this._lastPoints=a,this._active=!0,{pitchDelta:(P.y+H.y)/2*-.5})}gestureBeginsVertically(a,m,b){if(this._valid!==void 0)return this._valid;const S=a.mag()>=2,P=m.mag()>=2;if(!S&&!P)return;if(!S||!P)return this._firstMove==null&&(this._firstMove=b),b-this._firstMove<100&&void 0;const H=a.y>0==m.y>0;return oe(a)&&oe(m)&&H}}const ve={panStep:100,bearingStep:15,pitchStep:10};class Te{constructor(){const a=ve;this._panStep=a.panStep,this._bearingStep=a.bearingStep,this._pitchStep=a.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(a){if(a.altKey||a.ctrlKey||a.metaKey)return;let m=0,b=0,S=0,P=0,H=0;switch(a.keyCode){case 61:case 107:case 171:case 187:m=1;break;case 189:case 109:case 173:m=-1;break;case 37:a.shiftKey?b=-1:(a.preventDefault(),P=-1);break;case 39:a.shiftKey?b=1:(a.preventDefault(),P=1);break;case 38:a.shiftKey?S=1:(a.preventDefault(),H=-1);break;case 40:a.shiftKey?S=-1:(a.preventDefault(),H=1);break;default:return}return this._rotationDisabled&&(b=0,S=0),{cameraAnimation:W=>{const ee=W.getZoom();W.easeTo({duration:300,easeId:"keyboardHandler",easing:ze,zoom:m?Math.round(ee)+m*(a.shiftKey?2:1):ee,bearing:W.getBearing()+b*this._bearingStep,pitch:W.getPitch()+S*this._pitchStep,offset:[-P*this._panStep,-H*this._panStep],center:W.getCenter()},{originalEvent:a})}}}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 ze(x){return x*(2-x)}const je=4.000244140625;class bt{constructor(a,m){this._map=a,this._el=a.getCanvasContainer(),this._handler=m,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,i.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(a){this._defaultZoomRate=a}setWheelZoomRate(a){this._wheelZoomRate=a}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(a){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!a&&a.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(a){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(a.ctrlKey||a.metaKey||this.isZooming()||i.isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let m=a.deltaMode===i.window.WheelEvent.DOM_DELTA_LINE?40*a.deltaY:a.deltaY;const b=i.exported.now(),S=b-(this._lastWheelEventTime||0);this._lastWheelEventTime=b,m!==0&&m%je==0?this._type="wheel":m!==0&&Math.abs(m)<4?this._type="trackpad":S>400?(this._type=null,this._lastValue=m,this._timeout=setTimeout(this._onTimeout,40,a)):this._type||(this._type=Math.abs(S*m)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,m+=this._lastValue)),a.shiftKey&&m&&(m/=4),this._type&&(this._lastWheelEvent=a,this._delta-=m,this._active||this._start(a)),a.preventDefault()}_onTimeout(a){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)}_start(a){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 m=me(this._el,a);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:m,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const a=this._map.transform;this._type==="wheel"&&a.projection.wrap&&(a._center.lng>=180||a._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const m=()=>a._terrainEnabled()&&this._aroundCoord?a.computeZoomRelativeTo(this._aroundCoord):a.zoom;if(this._delta!==0){const ee=this._type==="wheel"&&Math.abs(this._delta)>je?this._wheelZoomRate:this._defaultZoomRate;let pe=2/(1+Math.exp(-Math.abs(this._delta*ee)));this._delta<0&&pe!==0&&(pe=1/pe);const fe=m(),Me=Math.pow(2,fe),Ne=typeof this._targetZoom=="number"?a.zoomScale(this._targetZoom):Me;this._targetZoom=Math.min(a.maxZoom,Math.max(a.minZoom,a.scaleZoom(Ne*pe))),this._type==="wheel"&&(this._startZoom=fe,this._easing=this._smoothOutEasing(200)),this._delta=0}const b=typeof this._targetZoom=="number"?this._targetZoom:m(),S=this._startZoom,P=this._easing;let H,W=!1;if(this._type==="wheel"&&S&&P){const ee=Math.min((i.exported.now()-this._lastWheelEventTime)/200,1),pe=P(ee);H=i.number(S,b,pe),ee<1?this._frameId||(this._frameId=!0):W=!0}else H=b,W=!0;return this._active=!0,W&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!W,zoomDelta:H-m(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(a){let m=i.ease;if(this._prevEase){const b=this._prevEase,S=(i.exported.now()-b.start)/b.duration,P=b.easing(S+.01)-b.easing(S),H=.27/Math.sqrt(P*P+1e-4)*.01,W=Math.sqrt(.0729-H*H);m=i.bezier(H,W,.25,1)}return this._prevEase={start:i.exported.now(),duration:a,easing:m},m}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=z("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(i.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class mt{constructor(a,m){this._clickZoom=a,this._tapZoom=m}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 gt{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(a,m){return a.preventDefault(),{cameraAnimation:b=>{b.easeTo({duration:300,zoom:b.getZoom()+(a.shiftKey?-1:1),around:b.unproject(m)},{originalEvent:a})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Vt{constructor(){this._tap=new Go({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(a,m,b){this._swipePoint||(this._tapTime&&a.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?b.length>0&&(this._swipePoint=m[0],this._swipeTouch=b[0].identifier):this._tap.touchstart(a,m,b))}touchmove(a,m,b){if(this._tapTime){if(this._swipePoint){if(b[0].identifier!==this._swipeTouch)return;const S=m[0],P=S.y-this._swipePoint.y;return this._swipePoint=S,a.preventDefault(),this._active=!0,{zoomDelta:P/128}}}else this._tap.touchmove(a,m,b)}touchend(a,m,b){this._tapTime?this._swipePoint&&b.length===0&&this.reset():this._tap.touchend(a,m,b)&&(this._tapTime=a.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Zt{constructor(a,m,b){this._el=a,this._mousePan=m,this._touchPan=b}enable(a){this._inertiaOptions=a||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class ni{constructor(a,m,b){this._pitchWithRotate=a.pitchWithRotate,this._mouseRotate=m,this._mousePitch=b}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 St{constructor(a,m,b,S){this._el=a,this._touchZoom=m,this._touchRotate=b,this._tapDragZoom=S,this._rotationDisabled=!1,this._enabled=!0}enable(a){this._touchZoom.enable(a),this._rotationDisabled||this._touchRotate.enable(a),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const zt=x=>x.zoom||x.drag||x.pitch||x.rotate;class ai extends i.Event{}class Ei{constructor(){this.constants=[1,1,.01],this.radius=0}setup(a,m){const b=i.sub([],m,a);this.radius=i.length(b[2]<0?i.div([],b,this.constants):[b[0],b[1],0])}projectRay(a){i.div(a,a,this.constants),i.normalize(a,a),i.mul$1(a,a,this.constants);const m=i.scale$2([],a,this.radius);if(m[2]>0){const b=i.scale$2([],[0,0,1],i.dot(m,[0,0,1])),S=i.scale$2([],i.normalize([],[m[0],m[1],0]),this.radius),P=i.add([],m,i.scale$2([],i.sub([],i.add([],S,b),m),2));m[0]=P[0],m[1]=P[1]}return m}}function Bi(x){return x.panDelta&&x.panDelta.mag()||x.zoomDelta||x.bearingDelta||x.pitchDelta}class Hi{constructor(a,m){this._map=a,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new jh(a),this._bearingSnap=m.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Ei,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(m),i.bindAll(["handleEvent","handleWindowEvent"],this);const b=this._el;this._listeners=[[b,"touchstart",{passive:!0}],[b,"touchmove",{passive:!1}],[b,"touchend",void 0],[b,"touchcancel",void 0],[b,"mousedown",void 0],[b,"mousemove",void 0],[b,"mouseup",void 0],[i.window.document,"mousemove",{capture:!0}],[i.window.document,"mouseup",void 0],[b,"mouseover",void 0],[b,"mouseout",void 0],[b,"dblclick",void 0],[b,"click",void 0],[b,"keydown",{capture:!1}],[b,"keyup",void 0],[b,"wheel",{passive:!1}],[b,"contextmenu",void 0],[i.window,"blur",void 0]];for(const[S,P,H]of this._listeners)S.addEventListener(P,S===i.window.document?this.handleWindowEvent:this.handleEvent,H)}destroy(){for(const[a,m,b]of this._listeners)a.removeEventListener(m,a===i.window.document?this.handleWindowEvent:this.handleEvent,b)}_addDefaultHandlers(a){const m=this._map,b=m.getCanvasContainer();this._add("mapEvent",new sh(m,a));const S=m.boxZoom=new yl(m,a);this._add("boxZoom",S);const P=new pA,H=new gt;m.doubleClickZoom=new mt(H,P),this._add("tapZoom",P),this._add("clickZoom",H);const W=new Vt;this._add("tapDragZoom",W);const ee=m.touchPitch=new ue(m);this._add("touchPitch",ee);const pe=new Kh(a),fe=new xl(a);m.dragRotate=new ni(a,pe,fe),this._add("mouseRotate",pe,["mousePitch"]),this._add("mousePitch",fe,["mouseRotate"]);const Me=new Is(a),Ne=new M(m,a);m.dragPan=new Zt(b,Me,Ne),this._add("mousePan",Me),this._add("touchPan",Ne,["touchZoom","touchRotate"]);const st=new K,it=new F;m.touchZoomRotate=new St(b,it,st,W),this._add("touchRotate",st,["touchPan","touchZoom"]),this._add("touchZoom",it,["touchPan","touchRotate"]),this._add("blockableMapEvent",new dA(m));const lt=m.scrollZoom=new bt(m,this);this._add("scrollZoom",lt,["mousePan"]);const qe=m.keyboard=new Te;this._add("keyboard",qe);for(const Ye of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])a.interactive&&a[Ye]&&m[Ye].enable(a[Ye])}_add(a,m,b){this._handlers.push({handlerName:a,handler:m,allowed:b}),this._handlersById[a]=m}stop(a){if(!this._updatingCamera){for(const{handler:m}of this._handlers)m.reset();this._inertia.clear(),this._fireEvents({},{},a),this._changes=[]}}isActive(){for(const{handler:a}of this._handlers)if(a.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!zt(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(a,m,b){for(const S in a)if(S!==b&&(!m||m.indexOf(S)<0))return!0;return!1}handleWindowEvent(a){this.handleEvent(a,`${a.type}Window`)}_getMapTouches(a){const m=[];for(const b of a)this._el.contains(b.target)&&m.push(b);return m}handleEvent(a,m){this._updatingCamera=!0;const b=a.type==="renderFrame",S=b?void 0:a,P={needsRenderFrame:!1},H={},W={},ee=a.touches?this._getMapTouches(a.touches):void 0,pe=ee?De(this._el,ee):b?void 0:me(this._el,a);for(const{handlerName:Ne,handler:st,allowed:it}of this._handlers){if(!st.isEnabled())continue;let lt;this._blockedByActive(W,it,Ne)?st.reset():st[m||a.type]&&(lt=st[m||a.type](a,pe,ee),this.mergeHandlerResult(P,H,lt,Ne,S),lt&<.needsRenderFrame&&this._triggerRenderFrame()),(lt||st.isActive())&&(W[Ne]=st)}const fe={};for(const Ne in this._previousActiveHandlers)W[Ne]||(fe[Ne]=S);this._previousActiveHandlers=W,(Object.keys(fe).length||Bi(P))&&(this._changes.push([P,H,fe]),this._triggerRenderFrame()),(Object.keys(W).length||Bi(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:Me}=P;Me&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Me(this._map))}mergeHandlerResult(a,m,b,S,P){if(!b)return;i.extend(a,b);const H={handlerName:S,originalEvent:b.originalEvent||P};b.zoomDelta!==void 0&&(m.zoom=H),b.panDelta!==void 0&&(m.drag=H),b.pitchDelta!==void 0&&(m.pitch=H),b.bearingDelta!==void 0&&(m.rotate=H)}_applyChanges(){const a={},m={},b={};for(const[S,P,H]of this._changes)S.panDelta&&(a.panDelta=(a.panDelta||new i.pointGeometry(0,0))._add(S.panDelta)),S.zoomDelta&&(a.zoomDelta=(a.zoomDelta||0)+S.zoomDelta),S.bearingDelta&&(a.bearingDelta=(a.bearingDelta||0)+S.bearingDelta),S.pitchDelta&&(a.pitchDelta=(a.pitchDelta||0)+S.pitchDelta),S.around!==void 0&&(a.around=S.around),S.aroundCoord!==void 0&&(a.aroundCoord=S.aroundCoord),S.pinchAround!==void 0&&(a.pinchAround=S.pinchAround),S.noInertia&&(a.noInertia=S.noInertia),i.extend(m,P),i.extend(b,H);this._updateMapTransform(a,m,b),this._changes=[]}_updateMapTransform(a,m,b){const S=this._map,P=S.transform,H=dt=>[dt.x,dt.y,dt.z];if((dt=>{const ht=this._eventsInProgress.drag;return ht&&!this._handlersById[ht.handlerName].isActive()})()&&!Bi(a)){const dt=P.zoom;P.cameraElevationReference="sea",P.recenterOnTerrain(),P.cameraElevationReference="ground",dt!==P.zoom&&this._map._update(!0)}if(P._isCameraConstrained&&S._stop(!0),!Bi(a))return void this._fireEvents(m,b,!0);let{panDelta:W,zoomDelta:ee,bearingDelta:pe,pitchDelta:fe,around:Me,aroundCoord:Ne,pinchAround:st}=a;P._isCameraConstrained&&(ee>0&&(ee=0),P._isCameraConstrained=!1),st!==void 0&&(Me=st),(dt=>m.drag&&!this._eventsInProgress.drag)()&&Me&&(this._dragOrigin=H(P.pointCoordinate3D(Me)),this._trackingEllipsoid.setup(P._camera.position,this._dragOrigin)),P.cameraElevationReference="sea",S._stop(!0),Me=Me||S.transform.centerPoint,pe&&(P.bearing+=pe),fe&&(P.pitch+=fe),P._updateCameraState();const it=[0,0,0];if(W)if(P.projection.name==="mercator"){const dt=this._trackingEllipsoid.projectRay(P.screenPointToMercatorRay(Me).dir),ht=this._trackingEllipsoid.projectRay(P.screenPointToMercatorRay(Me.sub(W)).dir);it[0]=ht[0]-dt[0],it[1]=ht[1]-dt[1]}else{const dt=P.pointCoordinate(Me);if(P.projection.name==="globe"){W=W.rotate(-P.angle);const ht=P._pixelsPerMercatorPixel/P.worldSize;it[0]=-W.x*i.mercatorScale(i.latFromMercatorY(dt.y))*ht,it[1]=-W.y*i.mercatorScale(P.center.lat)*ht}else{const ht=P.pointCoordinate(Me.sub(W));dt&&ht&&(it[0]=ht.x-dt.x,it[1]=ht.y-dt.y)}}const lt=P.zoom,qe=[0,0,0];if(ee){const dt=H(Ne||P.pointCoordinate3D(Me)),ht={dir:i.normalize([],i.sub([],dt,P._camera.position))};if(ht.dir[2]<0){const Bt=P.zoomDeltaToMovement(dt,ee);i.scale$2(qe,ht.dir,Bt)}}const Ye=i.add(it,it,qe);P._translateCameraConstrained(Ye),ee&&Math.abs(P.zoom-lt)>1e-4&&P.recenterOnTerrain(),P.cameraElevationReference="ground",this._map._update(),a.noInertia||this._inertia.record(a),this._fireEvents(m,b,!0)}_fireEvents(a,m,b){const S=zt(this._eventsInProgress),P=zt(a),H={};for(const fe in a){const{originalEvent:Me}=a[fe];this._eventsInProgress[fe]||(H[`${fe}start`]=Me),this._eventsInProgress[fe]=a[fe]}!S&&P&&this._fireEvent("movestart",P.originalEvent);for(const fe in H)this._fireEvent(fe,H[fe]);P&&this._fireEvent("move",P.originalEvent);for(const fe in a){const{originalEvent:Me}=a[fe];this._fireEvent(fe,Me)}const W={};let ee;for(const fe in this._eventsInProgress){const{handlerName:Me,originalEvent:Ne}=this._eventsInProgress[fe];this._handlersById[Me].isActive()||(delete this._eventsInProgress[fe],ee=m[Me]||Ne,W[`${fe}end`]=ee)}for(const fe in W)this._fireEvent(fe,W[fe]);const pe=zt(this._eventsInProgress);if(b&&(S||P)&&!pe){this._updatingCamera=!0;const fe=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),Me=Ne=>Ne!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new ai("renderFrame",{timeStamp:a})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const vi="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class xn extends i.Evented{constructor(a,m){super(),this._moving=!1,this._zooming=!1,this.transform=a,this._bearingSnap=m.bearingSnap,i.bindAll(["_renderFrameCallback"],this)}getCenter(){return new i.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(a,m){return this.jumpTo({center:a},m)}panBy(a,m,b){return a=i.pointGeometry.convert(a).mult(-1),this.panTo(this.transform.center,i.extend({offset:a},m),b)}panTo(a,m,b){return this.easeTo(i.extend({center:a},m),b)}getZoom(){return this.transform.zoom}setZoom(a,m){return this.jumpTo({zoom:a},m),this}zoomTo(a,m,b){return this.easeTo(i.extend({zoom:a},m),b)}zoomIn(a,m){return this.zoomTo(this.getZoom()+1,a,m),this}zoomOut(a,m){return this.zoomTo(this.getZoom()-1,a,m),this}getBearing(){return this.transform.bearing}setBearing(a,m){return this.jumpTo({bearing:a},m),this}getPadding(){return this.transform.padding}setPadding(a,m){return this.jumpTo({padding:a},m),this}rotateTo(a,m,b){return this.easeTo(i.extend({bearing:a},m),b)}resetNorth(a,m){return this.rotateTo(0,i.extend({duration:1e3},a),m),this}resetNorthPitch(a,m){return this.easeTo(i.extend({bearing:0,pitch:0,duration:1e3},a),m),this}snapToNorth(a,m){return Math.abs(this.getBearing())a.aspect?b/(2*Math.tan(.5*a.fovX)*a.aspect):S/(2*Math.tan(.5*a.fovY)*a.aspect)}_cameraForBoundsOnGlobe(a,m,b,S,P,H){const W=a.clone(),ee=this._extendCameraOptions(H);W.bearing=S,W.pitch=P;const pe=i.LngLat.convert(m),fe=i.LngLat.convert(b),Me=.5*(pe.lat+fe.lat),Ne=.5*(pe.lng+fe.lng),st=i.latLngToECEF(Me,Ne),it=i.normalize([],st),lt=i.normalize([],i.cross([],it,[0,1,0])),qe=i.cross([],lt,it),Ye=[lt[0],lt[1],lt[2],0,qe[0],qe[1],qe[2],0,it[0],it[1],it[2],0,0,0,0,1],dt=[st,i.latLngToECEF(pe.lat,pe.lng),i.latLngToECEF(fe.lat,pe.lng),i.latLngToECEF(fe.lat,fe.lng),i.latLngToECEF(pe.lat,fe.lng),i.latLngToECEF(Me,pe.lng),i.latLngToECEF(Me,fe.lng),i.latLngToECEF(pe.lat,Ne),i.latLngToECEF(fe.lat,Ne)];let ht=i.Aabb.fromPoints(dt.map(Jt=>[i.dot(lt,Jt),i.dot(qe,Jt),i.dot(it,Jt)]));const Bt=i.transformMat4([],ht.center,Ye);i.squaredLength(Bt)===0&&i.set(Bt,0,0,1),i.normalize(Bt,Bt),i.scale$2(Bt,Bt,i.GLOBE_RADIUS),W.center=i.ecefToLatLng(Bt);const Pt=W.getWorldToCameraMatrix(),It=i.invert(new Float64Array(16),Pt);ht=i.Aabb.applyTransform(ht,i.multiply([],Pt,Ye)),i.transformMat4(Bt,Bt,Pt);const Ht=.5*(ht.max[2]-ht.min[2]),hi=this._minimumAABBFrustumDistance(W,ht),si=i.scale$2([],[0,0,1],Ht),qt=i.add(si,Bt,si),ji=hi+(W.pitch===0?0:i.distance(Bt,qt)),Kt=W.globeCenterInViewSpace,Ci=i.sub([],Bt,[Kt[0],Kt[1],Kt[2]]);i.normalize(Ci,Ci),i.scale$2(Ci,Ci,ji);const di=i.add([],Bt,Ci);i.transformMat4(di,di,It);const Ri=i.earthRadius/i.GLOBE_RADIUS,Ai=i.length(di),Mi=i.mercatorZfromAltitude(Ai*Ri-i.earthRadius,0),$i=Math.min(W.zoomFromMercatorZAdjusted(Mi),ee.maxZoom);return $i>.5*(i.GLOBE_ZOOM_THRESHOLD_MIN+i.GLOBE_ZOOM_THRESHOLD_MAX)?(W.setProjection({name:"mercator"}),W.zoom=$i,this._cameraForBounds(W,m,b,S,P,H)):{center:W.center,zoom:$i,bearing:S,pitch:P}}queryTerrainElevation(a,m){const b=this.transform.elevation;return b?(m=i.extend({},{exaggerated:!0},m),b.getAtPoint(i.MercatorCoordinate.fromLngLat(a),null,m.exaggerated)):null}_cameraForBounds(a,m,b,S,P,H){if(a.projection.name==="globe")return this._cameraForBoundsOnGlobe(a,m,b,S,P,H);const W=a.clone(),ee=this._extendCameraOptions(H),pe=W.padding;W.bearing=S,W.pitch=P;const fe=i.LngLat.convert(m),Me=i.LngLat.convert(b),Ne=new i.LngLat(fe.lng,Me.lat),st=new i.LngLat(Me.lng,fe.lat),it=W.project(fe),lt=W.project(Me),qe=this.queryTerrainElevation(fe),Ye=this.queryTerrainElevation(Me),dt=this.queryTerrainElevation(Ne),ht=this.queryTerrainElevation(st),Bt=[[it.x,it.y,Math.min(qe||0,Ye||0,dt||0,ht||0)],[lt.x,lt.y,Math.max(qe||0,Ye||0,dt||0,ht||0)]];let Pt=i.Aabb.fromPoints(Bt);const It=W.getWorldToCameraMatrix(),Ht=i.invert(new Float64Array(16),It);Pt=i.Aabb.applyTransform(Pt,It);const hi=i.sub([],Pt.max,Pt.min),si=pe.left||0,qt=pe.right||0,ji=pe.bottom||0,Kt=pe.top||0,{left:Ci,right:di,top:Ri,bottom:Ai}=ee.padding,Mi=.5*(si+qt),$i=.5*(Kt+ji),Jt=Math.min(W.scaleZoom(W.scale*Math.min((W.width-(si+qt+Ci+di))/hi[0],(W.height-(ji+Kt+Ai+Ri))/hi[1])),ee.maxZoom),pi=W.scale/W.zoomScale(Jt);Pt=new i.Aabb([Pt.min[0]-(Ci+Mi)*pi,Pt.min[1]-(Ai+$i)*pi,Pt.min[2]],[Pt.max[0]+(di+Mi)*pi,Pt.max[1]+(Ri+$i)*pi,Pt.max[2]]);const In=.5*hi[2],Hn=this._minimumAABBFrustumDistance(W,Pt),Mn=[0,0,1,0];i.transformMat4$1(Mn,Mn,It),i.normalize$2(Mn,Mn);const $n=i.scale$2([],Mn,Hn+In),lr=i.add([],Pt.center,$n),On=(typeof ee.offset.x=="number"&&typeof ee.offset.y=="number"?new i.pointGeometry(ee.offset.x,ee.offset.y):i.pointGeometry.convert(ee.offset)).rotate(-i.degToRad(S));Pt.center[0]-=On.x*pi,Pt.center[1]+=On.y*pi,i.transformMat4(Pt.center,Pt.center,Ht),i.transformMat4(lr,lr,Ht);const _n=[Pt.center[0],Pt.center[1],lr[2]*W.pixelsPerMeter];i.scale$2(_n,_n,1/W.worldSize);const Dr=i.lngFromMercatorX(_n[0]),Or=i.latFromMercatorY(_n[1]),Nr=Math.min(W._zoomFromMercatorZ(_n[2]),ee.maxZoom),Qr=new i.LngLat(Dr,Or);return W.mercatorFromTransition&&Nr<.5*(i.GLOBE_ZOOM_THRESHOLD_MIN+i.GLOBE_ZOOM_THRESHOLD_MAX)?(W.setProjection({name:"globe"}),W.zoom=Nr,this._cameraForBounds(W,m,b,S,P,H)):{center:Qr,zoom:Nr,bearing:S,pitch:P}}fitBounds(a,m,b){const S=this.cameraForBounds(a,m);return this._fitInternal(S,m,b)}fitScreenCoordinates(a,m,b,S,P){const H=i.pointGeometry.convert(a),W=i.pointGeometry.convert(m),ee=new i.pointGeometry(Math.min(H.x,W.x),Math.min(H.y,W.y)),pe=new i.pointGeometry(Math.max(H.x,W.x),Math.max(H.y,W.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(H,W))return this;const fe=this.transform.pointLocation3D(ee),Me=this.transform.pointLocation3D(pe),Ne=this.transform.pointLocation3D(new i.pointGeometry(ee.x,pe.y)),st=this.transform.pointLocation3D(new i.pointGeometry(pe.x,ee.y)),it=[Math.min(fe.lng,Me.lng,Ne.lng,st.lng),Math.min(fe.lat,Me.lat,Ne.lat,st.lat)],lt=[Math.max(fe.lng,Me.lng,Ne.lng,st.lng),Math.max(fe.lat,Me.lat,Ne.lat,st.lat)],qe=S&&S.pitch?S.pitch:this.getPitch(),Ye=this._cameraForBounds(this.transform,it,lt,b,qe,S);return this._fitInternal(Ye,S,P)}_fitInternal(a,m,b){return a?(delete(m=i.extend(a,m)).padding,m.linear?this.easeTo(m,b):this.flyTo(m,b)):this}jumpTo(a,m){this.stop();const b=a.preloadOnly?this.transform.clone():this.transform;let S=!1,P=!1,H=!1;return"zoom"in a&&b.zoom!==+a.zoom&&(S=!0,b.zoom=+a.zoom),a.center!==void 0&&(b.center=i.LngLat.convert(a.center)),"bearing"in a&&b.bearing!==+a.bearing&&(P=!0,b.bearing=+a.bearing),"pitch"in a&&b.pitch!==+a.pitch&&(H=!0,b.pitch=+a.pitch),a.padding==null||b.isPaddingEqual(a.padding)||(b.padding=a.padding),a.preloadOnly?(this._preloadTiles(b),this):(this.fire(new i.Event("movestart",m)).fire(new i.Event("move",m)),S&&this.fire(new i.Event("zoomstart",m)).fire(new i.Event("zoom",m)).fire(new i.Event("zoomend",m)),P&&this.fire(new i.Event("rotatestart",m)).fire(new i.Event("rotate",m)).fire(new i.Event("rotateend",m)),H&&this.fire(new i.Event("pitchstart",m)).fire(new i.Event("pitch",m)).fire(new i.Event("pitchend",m)),this.fire(new i.Event("moveend",m)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.warnOnce(vi),this.transform.getFreeCameraOptions()}setFreeCameraOptions(a,m){const b=this.transform;if(!b.projection.supportsFreeCamera)return i.warnOnce(vi),this;this.stop();const S=b.zoom,P=b.pitch,H=b.bearing;b.setFreeCameraOptions(a);const W=S!==b.zoom,ee=P!==b.pitch,pe=H!==b.bearing;return this.fire(new i.Event("movestart",m)).fire(new i.Event("move",m)),W&&this.fire(new i.Event("zoomstart",m)).fire(new i.Event("zoom",m)).fire(new i.Event("zoomend",m)),pe&&this.fire(new i.Event("rotatestart",m)).fire(new i.Event("rotate",m)).fire(new i.Event("rotateend",m)),ee&&this.fire(new i.Event("pitchstart",m)).fire(new i.Event("pitch",m)).fire(new i.Event("pitchend",m)),this.fire(new i.Event("moveend",m)),this}easeTo(a,m){this._stop(!1,a.easeId),((a=i.extend({offset:[0,0],duration:500,easing:i.ease},a)).animate===!1||!a.essential&&i.exported.prefersReducedMotion)&&(a.duration=0);const b=this.transform,S=this.getZoom(),P=this.getBearing(),H=this.getPitch(),W=this.getPadding(),ee="zoom"in a?+a.zoom:S,pe="bearing"in a?this._normalizeBearing(a.bearing,P):P,fe="pitch"in a?+a.pitch:H,Me="padding"in a?a.padding:b.padding,Ne=i.pointGeometry.convert(a.offset);let st,it,lt;if(b.projection.name==="globe"){const si=i.MercatorCoordinate.fromLngLat(b.center),qt=Ne.rotate(-b.angle);si.x+=qt.x/b.worldSize,si.y+=qt.y/b.worldSize;const ji=si.toLngLat(),Kt=i.LngLat.convert(a.center||ji);this._normalizeCenter(Kt),st=b.centerPoint.add(qt),it=new i.pointGeometry(si.x,si.y).mult(b.worldSize),lt=new i.pointGeometry(i.mercatorXfromLng(Kt.lng),i.mercatorYfromLat(Kt.lat)).mult(b.worldSize).sub(it)}else{st=b.centerPoint.add(Ne);const si=b.pointLocation(st),qt=i.LngLat.convert(a.center||si);this._normalizeCenter(qt),it=b.project(si),lt=b.project(qt).sub(it)}const qe=b.zoomScale(ee-S);let Ye,dt;a.around&&(Ye=i.LngLat.convert(a.around),dt=b.locationPoint(Ye));const ht=this._zooming||ee!==S,Bt=this._rotating||P!==pe,Pt=this._pitching||fe!==H,It=!b.isPaddingEqual(Me),Ht=si=>qt=>{if(ht&&(si.zoom=i.number(S,ee,qt)),Bt&&(si.bearing=i.number(P,pe,qt)),Pt&&(si.pitch=i.number(H,fe,qt)),It&&(si.interpolatePadding(W,Me,qt),st=si.centerPoint.add(Ne)),Ye)si.setLocationAtPoint(Ye,dt);else{const ji=si.zoomScale(si.zoom-S),Kt=ee>S?Math.min(2,qe):Math.max(.5,qe),Ci=Math.pow(Kt,1-qt),di=si.unproject(it.add(lt.mult(qt*Ci)).mult(ji));si.setLocationAtPoint(si.renderWorldCopies?di.wrap():di,st)}return a.preloadOnly||this._fireMoveEvents(m),si};if(a.preloadOnly){const si=this._emulate(Ht,a.duration,b);return this._preloadTiles(si),this}const hi={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ht,this._rotating=Bt,this._pitching=Pt,this._padding=It,this._easeId=a.easeId,this._prepareEase(m,a.noMoveStart,hi),this._ease(Ht(b),si=>{b.recenterOnTerrain(),this._afterEase(m,si)},a),this}_prepareEase(a,m,b={}){this._moving=!0,this.transform.cameraElevationReference="sea",m||b.moving||this.fire(new i.Event("movestart",a)),this._zooming&&!b.zooming&&this.fire(new i.Event("zoomstart",a)),this._rotating&&!b.rotating&&this.fire(new i.Event("rotatestart",a)),this._pitching&&!b.pitching&&this.fire(new i.Event("pitchstart",a))}_fireMoveEvents(a){this.fire(new i.Event("move",a)),this._zooming&&this.fire(new i.Event("zoom",a)),this._rotating&&this.fire(new i.Event("rotate",a)),this._pitching&&this.fire(new i.Event("pitch",a))}_afterEase(a,m){if(this._easeId&&m&&this._easeId===m)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const b=this._zooming,S=this._rotating,P=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,b&&this.fire(new i.Event("zoomend",a)),S&&this.fire(new i.Event("rotateend",a)),P&&this.fire(new i.Event("pitchend",a)),this.fire(new i.Event("moveend",a))}flyTo(a,m){if(!a.essential&&i.exported.prefersReducedMotion){const Jt=i.pick(a,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Jt,m)}this.stop(),a=i.extend({offset:[0,0],speed:1.2,curve:1.42,easing:i.ease},a);const b=this.transform,S=this.getZoom(),P=this.getBearing(),H=this.getPitch(),W=this.getPadding(),ee="zoom"in a?i.clamp(+a.zoom,b.minZoom,b.maxZoom):S,pe="bearing"in a?this._normalizeBearing(a.bearing,P):P,fe="pitch"in a?+a.pitch:H,Me="padding"in a?a.padding:b.padding,Ne=b.zoomScale(ee-S),st=i.pointGeometry.convert(a.offset);let it=b.centerPoint.add(st);const lt=b.pointLocation(it),qe=i.LngLat.convert(a.center||lt);this._normalizeCenter(qe);const Ye=b.project(lt),dt=b.project(qe).sub(Ye);let ht=a.curve;const Bt=Math.max(b.width,b.height),Pt=Bt/Ne,It=dt.mag();if("minZoom"in a){const Jt=i.clamp(Math.min(a.minZoom,S,ee),b.minZoom,b.maxZoom),pi=Bt/b.zoomScale(Jt-S);ht=Math.sqrt(pi/It*2)}const Ht=ht*ht;function hi(Jt){const pi=(Pt*Pt-Bt*Bt+(Jt?-1:1)*Ht*Ht*It*It)/(2*(Jt?Pt:Bt)*Ht*It);return Math.log(Math.sqrt(pi*pi+1)-pi)}function si(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function qt(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const ji=hi(0);let Kt=function(Jt){return qt(ji)/qt(ji+ht*Jt)},Ci=function(Jt){return Bt*((qt(ji)*(si(pi=ji+ht*Jt)/qt(pi))-si(ji))/Ht)/It;var pi},di=(hi(1)-ji)/ht;if(Math.abs(It)<1e-6||!isFinite(di)){if(Math.abs(Bt-Pt)<1e-6)return this.easeTo(a,m);const Jt=Pta.maxDuration&&(a.duration=0);const Ri=P!==pe,Ai=fe!==H,Mi=!b.isPaddingEqual(Me),$i=Jt=>pi=>{const In=pi*di,Hn=1/Kt(In);Jt.zoom=pi===1?ee:S+Jt.scaleZoom(Hn),Ri&&(Jt.bearing=i.number(P,pe,pi)),Ai&&(Jt.pitch=i.number(H,fe,pi)),Mi&&(Jt.interpolatePadding(W,Me,pi),it=Jt.centerPoint.add(st));const Mn=pi===1?qe:Jt.unproject(Ye.add(dt.mult(Ci(In))).mult(Hn));return Jt.setLocationAtPoint(Jt.renderWorldCopies?Mn.wrap():Mn,it),Jt._updateCameraOnTerrain(),a.preloadOnly||this._fireMoveEvents(m),Jt};if(a.preloadOnly){const Jt=this._emulate($i,a.duration,b);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=Ri,this._pitching=Ai,this._padding=Mi,this._prepareEase(m,!1),this._ease($i(b),()=>this._afterEase(m),a),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(a,m){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const b=this._onEaseEnd;this._onEaseEnd=void 0,b.call(this,m)}if(!a){const b=this.handlers;b&&b.stop(!1)}return this}_ease(a,m,b){b.animate===!1||b.duration===0?(a(1),m()):(this._easeStart=i.exported.now(),this._easeOptions=b,this._onEaseFrame=a,this._onEaseEnd=m,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const a=Math.min((i.exported.now()-this._easeStart)/this._easeOptions.duration,1),m=this._onEaseFrame;m&&m(this._easeOptions.easing(a)),a<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(a,m){a=i.wrap(a,-180,180);const b=Math.abs(a-m);return Math.abs(a-360-m)180?-360:b<-180?360:0}_emulate(a,m,b){const S=Math.ceil(15*m/1e3),P=[],H=a(b.clone());for(let W=0;W<=S;W++){const ee=H(W/S);P.push(ee.clone())}return P}}class cn{constructor(a={}){this.options=a,i.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(a){const m=this.options&&this.options.compact;return this._map=a,this._container=z("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=z("button","mapboxgl-ctrl-attrib-button",this._container),z("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=z("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),m&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),m===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(a,m){const b=this._map._getUIString(`AttributionControl.${m}`);a.setAttribute("aria-label",b),a.removeAttribute("title"),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let a=this._editLink;a||(a=this._editLink=this._container.querySelector(".mapbox-improve-map"));const m=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.config.ACCESS_TOKEN}];if(a){const b=m.reduce((S,P,H)=>(P.value&&(S+=`${P.key}=${P.value}${HS.length-P.length),a=a.filter((S,P)=>{for(let H=P+1;H=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?a=[...this.options.customAttribution,...a]:a.unshift(this.options.customAttribution));const b=a.join(" | ");b!==this._attribHTML&&(this._attribHTML=b,a.length?(this._innerContainer.innerHTML=b,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Bn{constructor(){i.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(a){this._map=a,this._container=z("div","mapboxgl-ctrl");const m=z("a","mapboxgl-ctrl-logo");return m.target="_blank",m.rel="noopener nofollow",m.href="https://www.mapbox.com/",m.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),m.setAttribute("rel","noopener nofollow"),this._container.appendChild(m),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(a){a&&a.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const a=this._map.style._sourceCaches;if(Object.entries(a).length===0)return!0;for(const m in a){const b=a[m].getSource();if(b.hasOwnProperty("mapbox_logo")&&!b.mapbox_logo)return!1}return!0}_updateCompact(){const a=this._container.children;if(a.length){const m=a[0];this._map.getCanvasContainer().offsetWidth<250?m.classList.add("mapboxgl-compact"):m.classList.remove("mapboxgl-compact")}}}class tr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(a){const m=++this._id;return this._queue.push({callback:a,id:m,cancelled:!1}),m}remove(a){const m=this._currentlyRunning,b=m?this._queue.concat(m):this._queue;for(const S of b)if(S.id===a)return void(S.cancelled=!0)}run(a=0){const m=this._currentlyRunning=this._queue;this._queue=[];for(const b of m)if(!b.cancelled&&(b.callback(a),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function ur(x,a,m){if(x=new i.LngLat(x.lng,x.lat),a){const b=new i.LngLat(x.lng-360,x.lat),S=new i.LngLat(x.lng+360,x.lat),P=360*Math.ceil(Math.abs(x.lng-m.center.lng)/360),H=m.locationPoint(x).distSqr(a),W=a.x<0||a.y<0||a.x>m.width||a.y>m.height;m.locationPoint(b).distSqr(a)180;){const b=m.locationPoint(x);if(b.x>=0&&b.y>=0&&b.x<=m.width&&b.y<=m.height)break;x.lng>m.center.lng?x.lng-=360:x.lng+=360}return x}const Un={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class Lr extends i.Evented{constructor(a,m){if(super(),(a instanceof i.window.HTMLElement||m)&&(a=i.extend({element:a},m)),i.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=a&&a.anchor||"center",this._color=a&&a.color||"#3FB1CE",this._scale=a&&a.scale||1,this._draggable=a&&a.draggable||!1,this._clickTolerance=a&&a.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=a&&a.rotation||0,this._rotationAlignment=a&&a.rotationAlignment||"auto",this._pitchAlignment=a&&a.pitchAlignment&&a.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=a&&a.occludedOpacity||.2,a&&a.element)this._element=a.element,this._offset=i.pointGeometry.convert(a&&a.offset||[0,0]);else{this._defaultMarker=!0,this._element=z("div");const S=41,P=27,H=G("svg",{display:"block",height:S*this._scale+"px",width:P*this._scale+"px",viewBox:`0 0 ${P} ${S}`},this._element),W=G("radialGradient",{id:"shadowGradient"},G("defs",{},H));G("stop",{offset:"10%","stop-opacity":.4},W),G("stop",{offset:"100%","stop-opacity":.05},W),G("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},H),G("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},H),G("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},H),G("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},H),this._offset=i.pointGeometry.convert(a&&a.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",S=>{S.preventDefault()}),this._element.addEventListener("mousedown",S=>{S.preventDefault()});const b=this._element.classList;for(const S in Un)b.remove(`mapboxgl-marker-anchor-${S}`);b.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(a){return a===this._map||(this.remove(),this._map=a,a.getCanvasContainer().appendChild(this._element),a.on("move",this._updateMoving),a.on("moveend",this._update),a.on("remove",this._clearFadeTimer),a._addMarker(this),this.setDraggable(this._draggable),this._update(),a.on("click",this._onMapClick)),this}remove(){const a=this._map;return a&&(a.off("click",this._onMapClick),a.off("move",this._updateMoving),a.off("moveend",this._update),a.off("mousedown",this._addDragHandler),a.off("touchstart",this._addDragHandler),a.off("mouseup",this._onUp),a.off("touchend",this._onUp),a.off("mousemove",this._onMove),a.off("touchmove",this._onMove),a.off("remove",this._clearFadeTimer),a._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(a){return this._lngLat=i.LngLat.convert(a),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(a){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),a){if(!("offset"in a.options)){const S=Math.sqrt(Math.pow(13.5,2)/2);a.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[S,-1*(38.1-13.5+S)],"bottom-right":[-S,-1*(38.1-13.5+S)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=a,a._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(a){const m=a.code,b=a.charCode||a.keyCode;m!=="Space"&&m!=="Enter"&&b!==32&&b!==13||this.togglePopup()}_onMapClick(a){const m=a.originalEvent.target,b=this._element;this._popup&&(m===b||b.contains(m))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const a=this._popup;return a?(a.isOpen()?(a.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(a.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const a=this._map,m=this._pos;if(!a||!m)return!1;const b=a.unproject(m),S=a.getFreeCameraOptions();if(!S.position)return!1;const P=S.position.toLngLat();return P.distanceTo(b)<.9*P.distanceTo(this._lngLat)}_evaluateOpacity(){const a=this._map;if(!a)return;const m=this._pos;if(!m||m.x<0||m.x>a.transform.width||m.y<0||m.y>a.transform.height)return void this._clearFadeTimer();const b=a.unproject(m);let S;a._showingGlobe()&&i.isLngLatBehindGlobe(a.transform,this._lngLat)?S=0:(S=1-a._queryFogOpacity(b),a.transform._terrainEnabled()&&a.getTerrain()&&this._behindTerrain()&&(S*=this._occludedOpacity)),this._element.style.opacity=`${S}`,this._element.style.pointerEvents=S>0?"auto":"none",this._popup&&this._popup._setOpacity(S),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const a=this._pos;if(!a||!this._map)return;const m=this._offset.mult(this._scale);this._element.style.transform=` translate(${a.x}px,${a.y}px) ${Un[this._anchor]} ${this._calculateXYTransform()} ${this._calculateZTransform()} translate(${m.x}px,${m.y}px) `}_calculateXYTransform(){const a=this._pos,m=this._map,b=this.getPitchAlignment();if(!m||!a||b!=="map")return"";if(!m._showingGlobe()){const ee=m.getPitch();return ee?`rotateX(${ee}deg)`:""}const S=i.radToDeg(i.globeTiltAtLngLat(m.transform,this._lngLat)),P=a.sub(i.globeCenterToScreenPoint(m.transform)),H=Math.abs(P.x)+Math.abs(P.y);if(H===0)return"";const W=S/H;return`rotateX(${-P.y*W}deg) rotateY(${P.x*W}deg)`}_calculateZTransform(){const a=this._pos,m=this._map;if(!m||!a)return"";let b=0;const S=this.getRotationAlignment();if(S==="map")if(m._showingGlobe()){const P=m.project(new i.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),H=m.project(new i.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(P);b=i.radToDeg(Math.atan2(H.y,H.x))-90}else b=-m.getBearing();else if(S==="horizon"){const P=i.smoothstep(4,6,m.getZoom()),H=i.globeCenterToScreenPoint(m.transform);H.y+=P*m.transform.height;const W=a.sub(H),ee=i.radToDeg(Math.atan2(W.y,W.x));b=(ee>90?ee-270:ee+90)*(1-P)}return b+=this._rotation,b?`rotateZ(${b}deg)`:""}_update(a){i.window.cancelAnimationFrame(this._updateFrameId);const m=this._map;m&&(m.transform.renderWorldCopies&&(this._lngLat=ur(this._lngLat,this._pos,m.transform)),this._pos=m.project(this._lngLat),a===!0?this._updateFrameId=i.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),m._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(m._showingGlobe()||m.getTerrain()||m.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(a){return this._offset=i.pointGeometry.convert(a),this._update(),this}_onMove(a){const m=this._map;if(!m)return;const b=this._pointerdownPos,S=this._positionDelta;if(b&&S){if(!this._isDragging){const P=this._clickTolerance||m._clickTolerance;if(a.point.dist(b)=this._endTime)return this._end;const m=i.easeCubicInOut((a-this._startTime)/(this._endTime-this._startTime));return this._start*(1-m)+this._end*m}isEasing(a){return a>=this._startTime&&a<=this._endTime}jumpTo(a){this._startTime=-1/0,this._endTime=-1/0,this._start=a,this._end=a}easeTo(a,m,b){this._start=this.getValue(m),this._end=a,this._startTime=m,this._endTime=m+b}}const js={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},wa={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},ua={showCompass:!0,showZoom:!0,visualizePitch:!1};class ba{constructor(a,m,b=!1){this._clickTolerance=10,this.element=m,this.mouseRotate=new Kh({clickTolerance:a.dragRotate._mouseRotate._clickTolerance}),this.map=a,b&&(this.mousePitch=new xl({clickTolerance:a.dragRotate._mousePitch._clickTolerance})),i.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),m.addEventListener("mousedown",this.mousedown),m.addEventListener("touchstart",this.touchstart,{passive:!1}),m.addEventListener("touchmove",this.touchmove),m.addEventListener("touchend",this.touchend),m.addEventListener("touchcancel",this.reset)}down(a,m){this.mouseRotate.mousedown(a,m),this.mousePitch&&this.mousePitch.mousedown(a,m),ae()}move(a,m){const b=this.map,S=this.mouseRotate.mousemoveWindow(a,m),P=S&&S.bearingDelta;if(P&&b.setBearing(b.getBearing()+P),this.mousePitch){const H=this.mousePitch.mousemoveWindow(a,m),W=H&&H.pitchDelta;W&&b.setPitch(b.getPitch()+W)}}off(){const a=this.element;a.removeEventListener("mousedown",this.mousedown),a.removeEventListener("touchstart",this.touchstart,{passive:!1}),a.removeEventListener("touchmove",this.touchmove),a.removeEventListener("touchend",this.touchend),a.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){ce(),i.window.removeEventListener("mousemove",this.mousemove),i.window.removeEventListener("mouseup",this.mouseup)}mousedown(a){this.down(i.extend({},a,{ctrlKey:!0,preventDefault:()=>a.preventDefault()}),me(this.element,a)),i.window.addEventListener("mousemove",this.mousemove),i.window.addEventListener("mouseup",this.mouseup)}mousemove(a){this.move(a,me(this.element,a))}mouseup(a){this.mouseRotate.mouseupWindow(a),this.mousePitch&&this.mousePitch.mouseupWindow(a),this.offTemp()}touchstart(a){a.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=De(this.element,a.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>a.preventDefault()},this._startPos))}touchmove(a){a.targetTouches.length!==1?this.reset():(this._lastPos=De(this.element,a.targetTouches)[0],this.move({preventDefault:()=>a.preventDefault()},this._lastPos))}touchend(a){a.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._container.style.width=x*S+"px",this._container.innerHTML=`${b} ${P}`})}function Ba(x){const a=Math.pow(10,`${Math.floor(x)}`.length-1);let m=x/a;return m=m>=10?10:m>=5?5:m>=3?3:m>=2?2:m>=1?1:function(b){const S=Math.pow(10,Math.ceil(-Math.log(b)/Math.LN10));return Math.round(b*S)/S}(m),a*m}const $l={version:i.version,supported:D,setRTLTextPlugin:i.setRTLTextPlugin,getRTLTextPluginStatus:i.getRTLTextPluginStatus,Map:class extends xn{constructor(x){if(i.LivePerformanceUtils.mark(i.PerformanceMarkers.create),(x=i.extend({},wa,x)).minZoom!=null&&x.maxZoom!=null&&x.minZoom>x.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(x.minPitch!=null&&x.maxPitch!=null&&x.minPitch>x.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(x.minPitch!=null&&x.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(x.maxPitch!=null&&x.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(x.antialias&&i.isSafariWithAntialiasingBug(i.window)&&(x.antialias=!1,i.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Kl(x.minZoom,x.maxZoom,x.minPitch,x.maxPitch,x.renderWorldCopies),x),this._interactive=x.interactive,this._minTileCacheSize=x.minTileCacheSize,this._maxTileCacheSize=x.maxTileCacheSize,this._failIfMajorPerformanceCaveat=x.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=x.preserveDrawingBuffer,this._antialias=x.antialias,this._trackResize=x.trackResize,this._bearingSnap=x.bearingSnap,this._refreshExpiredTiles=x.refreshExpiredTiles,this._fadeDuration=x.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=x.crossSourceCollisions,this._collectResourceTiming=x.collectResourceTiming,this._optimizeForTerrain=x.optimizeForTerrain,this._language=this._parseLanguage(x.language),this._worldview=x.worldview,this._renderTaskQueue=new tr,this._domRenderTaskQueue=new tr,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.uniqueId(),this._locale=i.extend({},js,x.locale),this._clickTolerance=x.clickTolerance,this._cooperativeGestures=x.cooperativeGestures,this._performanceMetricsCollection=x.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Gr(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new i.RequestManager(x.transformRequest,x.accessToken,x.testMode),this._silenceAuthErrors=!!x.testMode,typeof x.container=="string"){if(this._container=i.window.document.getElementById(x.container),!this._container)throw new Error(`Container '${x.container}' not found.`)}else{if(!(x.container instanceof i.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=x.container}if(this._container.childNodes.length>0&&i.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),x.maxBounds&&this.setMaxBounds(x.maxBounds),i.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),i.window!==void 0&&(i.window.addEventListener("online",this._onWindowOnline,!1),i.window.addEventListener("resize",this._onWindowResize,!1),i.window.addEventListener("orientationchange",this._onWindowResize,!1),i.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),i.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Hi(this,x),this._localFontFamily=x.localFontFamily,this._localIdeographFontFamily=x.localIdeographFontFamily,x.style&&this.setStyle(x.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),x.projection&&this.setProjection(x.projection),this._hash=x.hash&&new An(typeof x.hash=="string"&&x.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:x.center,zoom:x.zoom,bearing:x.bearing,pitch:x.pitch}),x.bounds&&(this.resize(),this.fitBounds(x.bounds,i.extend({},x.fitBoundsOptions,{duration:0})))),this.resize(),x.attributionControl&&this.addControl(new cn({customAttribution:x.customAttribution})),this._logoControl=new Bn,this.addControl(this._logoControl,x.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",a=>{this._update(a.dataType==="style"),this.fire(new i.Event(`${a.dataType}data`,a))}),this.on("dataloading",a=>{this.fire(new i.Event(`${a.dataType}dataloading`,a))})}_getMapId(){return this._mapId}addControl(x,a){if(a===void 0&&(a=x.getDefaultPosition?x.getDefaultPosition():"top-right"),!x||!x.onAdd)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const m=x.onAdd(this);this._controls.push(x);const b=this._controlPositions[a];return a.indexOf("bottom")!==-1?b.insertBefore(m,b.firstChild):b.appendChild(m),this}removeControl(x){if(!x||!x.onRemove)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const a=this._controls.indexOf(x);return a>-1&&this._controls.splice(a,1),x.onRemove(this),this}hasControl(x){return this._controls.indexOf(x)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(x){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const a=!this._moving;return a&&this.fire(new i.Event("movestart",x)).fire(new i.Event("move",x)),this.fire(new i.Event("resize",x)),a&&this.fire(new i.Event("moveend",x)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(x){return this.transform.setMaxBounds(i.LngLatBounds.convert(x)),this._update()}setMinZoom(x){if((x=x==null?-2:x)>=-2&&x<=this.transform.maxZoom)return this.transform.minZoom=x,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=x,this._update(),this.getZoom()>x?this.setZoom(x):this.fire(new i.Event("zoomstart")).fire(new i.Event("zoom")).fire(new i.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(x){if((x=x==null?0:x)<0)throw new Error("minPitch must be greater than or equal to 0");if(x>=0&&x<=this.transform.maxPitch)return this.transform.minPitch=x,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(x>=this.transform.minPitch)return this.transform.maxPitch=x,this._update(),this.getPitch()>x?this.setPitch(x):this.fire(new i.Event("pitchstart")).fire(new i.Event("pitch")).fire(new i.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(x){return this.transform.renderWorldCopies=x,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(x){return x==="auto"?i.window.navigator.language:Array.isArray(x)?x.length===0?void 0:x.map(a=>a==="auto"?i.window.navigator.language:a):x}setLanguage(x){const a=this._parseLanguage(x);if(!this.style||a===this._language)return this;this._language=a,this.style._reloadSources();for(const m of this._controls)m._setLanguage&&m._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(x){return this.style&&x!==this._worldview?(this._worldview=x,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(x){return this._lazyInitEmptyStyle(),x?typeof x=="string"&&(x={name:x}):x=null,this._useExplicitProjection=!!x,this._prioritizeAndUpdateProjection(x,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const x=this.transform,a=x.projection.name;let m;a==="globe"&&x.zoom>=i.GLOBE_ZOOM_THRESHOLD_MAX?(x.setMercatorFromTransition(),m=!0):a==="mercator"&&x.zoom=i.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(x),this.style.applyProjectionUpdate(),a){this.painter.clearBackgroundTiles();for(const m in this.style._sourceCaches)this.style._sourceCaches[m].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(x){return this.transform.locationPoint3D(i.LngLat.convert(x))}unproject(x){return this.transform.pointLocation3D(i.pointGeometry.convert(x))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(x,a,m){if(x==="mouseenter"||x==="mouseover"){let b=!1;const S=H=>{const W=a.filter(pe=>this.getLayer(pe)),ee=W.length?this.queryRenderedFeatures(H.point,{layers:W}):[];ee.length?b||(b=!0,m.call(this,new Js(x,this,H.originalEvent,{features:ee}))):b=!1},P=()=>{b=!1};return{layers:new Set(a),listener:m,delegates:{mousemove:S,mouseout:P}}}if(x==="mouseleave"||x==="mouseout"){let b=!1;const S=H=>{const W=a.filter(ee=>this.getLayer(ee));(W.length?this.queryRenderedFeatures(H.point,{layers:W}):[]).length?b=!0:b&&(b=!1,m.call(this,new Js(x,this,H.originalEvent)))},P=H=>{b&&(b=!1,m.call(this,new Js(x,this,H.originalEvent)))};return{layers:new Set(a),listener:m,delegates:{mousemove:S,mouseout:P}}}{const b=S=>{const P=a.filter(W=>this.getLayer(W)),H=P.length?this.queryRenderedFeatures(S.point,{layers:P}):[];H.length&&(S.features=H,m.call(this,S),delete S.features)};return{layers:new Set(a),listener:m,delegates:{[x]:b}}}}on(x,a,m){if(m===void 0)return super.on(x,a);Array.isArray(a)||(a=[a]);const b=this._createDelegatedListener(x,a,m);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[x]=this._delegatedListeners[x]||[],this._delegatedListeners[x].push(b);for(const S in b.delegates)this.on(S,b.delegates[S]);return this}once(x,a,m){if(m===void 0)return super.once(x,a);Array.isArray(a)||(a=[a]);const b=this._createDelegatedListener(x,a,m);for(const S in b.delegates)this.once(S,b.delegates[S]);return this}off(x,a,m){if(m===void 0)return super.off(x,a);a=new Set(Array.isArray(a)?a:[a]);const b=(P,H)=>{if(P.size!==H.size)return!1;for(const W of P)if(!H.has(W))return!1;return!0},S=this._delegatedListeners?this._delegatedListeners[x]:void 0;return S&&(P=>{for(let H=0;H{S?this.fire(new i.ErrorEvent(S)):P&&this._updateDiff(P,a)})}else typeof x=="object"&&this._updateDiff(x,a)}_updateDiff(x,a){try{this.style.setState(x)&&this._update(!0)}catch(m){i.warnOnce(`Unable to perform style diff: ${m.message||m.error||m}. Rebuilding the style from scratch.`),this._updateStyle(x,a)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(i.warnOnce("There is no style added to the map."),!1)}addSource(x,a){return this._lazyInitEmptyStyle(),this.style.addSource(x,a),this._update(!0)}isSourceLoaded(x){return!!this.style&&this.style._isSourceCacheLoaded(x)}areTilesLoaded(){const x=this.style&&this.style._sourceCaches;for(const a in x){const m=x[a]._tiles;for(const b in m){const S=m[b];if(S.state!=="loaded"&&S.state!=="errored")return!1}}return!0}addSourceType(x,a,m){this._lazyInitEmptyStyle(),this.style.addSourceType(x,a,m)}removeSource(x){return this.style.removeSource(x),this._updateTerrain(),this._update(!0)}getSource(x){return this.style.getSource(x)}addImage(x,a,{pixelRatio:m=1,sdf:b=!1,stretchX:S,stretchY:P,content:H}={}){if(this._lazyInitEmptyStyle(),a instanceof i.window.HTMLImageElement||i.window.ImageBitmap&&a instanceof i.window.ImageBitmap){const{width:W,height:ee,data:pe}=i.exported.getImageData(a);this.style.addImage(x,{data:new i.RGBAImage({width:W,height:ee},pe),pixelRatio:m,stretchX:S,stretchY:P,content:H,sdf:b,version:0})}else if(a.width===void 0||a.height===void 0)this.fire(new i.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:W,height:ee}=a,pe=a;this.style.addImage(x,{data:new i.RGBAImage({width:W,height:ee},new Uint8Array(pe.data)),pixelRatio:m,stretchX:S,stretchY:P,content:H,sdf:b,version:0,userImage:pe}),pe.onAdd&&pe.onAdd(this,x)}}updateImage(x,a){const m=this.style.getImage(x);if(!m)return void this.fire(new i.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const b=a instanceof i.window.HTMLImageElement||i.window.ImageBitmap&&a instanceof i.window.ImageBitmap?i.exported.getImageData(a):a,{width:S,height:P}=b;S!==void 0&&P!==void 0?S===m.data.width&&P===m.data.height?(m.data.replace(b.data,!(a instanceof i.window.HTMLImageElement||i.window.ImageBitmap&&a instanceof i.window.ImageBitmap)),this.style.updateImage(x,m)):this.fire(new i.ErrorEvent(new Error(`The width and height of the updated image (${S}, ${P}) must be that same as the previous version of the image (${m.data.width}, ${m.data.height})`))):this.fire(new i.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(x){return x?!!this.style.getImage(x):(this.fire(new i.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(x){this.style.removeImage(x)}loadImage(x,a){i.getImage(this._requestManager.transformRequest(x,i.ResourceType.Image),(m,b)=>{a(m,b instanceof i.window.HTMLImageElement?i.exported.getImageData(b):b)})}listImages(){return this.style.listImages()}addLayer(x,a){return this._lazyInitEmptyStyle(),this.style.addLayer(x,a),this._update(!0)}moveLayer(x,a){return this.style.moveLayer(x,a),this._update(!0)}removeLayer(x){return this.style.removeLayer(x),this._update(!0)}getLayer(x){return this.style.getLayer(x)}setLayerZoomRange(x,a,m){return this.style.setLayerZoomRange(x,a,m),this._update(!0)}setFilter(x,a,m={}){return this.style.setFilter(x,a,m),this._update(!0)}getFilter(x){return this.style.getFilter(x)}setPaintProperty(x,a,m,b={}){return this.style.setPaintProperty(x,a,m,b),this._update(!0)}getPaintProperty(x,a){return this.style.getPaintProperty(x,a)}setLayoutProperty(x,a,m,b={}){return this.style.setLayoutProperty(x,a,m,b),this._update(!0)}getLayoutProperty(x,a){return this.style.getLayoutProperty(x,a)}setLight(x,a={}){return this._lazyInitEmptyStyle(),this.style.setLight(x,a),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(x){return this._lazyInitEmptyStyle(),!x&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(x),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(x){return this._lazyInitEmptyStyle(),this.style.setFog(x),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(x){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.LngLat.convert(x),this.transform):0}setFeatureState(x,a){return this.style.setFeatureState(x,a),this._update()}removeFeatureState(x,a){return this.style.removeFeatureState(x,a),this._update()}getFeatureState(x){return this.style.getFeatureState(x)}_updateContainerDimensions(){if(!this._container)return;const x=this._container.getBoundingClientRect().width||400,a=this._container.getBoundingClientRect().height||300;let m,b,S,P=this._container;for(;P&&(!b||!S);){const H=i.window.getComputedStyle(P).transform;H&&H!=="none"&&(m=H.match(/matrix.*\((.+)\)/)[1].split(", "),m[0]&&m[0]!=="0"&&m[0]!=="1"&&(b=m[0]),m[3]&&m[3]!=="0"&&m[3]!=="1"&&(S=m[3])),P=P.parentElement}this._containerWidth=b?Math.abs(x/b):x,this._containerHeight=S?Math.abs(a/S):a}_detectMissingCSS(){i.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&i.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const x=this._container;x.classList.add("mapboxgl-map"),(this._missingCSSCanary=z("div","mapboxgl-canary",x)).style.visibility="hidden",this._detectMissingCSS();const a=this._canvasContainer=z("div","mapboxgl-canvas-container",x);this._interactive&&a.classList.add("mapboxgl-interactive"),this._canvas=z("canvas","mapboxgl-canvas",a),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const m=this._controlContainer=z("div","mapboxgl-control-container",x),b=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(S=>{b[S]=z("div",`mapboxgl-ctrl-${S}`,m)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(x,a){const m=i.exported.devicePixelRatio||1;this._canvas.width=m*Math.ceil(x),this._canvas.height=m*Math.ceil(a),this._canvas.style.width=`${x}px`,this._canvas.style.height=`${a}px`}_addMarker(x){this._markers.push(x)}_removeMarker(x){const a=this._markers.indexOf(x);a!==-1&&this._markers.splice(a,1)}_addPopup(x){this._popups.push(x)}_removePopup(x){const a=this._popups.indexOf(x);a!==-1&&this._popups.splice(a,1)}_setupPainter(){const x=i.extend({},D.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),a=this._canvas.getContext("webgl",x)||this._canvas.getContext("experimental-webgl",x);a?(i.storeAuthState(a,!0),this.painter=new cA(a,this.transform),this.on("data",m=>{m.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.exported$1.testSupport(a)):this.fire(new i.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(x){x.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.Event("webglcontextlost",{originalEvent:x}))}_contextRestored(x){this._setupPainter(),this.resize(),this._update(),this.fire(new i.Event("webglcontextrestored",{originalEvent:x}))}_onMapScroll(x){if(x.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(x){return this.style?(this._styleDirty=this._styleDirty||x,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(x){return this._update(),this._renderTaskQueue.add(x)}_cancelRenderFrame(x){this._renderTaskQueue.remove(x)}_requestDomTask(x){!this.loaded()||this.loaded()&&!this.isMoving()?x():this._domRenderTaskQueue.add(x)}_render(x){let a;const m=this.painter.context.extTimerQuery,b=i.exported.now();if(this.listens("gpu-timing-frame")&&(a=m.createQueryEXT(),m.beginQueryEXT(m.TIME_ELAPSED_EXT,a)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],i.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],i.window.performance.now())),this._renderTaskQueue.run(x),this._domRenderTaskQueue.run(x),this._removed)return;this._updateProjectionTransition();const S=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const W=this.transform.zoom,ee=this.transform.pitch,pe=i.exported.now(),fe=new i.EvaluationParameters(W,{now:pe,fadeDuration:S,pitch:ee,transition:this.style.getTransition()});this.style.update(fe)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let P=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),P=this._updateAverageElevation(b),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):P=this._updateAverageElevation(b),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,S,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:S,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new i.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),a){const W=i.exported.now()-b;m.endQueryEXT(m.TIME_ELAPSED_EXT,a),setTimeout(()=>{const ee=m.getQueryObjectEXT(a,m.QUERY_RESULT_EXT)/1e6;m.deleteQueryEXT(a),this.fire(new i.Event("gpu-timing-frame",{cpuTime:W,gpuTime:ee})),i.window.performance.mark("frame-gpu",{startTime:b,detail:{gpuTime:ee}})},50)}if(this.listens("gpu-timing-layer")){const W=this.painter.collectGpuTimers();setTimeout(()=>{const ee=this.painter.queryGpuTimers(W);this.fire(new i.Event("gpu-timing-layer",{layerTimes:ee}))},50)}if(this.listens("gpu-timing-deferred-render")){const W=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const ee=this.painter.queryGpuTimeDeferredRender(W);this.fire(new i.Event("gpu-timing-deferred-render",{gpuTime:ee}))},50)}const H=this._sourcesDirty||this._styleDirty||this._placementDirty||P;if(H||this._repaint)this.triggerRepaint();else{const W=!this.isMoving()&&this.loaded();if(W&&(P=this._updateAverageElevation(b,!0)),P)this.triggerRepaint();else if(this._triggerFrame(!1),W&&(this.fire(new i.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const ee=this._calculateSpeedIndex();this.fire(new i.Event("speedindexcompleted",{speedIndex:ee})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||H||(this._fullyLoaded=!0,i.LivePerformanceUtils.mark(i.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&i.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(x){for(const a of this._markers)x&&!this.getRenderWorldCopies()&&(a._lngLat=a._lngLat.wrap()),a._update();for(const a of this._popups)!x||this.getRenderWorldCopies()||a._trackPointer||(a._lngLat=a._lngLat.wrap()),a._update()}_updateAverageElevation(x,a=!1){const m=b=>(this.transform.averageElevation=b,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&m(0);if((a||x-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(x)){const b=this.transform.averageElevation;let S=this.transform.sampleAverageElevation(),P=!1;this.transform.elevation&&(P=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(S)?S=0:this._averageElevationLastSampledAt=x;const H=Math.abs(b-S);if(H>1){if(this._isInitialLoad||P)return this._averageElevation.jumpTo(S),m(S);this._averageElevation.easeTo(S,x,300)}else if(H>1e-4)return this._averageElevation.jumpTo(S),m(S)}return!!this._averageElevation.isEasing(x)&&m(this._averageElevation.getValue(x))}_authenticate(){i.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,x=>{if(x&&(x.message===i.AUTH_ERR_MSG||x.status===401)){const a=this.painter.context.gl;i.storeAuthState(a,!1),this._logoControl instanceof Bn&&this._logoControl._updateLogo(),a&&a.clear(a.DEPTH_BUFFER_BIT|a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),i.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const x=this._isDragging();this.painter.updateTerrain(this.style,x)}_calculateSpeedIndex(){const x=this.painter.canvasCopy(),a=this.painter.getCanvasCopiesAndTimestamps();a.timeStamps.push(performance.now());const m=this.painter.context.gl,b=m.createFramebuffer();function S(P){m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_2D,P,0);const H=new Uint8Array(m.drawingBufferWidth*m.drawingBufferHeight*4);return m.readPixels(0,0,m.drawingBufferWidth,m.drawingBufferHeight,m.RGBA,m.UNSIGNED_BYTE,H),H}return m.bindFramebuffer(m.FRAMEBUFFER,b),this._canvasPixelComparison(S(x),a.canvasCopies.map(S),a.timeStamps)}_canvasPixelComparison(x,a,m){let b=m[1]-m[0];const S=x.length/4;for(let P=0;P{const m=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,m&&this._render(a)}))}_preloadTiles(x){const a=this.style?Object.values(this.style._sourceCaches):[];return i.asyncAll(a,(m,b)=>m._preloadTiles(x,b),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(x){this._trackResize&&this.resize({originalEvent:x})._update()}_onVisibilityChange(){i.window.document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(x){this._showTileBoundaries!==x&&(this._showTileBoundaries=x,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(x){this._showTerrainWireframe!==x&&(this._showTerrainWireframe=x,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(x){this._speedIndexTiming!==x&&(this._speedIndexTiming=x,this._update())}get showPadding(){return!!this._showPadding}set showPadding(x){this._showPadding!==x&&(this._showPadding=x,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(x){this._showCollisionBoxes!==x&&(this._showCollisionBoxes=x,x?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(x){this._showOverdrawInspector!==x&&(this._showOverdrawInspector=x,this._update())}get repaint(){return!!this._repaint}set repaint(x){this._repaint!==x&&(this._repaint=x,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(x){this._vertices=x,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(x){this._showTileAABBs!==x&&(this._showTileAABBs=x,x&&this._update())}_setCacheLimits(x,a){i.setCacheLimits(x,a)}get version(){return i.version}},NavigationControl:class{constructor(x){this.options=i.extend({},ua,x),this._container=z("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",a=>a.preventDefault()),this.options.showZoom&&(i.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",a=>{this._map&&this._map.zoomIn({},{originalEvent:a})}),z("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",a=>{this._map&&this._map.zoomOut({},{originalEvent:a})}),z("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",a=>{const m=this._map;m&&(this.options.visualizePitch?m.resetNorthPitch({},{originalEvent:a}):m.resetNorth({},{originalEvent:a}))}),this._compassIcon=z("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const x=this._map;if(!x)return;const a=x.getZoom(),m=a===x.getMaxZoom(),b=a===x.getMinZoom();this._zoomInButton.disabled=m,this._zoomOutButton.disabled=b,this._zoomInButton.setAttribute("aria-disabled",m.toString()),this._zoomOutButton.setAttribute("aria-disabled",b.toString())}_rotateCompassArrow(){const x=this._map;if(!x)return;const a=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(x.transform.pitch*(Math.PI/180)),.5)}) rotateX(${x.transform.pitch}deg) rotateZ(${x.transform.angle*(180/Math.PI)}deg)`:`rotate(${x.transform.angle*(180/Math.PI)}deg)`;x._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=a)})}onAdd(x){return this._map=x,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),x.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&x.on("pitch",this._rotateCompassArrow),x.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ba(x,this._compass,this.options.visualizePitch)),this._container}onRemove(){const x=this._map;x&&(this._container.remove(),this.options.showZoom&&x.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&x.off("pitch",this._rotateCompassArrow),x.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(x,a){const m=z("button",x,this._container);return m.type="button",m.addEventListener("click",a),m}_setButtonTitle(x,a){if(!this._map)return;const m=this._map._getUIString(`NavigationControl.${a}`);x.setAttribute("aria-label",m),x.firstElementChild&&x.firstElementChild.setAttribute("title",m)}},GeolocateControl:class extends i.Evented{constructor(x){super(),this.options=i.extend({geolocation:i.window.navigator.geolocation},Wa,x),i.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=_l(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(x){return this._map=x,this._container=z("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(x){const a=(m=!!this.options.geolocation)=>{this._supportsGeolocation=m,x(m)};this._supportsGeolocation!==void 0?x(this._supportsGeolocation):i.window.navigator.permissions!==void 0?i.window.navigator.permissions.query({name:"geolocation"}).then(m=>a(m.state!=="denied")).catch(()=>a()):a()}_isOutOfMapMaxBounds(x){const a=this._map.getMaxBounds(),m=x.coords;return!!a&&(m.longitudea.getEast()||m.latitudea.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(x){if(this._map){if(this._isOutOfMapMaxBounds(x))return this._setErrorState(),this.fire(new i.Event("outofmaxbounds",x)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=x,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(x),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(x),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new i.Event("geolocate",x)),this._finish()}}_updateCamera(x){const a=new i.LngLat(x.coords.longitude,x.coords.latitude),m=x.coords.accuracy,b=this._map.getBearing(),S=i.extend({bearing:b},this.options.fitBoundsOptions);this._map.fitBounds(a.toBounds(m),S,{geolocateSource:!0})}_updateMarker(x){if(x){const a=new i.LngLat(x.coords.longitude,x.coords.latitude);this._accuracyCircleMarker.setLngLat(a).addTo(this._map),this._userLocationDotMarker.setLngLat(a).addTo(this._map),this._accuracy=x.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const x=this._map.transform,a=i.mercatorZfromAltitude(1,x._center.lat)*x.worldSize,m=Math.ceil(2*this._accuracy*a);this._circleElement.style.width=`${m}px`,this._circleElement.style.height=`${m}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(x){if(this._map){if(this.options.trackUserLocation)if(x.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const a=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",a),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",a),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(x.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new i.Event("error",x)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(x){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",a=>a.preventDefault()),this._geolocateButton=z("button","mapboxgl-ctrl-geolocate",this._container),z("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",x===!1){i.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const a=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",a),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",a)}else{const a=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",a),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",a)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=z("div","mapboxgl-user-location"),this._dotElement.appendChild(z("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(z("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Lr({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=z("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Lr({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",a=>{a.geolocateSource||this._watchState!=="ACTIVE_LOCK"||a.originalEvent&&a.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new i.Event("trackuserlocationend")))})}}_onDeviceOrientation(x){this._userLocationDotMarker&&(x.webkitCompassHeading?this._heading=x.webkitCompassHeading:x.absolute===!0&&(this._heading=-1*x.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let x;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(x={maximumAge:6e5,timeout:0},this._noTimeout=!0):(x=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,x),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const x=()=>{i.window.addEventListener("ondeviceorientationabsolute"in i.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};i.window.DeviceMotionEvent!==void 0&&typeof i.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(a=>{a==="granted"&&x()}).catch(console.error):x()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),i.window.removeEventListener("deviceorientation",this._onDeviceOrientation),i.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:cn,ScaleControl:class{constructor(x){this.options=i.extend({},Wo,x),function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"narrow",unit:"meter"}),!0}catch{return!1}}()||(this._setScale=mo.bind(this)),i.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const x=this.options.maxWidth||100,a=this._map,m=a._containerHeight/2,b=a._containerWidth/2-x/2,S=a.unproject([b,m]),P=a.unproject([b+x,m]),H=S.distanceTo(P);if(this.options.unit==="imperial"){const W=3.2808*H;W>5280?this._setScale(x,W/5280,"mile"):this._setScale(x,W,"foot")}else this.options.unit==="nautical"?this._setScale(x,H/1852,"nautical-mile"):H>=1e3?this._setScale(x,H/1e3,"kilometer"):this._setScale(x,H,"meter")}_setScale(x,a,m){const b=Ba(a),S=b/a;this._map._requestDomTask(()=>{this._container.style.width=x*S+"px",this._container.innerHTML=m!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"narrow",unit:m}).format(b):`${b} nm`})}onAdd(x){return this._map=x,this._language=x.getLanguage(),this._container=z("div","mapboxgl-ctrl mapboxgl-ctrl-scale",x.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(x){this._language=x,this._update()}setUnit(x){this.options.unit=x,this._update()}},FullscreenControl:class{constructor(x){this._fullscreen=!1,x&&x.container&&(x.container instanceof i.window.HTMLElement?this._container=x.container:i.warnOnce("Full screen control 'container' must be a DOM element.")),i.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in i.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in i.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(x){return this._map=x,this._container||(this._container=this._map.getContainer()),this._controlContainer=z("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,i.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!i.window.document.fullscreenEnabled&&!i.window.document.webkitFullscreenEnabled)}_setupUI(){const x=this._fullscreenButton=z("button","mapboxgl-ctrl-fullscreen",this._controlContainer);z("span","mapboxgl-ctrl-icon",x).setAttribute("aria-hidden","true"),x.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),i.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const x=this._getTitle();this._fullscreenButton.setAttribute("aria-label",x),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",x)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(i.window.document.fullscreenElement||i.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?i.window.document.exitFullscreen?i.window.document.exitFullscreen():i.window.document.webkitCancelFullScreen&&i.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends i.Evented{constructor(x){super(),this.options=i.extend(Object.create(Rr),x),i.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(x&&x.className?x.className.trim().split(/\s+/):[])}addTo(x){return this._map&&this.remove(),this._map=x,this.options.closeOnClick&&x.on("preclick",this._onClose),this.options.closeOnMove&&x.on("move",this._onClose),x.on("remove",this.remove),this._update(),x._addPopup(this),this._focusFirstElement(),this._trackPointer?(x.on("mousemove",this._onMouseEvent),x.on("mouseup",this._onMouseEvent),x._canvasContainer.classList.add("mapboxgl-track-pointer")):x.on("move",this._update),this.fire(new i.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const x=this._map;return x&&(x.off("move",this._update),x.off("move",this._onClose),x.off("preclick",this._onClose),x.off("click",this._onClose),x.off("remove",this.remove),x.off("mousemove",this._onMouseEvent),x.off("mouseup",this._onMouseEvent),x.off("drag",this._onMouseEvent),x._canvasContainer&&x._canvasContainer.classList.remove("mapboxgl-track-pointer"),x._removePopup(this),this._map=void 0),this.fire(new i.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(x){this._lngLat=i.LngLat.convert(x),this._pos=null,this._trackPointer=!1,this._update();const a=this._map;return a&&(a.on("move",this._update),a.off("mousemove",this._onMouseEvent),a._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const x=this._map;return x&&(x.off("move",this._update),x.on("mousemove",this._onMouseEvent),x.on("drag",this._onMouseEvent),x._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(x){return this.setDOMContent(i.window.document.createTextNode(x))}setHTML(x){const a=i.window.document.createDocumentFragment(),m=i.window.document.createElement("body");let b;for(m.innerHTML=x;b=m.firstChild,b;)a.appendChild(b);return this.setDOMContent(a)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(x){return this.options.maxWidth=x,this._update(),this}setDOMContent(x){let a=this._content;if(a)for(;a.hasChildNodes();)a.firstChild&&a.removeChild(a.firstChild);else a=this._content=z("div","mapboxgl-popup-content",this._container||void 0);if(a.appendChild(x),this.options.closeButton){const m=this._closeButton=z("button","mapboxgl-popup-close-button",a);m.type="button",m.setAttribute("aria-label","Close popup"),m.setAttribute("aria-hidden","true"),m.innerHTML="×",m.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(x){return this._classList.add(x),this._updateClassList(),this}removeClassName(x){return this._classList.delete(x),this._updateClassList(),this}setOffset(x){return this.options.offset=x,this._update(),this}toggleClassName(x){let a;return this._classList.delete(x)?a=!1:(this._classList.add(x),a=!0),this._updateClassList(),a}_onMouseEvent(x){this._update(x.point)}_getAnchor(x){if(this.options.anchor)return this.options.anchor;const a=this._map,m=this._container,b=this._pos;if(!a||!m||!b)return"bottom";const S=m.offsetWidth,P=m.offsetHeight,H=b.xa.transform.width-S/2;if(b.y+xa.transform.height-P){if(H)return"bottom-left";if(W)return"bottom-right"}return H?"left":W?"right":"bottom"}_updateClassList(){const x=this._container;if(!x)return;const a=[...this._classList];a.push("mapboxgl-popup"),this._anchor&&a.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&a.push("mapboxgl-popup-track-pointer"),x.className=a.join(" ")}_update(x){const a=this._map,m=this._content;if(!a||!this._lngLat&&!this._trackPointer||!m)return;let b=this._container;if(b||(b=this._container=z("div","mapboxgl-popup",a.getContainer()),this._tip=z("div","mapboxgl-popup-tip",b),b.appendChild(m)),this.options.maxWidth&&b.style.maxWidth!==this.options.maxWidth&&(b.style.maxWidth=this.options.maxWidth),a.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=ur(this._lngLat,this._pos,a.transform)),!this._trackPointer||x){const S=this._pos=this._trackPointer&&x?x:a.project(this._lngLat),P=Er(this.options.offset),H=this._anchor=this._getAnchor(P.y),W=Er(this.options.offset,H),ee=S.add(W).round();a._requestDomTask(()=>{this._container&&H&&(this._container.style.transform=`${Un[H]} translate(${ee.x}px,${ee.y}px)`)})}if(!this._marker&&a._showingGlobe()){const S=i.isLngLatBehindGlobe(a.transform,this._lngLat)?0:1;this._setOpacity(S)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const x=this._container.querySelector(Cr);x&&x.focus()}_onClose(){this.remove()}_setOpacity(x){this._container&&(this._container.style.opacity=`${x}`),this._content&&(this._content.style.pointerEvents=x?"auto":"none")}},Marker:Lr,Style:Ws,LngLat:i.LngLat,LngLatBounds:i.LngLatBounds,Point:i.pointGeometry,MercatorCoordinate:i.MercatorCoordinate,FreeCameraOptions:Vh,Evented:i.Evented,config:i.config,prewarm:function(){jt().acquire(et)},clearPrewarmedResources:function(){const x=Lt;x&&(x.isPreloaded()&&x.numActive()===1?(x.release(et),Lt=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return i.config.ACCESS_TOKEN},set accessToken(x){i.config.ACCESS_TOKEN=x},get baseApiUrl(){return i.config.API_URL},set baseApiUrl(x){i.config.API_URL=x},get workerCount(){return pt.workerCount},set workerCount(x){pt.workerCount=x},get maxParallelImageRequests(){return i.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(x){i.config.MAX_PARALLEL_IMAGE_REQUESTS=x},clearStorage(x){i.clearTileCache(x)},workerUrl:"",workerClass:null,setNow:i.exported.setNow,restoreNow:i.exported.restoreNow};return $l});var y=c;return y})})(UF);const Em=UF.exports,bV=` varying vec2 vUv; varying vec3 v3; varying vec3 v_color; attribute vec3 color; void main(){ v_color = color; vUv = uv; // v3 = vec3((position.x+1.0) /2.0,(position.y+1.0) /2.0,(position.z+1.0) /2.0); // v3 = vec3((position.x+1.0) /2.0,(position.y+1.0) /2.0,(position.z+1.0) /2.0); gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); } `,BV=` varying vec2 vUv; varying vec3 v3; uniform float iTime; uniform float opacity; uniform vec3 color; varying vec3 v_color; void main(){ vec2 uv = vUv; // vec3 vv3 = vec3((v3.x+1.0) /2.0,(v3.y+1.0) /2.0,(v3.z+1.0) /2.0); // v3.x = (v3.x + 1.0) / 2.0; // float time = iTime * 0.3 + 0.0*0.01; // // To create the BG pattern // vec3 wave_color = vec3(0.0); // // To create the waves // float wave_width = 0.01; // // uv.y -= 0.5; // // for(float i = 0.0; i < 1.0; i++) { // // // uv.y += cos(i * 2.0 + iTime ) > 0.0 ? sin(i * 2.0 + iTime ) : -sin(i * 2.0 + iTime ) ; // // \u63A7\u5236\u7EBF\u6761\u8FD0\u52A8\u65B9\u5F0F\u3002 sin \u5185\u90E8\u63A7\u5236\u901F\u5EA6 \u5916\u9762\u63A7\u5236\u5E45\u5EA6 // // uv.y += sin(i * 2.3 + iTime ) * 0.5 + 0.0 ; // 0 => 0.3 ,uv.y \u662F0-1\u533A\u95F4\u5185 // // uv.y += 1.5; // // | uv.y | < 0.293 \u9010\u6B65\u663E\u793A > 0.293 \u9010\u6B65\u9690\u85CF // // uv.y = 0.293; // // \u63A7\u5236\u7EBF\u6761\u5BBD\u5EA6 // wave_width = abs(1.0 / (40.0 * uv.y)); // wave_color = vec3(wave_width , wave_width * 3.9, wave_width * 4.5); // } // // float random = ((wave_color.r + wave_color.g + wave_color.b) / 4.0) - 0.2; // // gl_FragColor = vec4(wave_color, random); // // uv.y += 0.5; // gl_FragColor = vec4(uv.y,0.0,0.0,1.0); gl_FragColor = vec4(v_color,opacity); } `;function CV(u){let e=[];return u.features.forEach(function(t){const r={geo:[],name:t.properties.name};r.name,e.push(r);const c=0;t.geometry.type==="Polygon"?(r.geo[0]=[],t.geometry.coordinates[0].forEach((p=[0,1,2])=>{p[0]=Em.MercatorCoordinate.fromLngLat(p,c).x,p[1]=Em.MercatorCoordinate.fromLngLat(p,c).y,p[2]=Em.MercatorCoordinate.fromLngLat(p,c).z,r.geo[0].push(new Di(p[0],p[1]))})):t.geometry.type==="MultiPolygon"&&t.geometry.coordinates.forEach((p,y)=>{r.geo[y]=[],p[0].forEach(i=>{i[0]=Em.MercatorCoordinate.fromLngLat(i,c).x,i[1]=Em.MercatorCoordinate.fromLngLat(i,c).y,i[2]=Em.MercatorCoordinate.fromLngLat(i,c).z,r.geo[y].push(new ft(i[0],i[1],i[2]))})})}),e}function Jw(u){let e=new Hs;return e.name="geojson",CV(u)}var ic=63710088e-1,zF={centimeters:ic*100,centimetres:ic*100,degrees:ic/111325,feet:ic*3.28084,inches:ic*39.37,kilometers:ic/1e3,kilometres:ic/1e3,meters:ic,metres:ic,miles:ic/1609.344,millimeters:ic*1e3,millimetres:ic*1e3,nauticalmiles:ic/1852,radians:1,yards:ic*1.0936};function EV(u,e,t){t===void 0&&(t={});var r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=u,r}function TV(u,e,t){if(t===void 0&&(t={}),!u)throw new Error("coordinates is required");if(!Array.isArray(u))throw new Error("coordinates must be an Array");if(u.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!nS(u[0])||!nS(u[1]))throw new Error("coordinates must contain numbers");var r={type:"Point",coordinates:u};return EV(r,e,t)}function SV(u,e){e===void 0&&(e="kilometers");var t=zF[e];if(!t)throw new Error(e+" units is invalid");return u*t}function MV(u,e){e===void 0&&(e="kilometers");var t=zF[e];if(!t)throw new Error(e+" units is invalid");return u/t}function _2(u){var e=u%(2*Math.PI);return e*180/Math.PI}function hu(u){var e=u%360;return e*Math.PI/180}function nS(u){return!isNaN(u)&&u!==null&&!Array.isArray(u)}function ry(u){if(!u)throw new Error("coord is required");if(!Array.isArray(u)){if(u.type==="Feature"&&u.geometry!==null&&u.geometry.type==="Point")return u.geometry.coordinates;if(u.type==="Point")return u.coordinates}if(Array.isArray(u)&&u.length>=2&&!Array.isArray(u[0])&&!Array.isArray(u[1]))return u;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function kF(u,e,t){t===void 0&&(t={});var r=ry(u),c=ry(e),p=hu(c[1]-r[1]),y=hu(c[0]-r[0]),i=hu(r[1]),C=hu(c[1]),D=Math.pow(Math.sin(p/2),2)+Math.pow(Math.sin(y/2),2)*Math.cos(i)*Math.cos(C);return SV(2*Math.atan2(Math.sqrt(D),Math.sqrt(1-D)),t.units)}function IV(u,e,t,r){r===void 0&&(r={});var c=ry(u),p=hu(c[0]),y=hu(c[1]),i=hu(t),C=MV(e,r.units),D=Math.asin(Math.sin(y)*Math.cos(C)+Math.cos(y)*Math.sin(C)*Math.cos(i)),R=p+Math.atan2(Math.sin(i)*Math.sin(C)*Math.cos(y),Math.cos(C)-Math.sin(y)*Math.sin(D)),Q=_2(R),z=_2(D);return TV([Q,z],r.properties)}function OF(u,e,t){if(t===void 0&&(t={}),t.final===!0)return FV(u,e);var r=ry(u),c=ry(e),p=hu(r[0]),y=hu(c[0]),i=hu(r[1]),C=hu(c[1]),D=Math.sin(y-p)*Math.cos(C),R=Math.cos(i)*Math.sin(C)-Math.sin(i)*Math.cos(C)*Math.cos(y-p);return _2(Math.atan2(D,R))}function FV(u,e){var t=OF(e,u);return t=(t+180)%360,t}function LV(u,e){var t=kF(u,e),r=OF(u,e),c=IV(u,t/2,r);return c}var yv={exports:{}};/*! * Knockout JavaScript library v3.5.1 * (c) The Knockout.js team - http://knockoutjs.com/ * License: MIT (http://www.opensource.org/licenses/mit-license.php) */(function(u,e){(function(){(function(t){var r=this||(0,eval)("this"),c=r.document,p=r.navigator,y=r.jQuery,i=r.JSON;y||typeof jQuery>"u"||(y=jQuery),function(C){C(u.exports||e)}(function(C,D){function R(te,le){return te===null||typeof te in ae?te===le:!1}function Q(te,le){var ye;return function(){ye||(ye=B.a.setTimeout(function(){ye=t,te()},le))}}function z(te,le){var ye;return function(){clearTimeout(ye),ye=B.a.setTimeout(te,le)}}function G(te,le){le&&le!=="change"?le==="beforeChange"?this.pc(te):this.gb(te,le):this.qc(te)}function J(te,le){le!==null&&le.s&&le.s()}function Y(te,le){var ye=this.qd,xe=ye[De];xe.ra||(this.Qb&&this.mb[le]?(ye.uc(le,te,this.mb[le]),this.mb[le]=null,--this.Qb):xe.I[le]||ye.uc(le,te,xe.J?{da:te}:ye.$c(te)),te.Ja&&te.gd())}var B=typeof C<"u"?C:{};B.b=function(te,le){for(var ye=te.split("."),xe=B,Re=0;Re",ut[0];);return 4B.a.A(At,ut)&&At.push(ut)}),At},Mb:function(be,At,ut){var Nt=[];if(be)for(var Gt=0,Qt=be.length;GtNt?ut&&be.push(At):ut||be.splice(Nt,1)},Ba:Oe,extend:le,setPrototypeOf:ye,Ab:Oe?ye:le,P:te,Ga:function(be,At,ut){if(!be)return be;var Nt={},Gt;for(Gt in be)Re.call(be,Gt)&&(Nt[Gt]=At.call(ut,be[Gt],Gt,be));return Nt},Tb:function(be){for(;be.firstChild;)B.removeNode(be.firstChild)},Yb:function(be){be=B.a.la(be);for(var At=(be[0]&&be[0].ownerDocument||c).createElement("div"),ut=0,Nt=be.length;utKe?be.setAttribute("selected",At):be.selected=At},Db:function(be){return be===null||be===t?"":be.trim?be.trim():be.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")},Ud:function(be,At){return be=be||"",At.length>be.length?!1:be.substring(0,At.length)===At},vd:function(be,At){if(be===At)return!0;if(be.nodeType===11)return!1;if(At.contains)return At.contains(be.nodeType!==1?be.parentNode:be);if(At.compareDocumentPosition)return(At.compareDocumentPosition(be)&16)==16;for(;be&&be!=At;)be=be.parentNode;return!!be},Sb:function(be){return B.a.vd(be,be.ownerDocument.documentElement)},kd:function(be){return!!B.a.Lb(be,B.a.Sb)},R:function(be){return be&&be.tagName&&be.tagName.toLowerCase()},Ac:function(be){return B.onError?function(){try{return be.apply(this,arguments)}catch(At){throw B.onError&&B.onError(At),At}}:be},setTimeout:function(be,At){return setTimeout(B.a.Ac(be),At)},Gc:function(be){setTimeout(function(){throw B.onError&&B.onError(be),be},0)},B:function(be,At,ut){var Nt=B.a.Ac(ut);if(ut=Se[At],B.options.useOnlyNativeEvents||ut||!y)if(ut||typeof be.addEventListener!="function")if(typeof be.attachEvent<"u"){var Gt=function(Ct){Nt.call(be,Ct)},Qt="on"+At;be.attachEvent(Qt,Gt),B.a.K.za(be,function(){be.detachEvent(Qt,Gt)})}else throw Error("Browser doesn't support addEventListener or attachEvent");else be.addEventListener(At,Nt,!1);else vt||(vt=typeof y(be).on=="function"?"on":"bind"),y(be)[vt](At,Nt)},Fb:function(be,At){if(!be||!be.nodeType)throw Error("element must be a DOM node when calling triggerEvent");var ut;if(B.a.R(be)==="input"&&be.type&&At.toLowerCase()=="click"?(ut=be.type,ut=ut=="checkbox"||ut=="radio"):ut=!1,B.options.useOnlyNativeEvents||!y||ut)if(typeof c.createEvent=="function")if(typeof be.dispatchEvent=="function")ut=c.createEvent(Qe[At]||"HTMLEvents"),ut.initEvent(At,!0,!0,r,0,0,0,0,0,!1,!1,!1,!1,0,be),be.dispatchEvent(ut);else throw Error("The supplied element doesn't support dispatchEvent");else if(ut&&be.click)be.click();else if(typeof be.fireEvent<"u")be.fireEvent("on"+At);else throw Error("Browser doesn't support triggering events");else y(be).trigger(At)},f:function(be){return B.O(be)?be():be},bc:function(be){return B.O(be)?be.v():be},Eb:function(be,At,ut){var Nt;At&&(typeof be.classList=="object"?(Nt=be.classList[ut?"add":"remove"],B.a.D(At.match(nt),function(Gt){Nt.call(be.classList,Gt)})):typeof be.className.baseVal=="string"?xe(be.className,"baseVal",At,ut):xe(be,"className",At,ut))},Bb:function(be,At){var ut=B.a.f(At);(ut===null||ut===t)&&(ut="");var Nt=B.h.firstChild(be);!Nt||Nt.nodeType!=3||B.h.nextSibling(Nt)?B.h.va(be,[be.ownerDocument.createTextNode(ut)]):Nt.data=ut,B.a.Ad(be)},Yc:function(be,At){if(be.name=At,7>=Ke)try{var ut=be.name.replace(/[&<>'"]/g,function(Nt){return"&#"+Nt.charCodeAt(0)+";"});be.mergeAttributes(c.createElement(""),!1)}catch{}},Ad:function(be){9<=Ke&&(be=be.nodeType==1?be:be.parentNode,be.style&&(be.style.zoom=be.style.zoom))},wd:function(be){if(Ke){var At=be.style.width;be.style.width=0,be.style.width=At}},Pd:function(be,At){be=B.a.f(be),At=B.a.f(At);for(var ut=[],Nt=be;Nt<=At;Nt++)ut.push(Nt);return ut},la:function(be){for(var At=[],ut=0,Nt=be.length;ut",""],ye=[3,"","
"],xe=[1,""],Re={thead:le,tbody:le,tfoot:le,tr:[2,"","
"],td:ye,th:ye,option:xe,optgroup:xe},Oe=8>=B.a.W;B.a.ua=function(We,Ve){var Qe;if(y){if(y.parseHTML)Qe=y.parseHTML(We,Ve)||[];else if((Qe=y.clean([We],Ve))&&Qe[0]){for(var Se=Qe[0];Se.parentNode&&Se.parentNode.nodeType!==11;)Se=Se.parentNode;Se.parentNode&&Se.parentNode.removeChild(Se)}}else{(Qe=Ve)||(Qe=c);var Se=Qe.parentWindow||Qe.defaultView||r,Ke=B.a.Db(We).toLowerCase(),nt=Qe.createElement("div"),vt;for(vt=(Ke=Ke.match(/^(?:\x3c!--.*?--\x3e\s*?)*?<([a-z]+)[\s>]/))&&Re[Ke[1]]||te,Ke=vt[0],vt="ignored
"+vt[1]+We+vt[2]+"
",typeof Se.innerShiv=="function"?nt.appendChild(Se.innerShiv(vt)):(Oe&&Qe.body.appendChild(nt),nt.innerHTML=vt,Oe&&nt.parentNode.removeChild(nt));Ke--;)nt=nt.lastChild;Qe=B.a.la(nt.lastChild.childNodes)}return Qe},B.a.Md=function(We,Ve){var Qe=B.a.ua(We,Ve);return Qe.length&&Qe[0].parentElement||B.a.Yb(Qe)},B.a.fc=function(We,Ve){if(B.a.Tb(We),Ve=B.a.f(Ve),Ve!==null&&Ve!==t)if(typeof Ve!="string"&&(Ve=Ve.toString()),y)y(We).html(Ve);else for(var Qe=B.a.ua(Ve,We.ownerDocument),Se=0;Se"},bd:function(ye,xe){var Re=le[ye];if(Re===t)throw Error("Couldn't find any memo with ID "+ye+". Perhaps it's already been unmemoized.");try{return Re.apply(null,xe||[]),!0}finally{delete le[ye]}},cd:function(ye,xe){var Re=[];te(ye,Re);for(var Oe=0,We=Re.length;OeVe){if(5e3<=++Qe){We=Re,B.a.Gc(Error("'Too much recursion' after processing "+Qe+" task groups."));break}Ve=Re}try{Se()}catch(Ke){B.a.Gc(Ke)}}}}function le(){te(),We=Re=xe.length=0}var ye,xe=[],Re=0,Oe=1,We=0;return r.MutationObserver?ye=function(Ve){var Qe=c.createElement("div");return new MutationObserver(Ve).observe(Qe,{attributes:!0}),function(){Qe.classList.toggle("foo")}}(le):ye=c&&"onreadystatechange"in c.createElement("script")?function(Ve){var Qe=c.createElement("script");Qe.onreadystatechange=function(){Qe.onreadystatechange=null,c.documentElement.removeChild(Qe),Qe=null,Ve()},c.documentElement.appendChild(Qe)}:function(Ve){setTimeout(Ve,0)},{scheduler:ye,zb:function(Ve){return Re||B.na.scheduler(le),xe[Re++]=Ve,Oe++},cancel:function(Ve){Ve=Ve-(Oe-Re),Ve>=We&&Vebe[0]?Nt+be[0]:be[0]),Nt);for(var Nt=Gt===1?Nt:Math.min(vt+(be[1]||0),Nt),Gt=vt+Gt-2,Qt=Math.max(Nt,Gt),Ct=[],Ft=[],Xt=2;vtOe;Oe++)Re=Re();return Re})},B.toJSON=function(xe,Re,Oe){return xe=B.ad(xe),B.a.hc(xe,Re,Oe)},ye.prototype={constructor:ye,save:function(xe,Re){var Oe=B.a.A(this.keys,xe);0<=Oe?this.values[Oe]=Re:(this.keys.push(xe),this.values.push(Re))},get:function(xe){return xe=B.a.A(this.keys,xe),0<=xe?this.values[xe]:t}}}(),B.b("toJS",B.ad),B.b("toJSON",B.toJSON),B.Wd=function(te,le,ye){function xe(Re){var Oe=B.xb(te,ye).extend({ma:"always"}),We=Oe.subscribe(function(Ve){Ve&&(We.s(),Re(Ve))});return Oe.notifySubscribers(Oe.v()),We}return typeof Promise!="function"||le?xe(le.bind(ye)):new Promise(xe)},B.b("when",B.Wd),function(){B.w={M:function(te){switch(B.a.R(te)){case"option":return te.__ko__hasDomDataOptionValue__===!0?B.a.g.get(te,B.c.options.$b):7>=B.a.W?te.getAttributeNode("value")&&te.getAttributeNode("value").specified?te.value:te.text:te.value;case"select":return 0<=te.selectedIndex?B.w.M(te.options[te.selectedIndex]):t;default:return te.value}},cb:function(te,le,ye){switch(B.a.R(te)){case"option":typeof le=="string"?(B.a.g.set(te,B.c.options.$b,t),"__ko__hasDomDataOptionValue__"in te&&delete te.__ko__hasDomDataOptionValue__,te.value=le):(B.a.g.set(te,B.c.options.$b,le),te.__ko__hasDomDataOptionValue__=!0,te.value=typeof le=="number"?le:"");break;case"select":(le===""||le===null)&&(le=t);for(var xe=-1,Re=0,Oe=te.options.length,We;Re=vt){Qe.push(Ke&&nt.length?{key:Ke,value:nt.join("")}:{unknown:Ke||nt.join("")}),Ke=vt=0,nt=[];continue}}else if(ut===58){if(!vt&&!Ke&&nt.length===1){Ke=nt.pop();continue}}else{if(ut===47&&1",Oe=Re?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,We=Re?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,Ve={ul:!0,ol:!0},Qe="__ko_matchedEndComment__";B.h={ea:{},childNodes:function(Se){return te(Se)?ye(Se):Se.childNodes},Ea:function(Se){if(te(Se)){Se=B.h.childNodes(Se);for(var Ke=0,nt=Se.length;Kearguments.length){if(Ct=c.body,!Ct)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?")}else if(!Ct||Ct.nodeType!==1&&Ct.nodeType!==8)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");Qe(nt(Qt,Ft),Ct)},B.Dc=function(Qt){return!Qt||Qt.nodeType!==1&&Qt.nodeType!==8?t:B.Td(Qt)},B.Ec=function(Qt){return(Qt=B.Dc(Qt))?Qt.$data:t},B.b("bindingHandlers",B.c),B.b("bindingEvent",B.i),B.b("bindingEvent.subscribe",B.i.subscribe),B.b("bindingEvent.startPossiblyAsyncContentBinding",B.i.Cb),B.b("applyBindings",B.vc),B.b("applyBindingsToDescendants",B.Oa),B.b("applyBindingAccessorsToNode",B.ib),B.b("applyBindingsToNode",B.ld),B.b("contextFor",B.Dc),B.b("dataFor",B.Ec)}(),function(te){function le(We,Ve){var Qe=Object.prototype.hasOwnProperty.call(Re,We)?Re[We]:te,Se;Qe?Qe.subscribe(Ve):(Qe=Re[We]=new B.T,Qe.subscribe(Ve),ye(We,function(Ke,nt){var vt=!(!nt||!nt.synchronous);Oe[We]={definition:Ke,Gd:vt},delete Re[We],Se||vt?Qe.notifySubscribers(Ke):B.na.zb(function(){Qe.notifySubscribers(Ke)})}),Se=!0)}function ye(We,Ve){xe("getConfig",[We],function(Qe){Qe?xe("loadComponent",[We,Qe],function(Se){Ve(Se,Qe)}):Ve(null,null)})}function xe(We,Ve,Qe,Se){Se||(Se=B.j.loaders.slice(0));var Ke=Se.shift();if(Ke){var nt=Ke[We];if(nt){var vt=!1;if(nt.apply(Ke,Ve.concat(function(be){vt?Qe(null):be!==null?Qe(be):xe(We,Ve,Qe,Se)}))!==te&&(vt=!0,!Ke.suppressLoaderExceptions))throw Error("Component loaders must supply values by invoking the callback, not by returning values synchronously.")}else xe(We,Ve,Qe,Se)}else Qe(null)}var Re={},Oe={};B.j={get:function(We,Ve){var Qe=Object.prototype.hasOwnProperty.call(Oe,We)?Oe[We]:te;Qe?Qe.Gd?B.u.G(function(){Ve(Qe.definition)}):B.na.zb(function(){Ve(Qe.definition)}):le(We,Ve)},Bc:function(We){delete Oe[We]},oc:xe},B.j.loaders=[],B.b("components",B.j),B.b("components.get",B.j.get),B.b("components.clearCachedDefinition",B.j.Bc)}(),function(){function te(Qe,Se,Ke,nt){function vt(){--At===0&&nt(be)}var be={},At=2,ut=Ke.template;Ke=Ke.viewModel,ut?Re(Se,ut,function(Nt){B.j.oc("loadTemplate",[Qe,Nt],function(Gt){be.template=Gt,vt()})}):vt(),Ke?Re(Se,Ke,function(Nt){B.j.oc("loadViewModel",[Qe,Nt],function(Gt){be[Ve]=Gt,vt()})}):vt()}function le(Qe,Se,Ke){if(typeof Se=="function")Ke(function(vt){return new Se(vt)});else if(typeof Se[Ve]=="function")Ke(Se[Ve]);else if("instance"in Se){var nt=Se.instance;Ke(function(){return nt})}else"viewModel"in Se?le(Qe,Se.viewModel,Ke):Qe("Unknown viewModel value: "+Se)}function ye(Qe){switch(B.a.R(Qe)){case"script":return B.a.ua(Qe.text);case"textarea":return B.a.ua(Qe.value);case"template":if(xe(Qe.content))return B.a.Ca(Qe.content.childNodes)}return B.a.Ca(Qe.childNodes)}function xe(Qe){return r.DocumentFragment?Qe instanceof DocumentFragment:Qe&&Qe.nodeType===11}function Re(Qe,Se,Ke){typeof Se.require=="string"?D||r.require?(D||r.require)([Se.require],function(nt){nt&&typeof nt=="object"&&nt.Xd&&nt.default&&(nt=nt.default),Ke(nt)}):Qe("Uses require, but no AMD loader is present"):Ke(Se)}function Oe(Qe){return function(Se){throw Error("Component '"+Qe+"': "+Se)}}var We={};B.j.register=function(Qe,Se){if(!Se)throw Error("Invalid configuration for "+Qe);if(B.j.tb(Qe))throw Error("Component "+Qe+" is already registered");We[Qe]=Se},B.j.tb=function(Qe){return Object.prototype.hasOwnProperty.call(We,Qe)},B.j.unregister=function(Qe){delete We[Qe],B.j.Bc(Qe)},B.j.Fc={getConfig:function(Qe,Se){Se(B.j.tb(Qe)?We[Qe]:null)},loadComponent:function(Qe,Se,Ke){var nt=Oe(Qe);Re(nt,Se,function(vt){te(Qe,nt,vt,Ke)})},loadTemplate:function(Qe,Se,Ke){if(Qe=Oe(Qe),typeof Se=="string")Ke(B.a.ua(Se));else if(Se instanceof Array)Ke(Se);else if(xe(Se))Ke(B.a.la(Se.childNodes));else if(Se.element)if(Se=Se.element,r.HTMLElement?Se instanceof HTMLElement:Se&&Se.tagName&&Se.nodeType===1)Ke(ye(Se));else if(typeof Se=="string"){var nt=c.getElementById(Se);nt?Ke(ye(nt)):Qe("Cannot find element with ID "+Se)}else Qe("Unknown element type: "+Se);else Qe("Unknown template value: "+Se)},loadViewModel:function(Qe,Se,Ke){le(Oe(Qe),Se,Ke)}};var Ve="createViewModel";B.b("components.register",B.j.register),B.b("components.isRegistered",B.j.tb),B.b("components.unregister",B.j.unregister),B.b("components.defaultLoader",B.j.Fc),B.j.loaders.push(B.j.Fc),B.j.dd=We}(),function(){function te(ye,xe){var Re=ye.getAttribute("params");if(Re){var Re=le.parseBindingsString(Re,xe,ye,{valueAccessors:!0,bindingParams:!0}),Re=B.a.Ga(Re,function(Ve){return B.o(Ve,null,{l:ye})}),Oe=B.a.Ga(Re,function(Ve){var Qe=Ve.v();return Ve.ja()?B.o({read:function(){return B.a.f(Ve())},write:B.Za(Qe)&&function(Se){Ve()(Se)},l:ye}):Qe});return Object.prototype.hasOwnProperty.call(Oe,"$raw")||(Oe.$raw=Re),Oe}return{$raw:{}}}B.j.getComponentNameForNode=function(ye){var xe=B.a.R(ye);if(B.j.tb(xe)&&(xe.indexOf("-")!=-1||""+ye=="[object HTMLUnknownElement]"||8>=B.a.W&&ye.tagName===xe))return xe},B.j.tc=function(ye,xe,Re,Oe){if(xe.nodeType===1){var We=B.j.getComponentNameForNode(xe);if(We){if(ye=ye||{},ye.component)throw Error('Cannot use the "component" binding on a custom element matching a component');var Ve={name:We,params:te(xe,Re)};ye.component=Oe?function(){return Ve}:Ve}}return ye};var le=new B.ga;9>B.a.W&&(B.j.register=function(ye){return function(xe){return ye.apply(this,arguments)}}(B.j.register),c.createDocumentFragment=function(ye){return function(){var xe=ye();return B.j.dd,xe}}(c.createDocumentFragment))}(),function(){function te(xe,Re,Oe){if(Re=Re.template,!Re)throw Error("Component '"+xe+"' has no template");xe=B.a.Ca(Re),B.h.va(Oe,xe)}function le(xe,Re,Oe){var We=xe.createViewModel;return We?We.call(xe,Re,Oe):Re}var ye=0;B.c.component={init:function(xe,Re,Oe,We,Ve){function Qe(){var be=Se&&Se.dispose;typeof be=="function"&&be.call(Se),nt&&nt.s(),Ke=Se=nt=null}var Se,Ke,nt,vt=B.a.la(B.h.childNodes(xe));return B.h.Ea(xe),B.a.K.za(xe,Qe),B.o(function(){var be=B.a.f(Re()),At,ut;if(typeof be=="string"?At=be:(At=B.a.f(be.name),ut=B.a.f(be.params)),!At)throw Error("No component name specified");var Nt=B.i.Cb(xe,Ve),Gt=Ke=++ye;B.j.get(At,function(Qt){if(Ke===Gt){if(Qe(),!Qt)throw Error("Unknown component '"+At+"'");te(At,Qt,xe);var Ct=le(Qt,ut,{element:xe,templateNodes:vt});Qt=Nt.createChildContext(Ct,{extend:function(Ft){Ft.$component=Ct,Ft.$componentTemplateNodes=vt}}),Ct&&Ct.koDescendantsComplete&&(nt=B.i.subscribe(xe,B.i.pa,Ct.koDescendantsComplete,Ct)),Se=Ct,B.Oa(Qt,xe)}})},null,{l:xe}),{controlsDescendantBindings:!0}}},B.h.ea.component=!0}();var li={class:"className",for:"htmlFor"};B.c.attr={update:function(te,le){var ye=B.a.f(le())||{};B.a.P(ye,function(xe,Re){Re=B.a.f(Re);var Oe=xe.indexOf(":"),Oe="lookupNamespaceURI"in te&&0=B.a.W&&xe in li?(xe=li[xe],We?te.removeAttribute(xe):te[xe]=Re):We||(Oe?te.setAttributeNS(Oe,xe,Re):te.setAttribute(xe,Re)),xe==="name"&&B.a.Yc(te,We?"":Re)})}},function(){B.c.checked={after:["value","attr"],init:function(te,le,ye){function xe(){var be=te.checked,At=Oe();if(!B.S.Ya()&&(be||!Ve&&!B.S.qa())){var ut=B.u.G(le);if(Se){var Nt=Ke?ut.v():ut,Gt=vt;vt=At,Gt!==At?be&&(B.a.Na(Nt,At,!0),B.a.Na(Nt,Gt,!1)):B.a.Na(Nt,At,be),Ke&&B.Za(ut)&&ut(Nt)}else We&&(At===t?At=be:be||(At=t)),B.m.eb(ut,ye,"checked",At,!0)}}function Re(){var be=B.a.f(le()),At=Oe();Se?(te.checked=0<=B.a.A(be,At),vt=At):te.checked=We&&At===t?!!be:Oe()===be}var Oe=B.xb(function(){if(ye.has("checkedValue"))return B.a.f(ye.get("checkedValue"));if(nt)return ye.has("value")?B.a.f(ye.get("value")):te.value}),We=te.type=="checkbox",Ve=te.type=="radio";if(We||Ve){var Qe=le(),Se=We&&B.a.f(Qe)instanceof Array,Ke=!(Se&&Qe.push&&Qe.splice),nt=Ve||Se,vt=Se?Oe():t;Ve&&!te.name&&B.c.uniqueName.init(te,function(){return!0}),B.o(xe,null,{l:te}),B.a.B(te,"click",xe),B.o(Re,null,{l:te}),Qe=t}}},B.m.wa.checked=!0,B.c.checkedValue={update:function(te,le){te.value=B.a.f(le())}}}(),B.c.class={update:function(te,le){var ye=B.a.Db(B.a.f(le()));B.a.Eb(te,te.__ko__cssValue,!1),te.__ko__cssValue=ye,B.a.Eb(te,ye,!0)}},B.c.css={update:function(te,le){var ye=B.a.f(le());ye!==null&&typeof ye=="object"?B.a.P(ye,function(xe,Re){Re=B.a.f(Re),B.a.Eb(te,xe,Re)}):B.c.class.update(te,le)}},B.c.enable={update:function(te,le){var ye=B.a.f(le());ye&&te.disabled?te.removeAttribute("disabled"):ye||te.disabled||(te.disabled=!0)}},B.c.disable={update:function(te,le){B.c.enable.update(te,function(){return!B.a.f(le())})}},B.c.event={init:function(te,le,ye,xe,Re){var Oe=le()||{};B.a.P(Oe,function(We){typeof We=="string"&&B.a.B(te,We,function(Ve){var Qe,Se=le()[We];if(Se){try{var Ke=B.a.la(arguments);xe=Re.$data,Ke.unshift(xe),Qe=Se.apply(xe,Ke)}finally{Qe!==!0&&(Ve.preventDefault?Ve.preventDefault():Ve.returnValue=!1)}ye.get(We+"Bubble")===!1&&(Ve.cancelBubble=!0,Ve.stopPropagation&&Ve.stopPropagation())}})})}},B.c.foreach={Rc:function(te){return function(){var le=te(),ye=B.a.bc(le);return!ye||typeof ye.length=="number"?{foreach:le,templateEngine:B.ba.Ma}:(B.a.f(le),{foreach:ye.data,as:ye.as,noChildContext:ye.noChildContext,includeDestroyed:ye.includeDestroyed,afterAdd:ye.afterAdd,beforeRemove:ye.beforeRemove,afterRender:ye.afterRender,beforeMove:ye.beforeMove,afterMove:ye.afterMove,templateEngine:B.ba.Ma})}},init:function(te,le){return B.c.template.init(te,B.c.foreach.Rc(le))},update:function(te,le,ye,xe,Re){return B.c.template.update(te,B.c.foreach.Rc(le),ye,xe,Re)}},B.m.Ra.foreach=!1,B.h.ea.foreach=!0,B.c.hasfocus={init:function(te,le,ye){function xe(We){te.__ko_hasfocusUpdating=!0;var Ve=te.ownerDocument;if("activeElement"in Ve){var Qe;try{Qe=Ve.activeElement}catch{Qe=Ve.body}We=Qe===te}Ve=le(),B.m.eb(Ve,ye,"hasfocus",We,!0),te.__ko_hasfocusLastValue=We,te.__ko_hasfocusUpdating=!1}var Re=xe.bind(null,!0),Oe=xe.bind(null,!1);B.a.B(te,"focus",Re),B.a.B(te,"focusin",Re),B.a.B(te,"blur",Oe),B.a.B(te,"focusout",Oe),te.__ko_hasfocusLastValue=!1},update:function(te,le){var ye=!!B.a.f(le());te.__ko_hasfocusUpdating||te.__ko_hasfocusLastValue===ye||(ye?te.focus():te.blur(),!ye&&te.__ko_hasfocusLastValue&&te.ownerDocument.body.focus(),B.u.G(B.a.Fb,null,[te,ye?"focusin":"focusout"]))}},B.m.wa.hasfocus=!0,B.c.hasFocus=B.c.hasfocus,B.m.wa.hasFocus="hasfocus",B.c.html={init:function(){return{controlsDescendantBindings:!0}},update:function(te,le){B.a.fc(te,le())}},function(){function te(le,ye,xe){B.c[le]={init:function(Re,Oe,We,Ve,Qe){var Se,Ke,nt={},vt,be,At;if(ye){Ve=We.get("as");var ut=We.get("noChildContext");At=!(Ve&&ut),nt={as:Ve,noChildContext:ut,exportDependencies:At}}return be=(vt=We.get("completeOn")=="render")||We.has(B.i.pa),B.o(function(){var Nt=B.a.f(Oe()),Gt=!xe!=!Nt,Qt=!Ke,Ct;(At||Gt!==Se)&&(be&&(Qe=B.i.Cb(Re,Qe)),Gt&&((!ye||At)&&(nt.dataDependency=B.S.o()),Ct=ye?Qe.createChildContext(typeof Nt=="function"?Nt:Oe,nt):B.S.qa()?Qe.extend(null,nt):Qe),Qt&&B.S.qa()&&(Ke=B.a.Ca(B.h.childNodes(Re),!0)),Gt?(Qt||B.h.va(Re,B.a.Ca(Ke)),B.Oa(Ct,Re)):(B.h.Ea(Re),vt||B.i.ma(Re,B.i.H)),Se=Gt)},null,{l:Re}),{controlsDescendantBindings:!0}}},B.m.Ra[le]=!1,B.h.ea[le]=!0}te("if"),te("ifnot",!1,!0),te("with",!0)}(),B.c.let={init:function(te,le,ye,xe,Re){return le=Re.extend(le),B.Oa(le,te),{controlsDescendantBindings:!0}}},B.h.ea.let=!0;var xi={};B.c.options={init:function(te){if(B.a.R(te)!=="select")throw Error("options binding applies only to SELECT elements");for(;0"u"&&(Qe=[Qe]),nt=B.a.jb(Qe,function(ut){return Ke||ut===t||ut===null||!B.a.f(ut._destroy)}),ye.has("optionsCaption")&&(Qe=B.a.f(ye.get("optionsCaption")),Qe!==null&&Qe!==t&&nt.unshift(xi)));var be=!1;if(le.beforeRemove=function(ut){te.removeChild(ut)},Qe=Oe,ye.has("optionsAfterRender")&&typeof ye.get("optionsAfterRender")=="function"&&(Qe=function(ut,Nt){Oe(0,Nt),B.u.G(ye.get("optionsAfterRender"),null,[Nt[0],ut!==xi?ut:t])}),B.a.ec(te,nt,function(ut,Nt,Gt){return Gt.length&&(vt=!Se&&Gt[0].selected?[B.w.M(Gt[0])]:[],be=!0),Nt=te.ownerDocument.createElement("option"),ut===xi?(B.a.Bb(Nt,ye.get("optionsCaption")),B.w.cb(Nt,t)):(Gt=Re(ut,ye.get("optionsValue"),ut),B.w.cb(Nt,B.a.f(Gt)),ut=Re(ut,ye.get("optionsText"),Gt),B.a.Bb(Nt,ut)),[Nt]},le,Qe),!Se){var At;We?At=vt.length&&xe().lengthOe)var Ve=B.a.g.Z(),Qe=B.a.g.Z(),Se=function(nt){var vt=this.activeElement;(vt=vt&&B.a.g.get(vt,Qe))&&vt(nt)},Ke=function(nt,vt){var be=nt.ownerDocument;B.a.g.get(be,Ve)||(B.a.g.set(be,Ve,!0),B.a.B(be,"selectionchange",Se)),B.a.g.set(nt,Qe,vt)};B.c.textInput={init:function(nt,vt,be){function At(fi,Gi){B.a.B(nt,fi,Gi)}function ut(){var fi=B.a.f(vt());(fi===null||fi===t)&&(fi=""),Ft!==t&&fi===Ft?B.a.setTimeout(ut,4):nt.value!==fi&&(_i=!0,nt.value=fi,_i=!1,Qt=nt.value)}function Nt(){Ct||(Ft=nt.value,Ct=B.a.setTimeout(Gt,4))}function Gt(){clearTimeout(Ct),Ft=Ct=t;var fi=nt.value;Qt!==fi&&(Qt=fi,B.m.eb(vt(),be,"textInput",fi))}var Qt=nt.value,Ct,Ft,Xt=B.a.W==9?Nt:Gt,_i=!1;Oe&&At("keypress",Gt),11>Oe&&At("propertychange",function(fi){_i||fi.propertyName!=="value"||Xt()}),Oe==8&&(At("keyup",Gt),At("keydown",Gt)),Ke&&(Ke(nt,Xt),At("dragend",Nt)),(!Oe||9<=Oe)&&At("input",Xt),5>xe&&B.a.R(nt)==="textarea"?(At("keydown",Nt),At("paste",Nt),At("cut",Nt)):11>ye?At("keydown",Nt):4>Re?(At("DOMAutoComplete",Gt),At("dragdrop",Gt),At("drop",Gt)):We&&nt.type==="number"&&At("keydown",Nt),At("change",Gt),At("blur",Gt),B.o(ut,null,{l:nt})}},B.m.wa.textInput=!0,B.c.textinput={preprocess:function(nt,vt,be){be("textInput",nt)}}}(),B.c.uniqueName={init:function(te,le){if(le()){var ye="ko_unique_"+ ++B.c.uniqueName.rd;B.a.Yc(te,ye)}}},B.c.uniqueName.rd=0,B.c.using={init:function(te,le,ye,xe,Re){var Oe;return ye.has("as")&&(Oe={as:ye.get("as"),noChildContext:ye.get("noChildContext")}),le=Re.createChildContext(le,Oe),B.Oa(le,te),{controlsDescendantBindings:!0}}},B.h.ea.using=!0,B.c.value={init:function(te,le,ye){var xe=B.a.R(te),Re=xe=="input";if(!Re||te.type!="checkbox"&&te.type!="radio"){var Oe=[],We=ye.get("valueUpdate"),Ve=!1,Qe=null;We&&(typeof We=="string"?Oe=[We]:Oe=B.a.wc(We),B.a.Pa(Oe,"change"));var Se=function(){Qe=null,Ve=!1;var vt=le(),be=B.w.M(te);B.m.eb(vt,ye,"value",be)};!B.a.W||!Re||te.type!="text"||te.autocomplete=="off"||te.form&&te.form.autocomplete=="off"||B.a.A(Oe,"propertychange")!=-1||(B.a.B(te,"propertychange",function(){Ve=!0}),B.a.B(te,"focus",function(){Ve=!1}),B.a.B(te,"blur",function(){Ve&&Se()})),B.a.D(Oe,function(vt){var be=Se;B.a.Ud(vt,"after")&&(be=function(){Qe=B.w.M(te),B.a.setTimeout(Se,0)},vt=vt.substring(5)),B.a.B(te,vt,be)});var Ke;if(Ke=Re&&te.type=="file"?function(){var vt=B.a.f(le());vt===null||vt===t||vt===""?te.value="":B.u.G(Se)}:function(){var vt=B.a.f(le()),be=B.w.M(te);Qe!==null&&vt===Qe?B.a.setTimeout(Ke,0):(vt!==be||be===t)&&(xe==="select"?(be=ye.get("valueAllowUnset"),B.w.cb(te,vt,be),be||vt===B.w.M(te)||B.u.G(Se)):B.w.cb(te,vt))},xe==="select"){var nt;B.i.subscribe(te,B.i.H,function(){nt?ye.get("valueAllowUnset")?Ke():Se():(B.a.B(te,"change",Se),nt=B.o(Ke,null,{l:te}))},null,{notifyImmediately:!0})}else B.a.B(te,"change",Se),B.o(Ke,null,{l:te})}else B.ib(te,{checkedValue:le})},update:function(){}},B.m.wa.value=!0,B.c.visible={update:function(te,le){var ye=B.a.f(le()),xe=te.style.display!="none";ye&&!xe?te.style.display="":!ye&&xe&&(te.style.display="none")}},B.c.hidden={update:function(te,le){B.c.visible.update(te,function(){return!B.a.f(le())})}},function(te){B.c[te]={init:function(le,ye,xe,Re,Oe){return B.c.event.init.call(this,le,function(){var We={};return We[te]=ye(),We},xe,Re,Oe)}}}("click"),B.ca=function(){},B.ca.prototype.renderTemplateSource=function(){throw Error("Override renderTemplateSource")},B.ca.prototype.createJavaScriptEvaluatorBlock=function(){throw Error("Override createJavaScriptEvaluatorBlock")},B.ca.prototype.makeTemplateSource=function(te,le){if(typeof te=="string"){le=le||c;var ye=le.getElementById(te);if(!ye)throw Error("Cannot find template with ID "+te);return new B.C.F(ye)}if(te.nodeType==1||te.nodeType==8)return new B.C.ia(te);throw Error("Unknown template type: "+te)},B.ca.prototype.renderTemplate=function(te,le,ye,xe){return te=this.makeTemplateSource(te,xe),this.renderTemplateSource(te,le,ye,xe)},B.ca.prototype.isTemplateRewritten=function(te,le){return this.allowTemplateRewriting===!1?!0:this.makeTemplateSource(te,le).data("isRewritten")},B.ca.prototype.rewriteTemplate=function(te,le,ye){te=this.makeTemplateSource(te,ye),le=le(te.text()),te.text(le),te.data("isRewritten",!0)},B.b("templateEngine",B.ca),B.kc=function(){function te(xe,Re,Oe,We){xe=B.m.ac(xe);for(var Ve=B.m.Ra,Qe=0;Qe]*))?)*\s+)data-bind\s*=\s*(["'])([\s\S]*?)\3/gi,ye=/\x3c!--\s*ko\b\s*([\s\S]*?)\s*--\x3e/g;return{xd:function(xe,Re,Oe){Re.isTemplateRewritten(xe,Oe)||Re.rewriteTemplate(xe,function(We){return B.kc.Ld(We,Re)},Oe)},Ld:function(xe,Re){return xe.replace(le,function(Oe,We,Ve,Qe,Se){return te(Se,We,Ve,Re)}).replace(ye,function(Oe,We){return te(We,"","#comment",Re)})},md:function(xe,Re){return B.aa.Xb(function(Oe,We){var Ve=Oe.nextSibling;Ve&&Ve.nodeName.toLowerCase()===Re&&B.ib(Ve,xe,We)})}}}(),B.b("__tr_ambtns",B.kc.md),function(){B.C={},B.C.F=function(ye){if(this.F=ye){var xe=B.a.R(ye);this.ab=xe==="script"?1:xe==="textarea"?2:xe=="template"&&ye.content&&ye.content.nodeType===11?3:4}},B.C.F.prototype.text=function(){var ye=this.ab===1?"text":this.ab===2?"value":"innerHTML";if(arguments.length==0)return this.F[ye];var xe=arguments[0];ye==="innerHTML"?B.a.fc(this.F,xe):this.F[ye]=xe};var te=B.a.g.Z()+"_";B.C.F.prototype.data=function(ye){if(arguments.length===1)return B.a.g.get(this.F,te+ye);B.a.g.set(this.F,te+ye,arguments[1])};var le=B.a.g.Z();B.C.F.prototype.nodes=function(){var ye=this.F;if(arguments.length==0){var xe=B.a.g.get(ye,le)||{},Re=xe.lb||(this.ab===3?ye.content:this.ab===4?ye:t);if(!Re||xe.jd){var Oe=this.text();Oe&&Oe!==xe.bb&&(Re=B.a.Md(Oe,ye.ownerDocument),B.a.g.set(ye,le,{lb:Re,bb:Oe,jd:!0}))}return Re}xe=arguments[0],this.ab!==t&&this.text(""),B.a.g.set(ye,le,{lb:xe})},B.C.ia=function(ye){this.F=ye},B.C.ia.prototype=new B.C.F,B.C.ia.prototype.constructor=B.C.ia,B.C.ia.prototype.text=function(){if(arguments.length==0){var ye=B.a.g.get(this.F,le)||{};return ye.bb===t&&ye.lb&&(ye.bb=ye.lb.innerHTML),ye.bb}B.a.g.set(this.F,le,{bb:arguments[0]})},B.b("templateSources",B.C),B.b("templateSources.domElement",B.C.F),B.b("templateSources.anonymousTemplate",B.C.ia)}(),function(){function te(Qe,Se,Ke){var nt;for(Se=B.h.nextSibling(Se);Qe&&(nt=Qe)!==Se;)Qe=B.h.nextSibling(nt),Ke(nt,Qe)}function le(Qe,Se){if(Qe.length){var Ke=Qe[0],nt=Qe[Qe.length-1],vt=Ke.parentNode,be=B.ga.instance,At=be.preprocessNode;if(At){if(te(Ke,nt,function(ut,Nt){var Gt=ut.previousSibling,Qt=At.call(be,ut);Qt&&(ut===Ke&&(Ke=Qt[0]||Nt),ut===nt&&(nt=Qt[Qt.length-1]||Gt))}),Qe.length=0,!Ke)return;Ke===nt?Qe.push(Ke):(Qe.push(Ke,nt),B.a.Ua(Qe,vt))}te(Ke,nt,function(ut){ut.nodeType!==1&&ut.nodeType!==8||B.vc(Se,ut)}),te(Ke,nt,function(ut){ut.nodeType!==1&&ut.nodeType!==8||B.aa.cd(ut,[Se])}),B.a.Ua(Qe,vt)}}function ye(Qe){return Qe.nodeType?Qe:0"u"&&(Ft=[Ft]),Qt&&(Ft=B.a.jb(Ft,function(Xt){return Xt===t||Xt===null||!B.a.f(Xt._destroy)})),be(Ft)},null,{l:nt});be(Se.v());var Ct=Se.subscribe(function(Ft){be(Se(),Ft)},null,"arrayChange");return Ct.l(nt),Ct};var We=B.a.g.Z(),Ve=B.a.g.Z();B.c.template={init:function(Qe,Se){var Ke=B.a.f(Se());if(typeof Ke=="string"||"name"in Ke)B.h.Ea(Qe);else if("nodes"in Ke){if(Ke=Ke.nodes||[],B.O(Ke))throw Error('The "nodes" option must be a plain, non-observable array.');var nt=Ke[0]&&Ke[0].parentNode;nt&&B.a.g.get(nt,Ve)||(nt=B.a.Yb(Ke),B.a.g.set(nt,Ve,!0)),new B.C.ia(Qe).nodes(nt)}else if(Ke=B.h.childNodes(Qe),0"u"&&(Re=[Re]),We=We||{};var vt=B.a.g.get(xe,le),be=!vt,At=[],ut=0,Nt=0,Gt=[],Qt=[],Ct=[],Ft=[],Xt=[],_i,fi=0;if(be)B.a.D(Re,Se);else{if(!Qe||vt&&vt._countWaitingForRemove){var Gi=B.a.Mb(vt,function(ti){return ti.Aa});Qe=B.a.Pb(Gi,Re,{dontLimitMoves:We.dontLimitMoves,sparse:!0})}for(var Gi=0,wn,zi,Gn;wn=Qe[Gi];Gi++)switch(zi=wn.moved,Gn=wn.index,wn.status){case"deleted":for(;utB.a.W)&&te.nodes?te.nodes():null)?B.a.la(le.cloneNode(!0).childNodes):(te=te.text(),B.a.ua(te,xe))},B.ba.Ma=new B.ba,B.gc(B.ba.Ma),B.b("nativeTemplateEngine",B.ba),function(){B.$a=function(){var le=this.Hd=function(){if(!y||!y.tmpl)return 0;try{if(0<=y.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch{}return 1}();this.renderTemplateSource=function(ye,xe,Re,Oe){if(Oe=Oe||c,Re=Re||{},2>le)throw Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.");var We=ye.data("precompiled");return We||(We=ye.text()||"",We=y.template(null,"{{ko_with $item.koBindingContext}}"+We+"{{/ko_with}}"),ye.data("precompiled",We)),ye=[xe.$data],xe=y.extend({koBindingContext:xe},Re.templateOptions),xe=y.tmpl(We,ye,xe),xe.appendTo(Oe.createElement("div")),y.fragments={},xe},this.createJavaScriptEvaluatorBlock=function(ye){return"{{ko_code ((function() { return "+ye+" })()) }}"},this.addTemplate=function(ye,xe){c.write("